The Eggdrop FAQ |
TCL-Scripting |
How can I learn the secrets to be an eggdrop TCL scripter? |
|
How do I add mIRC colours/bolds/etc to my scripts output? | |||||||||||||||
These can be added using the following code:
So you can use: putserv "PRIVMSG #chann :\00312,4BLUE ON RED!\003" |
How can I match users in my script with this AND that flag? |
Use the userlist flags channel command to get persons with the specified flags. If you use: userlist AB You will get all users that have flags A or B. If you want it to be A and B, you must use: userlist AB& The default matching method used in eggdrop is OR, so you must tell it when you want another thing (an AND). '|' and '&' are equivalent seperators, one meaning OR, one meaning AND. |
How can I bind an evento to an ACTION (/me text)? |
bind ctcp - "ACTION" action_proc This will trigger 'action_proc' when someone does an action to the channel or to the bot in private. You need to pick up what you want inside your proc. Send to the bot privately: proc action_bind { nick uhost hand dest keyword text } { if {[string index $dest 0] == "#"} { return 0 } ... } Send to a channel: proc action_bind { nick uhost hand dest keyword text } { if {[string index $dest 0] != "#"} { return 0 } ... } The ACTION will be triggered if sent to a channel or when sent to the bot privately, that's why you need to check which was the destination right at the beginning of the proc. The $dest will be a channel name or the nickname of your bot. |
I miss the addhost command in 1.3.x! |
This was replaced with: setuser <nick> HOST <hostmask> |
How to bind an event to occur at a specific time of the day? |
Use the time binding: bind time - <mask> time:proc proc time:proc { min hour day month year } { ... } The <mask> should be a set of 5 integer numbers, in the form: min hour day month year. Examples:
|
How to make the bot execute a TCL procedure every XX minutes? |
if {![info exists myproc_running]} { timer 20 myproc set myproc_running 1 } proc myproc {} { # your stuff here ... # ... timer 20 myproc return 1 } This will guarantee that your script will not start another timer if the owner rehashs the bot. |
The RAW binding does not work after switching from 1.1 to 1.3! |
The syntax was changed:
The matched mask now just includes the "keyword" of the raw command, and it can be a numeric, or another thing (NOTICE, PRIVMSG, etc). |
How can I remove all hosts from an user in one command? |
bind dcc n|- zaphosts dcc:zaphosts proc dcc:zaphosts { idx hand text } { foreach host [getuser $text hosts] { delhost $text $host } return 1 } |
What should I care when I port my scripts from 1.1 to 1.3? |
This will try to make a summary of *all* changes that you must consider when you port a script from an 1.1 bot to a 1.3 bot.
|
What new features are avaliable with TCL on 1.3 bots that were not found in 1.1? |
Some things were already pointed out in the last question, you can recognize them by the 'New in 1.3'. Here are other new things you might want to use:
There may be more things, almost all of this was extracted from the documentation changes. |
How to bind an event to NOTICEs? |
|
I have a proc with an parameter called args and I always get '{' and '}' around the text passed to it. Why? |
When you use the parameter name args, it has a special meaning to TCL. It means: Accept any number of parameters here (even zero!), and put each argument into a separate list item. If you pass just one argument, it still makes a list of it. If you are confused, just avoid using args, use arg or something else instead. |
How to find out how long time one's bot has been online (connected to a server) in a TCL script? |
You can use the (undocummented) TCL global variable "server-online" to find out the timestamp of when your bot connected to the server. set time [expr [unixtime] - ${server-online}] would give you the ammount of seconds your bot is connected. |
Why does putserv "PRIVMSG $nick :[OP]" gives an error invalid command name "OP"? |
Use a bachslash to "quote" characters that might be misinterpreted by TCL, like "[", "{", "$" or sometimes "(". |
I tried the exec TCL command and it tells me couldn't execute "command bla": no such file or directory, but command is a valid command! So what? |
Don't quote the whole command, pass each argument separately. So if you want to execute ls -l DEBUG: WRONG: exec "ls -l DEBUG" -> this will give you an error RIGHT: exec ls -l DEBUG If you have the whole command you want to execute in a variable, you will need to do a trick with eval like: set varname "ls -ls DEBUG" WRONG: exec $varname -> this will give you an error RIGHT: eval exec $varname |