defset ownfullname "testing bot"
defset ownmailaddr test-irc-bot@example.com
-defset musthaveping_ms 10000
+defset muststartby_ms 10000
defset out_maxburst 6
defset out_interval 2100
defset out_lag_lag 5000
defset out_lag_very 25000
-
-defset marktime_min 300
-defset marktime_join_startdelay 5000
+defset ownping_every 300000
proc manyset {list args} {
foreach val $list var $args {
proc onread {args} {
global sock nick calling_nick errorInfo errorCode line_org_endchar
- if {[gets $sock line] == -1} { fail "EOF/error on input" }
+ if {[catch { gets $sock line } rv]} { fail "error on input: $rv" }
+ if {$rv == -1} { fail "EOF on input" }
+
set line_org_endchar [string range $line end end]
regsub -all "\[^ -\176\240-\376\]" $line ? line
set org $line
}
}
+proc catch_logged {body} {
+ if {[catch { uplevel 1 $body } emsg]} {
+ logerror "error (catch_logged): $emsg"
+ }
+}
+
proc sendprivmsg {dest l} {
foreach v [split $l "\n"] {
sendout [expr {[ischan $dest] ? "PRIVMSG" : "NOTICE"}] $dest $v
}
proc msg_PING {p c s1} {
- global musthaveping_after
prefix_none
sendout PONG $s1
- if {[info exists musthaveping_after]} {
- after cancel $musthaveping_after
- unset musthaveping_after
+}
+
+proc sendownping {} {
+ global ownping_every nick
+ sendout ping $nick
+ after $ownping_every sendownping
+}
+
+proc msg_001 {args} {
+ global muststartby_after
+ if {[info exists muststartby_after]} {
+ after cancel $muststartby_after
+ unset muststartby_after
+ sendownping
connected
}
}
proc ensure_connecting {} {
global sock ownfullname host port nick ident socketargs
- global musthaveping_ms musthaveping_after
+ global muststartby_ms muststartby_after
ensure_outqueue
sendout NICK $nick
fileevent $sock readable onread
- set musthaveping_after [after $musthaveping_ms \
- {fail "no ping within timeout"}]
+ set muststartby_after [after $muststartby_ms \
+ {fail "no successfuly connect within timeout"}]
}