This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Ignore a channel in a "foreach chan" loop

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
Wuff
Voice
Posts: 7
Joined: Wed Oct 10, 2007 1:12 pm

Ignore a channel in a "foreach chan" loop

Post by Wuff »

Code: Select all

bind bot - announce botannounce
bind msg m announce gotannounce

proc announce {text} {
  foreach chan [channels] {
    if {[botonchan $chan]} {
      puthelp "privmsg $chan :$text"
    }
  }
}
proc botannounce {from cmd text} {
  announce $text
}
proc gotannounce {nick uhost hand text} {
  putallbots "announce $text"
} 

I simply want the bot not to post the message on a specific channel, when it runs through all the channels it's on.

I think it's something like: if ![$chan = "#channel"]
But I'm really not sure.


If someone could allso give me an example on how to ignore multiple channels, that would be great, but I would be happy if the script just ignores the one channel :D

Thanks in advance
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

Code: Select all

if {([botonchan $chan]) && ($chan != "#mychannel")} { 
User avatar
Wuff
Voice
Posts: 7
Joined: Wed Oct 10, 2007 1:12 pm

Post by Wuff »

Great.. Thank you
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Re: Ignore a channel in a "foreach chan" loop

Post by rosc2112 »

Wuff wrote:If someone could allso give me an example on how to ignore multiple channels
I didn't see this part earlier. I would do this:

Code: Select all

# list of channels to make announcements on
set mychanlist "#chan1 #chan2 #chan3 #etc"

proc announce {text} {
  foreach chan $::mychanlist {
    if {[botonchan $chan]} {
      puthelp "privmsg $chan :$text"
    }
  }
} 
Post Reply