Code: Select all
# Multi-Bind Messaging (the easy way to do this)
# AKA, PutServ-O-Matic v1.0
# by speechles (w/help from egghelp! yay!)
# Construct your triggers|channel|message
# here using the format below:
# "TRIGGER|#CHANNEL|METHOD AND MESSAGE"
# add as little, or as many as you want but you
# MUST use the format described above!
# You also have a few variables to use
# %b - will be replaced with $::botnick (bots current nickname)
# %n - will be replaced with $nick (person triggering)
# %c - will be replaced with $chan (channel triggered in)
# %u - will be replaced with $uhost (person triggering unique host)
# %h - will be replaced with $hand (person triggering handle)
# %t - will be replaced with users trigger (very first word)
# %i - will be replaced with user $input (entire thing)
# %i1 - will be replaced with user $input (just the first word)
# %i2 - will be replaced with user $input (second to last words)
# below are merely some examples.
variable mycommands {
"*slaps %b*|#test|privmsg %c :\001action blocks the slap and kicks %n in the face.\001"
"!notice*|#test|notice %n :notice message"
"!query*|#test|privmsg %n :query/private message"
"!kickme*|#test|kick %c %n :kick fulfilled.. hehe \037:P\037"
"!voiceme*|*|mode %c +v %n"
"!voiceme*|*|privmsg %c :\002%n\002, feel the \002Power\002 of voice!"
"!repeat*|*|privmsg %c :%n just said \002%i\002 :P"
"!voicenick*|*|mode %c +v %i1"
"!kickbannick*|*|mode %c +b %i1!*@*"
"!kickbannick*|*|kick %c %i1 :%i2 (Requested by %n)"
"!kicknick*|*|kick %c %i1 :%i2 (Requested by %n)"
}
# Script begins - change nothing below here
bind pubm -|- "*" mycommands_proc
proc mycommands_proc {nick uhand hand chan input} {
foreach item $::mycommands {
set trig [lindex [split $item \|] 0]
regsub -all -nocase {%b} $trig $::botnick trig
regsub -all -nocase {%n} $trig $nick trig
regsub -all -nocase {%c} $trig $chan trig
regsub -all -nocase {%u} $trig $uhand trig
regsub -all -nocase {%h} $trig $hand trig
regsub -all -nocase {%t} $trig [lindex [split $input] 0] trig
regsub -all -nocase {%i1} $trig [lindex [split $input] 1] trig
regsub -all -nocase {%i2} $trig [join [lrange [split $input] 2 end]]] trig
regsub -all -nocase {%i} $trig [join [lrange [split $input] 1 end]]] trig
if {[string match -nocase $trig $input]} {
if {[string match -nocase [lindex [split $item \|] 1] $chan]} {
set message [join [lrange [split $item \|] 2 end]]
regsub -all -nocase {%b} $message $::botnick message
regsub -all -nocase {%n} $message $nick message
regsub -all -nocase {%c} $message $chan message
regsub -all -nocase {%u} $message $uhand message
regsub -all -nocase {%h} $message $hand message
regsub -all -nocase {%t} $message [lindex [split $input] 0] message
regsub -all -nocase {%i1} $message [lindex [split $input] 1] message
regsub -all -nocase {%i2} $message [join [lrange [split $input] 2 end]]] message
regsub -all -nocase {%i} $message [join [lrange [split $input] 1 end]]] message
putserv "$message"
}
}
}
}
putlog "Multi-bind messaging with action missles script loaded."
<speechles> !voiceme
* bot sets mode: +v speechles
<bot> speechles, feel the Power of voice!
<speechles> !kickme
you were kicked by bot (kick fulfilled.. hehe :P)
<funny> haha.. your own bot kicks you :P
<speechles> !kick funny haha.. not so funny now is it?
funny was kicked by bot (haha.. not so funny now is it? (Requested by speechles))
**EDIT: The code above requires knowledge of tcl special characters and proper list arrangements.
Code: Select all
variable mycommands [list "!notice|#test|notice %n :notice message" \
"!query|#test|privmsg %c :query/private message" \
"!kickme|#test|kick %c %n :kick fulfilled.. hehe \037:P\037" \
"!voiceme|*|mode %c +v %n" \
"!voiceme|*|privmsg %c :\002%n\002, feel the \002Power\002 of voice!" \
"!repeat|*|privmsg %c :you just said \002%i\002" \
"!voicenick|*|mode %c +v %i1" \
"!kickbannick|*|mode %c +b %i1*!*@*" \
"!kickbannick|*|kick %c %i1 :%i2 (Requested by %n)" \
"!kicknick|*|kick %c %i1 :%i2 (Requested by %n)" ]
This is the correct way to encapsulate the list, without crafting it by hand. Those having issues of any sort should use the correct way (the list method above). Those more experienced can of course, craft the list by hand just fine (it's original state).
Mycommands Configuration: (for those new to tcl this should explain it)
"*slaps %b*|#test|privmsg %c :\001action blocks the slap and kicks %n in the face.\001"
If anyone slaps the bot, it will block the slap and kick them in the face.
"!notice|#test|notice %n :notice message"
obvious, it will notice the nickname 'notice message'
"!query|#test|privmsg %n :query/private message"
another obvious one, will query the nickname 'query/private message'
"!kickme|#test|kick %c %n :kick fulfilled.. hehe \037:P\037"
kinda obvious. kicks the person requesting a kick.
"!voiceme|*|mode %c +v %n"
voices you if you ever cared to be voiced.
"!voiceme|*|privmsg %c :\002%n\002, feel the \002Power\002 of voice!"
this is to show a 2nd handler for a trigger, this will be carried out after the one above it. Basically telling you voice has power or smish..
"!repeat|*|privmsg %c :%n just said \002%i\002

"
basically mirrors whatever you type, to show the variable %i is entire input.
"!voicenick|*|mode %c +v %i1"
this is to show the power of %i1 the first word of input. Voices a nickname u put.
"!kickbannick|*|mode %c +b %i1!*@*"
This is to show the power of %n and %i1/%i2 combined. First the mode to ban them is set, using their nickname.
"!kickbannick|*|kick %c %i1 :%i2 (Requested by %n)"
Now we kick them down here with our message. And for courtesy, the bot is merely the messenger so attched the requested by nickname message.
"!kicknick|*|kick %c %i1 :%i2 (Requested by %n)"
This was to mirror the kick command above but because it's tied to ban, we need a new name so just the kick part will occur.
Hope this explains most of how to 'script' the mycommands section. Basically, _anything_ you can have putserv'd can be your message, all of the variables can be used on either