This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

/msg bot, reply to channel

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
S
Schubi
Voice
Posts: 5
Joined: Thu Sep 06, 2007 4:37 pm

/msg bot, reply to channel

Post by Schubi »

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: Select all

# /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
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Re: /msg bot, reply to channel

Post by user »

What channel? There's no channel associated with a message sent directly to the bot.
Have you ever read "The Manual"?
S
Schubi
Voice
Posts: 5
Joined: Thu Sep 06, 2007 4:37 pm

Post by Schubi »

Code: Select all

bind msg - laugh msg:laugh

set chan "#test"

proc msg:laugh {nick host hand text} {
   putserv "PRIVMSG $chan :$nick: Ha Ha!"
Still something missing...?!
User avatar
YooHoo
Owner
Posts: 939
Joined: Thu Feb 13, 2003 10:07 pm
Location: Redwood Coast

Post by YooHoo »

Schubi wrote:

Code: Select all

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: Select all

bind msg - laugh msg:laugh

set laughchan "#test"

proc msg:laugh {nick host hand text} {
  global laughchan
   putserv "PRIVMSG $laughchan :$nick Ha Ha!"
}
S
Schubi
Voice
Posts: 5
Joined: Thu Sep 06, 2007 4:37 pm

Post by Schubi »

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)
S
Schubi
Voice
Posts: 5
Joined: Thu Sep 06, 2007 4:37 pm

Post by Schubi »

After a long, long time:

Code: Select all

## 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"
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

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]
S
Schubi
Voice
Posts: 5
Joined: Thu Sep 06, 2007 4:37 pm

Post by Schubi »

Thanks for the info!
Post Reply