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.
K
Koach
Voice
Posts: 21
Joined: Sun Apr 19, 2009 6:42 pm
Contact:

Post by Koach »

heartbroken,

I wonder if you have any idea why this happens. Periodically, the bot will just hang and stop responding. The error message I get in the party line is:

couldn't open socket: Name or service not known ,error

The bot isn't hanging in any other way, just in talking via pandorabots.
Thanks.
Koach
User avatar
heartbroken
Op
Posts: 110
Joined: Thu Jun 23, 2011 11:15 pm
Location: somewhere out there

Post by heartbroken »

I am not regularly using any AI scripts. I am only testing when needed to see whats wrong . and i still didn't get any error from this while my tests.

I assume, your bot/shell sometimes having an issue to resolve dns address of this pandorabots link.

Anyway I've just changed the script little bit and added somethings to handle this "couldn't open socket*" error.
now if that happen once again ; it will try to get ip of the host and callback with host's ip instead until got a real response from them.

I have tested in my home PC with tclsh.
Image

Whatever , here is the 'new' code:

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"

# enable chat in bot pm : 1 ,disable : 0 or ""
set botpm 1

# user must wait xx seconds between messages to get a response from bot.
set chatstop 10

#STOP EDITING HERE

package require http 2.5
if {[catch {package require tls 1.6}]} {
	putcmdlog "https links requires tcltls : https://core.tcl.tk/tcltls/wiki/Download"
	set enabletls 0
} else {
	set enabletls 1
	tls::init -ssl3 0 -ssl2 0 -tls1 1
	http::register https 443 [list ::tls::socket -require 0 -request 1]
}

# .chanset #channel +talk
setudef flag talk

bind pubm - "*" talkto_pub
bind msgm - "*" talkto_pvt

proc talkto_pub {nick uhost hand chan text} {
	if {![channel get $chan talk] || ([expr {[lsearch -nocase [fix_chars $text] $::pandoraNick*]}] == "-1")} { return 0 }
	talkto $nick $uhost $hand $chan $text
}

proc talkto_pvt {nick uhost hand text} {
	if {[expr {[lsearch -nocase [fix_chars $text] $::pandoraNick*]}] == "-1"} { return 0 }
	if {[string length $::botpm] && $::botpm >= "1"} {
		talkto $nick $uhost $hand $nick $text
	}
	return 0
}

proc talkto {nick uhost hand chan text} {
	if {[info exists ::flooder($nick)] && [expr {$::flooder($nick) + $::chatstop}] > [clock seconds]} { return 0 }
	regsub -all -nocase $::pandoraNick [fix_chars $text] {} TxT
	puthelp "privmsg $chan :$nick: [fetch_pandora https://pandorabots.com/pandora/talk-xml $nick $TxT]"
	set ::flooder($nick) [clock seconds]
	return 0
}

proc fetch_pandora {pandurl who {str ""}} {
	set ua "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5"
	set token [::http::config -useragent $ua -urlencoding "utf-8"]
	set query [::http::formatQuery botid $::botid custid $who input $str]
	catch {set token [::http::geturl $pandurl -query $query -timeout 16000]} err
	if {[string match -nocase "*open socket*" $err]} {
		catch { eval exec host pandorabots.com } res
		if {[regexp {(?i)address\s(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})} $res -> pandip]} {
			fetch_pandora https://$pandip/pandora/talk-xml $who $str
		} else {
			fetch_pandora $pandurl $who $str
		}
		putlog "[string map [list \n " ,"] $err] ,[::http::status $token]"
		::http::cleanup $token
	} elseif {[string match -nocase "timeout" [::http::status $token]]} {
		putlog "[::http::code $token]"
		fetch_pandora $pandurl $who $str
		::http::cleanup $token
	} elseif {![string equal -nocase [::http::status $token] "ok"]} {
		putlog "[::http::code $token] ,[::http::status $token]"
		::http::cleanup $token
	} elseif {[::http::ncode $token] == "200" && [string equal -nocase [::http::status $token] "ok"]} {
		set pandata [::http::data $token]
		::http::cleanup $token
	} else {
		putlog "Error: [string map [list \n " ,"] $err]"
		fetch_pandora $pandurl $who $str
		::http::cleanup $token
	}
	if {[info exists pandata] && [llength $pandata]} {
		if {![regexp {<that>(.*?)</that>} $pandata -> responce]} {
			return -code error "This regex sucks!!! Source codes changed or what?!?"
		} else {
			return [fix_talk $responce]
		}
	}
}

proc fix_chars {txt} {
	return [string map {\\ \\\\ [ \\\[ ] \\\] \{ \\\{ \} \\\} \$ \\\$ \" \\\"} $txt]
}

proc fix_talk {str} {
	return [string map {" " " " "&" {\&} """ "\'" "©" "(c)"\
			"&#" "#" "<" "<" ">" ">" "%20" " "} $str]
}
Life iS Just a dReaM oN tHE wAy to DeaTh
K
Koach
Voice
Posts: 21
Joined: Sun Apr 19, 2009 6:42 pm
Contact:

Post by Koach »

Thanks once again, heartbroken.

I am still still having problems with fovea, the bot I have been asking about.
Here is an example in the channel.

[14:06] <Koach> hi fovea
[14:07] <Fovea> Koach:

and partyline:
<Fovea> [16:10:50] couldn't open socket: Name or service not known ,error

So I tested another eggdrop I have online, running on the same server, using the script you posted just before your last fixes, and it seems to be working fine.

So, it seems the problem is with Fovea. I will recompile the bot, make sure everything else is correct, and try again.

I will post here what I find out in case others have the same problem.

Thanks again. By now you have probably pulled all your hair out, and banged your head on your keyboard several times lol

I appreciate your patience and help more than you can imagine.

Koach
K
Koach
Voice
Posts: 21
Joined: Sun Apr 19, 2009 6:42 pm
Contact:

Post by Koach »

heartbroken,

It seems the problem was the bot. I recompiled, from 1.8.0 to 1.8.1, went through the conf line by line, making some minor changes, but nothing that should have affected anything.

But, when i was done, everything works beautifully. Thanks again for all your time and work.
Koach
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

heartbroken :


Have you had an opportunity to look into the alice script any more, yet?

Thanks.
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
a
anotherrace
Voice
Posts: 17
Joined: Wed May 14, 2014 8:10 pm

Post by anotherrace »

I've been using my alice.tcl on Dalnet for a long time now, and all of a sudden it stopped working. This is my script :
geocities.ws/zakforradio/alice2.txt

But pandorabots seems to be working fine
https://www.pandorabots.com/pandora/tal ... 917e343663

I'm getting the error message:
Tcl error [alice:msg_query]: invalid command name "egghttp:geturl"

I don't know whats wrong, please help
K
Koach
Voice
Posts: 21
Joined: Sun Apr 19, 2009 6:42 pm
Contact:

Post by Koach »

anotherrace, I realize it's been almost a year since you posted your question, but if you would like, I can post the script that I am using. Sorry I didn't see this sooner.
Koach
A
AllMassive
Voice
Posts: 2
Joined: Sat Aug 09, 2008 9:40 pm

Post by AllMassive »

Why you even ask :/
Yes - pls post your working Version.
K
Koach
Voice
Posts: 21
Joined: Sun Apr 19, 2009 6:42 pm
Contact:

Post by Koach »

I hope this pastes ok.

Code: Select all

######################################################################
# Script to create an AI bot for a chat room. 
# Uses https://www.pandorabots.com/botmaster/en/home for the AI brain
# Written by heartbroken
# version 2.4.1
# Written/edited by Branson
# version 2.4.3
# More info about the script: http://forum.egghelp.org/viewtopic.php?t=19887&start=45
# 12-26-2107 edited/repaired by Branson
# If you need help or have questions, 
# go to #koachsworkshop on chat.koach.com and ask for koach
#####################################################################

# Bot's Nickname to Respond to: ex. Gazer, what's 1+1? 
set pandoraNick "Fovea" 

# Your Pandora Bot ID. (Feel free to use the existing one if you want,
# but the bot will think it is fovea. 

# pandorabots.com will give you a link like this with the botid
# https://www.pandorabots.com/pandora/talk?botid=fba0b9735e362e4d

set botid "fba0b9735e362e4d"  

# enable chat in bot pm : 1 ,disable : 0 or "" 
set botpm 1 

# user must wait X seconds between messages sent to bot. 
set chatstop 1

# .chanset #channel +talk - Turn tells bot to chat in #channel
setudef flag talk 

bind pubm - "*" talkto_pub 
bind msgm - "*" talkto_pvt 

#STOP EDITING HERE 

package require http 2.5 
if {[catch {package require tls 1.6}]} { 
   putcmdlog "https links requires tcltls : https://core.tcl.tk/tcltls/wiki/Download" 
   set enabletls 0 
} else { 
   set enabletls 1 
   tls::init -ssl3 0 -ssl2 0 -tls1 1 
   http::register https 443 [list ::tls::socket -require 0 -request 1] 
} 

proc talkto_pub {nick uhost hand chan text} { 
   if {![channel get $chan talk] || ([expr {[lsearch -nocase [fix_chars $text] $::pandoraNick*]}] == "-1")} { return 0 } 
   talkto $nick $uhost $hand $chan $text 
} 

proc talkto_pvt {nick uhost hand text} { 
   if {[expr {[lsearch -nocase [fix_chars $text] $::pandoraNick*]}] == "-1"} { return 0 } 
   if {[string length $::botpm] && $::botpm >= "1"} { 
      talkto $nick $uhost $hand $nick $text 
   } 
   return 0 
} 

proc talkto {nick uhost hand chan text} { 

   if {[info exists ::flooder($nick)] && [expr {$::flooder($nick) + $::chatstop}] > [clock seconds]} { return 0 } 
 
   regsub -all -nocase $::pandoraNick [fix_chars $text] {} TxT
   set TxTx [string map { " " "+" "?" " " } $TxT];
   puthelp "privmsg $chan :$nick: [fetch_pandora  https://pandorabots.com/pandora/talk-xml?botid=fc05baafee345e53&custid=0&input=$TxTx]" 
  set ::flooder($nick) [clock seconds] 
   return 0 
} 

proc fetch_pandora {pandurl} { 

   set pandata [exec curl -sSL $pandurl] 
   if {[info exists pandata] && [llength $pandata]} { 
      if {![regexp {<that>(.*?)</that>} $pandata -> responce]} { 
         return -code error "This regex sucks!!! Source codes changed or what?!?" 
      } else { 
         return [fix_talk $responce] 
      } 
   } 
} 

proc fix_chars {txt} { 
   return  [string trim $txt "?"] 
} 

proc fix_talk {str} { 
   return [string map {" " " " "&" {\&} """ "\'" "©" "(c)" "&#" "#" "<" "<" ">" ">" "%20" " "} $str] 
}

putlog "Loaded  pandora.2.4.3.tcl"
M
Merky
Voice
Posts: 17
Joined: Sun Jan 21, 2007 9:07 am

Post by Merky »

error

Code: Select all

Tcl error [talkto_pub]: This regex sucks!!! Source codes changed or what?!?
This regex sucks!!! Source codes changed or what?!?
    while executing
"fetch_pandora  https://pandorabots.com/pandora/talk-xml?botid=fba0b9735e362e4d&custid=0&input=$TxTx"
    (procedure "talkto" line 8)
    invoked from within
"talkto $nick $uhost $hand $chan $text "
    (procedure "talkto_pub" line 3)
    invoked from within
"talkto_pub $_pubm1 $_pubm2 $_pubm3 $_pubm4 $_pubm5"
K
Koach
Voice
Posts: 21
Joined: Sun Apr 19, 2009 6:42 pm
Contact:

Post by Koach »

ok, let's try this again:

Code: Select all

####################################################################### Script to create an AI bot for a chat room. 
# Uses https://www.pandorabots.com/botmaster/en/home for the AI brain
# Written by heartbroken
# version 2.4.3
# More info about the script: http://forum.egghelp.org/viewtopic.php?t=19887&start=45
# 12-26-2107 edited/repaired by Branson
# If you need help or have questions, 
# go to #koachsworkshop on chat.koach.com and ask for koach
#####################################################################

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

#Your Pandora Bot ID. (Feel free to use the existing one if you want,
# but the bot will think it is fovea. 

# pandorabots.com will give you a link like this with the botid
# https://www.pandorabots.com/pandora/talk?botid=fba0b9735e362e4d
set botid "fba0b9735e362e4d"  

# enable chat in bot pm : 1 ,disable : 0 or "" 
set botpm 1 

# user must wait X seconds between messages sent to bot. 
set chatstop 1

# .chanset #channel +talk - Turn tells bot to chat in #channel
setudef flag talk 

bind pubm - "*" talkto_pub 
bind msgm - "*" talkto_pvt 

#STOP EDITING HERE 

package require http 2.5 
if {[catch {package require tls 1.6}]} { 
   putcmdlog "https links requires tcltls : https://core.tcl.tk/tcltls/wiki/Download" 
   set enabletls 0 
} else { 
   set enabletls 1 
   tls::init -ssl3 0 -ssl2 0 -tls1 1 
   http::register https 443 [list ::tls::socket -require 0 -request 1] 
} 

proc talkto_pub {nick uhost hand chan text} { 
   if {![channel get $chan talk] || ([expr {[lsearch -nocase [fix_chars $text] $::pandoraNick*]}] == "-1")} { return 0 } 
   talkto $nick $uhost $hand $chan $text 
} 

proc talkto_pvt {nick uhost hand text} { 
   if {[expr {[lsearch -nocase [fix_chars $text] $::pandoraNick*]}] == "-1"} { return 0 } 
   if {[string length $::botpm] && $::botpm >= "1"} { 
      talkto $nick $uhost $hand $nick $text 
   } 
   return 0 
} 

proc talkto {nick uhost hand chan text} { 
   global botid
   if {[info exists ::flooder($nick)] && [expr {$::flooder($nick) + $::chatstop}] > [clock seconds]} { return 0 } 
 
   regsub -all -nocase $::pandoraNick [fix_chars $text] {} TxT
   set TxTx [string map { " " "+" "?" " " } $TxT];
   puthelp "privmsg $chan :$nick: [fetch_pandora  https://pandorabots.com/pandora/talk-xml?botid=$botid&custid=0&input=$TxTx]" 
  set ::flooder($nick) [clock seconds] 
   return 0 
} 

proc fetch_pandora {pandurl} { 

   set pandata [exec curl -sSL $pandurl] 
   if {[info exists pandata] && [llength $pandata]} { 
      if {![regexp {<that>(.*?)</that>} $pandata -> responce]} { 
         return -code error "This regex sucks!!! Source codes changed or what?!?" 
      } else { 
         return [fix_talk $responce] 
      } 
   } 
} 

proc fix_chars {txt} { 
   return  [string trim $txt "?"] 
} 

proc fix_talk {str} { 
   return [string map {" " " " "&" {\&} """ "\'" "©" "(c)" "&#" "#" "<" "<" ">" ">" "%20" " "} $str] 
}

putlog "Loaded  pandora.2.4.4.tcl"
K
Koach
Voice
Posts: 21
Joined: Sun Apr 19, 2009 6:42 pm
Contact:

Post by Koach »

The last code I pasted still has a problem. If you put a unmatched bracket, the bot will not respond and will show the error in the party line.
Like this, for example: fovea, what is your name?]
You'll see this error in party line:
Tcl error [talkto_pub]: curl: (3) [globbing] unmatched close brace/bracket in column 105

I am too tired to fix it tonight, but I will look at it tomorrow. If anyone else wants to fix it, feel free.
Koach
K
Koach
Voice
Posts: 21
Joined: Sun Apr 19, 2009 6:42 pm
Contact:

Post by Koach »

I think this works now (crosses fingers)

I am sure parts of this script might be written better. So, to all TCL experts (and non experts), please feel free to give me constructive criticism.

Code: Select all

####################################################################### Script to create an AI bot for a chat room. 
# Uses https://www.pandorabots.com/botmaster/en/home for the AI brain
# Written by heartbroken
# version 2.4.3
# More info about the script: http://forum.egghelp.org/viewtopic.php?t=19887&start=45
# 12-26-2107, 4/27/2018 edited/repaired by Branson
# If you need help or have questions, 
# go to #koachsworkshop on chat.koach.com and ask for koach
#####################################################################

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

#Your Pandora Bot ID. (Feel free to use the existing one if you want,
# but the bot will think it is fovea. 

# pandorabots.com will give you a link like this with the botid
# https://www.pandorabots.com/pandora/talk?botid=fba0b9735e362e4d
set botid "fba0b9735e362e4d"  

# enable chat in bot pm : 1 ,disable : 0 or "" 
set botpm 1 

# user must wait X seconds between messages sent to bot. 
set chatstop 1

# .chanset #channel +talk - Turn tells bot to chat in #channel
setudef flag talk 

bind pubm - "*" talkto_pub 
bind msgm - "*" talkto_pvt 

#STOP EDITING HERE 

package require http 2.5 
if {[catch {package require tls 1.6}]} { 
   putcmdlog "https links requires tcltls : https://core.tcl.tk/tcltls/wiki/Download" 
   set enabletls 0 
} else { 
   set enabletls 1 
   tls::init -ssl3 0 -ssl2 0 -tls1 1 
   http::register https 443 [list ::tls::socket -require 0 -request 1] 
} 

proc talkto_pub {nick uhost hand chan text} { 
   if {![channel get $chan talk] || ([expr {[lsearch -nocase [fix_chars $text] $::pandoraNick*]}] == "-1")} { return 0 } 
   talkto $nick $uhost $hand $chan $text 
} 

proc talkto_pvt {nick uhost hand text} { 
   if {[expr {[lsearch -nocase [fix_chars $text] $::pandoraNick*]}] == "-1"} { return 0 } 
   if {[string length $::botpm] && $::botpm >= "1"} { 
      talkto $nick $uhost $hand $nick $text 
   } 
   return 0 
} 

proc talkto {nick uhost hand chan text} { 
   global botid
   if {[info exists ::flooder($nick)] && [expr {$::flooder($nick) + $::chatstop}] > [clock seconds]} { return 0 } 
 
   regsub -all -nocase $::pandoraNick [fix_chars $text] {} TxT
   set TxTx [string map { " " "+" "?" "+" "]" "+" "[" "+" "{" "+" "}" "+" } $TxT]; 
   puthelp "privmsg $chan :$nick: [fetch_pandora  https://pandorabots.com/pandora/talk-xml?botid=$botid&custid=0&input=$TxTx]" 
  set ::flooder($nick) [clock seconds] 
   return 0 
} 

proc fetch_pandora {pandurl} { 

   set pandata [exec curl -sSL $pandurl] 
   if {[info exists pandata] && [llength $pandata]} { 
      if {![regexp {<that>(.*?)</that>} $pandata -> responce]} { 
         return -code error "This regex sucks!!! Source codes changed or what?!?" 
      } else { 
         return [fix_talk $responce] 
      } 
   } 
} 

proc fix_chars {txt} { 
   return  [string trim $txt "?"] 
} 

proc fix_talk {str} { 
   return [string map {" " " " "&" {\&} """ "\'" "©" "(c)" "&#" "#" "<" "<" ">" ">" "%20" " "} $str] 
}

putlog "Loaded  pandora.2.4.4.tcl"

M
Merky
Voice
Posts: 17
Joined: Sun Jan 21, 2007 9:07 am

Post by Merky »

Error bro

Code: Select all

[21:15:41] Tcl error [talkto_pub]: This regex sucks!!! Source codes changed or what?!?
This regex sucks!!! Source codes changed or what?!?
    while executing
"fetch_pandora  https://pandorabots.com/pandora/talk-xml?botid=$botid&custid=0&input=$TxTx"
    (procedure "talkto" line 7)
    invoked from within
"talkto $nick $uhost $hand $chan $text "
    (procedure "talkto_pub" line 3)
    invoked from within
"talkto_pub $_pubm1 $_pubm2 $_pubm3 $_pubm4 $_pubm5"
K
Koach
Voice
Posts: 21
Joined: Sun Apr 19, 2009 6:42 pm
Contact:

Post by Koach »

Hi Merky,

I can't duplicate your error. What did you type when you received the error?

Although I didn't write this script, I can probably get it fixed, and any info you can provide will help.

Thanks,
Koach
Post Reply