| View previous topic :: View next topic |
| Author |
Message |
raider2k Op
Joined: 01 Jan 2008 Posts: 140
|
Posted: Tue Jan 01, 2008 11:20 pm Post subject: msg all channels/on channel? [solved] |
|
|
The one post Weird behavior of FOREACH command gave me some idea in how to handle what I was thinking about a few days ago.
So I figured out this isnt a problem at all - but what is a problem is another feature that needs to be combined with that one, but lets start from the beginning ^^
Im up to let the bot catch specific messages from (make it a random number) 3 channels where it sits in. There are 3 different channels where other bots are going to announce news from 3 different news sites which will be catched from my bot. So now I want my bot to announce ALL of the 3 channels it is in except the one where it got the news message from. I hope I explained it well ^^
here is an example of what I tried:
| Code: |
bind pub - !lol lolproc
set diffchans [list "#LOL" "#ROFL" "#OMGWTF"]
proc lolproc { nick uhost handle chan text } {
set value [lindex $text 0]
set dchans [split $::diffchans]
if { [string equal -nocase $chan $dchans] } {
set dchans [string map { "$chan" "" } $dchans]
}
foreach schan $diffchans {
putquick "PRIVMSG $schan :\[NEWS\] - $value"
}
}
|
This is just a testproc to see if the idea would even work so far. So I provide info to the bot by typing "!lol test". Somehow the whole if loop gets ignored and the bot just messages into all channels.
Im not sure if there is also another way to remove a item from a list temporarily - thats why I did the set dchans [string map { "$chan" "" } $dchans. Someone please keep the ball rolling so I can get a new impression on this one
appreciated 
Last edited by raider2k on Sat Jan 12, 2008 7:46 am; edited 1 time in total |
|
| Back to top |
|
 |
metroid Owner
Joined: 16 Jun 2004 Posts: 771
|
Posted: Wed Jan 02, 2008 9:19 am Post subject: |
|
|
| You use split on lists, you shouldn't. |
|
| Back to top |
|
 |
raider2k Op
Joined: 01 Jan 2008 Posts: 140
|
Posted: Wed Jan 02, 2008 11:09 am Post subject: |
|
|
mh weird .. can you get me an impression how to handle this please? ^^
//edit:
I was wondering if I shouldnt do it that way:
| Code: |
bind pub - !lol lolproc
set diffchans "#LOL #ROFL #OMGWTF"
proc lolproc { nick uhost handle chan text } {
set value [lindex $text 0]
set dchans [split $::diffchans " "]
if { [string equal -nocase $chan $dchans] } {
set dchans [string map { "$chan" "" } $dchans]
}
foreach schan $diffchans {
putquick "PRIVMSG $schan :\[NEWS\] - $value"
}
}
|
removed [list when setting diffchans and added split $::diffchans " ". maybe that one is gonna work. what do you think?
//edit:
not working either
very weird thingie. Though Im trying to remove that channel where the bot is in temporarely so it wont get messaged ... very weird :/ |
|
| Back to top |
|
 |
tsukeh Voice
Joined: 20 Jan 2005 Posts: 31
|
Posted: Wed Jan 02, 2008 12:32 pm Post subject: |
|
|
| Code: |
bind pub - !lol lolproc
set diffchans [list #LOL #ROFL #OMGWTF]
proc lolproc {nick uhost hand chan text} {
set value [lindex [split $text] 0]
foreach i $::diffchans {
if ![string equal -nocase $chan $i] {
putquick "PRIVMSG $i :\[NEWS\] - $value"
}
}
}
|
|
|
| Back to top |
|
 |
raider2k Op
Joined: 01 Jan 2008 Posts: 140
|
Posted: Sun Jan 06, 2008 6:31 pm Post subject: |
|
|
thx tsukeh
working like a charm  |
|
| Back to top |
|
 |
|