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.

Talker Script

Old posts that have not been replied to for several years.
Locked
f
freeMonday

Talker Script

Post by freeMonday »

Hi there, I tried to write a "talker-script", where the bot sends a message to the channel if I tell him to do so (/msg <botname> tell <message>). Well, obviously it does not work. I am new at tcl and I do not really know what to do. I guess it is just a simple mistake.

This is the script:

bind msg - tell talker

proc talker {nick uhost hand chan text} {

putserv "privmsg $chan :$text"
return 1
}

And this is the error that I get:
Tcl error [talker]: no value given for parameter "target" to "talker"

I would be very happy if you could help me.
D
Dw2k
Voice
Posts: 16
Joined: Sat Dec 07, 2002 4:40 pm
Location: Dundee || Liverpool
Contact:

Post by Dw2k »

You need to replace

Code: Select all

 proc talker {nick uhost hand chan text} { 
witu

Code: Select all

 proc talker {nick uhost hand args} { 
and have

Code: Select all

set args [join $args]
set chan [lindex $args 0]
set text [lindex $args 1]
then the rest of your code
you will need to use /msg botname tell #chan message

Hope that helps :)
Dave
f
freeMonday

Post by freeMonday »

It does not work this way :-?
It is still the same mistake

Code: Select all

Tcl error [talker]: no value given for parameter "target" to "talker"
D
Dw2k
Voice
Posts: 16
Joined: Sat Dec 07, 2002 4:40 pm
Location: Dundee || Liverpool
Contact:

Post by Dw2k »

Code: Select all

bind msg - talk cmd:talker
proc cmd:talker {nick uhost hand args} {
  set args [join $args]
  set chan [lindex $args 0]
  set text [lrange $args 1 end]

   putserv "PRIVMSG $chan :$text"
}
That should :)
Dave
f
freeMonday

Post by freeMonday »

Great!
It works, thank you very much.

But, is there a way to use the script to tell the bot in which channel he shall message?

So that I can use: /msg <botname> talk <message>
Instead of: /msg <botname> talk <chan> <message>
D
Dw2k
Voice
Posts: 16
Joined: Sat Dec 07, 2002 4:40 pm
Location: Dundee || Liverpool
Contact:

Post by Dw2k »

Yeah I suppose you could, as long as its just the one channel and it never changes :)

take out

Code: Select all

set chan [lindex $args 0] 
and rename the other to:

Code: Select all

set text [lrange $args 0 end] 
then have

Code: Select all

 putserv "PRIVMSG #yourchannel :$text" 
put in the channel you want to message and it will always message that channel no matter what.

:)
Dave
f
freeMonday

Post by freeMonday »

Yeha, it works, thank you.
All hail Dw2k that shalt be King hereafter.
User avatar
arcane
Master
Posts: 280
Joined: Thu Jan 30, 2003 9:18 am
Location: Germany
Contact:

Post by arcane »

Dw2k wrote:

Code: Select all

set text [lrange $args 0 end] 
quite useless eh? ;)
just remove that line and replace $text with $args

btw @Dw2k:
by using "join $args" you convert it to a string. using list commands on that is not a good idea. your "set text [lrange $args 0 end]" on the other hand returns a list, so you would have to use "join text" again.
aVote page back online!
Check out the most popular voting script for eggdrop bots.

Join the metal tavern!
D
Dw2k
Voice
Posts: 16
Joined: Sat Dec 07, 2002 4:40 pm
Location: Dundee || Liverpool
Contact:

Post by Dw2k »

I sometimes use

Code: Select all

 set args [split [join $args] " "]
I'll have to look at it more :D
Dave
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

arcane wrote:
Dw2k wrote:

Code: Select all

set text [lrange $args 0 end] 
quite useless eh? ;)
just remove that line and replace $text with $args

btw @Dw2k:
by using "join $args" you convert it to a string. using list commands on that is not a good idea. your "set text [lrange $args 0 end]" on the other hand returns a list, so you would have to use "join text" again.
Arcane, normally, you would be correct, assuming we were talking about just plain ol TCL... but we are dealing with eggdrop TCL here, and the way "bind" calls procedures.... when args is used in this scenario, it is a list of lists, so by join'ing it once, it becomes a list...

Now, don't get me wrong, I agree with you arcane that it is an inefficient and impractical method... Using a variable name such as "text", and using split, etc.. would be much better, imo.

But just for informations sake, you should check out peterre's special characters page: http://www.peterre.com/characters.html
D
Dw2k
Voice
Posts: 16
Joined: Sat Dec 07, 2002 4:40 pm
Location: Dundee || Liverpool
Contact:

Post by Dw2k »

strikelight wrote:
arcane wrote:
Dw2k wrote:

Code: Select all

set text [lrange $args 0 end] 
quite useless eh? ;)
just remove that line and replace $text with $args

btw @Dw2k:
by using "join $args" you convert it to a string. using list commands on that is not a good idea. your "set text [lrange $args 0 end]" on the other hand returns a list, so you would have to use "join text" again.
Arcane, normally, you would be correct, assuming we were talking about just plain ol TCL... but we are dealing with eggdrop TCL here, and the way "bind" calls procedures.... when args is used in this scenario, it is a list of lists, so by join'ing it once, it becomes a list...

Now, don't get me wrong, I agree with you arcane that it is an inefficient and impractical method... Using a variable name such as "text", and using split, etc.. would be much better, imo.

But just for informations sake, you should check out peterre's special characters page: http://www.peterre.com/characters.html
Thanks, that page is great :)
Dave
Locked