Public binds
1. possibility
1
|
bind pub <flags> <command> <proc>
|
Flags: What flags must a user have on the Bot to trigger that bind?
- or -|- = no flags needed
n = global owner
-|n = channel owner
n|n = global owner OR channel owner
n&n = global owner AND channel owner
m|n = global master OR channel owner
You can replace the "n" and "m" with what ever flag you want.
Command: The first word the user writes in his line is the command. So if someone says "Hey guys" in the channel and the command is "Hey" the bind is triggered and the specific procedure called.
Proc: The procedure that should be called when the bind is triggered
Call the procedure "greet" when someone says "Hello" on any channel the bot is on:
1
|
bind pub - "hello" greet
|
We can write "hello" as the command because l
etter case doesn't matter in binds
Example trigger: Someuser (
Someuser!user@coolhost.us) writes "hello world!" on channel "#we.learn.tcl" and is known as "Beginner" by the Bot.
Example procedure header for the greet:
1
|
proc greet { nick uhost handle channel text } {
|
So regarding the example trigger the following content would be in the following variables ($variable - content):
$nick - Someuser
$uhost -
user@coolhost.us
$handle - Beginner
$channel - #we.learn.tcl
$text - world! (everything after the command)
2. possibility
Whenever you want to check more than the first word of a line or if you want to use wildcards you have to use the bind type PUBM
1
|
bind pubm <flags> <mask> <proc>
|
Flags: as aforementioned
Mask: The mask is a bit different to command parameter in the bind type pub. It is matched against the channel the user said something on and the text he had written. Means: "#channel text". Examples beneath.
Proc: as aforementioned
Ok. Let's make the procedure "greet" being called when users write something with an @ in the channel #we.learn.tcl.
1
|
bind pubm - "#we.learn.tcl *@*" greet
|
Or making the channel name regardless:
1
|
bind pubm - "% *@*" greet
|
% = wildcard for "one word"
Example trigger (matches for both binds): Someuser (
Someuser!user@coolhost.us) writes "write to me: cooluser@someisp.org" on channel "#we.learn.tcl" and is known as "Beginner" by the Bot.
Example procedure header:
1
|
proc greet { nick uhost hand chan arg } {
|
Regarding the example trigger the variables will get the following content:
$nick - Someuser
$uhost -
user@coolhost.us
$hand - Beginner
$chan - #we.learn.tcl
$arg - write to me:
cooluser@someisp.org (the first word is not stripped like when it is called by a pub bind, the 5th argument contents the whole line here)
As you can see you can name the variables as you want (but be careful with using the name "args" for 5th argument - this has a special meaning). Only the order of the content is always the same and you always have to provide 5 variable names for those two bind types.
I hope this will help you making your first public binds.