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.

Pandorabot.tcl

Support & discussion of released scripts, and announcements of new releases.
A
AlphaTech
Voice
Posts: 12
Joined: Wed Jul 23, 2014 1:07 am
Location: New York, USA

Pandorabot.tcl

Post by AlphaTech »

I've noticed that with the script "alice.tcl," I keep getting a funky socket error that I cannot seem to resolve anywhere. That's when I decided to create Pandorabot.tcl. It's a fairly simple, yet complex script that works perfect for the job. Here it is:

Code: Select all

#Bot's Nickname to Respond to: ex. MyBot - Usage: MyBot, what's 1+1?
set pandoraNick "MyBot"

#Your Pandora Bot ID. (Feel free to use the existing one if you want, but the bot will think its name is AlphaBot
set botid "a5cd504e4e342614"

#STOP EDITING HERE

package require http
bind pubm - "% $pandoraNick: *" talkto
bind pubm - "% $pandoraNick, *" talkto
bind pubm - "% $pandoraNick *" talkto

proc talkto {n u h c t} {
set query [::http::formatQuery botid "$botid" custid "$n" input "[join [lrange [split $t] 1 end] ]"]
set token [::http::geturl http://pandorabots.com/pandora/talk-xml -query $query]
regexp {<that>(.*?)</that>} [::http::data $token] - responce
putnow "privmsg $c :$responce"
::http::cleanup $token
}
Yup, that's all. Just shove it in the scripts directory, source it in the conf and you're set to go. Just make sure you http package is working correctly. Enjoy!
J
Jonny12
Voice
Posts: 9
Joined: Thu Jun 28, 2012 7:57 pm

Re: Pandorabot.tcl

Post by Jonny12 »

Thanks for writing this, AlphaTech.

However, I am having an issue.
When I speak to the bot in a chat room, I see in the partyline this error:
Tcl error [talkto]: can't read "botid": no such variable

I have egghttp.tcl API v1.1.0 by strikelight installed.
I am using the eggdrop dev release:
VERSION reply]: eggdrop v1.8.0+infiniteinfo

And I have TCL 8.6.0 installed, and Debian Linux 8.4.

Any ideas?

Thanks in advance.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Long explanation: You get that error, and I wonder why didn't OP get it, cos the botid variable is called in the local environment (meaning inside the talkto process while it is not defined there but outside so should have called that global variable first.

Short explanation (and fix): before the set query line add:

Code: Select all

global botid
then rehash the bot and it should work.

I would also replace the:

Code: Select all

putnow "privmsg $c :$responce" 
with:

Code: Select all

puthelp "privmsg $c :$responce"
cos it's a slower queue system so the bot won't flood itself off nor lag in other scripts.

Belated edit: fixed the puthelp typo.
Last edited by caesar on Mon Mar 13, 2017 4:19 pm, edited 1 time in total.
Once the game is over, the king and the pawn go back in the same box.
J
Jonny12
Voice
Posts: 9
Joined: Thu Jun 28, 2012 7:57 pm

Post by Jonny12 »

Thanks casear, that did the trick.
S
Settore
Voice
Posts: 8
Joined: Sun Mar 05, 2017 4:55 am

Pandorabots code

Post by Settore »

Hey there..

It's a long time since this post was written, but maybe someone will respond to it.

I have this code to connect my eggdrop to pandorabots.com.

Code: Select all

#Bot's Nickname to Respond to: ex. MyBot - Usage: MyBot, what's 1+1?
set pandoraNick "AI"

#Your Pandora Bot ID. (Feel free to use the existing one if you want, but the bot will think its name is AlphaBot
set botid "8e67ce4d1e345ae6"

#STOP EDITING HERE

package require http
bind pubm - "% $pandoraNick: *" talkto
bind pubm - "% $pandoraNick, *" talkto
bind pubm - "% $pandoraNick *" talkto

proc talkto {n u h c t} {
global botid
set query [::http::formatQuery botid "$botid" custid "$n" input "[join [lrange [split $t] 1 end] ]"]
set token [::http::geturl http://pandorabots.com/pandora/talk-xml -query $query]
regexp {<that>(.*?)</that>} [::http::data $token] - responce
puthelp "puthelp $c :$responce" 
::http::cleanup $token
} 
It sends the text I address the eggdrop in the channel (it appears in the pandorabots.com bot logs), but I get no response on IRC.

Can anyone help me?

Thanks!
User avatar
Get_A_Fix
Master
Posts: 206
Joined: Sat May 07, 2005 6:11 pm
Location: New Zealand

Post by Get_A_Fix »

caesar wrote: I would also replace the:

Code: Select all

putnow "privmsg $c :$responce" 
with:

Code: Select all

puthelp "puthelp $c :$responce"
Settore wrote:It sends the text I address the eggdrop in the channel (it appears in the pandorabots.com bot logs), but I get no response on IRC.

Can anyone help me?

Thanks!
This is a typo by caesar, it should be

Code: Select all

puthelp "PRIVMSG $c :$responce"
exactly as it was for the putnow.
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.
S
Settore
Voice
Posts: 8
Joined: Sun Mar 05, 2017 4:55 am

Thank you my friend

Post by Settore »

Thank you very much for your help.

Have a great day!
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

What typo? I'm confused cos all i did was copy/paste the old line and replace the putnow with puthelp. :roll:
Once the game is over, the king and the pawn go back in the same box.
User avatar
Get_A_Fix
Master
Posts: 206
Joined: Sat May 07, 2005 6:11 pm
Location: New Zealand

Post by Get_A_Fix »

caesar wrote:What typo? I'm confused cos all i did was copy/paste the old line and replace the putnow with puthelp. :roll:
Then it must be a copy/paste error.

Code: Select all

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

Post by caesar »

I was blind and now i can see. Indeed I added the puthelp twice when clearly I shoudln't. :oops: Thanks for spotting that Get_A_Fix.
Once the game is over, the king and the pawn go back in the same box.
J
Jonny12
Voice
Posts: 9
Joined: Thu Jun 28, 2012 7:57 pm

Post by Jonny12 »

I am using the same code:

Code: Select all

#Bot's Nickname to Respond to: ex. MyBot - Usage: MyBot, what's 1+1? 
set pandoraNick "AI" 

#Your Pandora Bot ID. (Feel free to use the existing one if you want, but the bot will think its name is AlphaBot 
set botid "8e67ce4d1e345ae6" 

#STOP EDITING HERE 

package require http 
bind pubm - "% $pandoraNick: *" talkto 
bind pubm - "% $pandoraNick, *" talkto 
bind pubm - "% $pandoraNick *" talkto 

proc talkto {n u h c t} { 
global botid 
set query [::http::formatQuery botid "$botid" custid "$n" input "[join [lrange [split $t] 1 end] ]"] 
set token [::http::geturl http://pandorabots.com/pandora/talk-xml -query $query] 
regexp {<that>(.*?)</that>} [::http::data $token] - responce 
puthelp "PRIVMSG $c :$responce" 
::http::cleanup $token 
}
However, I am getting a new error (to me):
Tcl error [talkto]: can't read "responce": no such variable

Does anyone have any guesses?
Thanks!
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

This could mean only one thing: you either don't get any reply from the pandorabots website or the response doesn't match what is expected. Either way the variable responce isn't created and the error you get is normal.

In order to prevent getting the error just add:

Code: Select all

if {![info exists responce]} return
before the puthelp line.

Now this won't fix the root problem, so we would have to debug to see what is going on. For starters, I would replace this line:

Code: Select all

regexp {<that>(.*?)</that>} [::http::data $token] - responce 
with this:

Code: Select all

set content [::http::data $token]
::http::cleanup $content 
putlog "Received the following data from pandorabots:"
foreach line [split $content \n] {
	putlog "$line"
}
regexp {<that>(.*?)</that>} $content - responce 
Notice that I pushed the cleanup higher in the execution chain so the one after puthelp needs to be removed. Now you should see something in your DCC Chat/Telnet with the bot and copy/paste the output.
Once the game is over, the king and the pawn go back in the same box.
J
Jonny12
Voice
Posts: 9
Joined: Thu Jun 28, 2012 7:57 pm

Post by Jonny12 »

Added info: I just tried to load the pandora website and I am getting a 502 Bad Gateway message. I was not getting this yesterday, so the data I posted below may not apply now. I will post more info when I get it.

-------------------------------------

Thanks caesar

Here is the response I am getting now.

Received the following data from pandorabots:
<html>
<head><title>301 Moved Permanently</title></head>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.10.0 (Ubuntu)</center>
</body>
</html>

Tcl error [talkto]: can't read "responce": no such variable
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

Jonny12 wrote:Added info: I just tried to load the pandora website and I am getting a 502 Bad Gateway message. I was not getting this yesterday, so the data I posted below may not apply now. I will post more info when I get it.
Something is goofed up. I had a chat with someone about it a week or two ago.
I think I recall that at that time, both his and my pandorabot worked (via web browser). But alice.tcl script had ceased to produce.
Then, a day or so later, the pandorabot did the 502 thing - same as today. (I just checked mine again.. same as you, 502 )

A couple days ago, the pandorabot worked fine via web browser, but still alice.tcl would not produce.

Just letting you all know what I've observed.

By the way, this link :
http://www.pandorabots.com/botmaster/en/new-account
is the one that I would use to log into my pandorabot via the web .... It also will not load (a few minutes ago).
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
J
Jonny12
Voice
Posts: 9
Joined: Thu Jun 28, 2012 7:57 pm

Post by Jonny12 »

Thanks willyw,
At least I know it's not just me. I tried emailing them. I'll let you know if I find anything out.
Post Reply