| View previous topic :: View next topic |
| Author |
Message |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Fri Jul 25, 2008 12:05 am Post subject: |
|
|
| Code: | # 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." |
| Quote: | <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: | 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 _________________ speechles' eggdrop tcl archive
Last edited by speechles on Tue Jan 05, 2010 8:32 pm; edited 18 times in total |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Fri Jul 25, 2008 8:05 am Post subject: |
|
|
Removing the split of mycommands, as suggested, does improve the behavior of the script. However, given the nature of this forum and the vast range of knowledge (from "what's tcl" to "expert programmer"), it would be advisable to post code that is "theoretically correct"; that is, make no assumptions that whoever is going to use the script has any knowledge 'bout advanced list structures or other. Using the list command provides a valid list, no matter of the input (each argument becomes a separate list item), whereas crafting list structures by hand requires a lot of experience.
Many new coders will search these threads and use code-snippets as learning examples, and in my opinion, it is far better to use proper coding rather than advanced "hacks". I am not questioning your ability to create proper list structures by hand, I'm just saying that you can't expect anyone reading this example to be able to accomplish the same. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Lanh Voice
Joined: 04 Jul 2008 Posts: 6
|
Posted: Sat Aug 02, 2008 11:17 pm Post subject: |
|
|
I just want to say thank you to everybody who has contributed to this thread, your help and encouragement has been hugely appreciated and has been invaluable.
I have been able to not only get the triggers that I would like but also to use a number of other scripts, modify them for our use in our channel which will make things a lot easier in the long run.
Thank you everybody. |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sun Aug 03, 2008 10:03 am Post subject: |
|
|
Nice to hear of your progress. If you get stuck on anything, don't hesitate to ask, and we'll gladly do our best to help. _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Repdientu Voice
Joined: 30 Apr 2009 Posts: 33 Location: Viet Nam
|
Posted: Wed Jul 29, 2009 1:50 am Post subject: |
|
|
Hi Speechles
| Code: | # 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)
# %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
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 {%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." |
can i used file /data/command.txt for variable mycommands ?
and can add some command via: !addcmd !mode*|#myroom|mode %c %i1 to command.txt ? |
|
| Back to top |
|
 |
Daedalus Voice
Joined: 27 Jun 2007 Posts: 24
|
Posted: Wed Jul 29, 2009 6:13 am Post subject: |
|
|
I have a question.
How would I make this work with actions? Currently, it does not.
Basically, I'm making a "character" bot, that replies to some simple, specific stimulus in channel that relates to some very random things she says at random intervals. So if she says
"How do I get these rhinoes into the jar?"
a user might say
"There are no rhinoes!"
to which she would say
"sadface:("
...so basically it's a REALLY simple way of doing "AI" with less chance of having really stupid responses that are out of context.
Now, the "character" likes having her tummy tickled. But people can't do that, because she doesn't understand
/me tickles the bot's tummy
...any ideas?
I could just write action procs, but this would defeat the object of this script. |
|
| Back to top |
|
 |
|
|
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
|
|