#=================================================================================
# ** Notification(c) 1.0 by Hen Asraf
#=================================================================================
# * What does it do?
#---------------------------------------------------------------------------------
# Reads from the keywords list and sends a PM to every nick in the nicknames
# list whenever any of the keywords are mentioned in one of the bot's channels.
# It also sends the original time of which it was triggered to prevent the lag
# from causing a delay without the users knowing.
#
# Good for cases where the botmaster is asleep or away and wouldn't want to miss
# messages that were referring to them or something important.
#=================================================================================
# Set the keywords to trigger the notifier. Seperate with a space.
set keywords "Spide Spidy kumo kami"
# Set the nicknames to send the PM to. Seperate with a space.
set nicknames "kumoKami"
# MAIN #
# Turn the keywords and nicknames variables into lists.
set keywords [split $keywords ]
set nicknames [split $nicknames ]
# For each keyword in the list, bind the keyword to the spidey:notify procedure.
foreach keyword $keywords {
bind pubm * "*$keyword*" spidey:notify
bind ctcp * "ACTION*$keyword*" spidey:notify_tcl
}
# Start procedure
proc spidey:notify { nick host hand chan text } {
# If the notified user said one of the keywords, you don't have to trigger the
# messsage.
foreach nickname $::nicknames {
if { $nick != "$nickname" } {
# Send the message in the following format:
# (@time) [ #channel ] Nickname: Entire line containing the keyword(s)
putserv "PRIVMSG $nickname :(@[strftime {%I:%M:%S %p}]) \[ $chan \] \002$nick:\002 \00312$text\003"
}
}
}
# Action procedure (/me)
proc spidey:notify_tcl { nick host hand chan key text } {
# If the notified user said one of the keywords, you don't have to trigger the
# messsage.
foreach nickname $::nicknames {
if { $nick != "$nickname" } {
# Send the message in the following format:
# (@time) [ #channel ] Nickname: Entire line containing the keyword(s)
putserv "PRIVMSG $nickname :(@[strftime {%I:%M:%S %p}]) \[ $chan \] \0036\002$nick\002 $text\003"
}
}
}
# When successfully loaded, put this line into the partyline for logging purposes.
putlog "Notification 1.0 by Hen Asraf: Loaded"
Oh yeah I wasn't very descriptive >_< Sorry.
I wanted to say, that I need only certain action CTCPs to be binded. How would I go upon doing this? "ACTION*keyword*" doesn't seem to bind what I need, if you look inside the first foreach loop.
And oops, I didn't notice I put it here :x If someone could put it in the scripting help section, It'd be lovely.
Bind against "ACTION", nothing else. Then within spidey:notify_tcl, test wether text contains any of your keywords.
Basically, Only the first word in a ctcp-message is the "key", the rest is the message/text/parameters/whatever. That's why you need to bind against "ACTION", and not "ACTION something".
I was trying to avoid that to make things simpler, but I guess I won't :P
Ok, so I have another question:
If several keywords appear in one message, the message is triggered for every one of them. How do I make it stop after only one trigger for each message? break didn't work :<
Hmm... think you could post your test, cause break should end any kind of loop (innermost if nested loops).
One approach might be to iterate through the whole list of keywords, set some temp-variable if matched. Then, once the loop has completed, test for the presence of that variable, and take appropriate actions.