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.

Modifying a pub trigger to a msg trigger

Old posts that have not been replied to for several years.
Locked
C
Calamaro
Voice
Posts: 5
Joined: Tue Sep 28, 2004 7:07 pm
Contact:

Modifying a pub trigger to a msg trigger

Post by Calamaro »

Hi,
I'm trying to modify a script that has a "bind pub" trigger to use a "bind msg" trigger. Here's what i got so far.

Code: Select all

bind pub - trigger pub_trigger
bind msg - trigger msg_trigger

proc msg_trigger { nick host handle text } {
    pub_trigger $nick $host $handle "#channel" $text
}

proc pub_trigger {nick uhost hand channel rest} {
    ...
}
With this code the script works when called with either the pub or msg trigger. The problem is that anyone can msg the trigger to the bot without being in #channel. I need some help with the code to make it check if the user is on #channel and then if a)the user is not on the channel they would get a message informing them that they need to join #channel or b)they are on the channel and can use the script.

Am i making any sense?

-Calamaro
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

use 'onchan' to check if they're on a particular channel (it's in tcl-commands.doc)
Have you ever read "The Manual"?
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Here is what you need:

Code: Select all

Set your channel here
set channel "#mychannel"

### PUB TRIGGER ###
bind pub - trigger pub_trigger 

proc pub_trigger {nick uhost hand chan text} {
 global channel
 if {([string equal -nocase $channel $chan])} { # do your stuff 
 }
}

### MSG TRIGGER ###
bind msg - trigger msg_trigger 

proc msg_trigger {nick uhost hand text} {
 global channel
 if {(![onchan $nick $channel])} { putserv "PRIVMSG $nick :You need to join $channel for this script to be triggered."; return 0 }
 if {([onchan $nick $channel])} { # do your stuff 
 }
}
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
C
Calamaro
Voice
Posts: 5
Joined: Tue Sep 28, 2004 7:07 pm
Contact:

Post by Calamaro »

user wrote:use 'onchan' to check if they're on a particular channel (it's in tcl-commands.doc)
Thanks for telling me about this file. I'm finding it very helpful.
awyeah wrote:Here is what you need:

Code: Select all


Set your channel here
set channel "#mychannel"

### PUB TRIGGER ###
bind pub - trigger pub_trigger 

proc pub_trigger {nick uhost hand chan text} {
 global channel
 if {([string equal -nocase $channel $chan])} { # do your stuff 
 }
}

### MSG TRIGGER ###
bind msg - trigger msg_trigger 

proc msg_trigger {nick uhost hand text} {
 global channel
 if {(![onchan $nick $channel])} { putserv "PRIVMSG $nick :You need to join $channel for this script to be triggered."; return 0 }
 if {([onchan $nick $channel])} { # do your stuff 
 }
}
Thanks dude, i appreciate it. Works like a charm.

-Calamaro
Locked