| View previous topic :: View next topic |
| Author |
Message |
Miku Voice
Joined: 08 Feb 2009 Posts: 3
|
Posted: Sun Feb 08, 2009 9:54 am Post subject: Multiple Notices |
|
|
Hello, I am trying to send a user multiple notices when they say a specific trigger, but each time it stops after only 2.
My code looks like this:
| Code: | proc putnot {nick msg} { putserv "NOTICE $nick :$msg" }
proc pub_!trigger {nick uhost hand chan rest} {
global botnick
set cmd [string tolower [lindex $rest 0]]
if {$cmd == ""} {
putnot $nick "Message 1"
putnot $nick "Message 2"
putnot $nick "Message 3"
putnot $nick "Message 4"
putnot $nick "Message 5" ;return 0}
}
bind pub - !trigger pub_!trigger |
Any help is appreciated. Thanks!
Last edited by Miku on Sun Feb 08, 2009 12:20 pm; edited 1 time in total |
|
| Back to top |
|
 |
TCL_no_TK Owner

Joined: 25 Aug 2006 Posts: 509 Location: England, Yorkshire
|
Posted: Sun Feb 08, 2009 11:00 am Post subject: |
|
|
Something like this often works: | Code: | set mynotcs {
Message 1
Message 2
Message 3
Message 4
}
proc mynotc {nick host handle channel text} {
global mynotcs
set dest [lindex [split $text] 0]
foreach notc $mynotcs {
puthelp "NOTICE $dest :$notc"
}
return
}
bind pub -|- !notc mynotc | The important things to be aware of are the global mynotcs which gives us the messages we set in set mynotcs. And as we use a foreach loop, we are able to use all the notc's one at a time using $notc
I dont know if that will work, but i hope it at least made sense.  _________________ TCL the misunderstood |
|
| Back to top |
|
 |
arfer Master

Joined: 26 Nov 2004 Posts: 436 Location: Manchester, UK
|
Posted: Sun Feb 08, 2009 11:44 am Post subject: |
|
|
You do seem to have a statement that, once called, would continue to attempt to call itself recursively :-
| Code: |
proc putnot {nick msg} { putnot "NOTICE $nick :$msg" }
|
You are fortunate it failed, probably because the first time it called itself (the second time it executes overall, coincidentally) it does so with one argument but the proc needs two. Therefore it would not send to the IRCD ad nauseum. Lucky you.
If you particularly wanted the code in the format you pasted, then try the following :-
| Code: |
bind PUB - !notice pNotice
proc pNotice {nick uhost hand chan rest} {
if {[string length [string trim $rest]] == 0} {
pOutput $nick "Message 1"
pOutput $nick "Message 2"
pOutput $nick "Message 3"
pOutput $nick "Message 4"
pOutput $nick "Message 5"
}
return 0
}
proc pOutput {nick msg} {putserv "NOTICE $nick :$msg"}
|
I favour the style of the previous poster. A list of responses set as a variable outside the bind proc gives greater flexibility, in case you wish to publish the script and allow users to configure their own messages.
Last edited by arfer on Sun Feb 08, 2009 4:12 pm; edited 1 time in total |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Sun Feb 08, 2009 12:05 pm Post subject: |
|
|
| TCL_no_TK wrote: | Something like this often works: | Code: | set mynotcs {
Message 1
Message 2
Message 3
Message 4
} |
|
| Code: | set mynotcs {
"Message 1"
"Message 2"
"Message 3"
"Message 4"
} |
You might need to build your tcl-list using double quotes to keep those spaces within each line from breaking things. _________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
Miku Voice
Joined: 08 Feb 2009 Posts: 3
|
Posted: Sun Feb 08, 2009 1:06 pm Post subject: |
|
|
Okay, I feel retarded now. Turns out that my initial script, as well as all of yours, would have worked except I have a special character in my message which chokes it. Now I just have to figure out a way around this and it'll be good to go.
The line reads:
| Code: | | "\002(MKV)\002 - \002(\002/msg [Hatsuyuki]Maka xdcc send #9\002)\002" |
in case any of you know an easy fix. It hangs up on the [Hatsuyuki] part.
Thanks for all your help so far. |
|
| Back to top |
|
 |
arfer Master

Joined: 26 Nov 2004 Posts: 436 Location: Manchester, UK
|
Posted: Sun Feb 08, 2009 4:09 pm Post subject: |
|
|
Tcl will attempt to interpret and substitute anything enclosed in square brackets as a command and its arguments (if it has any), so your script is choking on [Hatsuyuki] since no such command exists.
Simply escape the characters with special Tcl meaning in order for them to be accepted as their normal literal selves.
| Code: |
"\002(MKV)\002 - \002(\002/msg \[Hatsuyuki\]Maka xdcc send #9\002)\002"
|
|
|
| Back to top |
|
 |
Miku Voice
Joined: 08 Feb 2009 Posts: 3
|
Posted: Mon Feb 09, 2009 2:26 pm Post subject: |
|
|
Thanks that worked like a charm. I was reading a tutorial about how to filter special characters but it was rather confusing and had the "\" in series of 3 and 5.
Anywho thanks again, script works great now  |
|
| Back to top |
|
 |
|