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 Previous  1, 2, 3, 4
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
Koach
Voice


Joined: 19 Apr 2009
Posts: 14

PostPosted: Mon Mar 27, 2017 10:50 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
heartbroken
Halfop


Joined: 23 Jun 2011
Posts: 72
Location: somewhere out there

PostPosted: Tue Mar 28, 2017 1:31 pm    Post subject: Reply with quote

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.


Whatever , here is the 'new' code:
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"

# 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 {"&nbsp;" " " "&amp;" {\&} "&quot;" "\'" "&copy;" "(c)"\
         "&#" "#" "&lt;" "<" "&gt;" ">" "%20" " "} $str]
}

_________________
Life iS Just a dReaM oN tHE wAy to DeaTh
Back to top
View user's profile Send private message
Koach
Voice


Joined: 19 Apr 2009
Posts: 14

PostPosted: Tue Mar 28, 2017 4:16 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Koach
Voice


Joined: 19 Apr 2009
Posts: 14

PostPosted: Tue Mar 28, 2017 11:14 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
willyw
Owner


Joined: 15 Jan 2009
Posts: 921

PostPosted: Sun Apr 02, 2017 12:32 pm    Post subject: Reply with quote

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 !
Back to top
View user's profile Send private message
anotherrace
Voice


Joined: 14 May 2014
Posts: 17

PostPosted: Mon Apr 10, 2017 1:23 am    Post subject: Reply with quote

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/talk?botid=fca65e917e343663

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

I don't know whats wrong, please help
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 Previous  1, 2, 3, 4
Page 4 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