egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Pandorabot.tcl
Goto page 1, 2, 3, 4  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
AlphaTech
Voice


Joined: 23 Jul 2014
Posts: 12
Location: New York, USA

PostPosted: Mon Mar 16, 2015 5:42 pm    Post subject: Pandorabot.tcl Reply with quote

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
View user's profile Send private message Send e-mail
Jonny12
Voice


Joined: 28 Jun 2012
Posts: 9

PostPosted: Thu Jun 02, 2016 9:49 am    Post subject: Re: Pandorabot.tcl Reply with quote

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
View user's profile Send private message
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3403
Location: Area 51

PostPosted: Thu Jun 02, 2016 10:15 am    Post subject: Reply with quote

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:

global botid

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.
_________________
You may say anything about me, but don't misspell my name.


Last edited by caesar on Mon Mar 13, 2017 4:19 pm; edited 1 time in total
Back to top
View user's profile Send private message
Jonny12
Voice


Joined: 28 Jun 2012
Posts: 9

PostPosted: Thu Jun 02, 2016 10:25 am    Post subject: Reply with quote

Thanks casear, that did the trick.
Back to top
View user's profile Send private message
Settore
Voice


Joined: 05 Mar 2017
Posts: 7

PostPosted: Sat Mar 11, 2017 9:22 am    Post subject: Pandorabots code Reply with quote

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
View user's profile Send private message
Get_A_Fix
Master


Joined: 07 May 2005
Posts: 206
Location: New Zealand

PostPosted: Sat Mar 11, 2017 1:11 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Settore
Voice


Joined: 05 Mar 2017
Posts: 7

PostPosted: Sat Mar 11, 2017 1:41 pm    Post subject: Thank you my friend Reply with quote

Thank you very much for your help.

Have a great day!
Back to top
View user's profile Send private message
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3403
Location: Area 51

PostPosted: Sun Mar 12, 2017 12:42 pm    Post subject: Reply with quote

What typo? I'm confused cos all i did was copy/paste the old line and replace the putnow with puthelp. Rolling Eyes
_________________
You may say anything about me, but don't misspell my name.
Back to top
View user's profile Send private message
Get_A_Fix
Master


Joined: 07 May 2005
Posts: 206
Location: New Zealand

PostPosted: Mon Mar 13, 2017 12:19 am    Post subject: Reply with quote

caesar wrote:
What typo? I'm confused cos all i did was copy/paste the old line and replace the putnow with puthelp. Rolling Eyes


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
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3403
Location: Area 51

PostPosted: Mon Mar 13, 2017 4:20 pm    Post subject: Reply with quote

I was blind and now i can see. Indeed I added the puthelp twice when clearly I shoudln't. Embarassed Thanks for spotting that Get_A_Fix.
_________________
You may say anything about me, but don't misspell my name.
Back to top
View user's profile Send private message
Jonny12
Voice


Joined: 28 Jun 2012
Posts: 9

PostPosted: Tue Mar 14, 2017 10:00 pm    Post subject: Reply with quote

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
View user's profile Send private message
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3403
Location: Area 51

PostPosted: Wed Mar 15, 2017 2:00 am    Post subject: Reply with quote

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.
_________________
You may say anything about me, but don't misspell my name.
Back to top
View user's profile Send private message
Jonny12
Voice


Joined: 28 Jun 2012
Posts: 9

PostPosted: Wed Mar 15, 2017 10:13 am    Post subject: Reply with quote

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
View user's profile Send private message
willyw
Owner


Joined: 15 Jan 2009
Posts: 925

PostPosted: Wed Mar 15, 2017 11:06 am    Post subject: Reply with quote

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
View user's profile Send private message
Jonny12
Voice


Joined: 28 Jun 2012
Posts: 9

PostPosted: Wed Mar 15, 2017 12:31 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases All times are GMT - 4 Hours
Goto page 1, 2, 3, 4  Next
Page 1 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber