| View previous topic :: View next topic |
| Author |
Message |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Tue May 14, 2013 2:48 pm Post subject: |
|
|
| Code: |
set controlChan "#123"
bind pub * .all pub:all
proc pub:all {nick uhost hand channel text} {
if {![string match -nocase $channel $::controlChan]} return
foreach chan [channels] {
if {![botonchan $chan]} continue
puthelp "PRIVMSG $chan :$text"
}
}
|
_________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
true_life Voice
Joined: 14 May 2013 Posts: 11
|
Posted: Tue May 14, 2013 3:15 pm Post subject: |
|
|
its replying on all channel! including the 'main channel' twice!
and it has no o|o status so anyone can use it  |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Tue May 14, 2013 4:03 pm Post subject: |
|
|
| Code: | # 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"
}
} |
_________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
true_life Voice
Joined: 14 May 2013 Posts: 11
|
Posted: Tue May 14, 2013 5:33 pm Post subject: |
|
|
| Tcl error [pub:all]: missing close-bracket |
|
| Back to top |
|
 |
Madalin Master

Joined: 24 Jun 2005 Posts: 310 Location: Constanta, Romania
|
Posted: Tue May 14, 2013 5:59 pm Post subject: |
|
|
Try this
| Code: |
# 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"
}
} |
_________________ https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL |
|
| Back to top |
|
 |
true_life Voice
Joined: 14 May 2013 Posts: 11
|
Posted: Tue May 14, 2013 6:30 pm Post subject: |
|
|
working fine except.. posting 2 replies.
i did,
.all testing final.
reply,
[03:29:20] <+bot1> test final
[03:29:22] <+bot1> final |
|
| Back to top |
|
 |
Madalin Master

Joined: 24 Jun 2005 Posts: 310 Location: Constanta, Romania
|
Posted: Tue May 14, 2013 6:33 pm Post subject: |
|
|
I was just reparing the bracelet missing... to solve that remove following line
Set text [join ......] _________________ https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Tue May 14, 2013 6:36 pm Post subject: |
|
|
| 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.
| Code: | # 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. _________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Wed May 15, 2013 12:53 am Post subject: |
|
|
| Code: |
set controlChan "#123"
bind pub * .all pub:all
proc pub:all {nick uhost hand channel text} {
if {![string match -nocase $channel $::controlChan]} return
set channels [channels]
set pos [lsearch -nocase $channels $::controlChan]
set channels [lreplace $channels $pos $pos]
foreach chan $channels {
if {![botonchan $chan]} continue
puthelp "PRIVMSG $chan :$text"
}
}
|
There. Now it should send that message to all channels except the control one. You should restart the bot as some binds aren't removed by a rehash. _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
Madalin Master

Joined: 24 Jun 2005 Posts: 310 Location: Constanta, Romania
|
Posted: Wed May 15, 2013 5:22 am Post subject: |
|
|
Instead of
| Quote: |
set channels [channels]
set pos [lsearch -nocase $channels $::controlChan]
set channels [lreplace $channels $pos $pos]
|
i would really just use (thats why i dont use lsearch that much)
| Code: |
if {$chan != $chn} { ... }
|
_________________ https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Wed May 15, 2013 9:48 am Post subject: |
|
|
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.
The:
| Code: |
if {$chan != $chn} { ... }
|
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. |
|
| Back to top |
|
 |
|