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.

I need help with pubm

Help for those learning Tcl or writing their own scripts.
Post Reply
L
Landslyde
Halfop
Posts: 46
Joined: Thu May 01, 2014 6:01 pm

I need help with pubm

Post by Landslyde »

This won't work:

Code: Select all

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.
w
willyw
Revered One
Posts: 1196
Joined: Thu Jan 15, 2009 12:55 am

Re: I need help with pubm

Post by willyw »

Right.
if you change ".hugs *" to

Code: Select all

"#.hugs *"
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 " .
...So I'm at a loss how this is really suppose to work.
...
Go here:
http://www.eggheads.org/support/egghtml ... mands.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:
<@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"
llength - Count the number of elements in a list
Your little script has:

Code: Select all

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

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 !
L
Landslyde
Halfop
Posts: 46
Joined: Thu May 01, 2014 6:01 pm

Post by Landslyde »

willyw: .hugs is a channel command. example:

Code: Select all

<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.
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

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

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

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.
w
willyw
Revered One
Posts: 1196
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

I'm up too late, and foggy. So I'm glad caesar replied to you.

I will add this:

Again:
Go here:
http://www.eggheads.org/support/egghtml ... mands.html
You can text search there for
bind pubm
and it explains how it works, etc.
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 !
L
Landslyde
Halfop
Posts: 46
Joined: Thu May 01, 2014 6:01 pm

Post by Landslyde »

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.
w
willyw
Revered One
Posts: 1196
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

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.
...
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. :wink:

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 !
Post Reply