Development > Coding and development discussion

Items lookup modules

(1/2) > >>

xxxKarynxxx:
I wonder if anyone could help me please.
I recently downloaded BeBot after using IGNbot for sometime.
What struck me immediately about BeBot is that the items lookup function is very fast due to the database being held locally.
However, with my IGNbot I used to use a php file that would communicate with http://central.vhabot.net and I had the option of specifying it would return the results with lovely icons next to the items.
I'm not very good with php, in fact I have never touched it before in my life, but it seems that IGNbot and BeBot use very different procedures.

I was wondering basically if it is at all possible to make an items function for BeBot that gets info from the local database but displays it as lovely as Vhab's one with all the icons?

Any help would be very much appreciated  ;D

Thanks in advance.

Vhab:
The database that ships with bebot doesn't hold icon ID's so it's not possible without getting a new database.
Also would say the database the central uses isn't exactly suitable for local use.
You could always use the central database with bebot :P (Don't think there's a plugin out there yet, but I could slap one together once I get home if you want)
I do recall someone created a database including icons for bebot once, but it's probebly outdated by now. Try searching trough old posts a bit.

xxxKarynxxx:
Aww that would be awfully sweet of you if you did Vhab. I am trawling through old posts as we speak as I would much prefer that it got the information from my database here, but I haven't found anything yet, so if you could do that it would be awesome :)

Vhab:
Didn't have the chance to test it, but I think this will work

--- Code: ---<?
$VhItems = new VhItems($bot);

$commands["tell"]["items"] = &$VhItems;
$commands["pgmsg"]["items"] = &$VhItems;
$commands["gc"]["items"] = &$VhItems;

class VhItems
{
var $bot;
function VhItems (&$bot)
{
$this->bot = &$bot;
}
function tell($name, $msg)
{
$this->bot->send_tell($name, $this->process_command($name, $msg));
}
function pgmsg($name, $msg)
{
$this->bot->send_pgroup($this->process_command($name, $msg));
}

function gc($name, $msg)
{
$this->bot->send_gc($this->process_command($name, $msg));
}

function process_command($name, $msg)
{
if (preg_match('/^'.$this->bot->commpre.'items/i', $msg, $info)) {
$words = trim(substr($msg, strlen($this->bot->commpre.'items')));
if (!empty($words)) {
$parts = explode(' ', $words);
if (count($parts) > 1 && is_numeric($parts[0])) {
$ql = $parts[0];
unset($parts[0]);
$search = implode(' ', $parts);
} else {
$ql = 0;
$search = $words;
}
$result = file_get_contents('http://central.vhabot.net/data/items.php?bot=BeBot&search='.urlencode($search).'&ql='.$ql.'&output=rich2&max=50');
if (!empty($result))
return $result;
else
return "Unable to query database";
} else {
return "Usage: items [quality] [item]";
}
} else {
$this -> bot -> send_help($name);
}
}
}
?>

--- End code ---

xxxKarynxxx:
There was a bracket missing, but i fixed it.

You're an angel vhab, ty so much :)

Navigation

[0] Message Index

[#] Next page

Go to full version