You need to bind to pub, the pub bind is also explained in Tcl-commands.doc.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
So basically, you want something like this: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.
Code: Select all
# 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)
}
Code: Select all
bind pub - !notice pub_sendmeanotice
proc pub_sendmeanotice {nick uhost handle chan args} {
Code: Select all
bind pubm - !yellatme pub_yellatme
proc pub_yellatme {nick uhost handle chan} {
Code: Select all
# 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."
Code: Select all
[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)
Code: Select all
if {[string match -nocase [lindex [split $item \|] 0] [lindex [split $input] 0]] {
if {[string match -nocase [lindex [split $item \|] 1] $chan] {
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.Sir_Fz wrote:For some reason, speechles forgot to close the open-brace right before opening a new one.
Code: Select all
...
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: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: Select all
... variable mycommands [list \ "!trigger1|#room|notice %n :message" \ "!trigger2|#room|privmsg %c :message" \ ] ... foreach item $::mycommands { ...
It could be a command I forgot a procedure.nml375 wrote:Also... there's no command called resub. Maybe regsub?
Code: Select all
proc resub {args} {
set condtion [eval regsub $args]
return condition
}
I beg to differ, as I even verified the flaw in a native tcl shell..speechles wrote: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: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: Select all
variable mycommands [list \ "!trigger1|#room|notice %n :message" \ "!trigger2|#room|privmsg %c :message" \ ] ... foreach item $::mycommands { ...
...
Code: Select all
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"