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 

msg all channels/on channel? [solved]

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


Joined: 01 Jan 2008
Posts: 140

PostPosted: Tue Jan 01, 2008 11:20 pm    Post subject: msg all channels/on channel? [solved] Reply with quote

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 Smile

appreciated Smile


Last edited by raider2k on Sat Jan 12, 2008 7:46 am; edited 1 time in total
Back to top
View user's profile Send private message
metroid
Owner


Joined: 16 Jun 2004
Posts: 771

PostPosted: Wed Jan 02, 2008 9:19 am    Post subject: Reply with quote

You use split on lists, you shouldn't.
Back to top
View user's profile Send private message
raider2k
Op


Joined: 01 Jan 2008
Posts: 140

PostPosted: Wed Jan 02, 2008 11:09 am    Post subject: Reply with quote

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 Sad
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
View user's profile Send private message
tsukeh
Voice


Joined: 20 Jan 2005
Posts: 31

PostPosted: Wed Jan 02, 2008 12:32 pm    Post subject: Reply with quote

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
View user's profile Send private message
raider2k
Op


Joined: 01 Jan 2008
Posts: 140

PostPosted: Sun Jan 06, 2008 6:31 pm    Post subject: Reply with quote

thx tsukeh
working like a charm Smile
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