w00f wrote:Code: Select all
set allakhazam(search) "!item"
set allakhazam(url) "http://camelot.allakhazam.com/searchdb.html?a=Search&terms="
package require http
bind pub -|- $allakhazam(search) search_item
setudef flag allakhazam
proc search_item {nick host hand chan arg} {
if {[lsearch -exact [channel info $chan] +allakhazam] == -1} { return }
global allakhazam
if {$arg == ""} {
putquick "PRIVMSG $chan :\002Syntax\017: $allakhazam(search) \[item] "
return
} else {
set allakhazam(main_url) "http://camelot.allakhazam.com"
catch { set tok [::http::geturl $allakhazam(url)[string map {\ + \' %27} $arg] -timeout 9000] } error
if {[string match -nocase "*couldn't open socket*" $error] || [::http::status $tok] == "timeout"} {
putquick "PRIVMSG $chan :Couldn't connect to allakhazam.com. Try again later."
return
}
set html [::http::data $tok]
::http::cleanup $tok
if {[regexp {(.*)No items found(.*)} $html]} {
putquick "PRIVMSG $chan :No Results were found for\002 \'$arg\' "
return
} else {
if {[regexp -- {</table><ol><li><a href="(.*?)">(.*?)</a>} $html -> url item]} {
set url [append allakhazam(main_url) $url]
putlog "yep found it: $url"
set tok [::http::geturl $url]
set html [::http::data $tok]
::http::cleanup $tok
if {![regexp -- {<tr><td><b>Realm:</b></td><td><span id=(.*)>(.*?)</span></td></tr>} $html -> realm]} { set realm "N/A" }
if {![regexp -- {<ul id=foundin><li><a href=(.*?)>(.*?)</a></li>} $html -> foundinurl foundin]} { set foundin "N/A" ; set foundinurl "N/A" }
if {$foundinurl != "N/A"} { set foundinurl [append allakhazam(main_url) $foundinurl] }
if {![regexp -- {<tr><td><b>Slot:</b></td><td>(.*?)</td></tr>} $html -> slot]} { set slot "N/A" }
if {![regexp -- {<tr><td><b>Armor Factor:</b></td><td>(.*?)</td></tr>} $html -> armorFactor]} { set armorFactor "N/A" }
if {![regexp -- {<tr><td><b>Armor Absorb:</b></td><td>(.*?)</td></tr>} $html -> armorAbsord]} { set armorAbsord "N/A" }
if {![regexp -- {<tr><td colspan=2><b>Magical Bonuses:</b><br /> Strength: (.*?) pts<br /> Quickness: (.*?) pts</td></tr>} $html -> strength quickness]} { set strength "N/A" ; set quickness "N/A" }
if {![regexp -- {Base Factor: (.*?)<br />} $html -> baseFactor]} { set baseFactor "N/A" }
if {![regexp -- {Absorption: (.*?)<br />} $html -> absorption]} { set absorption "N/A" }
if {![regexp -- {Quality: (.*?)<br />} $html -> armorQuality]} { set armorQuality "N/A" }
if {![regexp -- {Condition: (.*?)<br /></td></tr>} $html -> condition]} { set condition "N/A" }
if {![regexp -- {<tr><td><b>Quality:</b></td><td>(.*?)</td></tr>} $html -> quality]} { set quality "N/A" }
putquick "PRIVMSG $chan :\002Item:\017 $item \00314-\017\002 URL:\017 $url"
putquick "PRIVMSG $chan :\002Realm:\017 $realm"
putquick "PRIVMSG $chan :\002Found in:\017 $foundin @ $foundinurl"
putquick "PRIVMSG $chan :\002Slot:\017 $slot"
putquick "PRIVMSG $chan :\002Armor Factor:\017 $armorFactor"
putquick "PRIVMSG $chan :\002Armor Absord:\017 $armorAbsord"
putquick "PRIVMSG $chan :\002Magical Bonuses:\017 \037Strength\017 $strength \00314-\017 \037Quickness\037 $quickness"
putquick "PRIVMSG $chan :\002Armor Base Factor:\017 $baseFactor"
putquick "PRIVMSG $chan :\002Armor Absorption:\017 $absorption"
putquick "PRIVMSG $chan :\002Armor Quality:\017 $armorQuality"
putquick "PRIVMSG $chan :\002Armor Condition:\017 $condition"
putquick "PRIVMSG $chan :\002Quality:\017 $quality"
} else {
putquick "PRIVMSG $chan :regexp error while parsing html!"
}
}
}
}
putlog "allakhazam loaded yay"
check this lil script and report any bugs, untested.
some stuff is missing, but i guess the most important is there (or no lol ;P)
im still a nub ;D
~w00f
iamdeath wrote:use puthelp instead of putquick, I had the same problem once, so I changed it to puthelp or putserv it's better than putquick.
Ya, it is working great, thanks!
I found two bugs.
The first one:
Strengt and Quickness are always shown, but each item has other bonuses
. Like this one -
http://camelot.allakhazam.com/item.html?citem=3528 - it has Empathy and Blades bonuses. The bonuses are different from item to item.
The second one:
I already said it in my first post, not all items have a Armor Factor (only amor) and not all items have a Damage Type (only weapons), so, if the item is a weapon, there should be no armor factor, armor absord etc.
It would also be nice if you could add the "This item is dropped off monsters:" and "Levels of Use:" information!
Thanks for this really nice script, w00f!
Here you can see the difference between the items:
Armor: http://camelot.allakhazam.com/item.html?citem=19797
Weapon: http://camelot.allakhazam.com/item.html?citem=3528
Jewellery: http://camelot.allakhazam.com/item.html?citem=6009
Generic item: http://camelot.allakhazam.com/item.html?citem=27489
EDIT:
I found another bug:
If I write !item glove, there a many results.
The bot always takes the first one, but it would be better if he would say "Too many results, please be more specific."
And if there is only one result, the bot should take it. (that is working correctly, just wanted to be sure that you don't change it
)
Example: