egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Ignore a channel in a "foreach chan" loop

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Wuff
Voice


Joined: 10 Oct 2007
Posts: 7

PostPosted: Sat Nov 17, 2007 2:06 pm    Post subject: Ignore a channel in a "foreach chan" loop Reply with quote

Code:
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 Very Happy

Thanks in advance
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Sat Nov 17, 2007 5:10 pm    Post subject: Reply with quote

Code:

if {([botonchan $chan]) && ($chan != "#mychannel")} {
Back to top
View user's profile Send private message
Wuff
Voice


Joined: 10 Oct 2007
Posts: 7

PostPosted: Sat Nov 17, 2007 6:23 pm    Post subject: Reply with quote

Great.. Thank you
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Sat Nov 17, 2007 9:51 pm    Post subject: Re: Ignore a channel in a "foreach chan" loop Reply with quote

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:

# 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"
    }
  }
}
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber