This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Allakhazam Script

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
M
Mogour
Voice
Posts: 17
Joined: Sun Feb 10, 2008 12:58 pm

Allakhazam Script

Post by Mogour »

Hi guys.

I need a script that can read out the items from http://camelot.allakhazam.com/searchdb.html

If I write !item <name>, the Bot should look up the informations for that item and write it into the channel.

Example how it could be:
<User> !item Test
<Bot> Realm: Albion
<Bot> This item is dropped off monsters: Monster1, Monster2, Monster3
<Bot> Found in: Test Zone
<Bot> Slot: Hands (requires: Armor: Chain)
<Bot> Armor Factor: 62
<Bot> Armor Absorb: 27
<Bot> Magical Bonuses: Dexterity 4 pts, Quickness 4 pts
<Bot> Base Factor: 102
<Bot> Absorption: 27%
<Bot> Quality: 100%
<Bot> Condition: 100%
<Bot> Quality: 90%

So, if I write !item Bright Miscreant's Gloves, the bot should write the listed informations from http://camelot.allakhazam.com/item.html?citem=1429 into the channel

The only problem would be, that a weapon has points (like Damage Type), that an amor or an jewellery item don't have.

Is that script realizable?


I know it is a big request, but it would be nice if someone could help me with that.
w
w00f
Halfop
Posts: 49
Joined: Wed Oct 04, 2006 6:50 pm

Post by w00f »

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
s
starpossen
Op
Posts: 139
Joined: Tue Jan 10, 2006 1:08 am

Post by starpossen »

User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

w00f wrote:

Code: Select all

         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" 
*** Quits: $::botnick (Excess Flood)
User avatar
iamdeath
Master
Posts: 323
Joined: Fri Feb 11, 2005 2:32 pm
Location: *HeLL*
Contact:

Post by iamdeath »

use puthelp instead of putquick, I had the same problem once, so I changed it to puthelp or putserv it's better than putquick.
|AmDeAtH @ Undernet
Death is only the *Beginning*...
M
Mogour
Voice
Posts: 17
Joined: Sun Feb 10, 2008 12:58 pm

Post by Mogour »

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 :P)

Example:
User: !item gloves
Bot: Too many results, please be more specific.
User: !item deceiver gloves
Bot: Item: Afterlife Deceiver Gloves (21462) - URL: http://camelot.allakhazam.com/item.html?citem=21462
[...]
w
w00f
Halfop
Posts: 49
Joined: Wed Oct 04, 2006 6:50 pm

Post by w00f »

lol ya its better you use puthelp instead of putquick , i don't rly have any probs cuz where i run my eggs i have special flags for them ;x

ill take a better look at your request when i got some time :)

btw starpossen posted one link that might be useful, you might wanna grab and test it.
M
Mogour
Voice
Posts: 17
Joined: Sun Feb 10, 2008 12:58 pm

Post by Mogour »

Thanks :)
btw starpossen posted one link that might be useful, you might wanna grab and test it.
Oh ya, but it is for another game :P
M
Mogour
Voice
Posts: 17
Joined: Sun Feb 10, 2008 12:58 pm

Post by Mogour »

Any news? :)
M
Mogour
Voice
Posts: 17
Joined: Sun Feb 10, 2008 12:58 pm

Post by Mogour »

Maybe someone else can help me with that?
Post Reply