| View previous topic :: View next topic |
| Author |
Message |
AlphaTech Voice
Joined: 23 Jul 2014 Posts: 12 Location: New York, USA
|
Posted: Mon Mar 16, 2015 5:42 pm Post subject: Pandorabot.tcl |
|
|
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: |
#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! |
|
| Back to top |
|
 |
Jonny12 Voice
Joined: 28 Jun 2012 Posts: 9
|
Posted: Thu Jun 02, 2016 9:49 am Post subject: Re: Pandorabot.tcl |
|
|
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. |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Thu Jun 02, 2016 10:15 am Post subject: |
|
|
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:
then rehash the bot and it should work.
I would also replace the:
| Code: |
putnow "privmsg $c :$responce"
|
with:
| Code: |
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. _________________ Once the game is over, the king and the pawn go back in the same box.
Last edited by caesar on Mon Mar 13, 2017 4:19 pm; edited 1 time in total |
|
| Back to top |
|
 |
Jonny12 Voice
Joined: 28 Jun 2012 Posts: 9
|
Posted: Thu Jun 02, 2016 10:25 am Post subject: |
|
|
| Thanks casear, that did the trick. |
|
| Back to top |
|
 |
Settore Voice
Joined: 05 Mar 2017 Posts: 8
|
Posted: Sat Mar 11, 2017 9:22 am Post subject: Pandorabots code |
|
|
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: | #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! |
|
| Back to top |
|
 |
Get_A_Fix Master

Joined: 07 May 2005 Posts: 206 Location: New Zealand
|
Posted: Sat Mar 11, 2017 1:11 pm Post subject: |
|
|
| caesar wrote: |
I would also replace the:
| Code: |
putnow "privmsg $c :$responce"
|
with:
| Code: |
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: | | 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. |
|
| Back to top |
|
 |
Settore Voice
Joined: 05 Mar 2017 Posts: 8
|
Posted: Sat Mar 11, 2017 1:41 pm Post subject: Thank you my friend |
|
|
Thank you very much for your help.
Have a great day! |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Sun Mar 12, 2017 12:42 pm Post subject: |
|
|
What typo? I'm confused cos all i did was copy/paste the old line and replace the putnow with puthelp.  _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
Get_A_Fix Master

Joined: 07 May 2005 Posts: 206 Location: New Zealand
|
Posted: Mon Mar 13, 2017 12:19 am Post subject: |
|
|
| caesar wrote: | What typo? I'm confused cos all i did was copy/paste the old line and replace the putnow with puthelp.  |
Then it must be a copy/paste error.
| Code: |
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. |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Mon Mar 13, 2017 4:20 pm Post subject: |
|
|
I was blind and now i can see. Indeed I added the puthelp twice when clearly I shoudln't. Thanks for spotting that Get_A_Fix. _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
Jonny12 Voice
Joined: 28 Jun 2012 Posts: 9
|
Posted: Tue Mar 14, 2017 10:00 pm Post subject: |
|
|
I am using the same code:
| Code: |
#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! |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Wed Mar 15, 2017 2:00 am Post subject: |
|
|
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: |
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: |
regexp {<that>(.*?)</that>} [::http::data $token] - responce
|
with this:
| Code: |
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. |
|
| Back to top |
|
 |
Jonny12 Voice
Joined: 28 Jun 2012 Posts: 9
|
Posted: Wed Mar 15, 2017 10:13 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Wed Mar 15, 2017 11:06 am Post subject: |
|
|
| 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 ! |
|
| Back to top |
|
 |
Jonny12 Voice
Joined: 28 Jun 2012 Posts: 9
|
Posted: Wed Mar 15, 2017 12:31 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
|