# main control channel
set controlChan "#123"
# flags required
# global|channel
set controlFlags "o|o"
# create bind using flags and chan
bind pubm $controlFlags "$controlChan .all *" pub:all
proc pub:all {nick uhost hand chan text} {
# pubm binds pass entire text, remove .all at front
set text [join [lrange [split $text] 1 end]]
# iterate channels
foreach ch [channels] {
# if bot isn't on channel or channel is control channel, skip
if {![botonchan $ch] || [string equal $ch $::controlChan} continue
# otherwise, issue text to the channel
puthelp "PRIVMSG $ch :$text"
}
}
# main control channel
set controlChan "#123"
# flags required
# global|channel
set controlFlags "o|o"
# create bind using flags and chan
bind pubm $controlFlags "$controlChan .all *" pub:all
proc pub:all {nick uhost hand chan text} {
# pubm binds pass entire text, remove .all at front
set text [join [lrange [split $text] 1 end]]
# iterate channels
foreach ch [channels] {
# if bot isn't on channel or channel is control channel, skip
if {![botonchan $ch] || [string equal $ch $::controlChan]} continue
# otherwise, issue text to the channel
puthelp "PRIVMSG $ch :$text"
}
}
true_life wrote:working fine except.. posting 2 replies.
i did,
.all testing final.
reply,
[03:29:20] <+bot1> test final
[03:29:22] <+bot1> final
You need to .restart your bot. Multiple binds are tiggering now causing that repeat. Both the pub and pubm are surely loaded. The text is being correctly removed from the "pubm" bind, but the "pub" bind is having the first word removed incorrectly. This is evidence that indeed, you have not .restart'ed your bot.
# main control channel
set controlChan "#123"
# flags required
# global|channel
set controlFlags "o|o"
# create bind using flags and chan
bind pubm $controlFlags "$controlChan .all *" pub:all
proc pub:all {nick uhost hand chan text} {
# pubm binds pass entire text, remove .all at front
set text [join [lrange [split $text] 1 end]]
# iterate channels
foreach ch [channels] {
# if bot isn't on channel or channel is control channel, skip
if {![botonchan $ch] || [string equal $ch $::controlChan]} continue
# otherwise, issue text to the channel
puthelp "PRIVMSG $ch :$text"
}
}
Use the code as is and it works. Make sure to .restart before you do so to "clean" the binds out.
The foreach loop would execute that if statement n times (that represents the number of elements in the [channels] result), so this translates into executing that if statement 15 times, when could easily avoid that by those 3 lines that removes the control channel from the list.
is a bad idea to compare two strings like that. You should at least make both lower/higher case first, or better use string match -nocase that doesn't care if the two strings are lower/higher case.
Once the game is over, the king and the pawn go back in the same box.