I have a problem with my code below. I have two bots in my channel. When Blacky joins, this bot1 sends the current uptime of the online users in #channel to Blacky. But before that those times are being sent to Blacky, Blacky needs to reset it's times. So this bot1 sends (putbot) "clear" to Blacky so that Blacky unset his parameters. After this the uptimes are being sent from bot1 to Blacky and Blacky confirms this by putting a copy of this into #controlchan.
Find below the code for this bot1:
Code: Select all
bind join - * joinproc
proc joinproc {nick uhost hand chan} {
if {![string match -nocase "$chan" "#channel"]} { return 0 }
global joined
#if {[isbotnick $nick]} {return} i removed this temporary
set ::joined($nick) [clock seconds]
#if {[string equal -nocase [nick2hand $nick] "Blacky"]} { i removed this temporary
if {[string equal -nocase $nick "Blacky"] || [string match -nocase "*@testing.com" $uhost]} {
puthelp "PRIVMSG #controlchan :Blacky, i'm clearing your uptime-database so you can update your uptimes with mine"
putbot Blacky "clear"
puthelp "PRIVMSG #controlchan :Blacky, I'm sending the info..."
foreach nick [chanlist "#channel"] {
if {![info exists ::joined($nick)]} {
set ::joined($nick) [getchanjoin $nick #channel]
}
putbot Blacky "join $nick [expr {[clock seconds] - $::joined($nick)}]"
puthelp "PRIVMSG #controlchan :$nick has already joined as of [duration [expr {[clock seconds] - $::joined($nick)}]] ago"
}
} else {
putbot Blacky "join $nick 0"
}
}
Code: Select all
bind bot - "clear" procbot_clear
proc procbot_clear {from-bot command arg} {
catch {unset ::joined}
}
bind bot - "join" procbot_join
proc procbot_join {from-bot command arg} {
puthelp "PRIVMSG #controlchan :Bot1 has sent me the following information:"
foreach {nick ago} $arg break
set ::joined($nick) [expr { [clock seconds] - $ago } ]
puthelp "PRIVMSG #controlchan :$nick has already joined as of [duration { $::joined($nick) } ] ago"
}
1/ When Blacky joins #channel, i get the following error in telnet:
What could be the problem? i checked all the }, but didn't find any too much.Tcl error [joinproc]: invalid command name "}"
2/ Additionally, once all the times are sent from bot1 to Blacky, i don't see the msg in #controlchan sent by Blacky:
$nick has already joined as of [duration { $::joined($nick) } ] ago
Does this mean that it's not triggered with the word "join" coming from bot1 ? Is the structure for putbot not correct? Or is the trigger script from Blacky not correct?
Thanks in advance.
Buffy