| View previous topic :: View next topic |
| Author |
Message |
Schubi Voice
Joined: 06 Sep 2007 Posts: 5
|
Posted: Fri Sep 07, 2007 5:23 am Post subject: /msg bot, reply to channel |
|
|
Hello,
I've been trying to write a script that lets the bot send a message to the channel after sending a query to the bot:
/msg Bot User
<Bot> User: Ha Ha!
I tried to adapt some scripts that I found, but as I'm not familiar with coding it's a bit hard (and I already tried serveral variants of this one):
| Code: | # /msg <bot> <nick>
bind msg * laugh msg:laugh
proc msg:laugh {nick host hand text} {
putserv "PRIVMSG $chan :$nick: Ha Ha!"
}
|
# bind msg <flags> <command> <proc>
# procname <nick> <user@host> <handle> <text>
# Description: used for /msg commands. The first word of the user's
# msg is the command, and everything else becomes the text argument.
Thanks for taking a look,
Schubi |
|
| Back to top |
|
 |
user

Joined: 18 Mar 2003 Posts: 1452 Location: Norway
|
Posted: Fri Sep 07, 2007 6:24 am Post subject: Re: /msg bot, reply to channel |
|
|
What channel? There's no channel associated with a message sent directly to the bot. _________________ Have you ever read "The Manual"? |
|
| Back to top |
|
 |
Schubi Voice
Joined: 06 Sep 2007 Posts: 5
|
Posted: Fri Sep 07, 2007 7:36 am Post subject: |
|
|
| Code: | bind msg - laugh msg:laugh
set chan "#test"
proc msg:laugh {nick host hand text} {
putserv "PRIVMSG $chan :$nick: Ha Ha!"
|
Still something missing...?! |
|
| Back to top |
|
 |
YooHoo Owner

Joined: 13 Feb 2003 Posts: 939 Location: Redwood Coast
|
Posted: Fri Sep 07, 2007 9:15 am Post subject: |
|
|
| Schubi wrote: | | Code: | bind msg - laugh msg:laugh
set chan "#test"
proc msg:laugh {nick host hand text} {
putserv "PRIVMSG $chan :$nick: Ha Ha!"
|
Still something missing...?! | yup. anytime you use a variable in a procedure, you need to declare it within the proc.
| Code: | bind msg - laugh msg:laugh
set laughchan "#test"
proc msg:laugh {nick host hand text} {
global laughchan
putserv "PRIVMSG $laughchan :$nick Ha Ha!"
} |
_________________
Johoho's TCL for beginners
 |
|
| Back to top |
|
 |
Schubi Voice
Joined: 06 Sep 2007 Posts: 5
|
Posted: Sun Sep 09, 2007 2:56 pm Post subject: |
|
|
| Thank you - but still not working. :-/ I guess it has something to do with $nick (but now idea how the script gets the "/msg bot <nick>" value) |
|
| Back to top |
|
 |
Schubi Voice
Joined: 06 Sep 2007 Posts: 5
|
Posted: Sun Sep 23, 2007 11:34 am Post subject: |
|
|
After a long, long time:
| Code: | ## NELSON 1.0.0
set chan "#testa"
bind msg - laugh nelson
## /msg botnick laugh <idiot>
proc nelson {nick uhost handle arg} {
global chan botnick
if { $arg == "" || $arg eq " " } {
putserv "PRIVMSG $nick :Usage: /msg $botnick laugh <idiot>"
return 0
}
putserv "PRIVMSG $chan :$arg: Haa Haa!"
}
putlog "Loaded NELSON 1.0.0"
|
|
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Sun Sep 23, 2007 7:31 pm Post subject: |
|
|
Just so you know, the bot does have built-in capability to do the same thing, eg .act or .say (check the built-in helpfiles via dcc, .help act, .help say)
One other tip, you can use [string trim] to make sure there's no spaces so you don't need to test for " "
eg:
set arg [string trim $arg] |
|
| Back to top |
|
 |
Schubi Voice
Joined: 06 Sep 2007 Posts: 5
|
Posted: Mon Oct 01, 2007 5:05 pm Post subject: |
|
|
| Thanks for the info! |
|
| Back to top |
|
 |
|