| View previous topic :: View next topic |
| Author |
Message |
Lanh Voice
Joined: 04 Jul 2008 Posts: 6
|
Posted: Fri Jul 04, 2008 2:05 am Post subject: Complete Newbie - Needing Basic Script With Basic Triggers |
|
|
Hi,
I am a complete newbie to all this kind of thing having previously run triggers from my copy of X-Chat, I have recently upgraded to an eggdrop bot and would like to run the triggers from there.
At the moment our triggers are in the format of:-
!trigger|#room|notice %n message
Basically the person wanting the information types "!trigger" in the room and they receive a notice back with the information they want.
There are around 50 of these triggers, but all I need to get me started converting them from is an example of 1. It is a very, very basic script that I am looking for, I just don't know where to begin.
There are no permissions complications, they should be available to everyone and the bot should respond whether it is a user, half-op or op in the room that it is in.
Is something like this possible? Could someone tell me where to look to learn how to create such a script? Is someone able to post an example which I could then expand upon for all the commands?
Any help at all would be appreciated as I have reached a place where I am now completely lost!
Also, could someone let me know if when the script is uploaded if it is updated to others in real time or if the eggdrop would need to be rehashed/restarted before it would show the updated information?
Thank you for reading,
Lanh |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Fri Jul 04, 2008 8:51 am Post subject: |
|
|
First you need to learn the [bind] command. Read about it in Tcl-commands.doc.
| Quote: | bind <type> <flags> <keyword/mask> [proc-name]
Description: You can use the 'bind' command to attach Tcl procedures
to certain events. flags are the flags the user must have to trigger
the event (if applicable). proc-name is the name of the Tcl procedure
to call for this command (see below for the format of the procedure
call). If the proc-name is omitted, no binding is added. Instead, the
current binding is returned (if it's stackable, a list of the current
bindings is returned).
Returns: name of the command that was added, or (if proc-name was
omitted), a list of the current bindings for this command |
You need to bind to pub, the pub bind is also explained in Tcl-commands.doc.
| Quote: | PUB
bind pub <flags> <command> <proc>
procname <nick> <user@host> <handle> <channel> <text>
Description: used for commands given on a channel. The first word
becomes the command and everything else is the text argument. |
So basically, you want something like this:
| Code: | # a pub bind that calls pub:trigger procedure
# whenever ANYONE (notice the '-') types !trigger in a channel
bind pub - !trigger pub:trigger
proc pub:trigger {nick uhost hand chan arg} {
# $nick is the nickname of the use who wrote !trigger
# $uhost is user@host of $nick
# $hand is the handle of $nick (on the bot)
# $chan is the channel-name in which the trigger was sent
# $arg contains all text after !trigger (it's a string)
} |
When you update a script, you need to at least .rehash your Eggdrop for the changes to be committed. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
Lanh Voice
Joined: 04 Jul 2008 Posts: 6
|
Posted: Fri Jul 04, 2008 11:53 pm Post subject: |
|
|
Having read the documentation and tried to play with the script for the past 3 hours to make it respond to me in the room, sadly, I am no wiser.
I've been completely unable to get the script to respond to me in any way either in the channel, in a notice or in a private message.
Is there a tutorial anywhere which can guide someone with absolutely no tcl experience at all through the different steps needed to create what I presumed (based on the xchat trigger script that I had been using) would be a very simple script like what I am trying to achieve?
It really needs to begin at the very beginning and to preferably include examples. |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sat Jul 05, 2008 9:33 am Post subject: |
|
|
Did you read about the [puthelp], [putserv], and [putquick] commands? You can also check other scripts and learn from them. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
Lanh Voice
Joined: 04 Jul 2008 Posts: 6
|
Posted: Wed Jul 09, 2008 5:53 am Post subject: |
|
|
Yep and attempted to use them. No luck, like I said I am flying completely blind here, complete and utter novice.
I mistakenly thought that it would be as easy as creating and maintaining the triggers like manually in x-chat through "uberscript" which is a level I almost understand, (editing txt files with a list of triggers in them).
I spent some time before I logged in here originally going through some of the scripts here and on other sites, I tried manipulating them and everything I tried in terms of modification either caused the bot to refuse to rehash (error in the script) or simply just didn't respond.
I'll keep looking I guess, if I have no luck by the end of the month, I'll just have to pay someone to set it up for me!  |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Wed Jul 09, 2008 6:04 am Post subject: |
|
|
You can get more help if you just show us what you've written so far. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
pitbull Voice
Joined: 12 Aug 2007 Posts: 13
|
Posted: Mon Jul 14, 2008 12:32 pm Post subject: |
|
|
Why not help the guy out a little... Rather than read for hours and still be lost, give him a simple example.
bind pub - !notice pub_sendmeanotice
proc pub_sendmeanotice {nick uhost handle chan args} {
putserv "NOTICE $nick :This is a notice!"
}
bind pubm - !yellatme pub_yellatme
proc pub_yellatme {nick uhost handle chan} {
putserv "NOTICE $nick :WHY WOULD YOU WANT ME TO DO THAT?"
}
Hope this inspires you to learn more, not give up because of over complicated manuals. _________________ irc://irc.efnet.net/peakoil |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Mon Jul 14, 2008 1:20 pm Post subject: |
|
|
@pitbull | Code: | bind pub - !notice pub_sendmeanotice
proc pub_sendmeanotice {nick uhost handle chan args} { |
You have used the 'special token' args in this. This will lead to problems for other users taking your advice. Use Arg or Text in this case, not args.
| Code: | bind pubm - !yellatme pub_yellatme
proc pub_yellatme {nick uhost handle chan} { |
This is incorrect, a public message bind needs 5 parameters: nick, uhost, handle, chan, and text. If you meant msgm, then change 'chan' into 'text' as private messages to the bot are not passed a channel parameter.
In all of this it is safe to say, reading doesn't hurt at all. Perhaps reading manuals is something you should do as well. Reading is like power. You are giving up power in failing to read. A good place to start reading is Here. Specifically the bottom part dealing with args. _________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Wed Jul 16, 2008 8:56 am Post subject: |
|
|
| Code: | # Multi-Bind Messaging (the easy way to do this)
# 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 two variables to use
# %n - will be replaced with $nick
# %c - will be replaced with $chan
variable mycommands {
"!trigger1|#room|notice %n :message"
"!trigger2|#room|privmsg %c :message"
}
# Script begins - change nothing below here
bind pubm -|- "*" mycommands_proc
proc mycommands_proc {nick uhand hand chan input} {
foreach item $::mycommands {
if {[string match -nocase [lindex [split $item \|] 0] [lindex [split $input] 0]]} {
if {[string match -nocase [lindex [split $item \|] 1] $chan]} {
set message [join [lrange [split $item \|] 2 end]]
resub -all -nocase {%n} $message $nick message
resub -all -nocase {%c} $message $chan message
putserv "$message"
}
}
}
}
putlog "Multi-bind messaging script loaded." |
This should accomplish what you desire with minimum hassle. It will allow you to use the lists you already have basically. You will need to add a space and colon into your messages like so: "notice %n :message" or "notice %c :message". This does it without having hundreds of procedures. You are allowed to use wildcards in mycommands. So an entry of "!help|*|notice %n :There is no help for %c. %n, you are silly." is totally valid. It will allow use in ANY channel, because of the * (wildcard) in the channel field. This is how you should script things of this nature rather than building tons of stand-alone procedures. You can also have multiple messages as well, just repeat the same !trigger|#channel with the next message you want displayed.
Edit: try #2, game on.
Edit: try #3, game is better. game has finesse. _________________ speechles' eggdrop tcl archive
Last edited by speechles on Thu Jul 24, 2008 9:45 pm; edited 4 times in total |
|
| Back to top |
|
 |
Lanh Voice
Joined: 04 Jul 2008 Posts: 6
|
Posted: Thu Jul 24, 2008 1:00 am Post subject: |
|
|
Thanks guys, I appreciate the encouragement, I have had limited success.
I have spent a lot of time trying to learn by altering existing scripts, which is the same way that I learned html, and it's slow going, I am cross referencing everything in the manuals and using google, I got a few books from the library regarding IRC that I am also making my way through, so I haven't given up, lol, I will learn this stuff if it kills me.
Speechles, thank you for the example, it's appreciated, it throws up the following error, it's very similar to what I have seen before in my testing, I have not yet been able to fix it. The error is below...
| Code: | [00:48] missing close-brace
while executing
"proc mycommands_proc {nick uhand hand chan input} {
foreach item [split $::mycommands] {
if {[string match -nocase [lindex [split $item \|]..."
(file "scripts/triggers.tcl" line 20) |
|
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Thu Jul 24, 2008 10:06 am Post subject: |
|
|
For some reason, speechles forgot to close the open-brace right before opening a new one.
| Code: | if {[string match -nocase [lindex [split $item \|] 0] [lindex [split $input] 0]] {
if {[string match -nocase [lindex [split $item \|] 1] $chan] { |
Add a close-brace (}) before the open-brace ({) at the end of each line in the code snippet above. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Thu Jul 24, 2008 10:28 am Post subject: |
|
|
| Sir_Fz wrote: | | For some reason, speechles forgot to close the open-brace right before opening a new one. |
Most of that I wrote directly into the reply box and it's sorta, well not sorta, it's very very tiny and word wraps everything..lol It's almost like notepad but in an extremely crippled way. Next time I'll just whip out notepad and do it. I've had this happen before trying to write code directly into the snippet box.. lmao. It's too easy to overlook something because of the tiny box and word wrap.
Btw, I fixed the code above at least the problematic line. ;D _________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Thu Jul 24, 2008 10:49 am Post subject: |
|
|
I'm afraid that code will not quite work as intended, as the quotes will end up within the list items, rather than encapsulating them...
I would recommend storing the triggers in a proper list structure within ::mycommands from the beginning...
| Code: | ...
variable mycommands [list \
"!trigger1|#room|notice %n :message" \
"!trigger2|#room|privmsg %c :message" \
]
...
foreach item $::mycommands {
...
|
Also... there's no command called resub. Maybe regsub? _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Thu Jul 24, 2008 4:13 pm Post subject: |
|
|
| nml375 wrote: | I'm afraid that code will not quite work as intended, as the quotes will end up within the list items, rather than encapsulating them...
I would recommend storing the triggers in a proper list structure within ::mycommands from the beginning...
| Code: | ...
variable mycommands [list \
"!trigger1|#room|notice %n :message" \
"!trigger2|#room|privmsg %c :message" \
]
...
foreach item $::mycommands {
...
|
|
It does work as intended (albeit with the full understanding special tcl characters will of course need escaping or else will toss tcl errors), because the unofficial google scripts uses something exactly similar to do vocabulary aversion (swear word replacement). But it is better, agreed, to keep it as a list to begin with (this way there is nothing to understand, the list arrangement guarantees escaping and no tcl errors).
| nml375 wrote: | | Also... there's no command called resub. Maybe regsub? |
It could be a command I forgot a procedure. | Code: | proc resub {args} {
set condtion [eval regsub $args]
return condition
} |
lmao.. that is probably sadly incorrect, but yeah. I forgot the g there, regsub, was sposta substitute text. _________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Thu Jul 24, 2008 4:48 pm Post subject: |
|
|
| speechles wrote: | | nml375 wrote: | I'm afraid that code will not quite work as intended, as the quotes will end up within the list items, rather than encapsulating them...
I would recommend storing the triggers in a proper list structure within ::mycommands from the beginning...
| Code: |
variable mycommands [list \
"!trigger1|#room|notice %n :message" \
"!trigger2|#room|privmsg %c :message" \
]
...
foreach item $::mycommands {
...
|
|
It does work as intended (albeit with the full understanding special tcl characters will of course need escaping or else will toss tcl errors), because the unofficial google scripts uses something exactly similar to do vocabulary aversion (swear word replacement). But it is better, agreed, to keep it as a list to begin with (this way there is nothing to understand, the list arrangement guarantees escaping and no tcl errors).
... |
I beg to differ, as I even verified the flaw in a native tcl shell..
| Code: | variable mycommands {
"!trigger1|#room|notice %n :message"
"!trigger2|#room|privmsg %c :message"
}
foreach item [split $::mycommands] {
puts stdout [split $item \|]
}
#Output starts here:
{"!trigger1} #room notice
%n
:message\"
{"!trigger2} #room privmsg
%c
:message\"
|
As you can see, there are several empty lines, representing empty list items, and the trigger has a leading ", while the message has a trailing one.
If you do not specify a specific separator, split will use any and all whitespace characters, including newlines, spaces, and tabs. Also, it will not care for "long lines" grouping. Using newline as separator will neither solve the issue, as "" would still not be removed (of course, if mycommands is altered to not include those quotes, things would look better). _________________ NML_375, idling at #eggdrop@IrcNET |
|
| 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
|
|