| View previous topic :: View next topic |
| Author |
Message |
Landslyde Halfop
Joined: 01 May 2014 Posts: 46
|
Posted: Tue May 03, 2016 8:27 pm Post subject: I need help with pubm |
|
|
This won't work:
| Code: | bind pubm - ".hugs *" pub_hugs
proc pub_hugs {nick host handle channel testes} {
set who [llength $testes]
putquick "PRIVMSG $channel :$nick hugs $who
} |
Nothing happens. Befire I came here, I looked and cldn't find a script that uses pubm. So I'm at a loss how this is really suppose to work.
Thanks in advance for your help. |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Tue May 03, 2016 10:57 pm Post subject: Re: I need help with pubm |
|
|
Right.
if you change ".hugs *" to
though, it will do something.
All channel names begin with a # .
What it will do, is produce an error in the partyline.
See the line that begins with putquick. It needs to end with " .
| Quote: |
...So I'm at a loss how this is really suppose to work.
...
|
Go here:
http://www.eggheads.org/support/egghtml/1.6.21/tcl-commands.html
You can text search there for
bind pubm
and it explains how it works, etc.
Once you get your script working as-is, I suspect that it won't do what you want.
You'll get something like this:
| Quote: |
<@tempnick> this is a test
<botnick> tempnick hugs 4
|
Also -
Here is the reference for llength:
http://www.tcl.tk/man/tcl8.5/TclCmd/llength.htm
While it is not emphasized there, a very key word there is "list"
| Quote: |
llength - Count the number of elements in a list
|
Your little script has:
| Code: |
set who [llength $testes]
|
So it is using llength on a string, not a list.
You can "get away" with that enough, to fool you into thinking it is working.
It can bite you in the butt, someday.
To convert a string to a list, see:
http://www.tcl.tk/man/tcl8.5/TclCmd/split.htm
Thus, it should be:
| Code: |
set who [llength [split $testes] ]
|
Even now, with the proper use of llength on a list, the output to the channel will be kind of weird. But... I don't know what you really intended. Yet.
I hope this helps. _________________ 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 |
|
 |
Landslyde Halfop
Joined: 01 May 2014 Posts: 46
|
Posted: Tue May 03, 2016 11:17 pm Post subject: |
|
|
willyw: .hugs is a channel command. example:
| Code: | <Slyde> .hugs gelay and samantha
<bot> Slyde hugs gelay and samantha |
What I need is for all the text after .hugs to be added. That's what I'm having a hard time with. I shld have been clearer with what this is suppose to do. My bad for that. |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Wed May 04, 2016 1:31 am Post subject: |
|
|
In this case you should use a pub bind instead of the pubm bind.
Also, if you want to count the number of members then llength (translation list length) is the correct approach, but if you wanted it to copy/paste that output then should sanitize the user input with a join and split like this:
| Code: |
bind pub - .hugs pub_hugs
proc pub_hugs {nick host handle channel text} {
puthelp "PRIVMSG $channel :$nick hugs [join [split $text]]"
}
|
if want to add a syntax for this then llength will come in handy:
| Code: |
bind pub - .hugs pub_hugs
proc pub_hugs {nick host handle channel text} {
if {![llength $text]} {
puthelp "PRIVMSG $channel :Syntax: .hugs <member or members name>"
} else {
puthelp "PRIVMSG $channel :$nick hugs [join [split $text]]"
}
}
|
_________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Wed May 04, 2016 3:16 am Post subject: |
|
|
I'm up too late, and foggy. So I'm glad caesar replied to you.
I will add this:
Again:
And while there, text search for
bind pub
and read about it too.
Compare to what you read there about
bind pubm
and you'll see why caesar directed you to
bind pub
Read the descriptions carefully. _________________ 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 |
|
 |
Landslyde Halfop
Joined: 01 May 2014 Posts: 46
|
Posted: Wed May 04, 2016 4:25 am Post subject: |
|
|
Thanks for the replies caesar and willyw.
You two are extremely helpful. Lots of knowledge!
willyw: i'll definitely check out that link.
caesar: i'm trying the code now. i'll try them both and see which is best suited.
Thanks to you both again.
EDIT: I used the first bit of code and it works to perfection. As to why I used pubm instead of pub, that was from something I read online. But now I know the difference. Thanks for the heads up, guys. |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Wed May 04, 2016 9:05 am Post subject: |
|
|
| Landslyde wrote: |
...
i'll definitely check out that link.
|
It would have saved you a lot of time.
I hope it does, on your next project.
| Quote: |
...
But now I know the difference.
...
|
Excellent.
From your original post here:
bind pubm - ".hugs *" pub_hugs
and from tcl-commands.doc, for bind pubm:
"The mask is matched against the channel name followed by the text and can contain wildcards. "
So, your original script had it looking for a channel named .hugs (no leading #) and triggering on everything said in that channel. Clearly (now) neither of those is what you really wanted to happen.
Also, know that you already have a copy of tcl-commands.doc . It is in a directory named
doc/
below your bot's directory. Something like this, is typical:
/home/your_name/eggdrop/doc
There are several files in there that are worth perusing.
I just find it convenient to keep it open in a tab, in the web browser, when playing with TCL .
Have you found:
http://www.tcl.tk/man/tcl8.5/TclCmd/contents.htm
as that is the rest of TCL (version 8.5). Simply keep it open in a tab too - it is that handy - for reference.
Have fun with your Eggdrop bot(s), and TCL scripts. _________________ 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 |
|
 |
|