nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Thu Jul 12, 2012 1:47 pm Post subject: |
|
|
In tcl, that would be something along these lines:
| Code: | if {test} {
code if test is TRUE
} {
code if test is FALSE
} |
In order to do string comparisons, the simplest approach would be to use the string command with the match option:
| Code: | | string match "*.id" $text |
In order to evaluate and test the string match command, we need to use command substitutions, which is done using brackets [ ]
| Code: | if {[string match "*.id" $text]} {
...
} {
...
} |
Printing text to stdout is done using the puts command, though that won't make much sense with eggdrops. In order to send text to the irc server, you can use the puthelp and putserv commands; if you'd rather like to log the message, use putlog for that:
| Code: | if {[string match "*.id" $text]} {
puthelp "PRIVMSG #Somechannel :The string \"${text}\" matches!"
} {
putlog "The string \"${text}\" does not match the test!"
} |
Next, in order to use this with a public trigger, we need a binding, and place the above code in a proc:
| Code: | bind pub !whois - pubWhois
proc pubWhois {nick host handle channel text} {
if {[string match "*.id" $text]} {
puthelp "PRIVMSG #Somechannel :The string \"${text}\" matches!"
} {
putlog "The string \"${text}\" does not match the test!"
}
} |
_________________ NML_375, idling at #eggdrop@IrcNET |
|