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 

probs with gbash script

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Ladykiller
Voice


Joined: 18 Feb 2007
Posts: 7

PostPosted: Tue Feb 27, 2007 6:39 pm    Post subject: probs with gbash script Reply with quote

Have that Script but get this error and dont know why

Quote:
Tcl error [::rss::admin]: can't read "token": no such variable


Code:
#

# - Namespace - #

namespace eval ::rss {

# - Packages - #

# Http

package require http

# - Settings - #

# Antispam Time (In Sekunden)

variable antispam "60"

# Feed

variable feed http://german-bash.org/latest-quotes.xml

# IDURL

variable idurl http://german-bash.org/index.php?id=%id%&action=show

# Style (Variablen: :title: :link

variable style "\[\002gBash Quote\002\] \037No.\037 %id% @ \037%link%\037 (%info%)"

# Zum Replacen

variable rep {
&lt; <
&gt; >
}


# - Setudef - #

# Flag

# RSS

setudef flag rss


# - Binds - #

# Pub

# Admin

bind pub nm|nm ".gbash" ::rss::admin

# Time

# Check

bind time -|- "13 *" ::rss::check



# - Procs - #

# Admin

proc admin { nick host hand chan arg } {

switch -- [string toupper [lindex $arg 0]] {

ON {

channel set $chan +rss

putserv "notice $nick :\[\002RSS\002\] ist jetzt \037aktiviert\037"

}

OFF {

channel set $chan -rss

putserv "notice $nick :\[\002RSS\002\] ist jetzt \037deaktiviert\037"

}

STATUS {

putserv "notice $nick :\[\002RSS\002\] ist immoment \037[string map {1 aktiviert 2 deaktiviert} [channel get $chan rss]]\037"

}

default {

if {[string length $arg] < 1} {

putserv "privmsg $chan :\002Commands are\002 $::lastbind ON/OFF/STATUS/ID"

return 0

}

if {[info exists ::rss::as($chan)] && ($::rss::as($chan) >= [unixtime])} {

return 0

}

puthelp "notice $nick :\002Getting Quote...\002 please wait"

set ::rss::as($chan) [expr [unixtime] + $::rss::antispam]

::rss::getid $chan [lindex [split $arg] 0]

return 1

}

}

}

# GetID

proc getid { chan id } {

variable idurl

set curr [string map -nocase "%id% $id" $idurl]

if {[catch { set token [http::geturl $curr -timeout 10000]} error] == 1} {
putlog "$error"
} elseif {[http::status $token] == "ok"} {
set output [http::data $token]
} elseif {[http::status $token] == "timeout"} {
putlog "Timeout occurred"
::rss::send $chan "" $curr $id "" "Timeout"
} elseif {[http::status $token] == "error"} {
putlog [http::error $token]
return 0
}

http::cleanup $token

if {![info exists output]} { return 0 }

if {[string match -nocase "*Ein Zitat mit dieser id existiert leider nicht.*" $output]} {

::rss::send $chan "Ein Zitat mit dieser id existiert leider nicht." $curr $id "" "Ein Zitat mit dieser id existiert leider nicht."

return 0

}

regexp -nocase -- {<span class="date">.+?)</span>} $output -> date

regexp -nocase -- {<span class="network">.+?)</span>} $output -> net

set info [string trim [regsub -all -nocase -- {<.+?>} "$date - $net" ""]]

regexp -nocase -- {<div class="zitat">.+?)</div>} $output -> description

regsub -all -nocase -- {<.+?>} $description "" description

set description [string trim [string map -nocase $::rss::rep $description]]

::rss::send $chan l $curr $id $info $description

return 1

}







# Check

proc check { args } {

variable feed

set curr $feed

if {![info exists ::rss::last($curr)]} {

set ::rss::last($curr) ""

}

putlog "\[\002RSS\002\] Checking \037$curr\037"

if {[catch { set token [http::geturl $curr -timeout 10000]} error] == 1} {
putlog "$error"
} elseif {[http::status $token] == "ok"} {
set output [http::data $token]
} elseif {[http::status $token] == "timeout"} {
putlog "Timeout occurred"
} elseif {[http::status $token] == "error"} {
putlog [http::error $token]
return 0
}

http::cleanup $token

if {![info exists output]} { return 0 }

if {![regexp -nocase -- {<item>.*?<title>.+?)</title>} $output -> title]} {

putlog "\[\002RSS\002\] Error! Nothing found at $curr"

return 0

}

regexp -nocase -- {Zitat \#([0-9]*)\s} $title -> id

regsub -all -nocase -- {Zitat \#[0-9]*\s-\s} $title "" title

regsub -all -nocase -- "\n" $title "" title

if {[string equal -nocase $::rss::last($curr) $title]} {

return 0

}

set ::rss::last($curr) $title

regexp -nocase -- {<item>.*?<link>.+?)</link>.*?<description>.+?)</description>} $output -> link description

set description [string range $description 9 end-3]

regexp -nocase -- {<p>.+?)</p>} $description -> info

regsub -all -nocase -- {<p>.+?</p>} $description "" description

regsub -all -nocase -- {<br />} $description "\n" description

set description [string map -nocase $::rss::rep $description]

if {![info exists link]} { set link $curr }

foreach chan [channels] {

if {[channel get $chan rss]} {

utimer 5 [list ::rss::send $chan $title $link $id $info $description]

}

}

return 1

}

# Send

proc send { chan title link id info text } {

variable style

set style [string map -nocase [list %url% $link] $style]
set style [string map -nocase [list %link% $link] $style]
set style [string map -nocase [list %title% $title] $style]
set style [string map -nocase [list %line% $title] $style]
set style [string map -nocase [list %info% $info] $style]
set style [string map -nocase [list %id% $id] $style]

puthelp "privmsg $chan :[join $style]"

foreach line [split $text \n] {

if {[string trim $line] == ""} { continue }

puthelp "privmsg $chan :$line"

}

}


putlog "\[\002RSS\002\] by \037#p0wl\037 Loaded!"

}
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Tue Feb 27, 2007 7:28 pm    Post subject: Reply with quote

You have to provide complete error info (.set errorInfo).
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
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