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.

bind/proc sections per channel?

Old posts that have not been replied to for several years.
Locked
O
ObelNix

bind/proc sections per channel?

Post by ObelNix »

Hi there,

At this moment I ahve set up 1 single bot that sits in three different channels. I want it to respond to public commands in all three channels.

Code: Select all

bind pub - !cmd cmd
  proc cmd {nick host handle chan text} {
  if {$chan == "#"} {        
    puthelp "PRIVMSG $chan : this is the output on #chan1"
    }
  if {$chan == "#chan2"} {
    puthelp "PRIVMSG $chan : And this is the output on #chan2"
    }
  }
My question is: Can I split a script in more sections, where each section describes all the binds and procs for it's own channel? Something like:

Code: Select all

if {$chan == "#chan1"} {        
  bind pub - !Samplecommand1 Samplecommand1 
  proc Samplecommand1 {nick host handle chan text} {
    puthelp "PRIVMSG $chan : this is the output on #chan1"
    }
  }

if {$chan == "#chan2"} {
  bind pub - !AnotherCommand AnotherCommand
  proc AnotherCommand {nick host handle chan text} {
    puthelp "PRIVMSG $chan : And this is the output on #chan2"
    }
  }
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Your above example creates two seperate triggers.

You simply check inside the proc which channel it is.
O
ObelNix

Post by ObelNix »

That is exactly what I want. I want to set up different triggers (or maybe even the same triggers) on different channels.

My question is: Is this valid? Can I do this?
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

ObelNix wrote:My question is: Is this valid? Can I do this?
Not unless you do the channel check inside the procs like ppslim told you to.
Checking a global variable at compile time (like you did in your code example) won't do you any good.
Locked