| View previous topic :: View next topic |
| Author |
Message |
Landslyde Halfop
Joined: 01 May 2014 Posts: 46
|
Posted: Wed Apr 13, 2016 10:38 pm Post subject: [SOLVED] Tcl error: wrong # args |
|
|
I'm new to TCL scripting. When I want my bot to do something, I find a script to learn from. That said, here I am. Stuck!
My code is:
| Code: | bind pub - .lovesme pub_lovesme
set lovesme1 {
"is in deep love with you, "
"loves loves loves you, "
}
proc pub_lovesme {nick host handle channel arg} {
global lovesme1
set lovesme2 [lindex $lovesme1 [rand [llength $lovesme1]]]
set mychanlist [chanlist $channel]
set randomnick [lindex $mychanlist [rand [llength $mychanlist]]]
putserv "PRIVMSG $channel :$randomnick $lovesme2 $nick" randomnick lovesme2
return 1
} |
But this fails and i get:
| Code: | | Tcl error [pub_lovesme]: wrong # args: should be "putserv text ?options?" |
What am I doing wrong? Any help wld be appreciated. Thanks.
Last edited by Landslyde on Thu Apr 14, 2016 1:32 am; edited 1 time in total |
|
| Back to top |
|
 |
Landslyde Halfop
Joined: 01 May 2014 Posts: 46
|
Posted: Thu Apr 14, 2016 12:25 am Post subject: |
|
|
Never mind. I figured it out. I added this to concatenate the two vars:
| Code: | {
...
set lovemsg $randomnick$lovesme2
putserv "PRIVMSG $channel :$lovemsg $nick" lovemsg
return 1
}
|
Sure. This is cheesy stuff, but the girls wanted it. What can I say
Peace out... |
|
| Back to top |
|
 |
Get_A_Fix Master

Joined: 07 May 2005 Posts: 206 Location: New Zealand
|
Posted: Thu Apr 14, 2016 6:46 am Post subject: |
|
|
lol, you were just declaring to variables after it has been processed and put to channel.
| Code: |
putserv "PRIVMSG $channel :$randomnick $lovesme2 $nick" randomnick lovesme2
|
So, your code was fine
I only added a small substitution so that you could use $nick $chan arguments within your set list, and a check to make sure randomnick wasn't botnick (and if it was, just send a silly message to chan).
| Code: |
bind pub - .lovesme pub_lovesme
set lovesme1 {
"is in deep love with you, $nick"
"loves loves loves you, $nick"
"only loves loves $chan ..."
}
proc pub_lovesme {nick uhost hand chan arg} {
global lovesme1
set lovesme2 [lindex $lovesme1 [rand [llength $lovesme1]]]
set lovesme2 [subst -nocommands $lovesme2]
set mychanlist [chanlist $chan]
set randomnick [lindex $mychanlist [rand [llength $mychanlist]]]
if {[isbotnick $randomnick]} {puthelp "PRIVMSG $chan :Sorry, $nick, but bot love leads to botulism.."; return}
puthelp "PRIVMSG $chan :$randomnick $lovesme2"
return 0
}
|
Alternatively, to remove the botnick completely, and avoid the above isbotnick check, use:
| Code: |
set mychanlist [chanlist $chan]
set rembot [lsearch $mychanlist $::botnick]
set mychanlist [lreplace $mychanlist $rembot $rembot]
set randomnick [lindex $mychanlist [rand [llength $mychanlist]]]
|
_________________ We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals. |
|
| Back to top |
|
 |
Landslyde Halfop
Joined: 01 May 2014 Posts: 46
|
Posted: Sat Apr 16, 2016 12:29 am Post subject: |
|
|
Get_A_Fix:
Thanks for your reply. What I ended up doing was this:
| Code: |
# Start of pub_lovesme
proc pub_lovesme {nick host handle channel arg} {
global loves0 loves1 emo1
set emo2 [lindex $emo1 [rand [llength $emo1]]]
set loves00 [lindex $loves0 [rand [llength $loves0]]]
set loves2 [lindex $loves1 [rand [llength $loves1]]]
set mychanlist [chanlist $channel]
set randomnick [lindex $mychanlist [rand [llength $mychanlist]]]
if { $loves2 != "" } {
set lovemsg $loves00$randomnick$loves2$nick$emo2
putserv "PRIVMSG $channel :$lovemsg" lovemsg
return 1
} else {
putserv "PRIVMSG $channel :Sorry, $nick, but no one loves you."
return 1
}
}
# End of .lovesme
|
Works like a charm. But I appreciate you showing me how to exclude the bot.
One of the things that puzzles me is the usages of:
| Code: | putserv
puthelp
putquick
|
I may have left some off, but I don't understand the differences, if any, between those. |
|
| Back to top |
|
 |
Get_A_Fix Master

Joined: 07 May 2005 Posts: 206 Location: New Zealand
|
Posted: Sat Apr 16, 2016 3:59 am Post subject: |
|
|
| Landslyde wrote: | Get_A_Fix:
One of the things that puzzles me is the usages of:
| Code: |
putserv
puthelp
putquick
|
I may have left some off, but I don't understand the differences, if any, between those. |
The difference is merely queue, where putserv (sending commands to server) has the highest sending queue, puthelp (sending commands to channel/nickname) has less, and putquick (sending commands as fast as queue allows) is for limited output as to not excess flood the bot offline.
Info about these queues, and other's (like putnow..) can be found in your doc/tcl-commands.doc file, shipped with your eggdrop.
Good luck! Keep coding  _________________ We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals. |
|
| Back to top |
|
 |
Landslyde Halfop
Joined: 01 May 2014 Posts: 46
|
Posted: Sat Apr 16, 2016 4:13 am Post subject: |
|
|
Get_A_Fix:
Much appreciated. Especially the info on the doc/tcl-commands.doc file. That's my next stop.
Have a good one. |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Sat Apr 16, 2016 7:57 am Post subject: |
|
|
| Landslyde wrote: |
...
the doc/tcl-commands.doc file. That's my next stop.
... |
Also found here:
http://www.eggheads.org/support/egghtml/1.6.21/tcl-commands.html
I find it handy to view/read/search it online, myself.
I think this is the current version. Maybe someone else can comment on this. _________________ For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia ! |
|
| Back to top |
|
 |
|