Code: Select all
tag when posting code/botlogs
Code: Select all
tag when posting code/botlogs[/quote]
.set errorInfo doesn't works for me..
the relevant part of the tcl code: (if you want the whole script: http://danger.rulez.sk/imdb.tcl)
[code]
proc imdb_handler { nick uhost hand chan args } {
global DEBUG imdbVERSION imdburl imdbsearchurl b_agent
global show_rating show_genre show_tagline show_outline show_cast
global pub_or_not
# How do you want your results ? chan or priv
if {$pub_or_not == 1 } {
set toput "PRIVMSG $chan"
} else {
set toput "NOTICE $nick"
}
# set to defaults
set o_rating $show_rating
set o_genre $show_genre
set o_tagline $show_tagline
set o_outline $show_outline
set o_cast $show_cast
set checkargs [string trim $args " \n"]
# if no arguments passed, show help
if {[string compare $checkargs "{}"] == 0} {
putserv "NOTICE $nick :^BIMDb info script v$imdbVERSION^B - ^C7General Help^C"
putserv "NOTICE $nick :^C14<===========================================>^C"
putserv "NOTICE $nick :^C7!imdb \[options\] <imdb title>"
putserv "NOTICE $nick :^C7options: -r ratings"
putserv "NOTICE $nick :^C7 -g genre"
putserv "NOTICE $nick :^C7 -t tagline"
putserv "NOTICE $nick :^C7 -o plot outline"
putserv "NOTICE $nick :^C7 -c cast"
putserv "NOTICE $nick :^C7Example: !imdb -o -c Beautiful Mind"
return
}
# Look for command line options and enable each, as desired
set fargs ""
set imdbtitle ""
foreach piece [split $args " "] {
set piece [string trim $piece "{}"]
if {[string compare $piece "-r"] == 0 } {
set o_rating 1
} elseif {[string compare $piece "-g"] == 0 } {
set o_genre 1
} elseif {[string compare $piece "-t"] == 0 } {
set o_tagline 1
} elseif {[string compare $piece "-o"] == 0 } {
set o_outline 1
} elseif {[string compare $piece "-c"] == 0 } {
set o_cast 1
} else {
set fargs "$fargs $piece"
}
}
#set fargs [string trimleft $args]
if {$DEBUG == 1} {
putserv "NOTICE $nick :I am doing a search for "$fargs" on imdb.com"
}
set query $fargs
# do initial search
set searchString [ ::http::formatQuery $query ]
set searchString [string trimleft $searchString "+"]
if {$DEBUG == 1} {
putserv "NOTICE $nick :searchString: "$searchString""
}
set page [::http::config -useragent $b_agent]
set page [::http::geturl ${imdbsearchurl}q=${searchString}&sort=smart&tv=off]
set redirect 0
set newurl ""
set lines [split [::http::data $page] \n]
set numLines [llength $lines]
for {set i 0} {$i < $numLines} {incr i 1} {
set line [lindex $lines $i]
#if redirect necessary, find first link and redirect
#putserv "NOTICE $nick : $line"
if {[string match "*title search*" $line]} {
set redirect 1
#putserv "NOTICE $nick : redirect 1"
for {} {$i < $numLines} {incr i 1} {
set line [lindex $lines $i]
if {[string match -nocase "*1. *" $line]} {
regexp href="\[^"\]*" $line title
set title [string range $title 6 [expr [string length $title] - 2]]
append newurl $imdburl $title
# get the page redirected to
set page [::http::config -useragent $b_agent]
set page [::http::geturl ${newurl}]
set lines [split [::http::data $page] \n]
}
}
set i $numLines
}
}
# if no redirect happened, then get first page on match
if {$redirect == 0} {
upvar 0 $page oldpage
regexp Location\ \[^\ \]*\ Connection $oldpage(meta) location
#putserv "NOTICE $nick : $oldpage(meta)"
set newurl [string range $location 9 [expr [string length $location] - 12]]
set page [::http::config -useragent $b_agent]
set page [::http::geturl ${newurl}]
set lines [split [::http::data $page] \n]
}
# for bogus searches
if {[string length $newurl] == 0} {
putserv "NOTICE $nick :No no no! I can't find that!"
return
}
set numLines [llength $lines]
# scan for wanted data from the page
for {set i 0} {$i < $numLines} {incr i 1} {
set line [lindex $lines $i]
if {[string compare -length 7 $line "<title>"] == 0} {
# the movie title, year, url
set title [string range $line 7 [expr [string length $line] - 9]]
set title [string map {ß ß ä ä ö ö ü ü Ä Ä Ö Ö Ü Ü è č é é ê ę á á à ŕ } $title]
putserv "$toput :^B$title^B \( $newurl \)"
} elseif {($o_tagline == 1) && ([regexp \[.\]*Tagline:\[.\]* $line] > 0)} {
# the tagline
regsub -all \<\[^\>\]*\> $line "" tagline
regsub -all \\\(\[^\\\)\]*\\\) $tagline "" tagline
regsub -all \[\ \t\]+ $tagline " " tagline
regsub -all \ \; $tagline " " tagline
set tagline [string trim $tagline " "]
set tagline [string map {ß ß ä ä ö ö ü ü Ä Ä Ö Ö Ü Ü è č é é ê ę á á à ŕ } $tagline]
putserv "$toput :$tagline"
} elseif {($o_outline == 1) && ([regexp \[.\]*Outline:\[.\]* $line] > 0)} {
# the outline
regsub -all \<\[^\>\]*\> $line "" outline
regsub -all \\\(\[^\\\)\]*\\\) $outline "" outline
regsub -all \[\ \t\]+ $outline " " outline
regsub -all \ \; $outline " " outline
set outline [string trim $outline " "]
set outline [string map {ß ß ä ä ö ö ü ü Ä Ä Ö Ö Ü Ü è č é é ê ę á á à ŕ } $outline]
putserv "NOTICE $nick :$outline"
} elseif {($o_genre == 1) && ([regexp \[.\]*Genres\[.\]* $line] > 0)} {
# the genre
regsub -all \<\[^\>\]*\> $line "" genre
regsub -all \\\(\[^\\\)\]*\\\) $genre "" genre
regsub -all \[\ \t\]+ $genre " " genre
set genre [string trim $genre " "]
set genre "Genre: $genre"
putserv "$toput :$genre"
} elseif {($o_rating == 1) && ([regexp \[.\]*User\ Rating\[.\]* $line] > 0)} {
# the user rating
set j [expr $i + 3]
set line2 [lindex $lines $j]
set j [expr $i + 4]
set line3 [lindex $lines $j]
regsub -all \<\[^\>\]*\> $line3 "" rating
regsub -all \ \; $rating " " rating
regsub -all \[\ \t\]+ $rating " " rating
set rating [string trim $rating " "]
set goldstars [regexp -all goldstar $line2]
set greystars [expr 10 - $goldstars]
# generating the rating bar
set marker "*"
set rating_bar "^C11\[^C7"
for {set i2 0} {$i2 < $goldstars} {incr i2 1} {
set rating_bar "$rating_bar$marker"
}
set marker "-"
set rating_bar "$rating_bar^C14"
for {set i3 0} {$i3 < $greystars} {incr i3 1} {
set rating_bar "$rating_bar$marker"
}
set rating_bar "$rating_bar^C11\]^C"
putserv "$toput :$rating $rating_bar"
} elseif {($o_cast == 1) && ([regexp \[.\]*\\\.\\\.\\\.\\\.\[.\]* $line] > 0)} {
if {[regexp Name $line] > 0} {
regsub -all \<\[^\>\]*\> $line "" cast
set cast [string map {ß ß ä ä ö ö ü ü Ä Ä Ö Ö Ü Ü è č é é ê ę á á à ŕ } $cast]
set checkargs [string trim $args " \n"]
putserv "NOTICE $nick :$cast"
}
}
}
}
dangerko wrote:.set errorInfo doesn't works for me..
Make your changes and simply .rehash your bot; the command demond mentioned will become available.# Comment these two lines if you wish to enable the .tcl and .set commands.
# If you select your owners wisely, you should be okay enabling these.
unbind dcc n tcl *dcc:tcl
unbind dcc n set *dcc:set
i made:Alchera wrote:dangerko wrote:.set errorInfo doesn't works for me..Make your changes and simply .rehash your bot; the command demond mentioned will become available.# Comment these two lines if you wish to enable the .tcl and .set commands.
# If you select your owners wisely, you should be okay enabling these.
unbind dcc n tcl *dcc:tcl
unbind dcc n set *dcc:set
i have found out, that when i use for example:demond wrote:2 likely reasons for this (naively and poorly implemented) script to fail with the (partial) error msg you provided:
- you haven't set correctly global variable imdbsearchurl
- search criteria are invalid (less likely to cause unsupported URL type)