But in your first post, you indicated that you felt that the problem IS a script.CP1832 wrote: ... but I have some 30 scripts loaded and they worked fine until recently
How about if it isn't a script at all? That much, you could find out within a couple days. Simply unload ALL scripts. Be sure they are unloaded. All of them. Then let bot run for a couple days. If it happens again, you know it is not a script.(haven't modified them in a long while), so I have no clues where to start. Is there any debugging tool available for this kind of issues?
Code: Select all
##############################################################################################
## ## rssreader.tcl for eggdrop by Ford_Lawnmower irc.geekshed.net #Script-Help ## ##
##############################################################################################
## .rss in the party line for commands and syntax. Example Feed Add Below: ##
##.rss add #Hawkee hawkee Hawkee http://www.hawkee.com/comment.rss.php?tool_type=snippet_id ##
##############################################################################################
## ____ __ ########################################### ##
## / __/___ _ ___ _ ___/ /____ ___ ___ ########################################### ##
## / _/ / _ `// _ `// _ // __// _ \ / _ \ ########################################### ##
## /___/ \_, / \_, / \_,_//_/ \___// .__/ ########################################### ##
## /___/ /___/ /_/ ########################################### ##
## ########################################### ##
##############################################################################################
## ## Start Setup. ## ##
##############################################################################################
namespace eval rssreader {
## Edit textf to change the color/state of the text shown ## ##
variable textf "\017\00304"
## Edit linkf to change the color/state of the links ## ##
variable linkf "\017\037"
## Change usetiny to shorten links with tinyurl. 1 = on , 0 = off ## ##
variable usetiny 0
## Change useisgd to shorten links with is.gd. 1 = on , 0 = off ## ##
variable useisgd 0
## Edit maxresults to the amount of results you want per query. This will not cause ## ##
## You to lose results. It will only spread them out over several querys. ## ##
variable maxresults 1
## Edit checkdelay to change the frequency feed pages are checked. Delay is in minutes. ## ##
variable checkdelay 30
## Edit startupdelay to add delay to startup/restart. Delay is in minutes. ## ##
variable startupdelay 0
##############################################################################################
## ## End Setup. ## ##
##############################################################################################
foreach bind [binds rssreader::settings] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}
foreach bind [binds rssreader::loadhash] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}
foreach bind [binds rssreader::load_hash] {lassign $bind type flags mask num proc; unbind $type $flags $mask $proc}
bind pub - !rss rssreader::settings
bind evnt -|- init-server rssreader::loadhash
bind evnt -|- prerehash rssreader::loadhash
bind time - "00 * * * *" rssreader::load_hash
proc settings {nick uhost hand chan text} {
set choice [lindex $text 0]; set name [lindex $text 1]; set logo [lindex $text 2]; set link [lindex $text 3]
if {[string equal -nocase "add" $choice] && $link != ""} {
set deleteinfo [string map {\[ ? \] ?} [hget "rssreader" $name]]
if {[set idx [lsearch -glob [timers] "*$deleteinfo*"]] != -1 && $deleteinfo != "0"} {
killtimer [lindex [lindex [timers] $idx] 2]
}
hadd "rssreader" "$name" "rssreader::type2 {$chan $logo $link}"
savehash
puthelp "PRIVMSG $chan :Feed $name added to $chan as $logo $link"
rssreader::type2 "$chan $logo $link"
} elseif {[string equal -nocase "list" $choice]} {
puthelp "PRIVMSG $chan :\[Feeds list\]"
set count [hfind "rssreader" "*" 0]; set counter 1
while {$count >= $counter} {
puthelp "PRIVMSG $chan :[hfind "rssreader" "*" $counter]"
incr counter
}
puthelp "PRIVMSG $chan :\[End of feeds list\]"
} elseif {[string equal -nocase "info" $choice] && $name != ""} {
set info [string map {\[ ? \] ?} [hget "rssreader" $name]]
if {[set idx [lsearch -glob [timers] "*$info*"]] != -1 && $info != "0"} {
puthelp "PRIVMSG $chan :[hget "rssreader" $name]"
} else {
puthelp "PRIVMSG $chan :Feed $name not found. Too see the feeds list, check !rss list"
}
} elseif {[string equal -nocase "delete" $choice] && $name != ""} {
set deleteinfo [string map {\[ ? \] ?} [hget "rssreader" $name]]
hdel "rssreader" $name
savehash
if {[set idx [lsearch -glob [timers] "*$deleteinfo*"]] != -1 && $deleteinfo != "0"} {
killtimer [lindex [lindex [timers] $idx] 2]
puthelp "PRIVMSG $chan :Feed $name deleted"
} else {
puthelp "PRIVMSG $chan :Feed $name not found. Too see the feeds list, check !rss list"
}
} elseif {[string equal -nocase "timers" $choice]} {
putlog [timers]
} elseif {[string equal -nocase "rehash" $choice]} {
puthelp "PRIVMSG $chan :Rehashing feeds..."
hfree rsstempold
hfree rsstempnew
puthelp "PRIVMSG $chan :Done, feeds rehashed"
} else {
puthelp "PRIVMSG $chan :\[RSS sintaxis\]"
puthelp "PRIVMSG $chan :Usage: !rss add <name> <logo> <link> - Add feed"
puthelp "PRIVMSG $chan :Usage: !rss delete <name> - Delete feed"
puthelp "PRIVMSG $chan :Usage: !rss info <name> - Feed information"
puthelp "PRIVMSG $chan :Usage: !rss list - Feeds list"
puthelp "PRIVMSG $chan :Usage: !rss rehash - Rehash feeds"
puthelp "PRIVMSG $chan :\[RSS sintaxis\]"
}
return 1
}
proc main {text} {
set chan [lindex $text 0]; set logo [lindex $text 1]; set linker [lindex $text 2]
set title ""; set link ""; set description ""; set maxcount 1; set json ""
if {[set idx [lsearch -glob [timers] "*rssreader::main {$chan [string map {\[ ? \] ?} $logo] ${linker}}*"]] != -1} {
killtimer [lindex [lindex [timers] $idx] 2]
}
timer $rssreader::checkdelay "rssreader::main {$chan $logo $linker}"
set rssreaderurl "/ajax/services/feed/load?v=1.0&num=$rssreader::maxresults&q=${linker}"
set rssreadersite "ajax.googleapis.com"; set rssout ""
set url ""
append url "http://" $rssreadersite $rssreaderurl
if {[catch {http::geturl $url -timeout 5000} sockerr]} {
putlog "RSS error: $sockerr"
return 1
} elseif {[http::ncode $sockerr] != 200 || ![string equal [http::status $sockerr] "ok"]} {
putlog "RSS error: [http::ncode $sockerr] -> [http::status $sockerr]"
http::cleanup $sockerr
return 1
} else {
if {![catch {set rssreadersock [socket -async $rssreadersite 80]; fconfigure $RacSock -blocking off;}]} {
puts $rssreadersock "GET $rssreaderurl HTTP/1.0"
puts $rssreadersock "Host: $rssreadersite"
puts $rssreadersock "User-Agent: Opera 9.6"
puts $rssreadersock "Connection: close"
puts $rssreadersock ""
flush $rssreadersock
while {![eof $rssreadersock]} {
set rssreadervar " [string map {<![CDATA[ "" ]]> "" \$ \002\$\002 \[ \( \] \)} [gets $rssreadersock]] "
if {[regexp {\"responseStatus\":\s?400} $rssreadervar]} {
if {[set idx [lsearch -glob [timers] "*rssreader::main {$chan $logo ${linker}}*"]] != -1} {
killtimer [lindex [lindex [timers] $idx] 2]
}
type2 "$chan $logo $linker"
close $rssreadersock
return
} else {
regexp {\:\[(\{.*)$} $rssreadervar match rssout
set rssout [regexp -all -inline {\{(.*?)\}} $rssout]
if {$rssout != ""} {
set count 0
foreach {match matched} $rssout {
incr count
set matched [regexp -all -inline {(".*?":".*?"\,)} $match]
foreach {innermatch innermatched} $matched {
regexp {\"(.*?)\":\".*?\"\,} $innermatch match varname
regexp {\".*?\":\"(.*?)\"\,} $innermatch match value
set value [string map {\$ \002\$\002 \] \002\]\002 \[ \002\[\002} $value]
set $varname $value
}
if {[hfindexact "rsstempold" "${link}" 1] != $link} {
if {$title == ""} { set title $description }
set linked $link
if {$rssreader::usetiny} { set linked [string trimright [tiny $link]] }
if {$rssreader::useisgd} { set linked [string trimright [isgd $link]] }
if {$maxcount <= $rssreader::maxresults} {
puthelp "PRIVMSG $chan :${logo} ${rssreader::textf}[dehex $title] ${rssreader::linkf}[dehex $linked]"
incr maxcount
hadd "rsstempnew" $link 1
}
}
}
hfree rsstempold
hcopy rsstempnew rsstempold
rssreader::savetemphash
}
}
}
close $rssreadersock
}
}
}
proc type2 {text} {
set chan [lindex $text 0]; set logo [lindex $text 1]; set linker [lindex $text 2]
set title ""; set link ""; set description ""
if {[set idx [lsearch -glob [timers] "*rssreader::type2 {$chan [string map {\[ ? \] ?} $logo] ${linker}}*"]] != -1} {
killtimer [lindex [lindex [timers] $idx] 2]
}
timer $rssreader::checkdelay "rssreader::type2 {$chan $logo $linker}"
regexp -- {https?\:\/\/(.*?)(\/.*)$} $linker wholematch rsstype2site rsstype2url
set itemfound 0 ; set maxcount 1
set readerurl ""
append readerurl "http://" $rsstype2site $rsstype2url
if {[catch {http::geturl $readerurl -timeout 5000} sockerr]} {
putlog "RSS error: $sockerr"
return 1
} elseif {[http::ncode $sockerr] != 200 || ![string equal [http::status $sockerr] "ok"]} {
putlog "RSS error: [http::ncode $sockerr] -> [http::status $sockerr]"
http::cleanup $sockerr
return 1
} else {
if {![catch {set rssreadersock [socket -async $rssreadersite 80]; fconfigure $RacSock -blocking off;}]} {
puts $rsstype2sock "GET $rsstype2url HTTP/1.0"
puts $rsstype2sock "Host: $rsstype2site"
puts $rsstype2sock "User-Agent: Opera 9.6"
puts $rsstype2sock "Connection: close"
puts $rsstype2sock ""
flush $rsstype2sock
while {![eof $rsstype2sock]} {
set rsstype2var " [string map {<![CDATA[ "" ]]> "" \$ \002\$\002 \[ \( \] \)} [gets $rsstype2sock]] "
if {[string match {*<item>*} $rsstype2var]} { set itemfound 1 }
if {[regexp {<title>(.*?)(?:<\/title>|$)} $rsstype2var match title]} { }
if {[regexp {<link>(.*?)(?:<\/link>|$)} $rsstype2var match link]} {
if {[hfindexact "rsstempold" "${link}" 1] != $link} {
if {$itemfound} {
if {$maxcount <= $rssreader::maxresults} {
set linked $link
if {$rssreader::usetiny} { set linked [string trimright [tiny $link]] }
if {$rssreader::useisgd} { set linked [string trimright [isgd $link]] }
puthelp "PRIVMSG $chan :${logo} ${rssreader::textf}[dehex $title] ${rssreader::linkf}[dehex $linked]"
incr maxcount
hadd "rsstempnew" $link 1
}
}
}
}
}
set itemfound 0
hfree rsstempold
hcopy rsstempnew rsstempold
rssreader::savetemphash
close $rsstype2sock
}
}
}
proc tiny {link} {
set tinyurl http://tinyurl.com/api-create.php?url=[urlencode ${link}]
if {[catch {http::geturl $tinyurl -timeout 5000} sockerr]} {
putlog "tinyurl error: $sockerr"
return 1
} elseif {[http::ncode $sockerr] != 200 || ![string equal [http::status $sockerr] "ok"]} {
putlog "tinyurl error: [http::ncode $sockerr] -> [http::status $sockerr]"
http::cleanup $sockerr
return 1
} else {
set tinyvar [http::data $sockerr]
http::cleanup $sockerr
if {[regexp {(http:\/\/.*)} $tinyvar match tinyresult]} {
return [string map {http:// https://} $tinyresult]
}
}
return $link
}
proc isgd {link} {
set isgdurl http://is.gd/create.php?format=simple&url=[urlencode ${link}]
if {[catch {http::geturl $isgdurl -timeout 5000} sockerr]} {
putlog "isgd error: $sockerr"
return 1
} elseif {[http::ncode $sockerr] != 200 || ![string equal [http::status $sockerr] "ok"]} {
putlog "isgd error: [http::ncode $sockerr] -> [http::status $sockerr]"
http::cleanup $sockerr
return 1
} else {
set isgdvar [http::data $sockerr]
http::cleanup $sockerr
if {[regexp {(http:\/\/.*)} $isgdvar match isgdresult]} {
return $isgdresult
}
}
return $link
}
proc hex {decimal} { return [format %x $decimal] }
proc decimal {hex} { return [expr 0x$hex] }
proc dehex {string} {
regsub -all {[\[]} $string "\(" string
regsub -all {[\]]} $string "\)" string
regsub -all {^\{|\}$} $string "" string
set string [subst [regsub -nocase -all {\\u([a-f0-9]{4})} $string {[format %c [decimal \1]]}]]
set string [subst [regsub -nocase -all {\%([a-f0-9]{2})} $string {[format %c [decimal \1]]}]]
set string [subst [regsub -nocase -all {\&#([0-9]{2});} $string {[format %c \1]}]]
set string [subst [regsub -nocase -all {\&#x([0-9]{2});} $string {[format %c [decimal \1]]}]]
set string [string map {" \" · · & & <b> \002 </b> \002 – – » \
» « « Ü Ü ü ü Á Á á á É É é é Í Í í \
í Ó Ó ó ó Ñ Ñ ñ ñ Ú Ú ú ú æ æ " " ' \' \
\( \002\(\002 \) \002\)\002 \{ \002\{\002 \} \002\}\002} $string]
return $string
}
proc urlencode {string} {
regsub -all {^\{|\}$} $string "" string
return [subst [regsub -nocase -all {([^a-z0-9\+])} $string {%[format %x [scan "\\&" %c]]}]]
}
proc hadd {hashname hashitem hashdata } {
global $hashname
set ${hashname}($hashitem) $hashdata
}
proc hget {hashname hashitem} {
upvar #0 $hashname hgethashname
if {[info exists hgethashname($hashitem)]} {
return $hgethashname($hashitem)
} else {
return 0
}
}
proc hfind {hashname search value} {
upvar #0 $hashname hfindhashname
if {[array exists hfindhashname]} {
if {$value == 0} {
return [llength [array names hfindhashname $search]]
} else {
set value [expr $value - 1]
return [lindex [array names hfindhashname $search] $value]
}
}
}
proc hfindexact {hashname search value} {
upvar #0 $hashname hfindhashname
if {[array exists hfindhashname]} {
if {$value == 0} {
return [llength [array names hfindhashname -exact $search]]
} else {
set value [expr $value - 1]
return [lindex [array names hfindhashname -exact $search] $value]
}
}
}
proc hsave {hashname filename} {
upvar #0 $hashname hsavehashname
if {[array exists hsavehashname]} {
fconfigure [set hsavefile [open $filename w]] -encoding binary
foreach {key value} [array get hsavehashname] {
puts $hsavefile "${key}=${value}"
}
close $hsavefile
}
}
proc hload {hashname filename} {
upvar #0 $hashname hloadhashname
hfree $hashname
fconfigure [set hloadfile [open $filename]] -encoding binary
set linenum 0
while {[gets $hloadfile line] >= 0} {
if {[regexp -- {([^\s]+)=(.*)$} $line wholematch item data]} {
set hloadhashname($item) $data
}
}
close $hloadfile
}
proc hfree {hashname} {
upvar #0 $hashname hfreehashname
if {[array exists hfreehashname]} {
foreach key [array names hfreehashname] {
unset hfreehashname($key)
}
}
}
proc hdel {hashname hashitem} {
upvar #0 $hashname hdelhashname
if {[info exists hdelhashname($hashitem)]} {
unset hdelhashname($hashitem)
}
}
proc hcopy {hashfrom hashto} {
upvar #0 $hashfrom hashfromlocal $hashto hashtolocal
array set hashtolocal [array get hashfromlocal]
}
proc savetemphash {} {
hsave "rsstempnew" "${::network}rsstemp.hsh"
}
proc savehash {} {
hsave "rssreader" "${::network}rssreader.hsh"
}
proc load_hash {min hour day month year} {
rssreader::loadhash 1
}
proc loadhash {type} {
if {[file exists "${::network}rssreader.hsh"]} {
rssreader::hload "rssreader" "${::network}rssreader.hsh"
}
if {[file exists "${::network}rsstemp.hsh"]} {
rssreader::hload "rsstempnew" "${::network}rsstemp.hsh"
rssreader::hload "rsstempold" "${::network}rsstemp.hsh"
}
set count $rssreader::startupdelay
foreach {key value} [array get ::rssreader] {
if {[set idx [lsearch -glob [timers] "*$value*"]] != -1} {
killtimer [lindex [lindex [timers] $idx] 2]
}
timer $count $value
incr count
}
}
}
putlog "\002*Loaded* \017\00304\002RSS Reader\017 \002by \
Ford_Lawnmower irc.GeekShed.net #Script-Help .rss for help"
Code: Select all
if {![catch {set rssreadersock [socket -async $rssreadersite 80]; fconfigure $RacSock -blocking off;}]}
Sorry I didn't post this before, but after a while, I figured out the problem was that there had been an update on the shell's TCL, so I had to recompile my bot and the problem was solved.CP1832 wrote:My guess is that this the HTTP socket gets closed or quit somehow and that is hanging the bot:Do you guys know how to improve this? Thanks in advance.Code: Select all
if {![catch {set rssreadersock [socket -async $rssreadersite 80]; fconfigure $RacSock -blocking off;}]}
Well, I was on the right track, in that _something_ changed.CP1832 wrote: ...
Sorry I didn't post this before, but after a while, I figured out the problem was that there had been an update on the shell's TCL, so I had to recompile my bot and the problem was solved.