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 

Allakhazam Script

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
Mogour
Voice


Joined: 10 Feb 2008
Posts: 17

PostPosted: Sun Feb 10, 2008 2:59 pm    Post subject: Allakhazam Script Reply with quote

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:

Quote:

<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.
Back to top
View user's profile Send private message
w00f
Halfop


Joined: 04 Oct 2006
Posts: 49

PostPosted: Sun Feb 10, 2008 9:00 pm    Post subject: Reply with quote

Code:

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 /> &nbsp; Strength:  (.*?) pts<br /> &nbsp; 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
Back to top
View user's profile Send private message
starpossen
Op


Joined: 10 Jan 2006
Posts: 139

PostPosted: Mon Feb 11, 2008 12:25 am    Post subject: Reply with quote

http://www.egghelp.org/tclhtml/8-4-0-0-1-wow-item.htm
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Mon Feb 11, 2008 12:40 am    Post subject: Reply with quote

w00f wrote:
Code:
         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)
Back to top
View user's profile Send private message
iamdeath
Master


Joined: 11 Feb 2005
Posts: 323
Location: *HeLL*

PostPosted: Mon Feb 11, 2008 7:53 am    Post subject: Reply with quote

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*...
Back to top
View user's profile Send private message Visit poster's website
Mogour
Voice


Joined: 10 Feb 2008
Posts: 17

PostPosted: Mon Feb 11, 2008 10:40 am    Post subject: Reply with quote

w00f wrote:
Code:

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 /> &nbsp; Strength:  (.*?) pts<br /> &nbsp; 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! Smile

I found two bugs.

The first one:

Strengt and Quickness are always shown, but each item has other bonuses Smile. 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 Razz)

Example:

Quote:

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
[...]
Back to top
View user's profile Send private message
w00f
Halfop


Joined: 04 Oct 2006
Posts: 49

PostPosted: Tue Feb 12, 2008 12:21 am    Post subject: Reply with quote

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 Smile

btw starpossen posted one link that might be useful, you might wanna grab and test it.
Back to top
View user's profile Send private message
Mogour
Voice


Joined: 10 Feb 2008
Posts: 17

PostPosted: Tue Feb 12, 2008 8:37 am    Post subject: Reply with quote

Thanks Smile

Quote:
btw starpossen posted one link that might be useful, you might wanna grab and test it.


Oh ya, but it is for another game Razz
Back to top
View user's profile Send private message
Mogour
Voice


Joined: 10 Feb 2008
Posts: 17

PostPosted: Sat Mar 08, 2008 5:32 am    Post subject: Reply with quote

Any news? Smile
Back to top
View user's profile Send private message
Mogour
Voice


Joined: 10 Feb 2008
Posts: 17

PostPosted: Thu Mar 20, 2008 10:33 am    Post subject: Reply with quote

Maybe someone else can help me with that?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests 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