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:
#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!
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.
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:
#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.
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.
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.
#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
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.
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.
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
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.