<?php
$item_info = new item_info($bot);
$commands["tell"]["item"] = &$item_info;
$commands["pgmsg"]["item"] = &$item_info;
$commands["gc"]["item"] = &$item_info;
class item_info
{
	var $bot;
	function item_info (&$bot)
	{
		$this->bot = &$bot;
		$this -> bot -> accesscontrol -> create('tell', 'item', 'GUEST');
		$this -> bot -> accesscontrol -> create('gc', 'item', 'GUEST');
		$this -> bot -> accesscontrol -> create('pgmsg', 'item', 'GUEST');
		$this -> help['description'] = 'Searches the central database for information about an item.';
		$this -> help['command']['items [ql] <item>']="Searches and displays information about an <item> of the optional [ql]";
		$this -> help['notes']="This module uses the Central Items Database v1.1, By Vhab.";
	}
	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 . "item <a href=\"itemref:\/\/(.*)\/(.*)\/(.*)\">(.*)/i", $msg, $info))
			return $this -> item($name, $info[1], $info[2], $info[3], $info[4]);
		else
			$this -> bot -> send_help($name);
	}
	function item($name, $lowid,$highid,$ql, $itemname)
	{
		$msg = "\n##normal## Item Name:##end## ##highlight##" . $itemname . "##end##";
		$msg .= "\n##normal## Item ID (Low):##end## ##highlight##" . $lowid . "##end##";
		$msg .= "\n##normal## Item ID (High):##end## ##highlight##" . $highid . "##end##";
		$msg .= "\n##normal## Item QL:##end## ##highlight##" . $ql . "##end##";
		$msg .= "\n##normal## Item Referance:##end## ##highlight##\n";
		$msg .= "<a href=\"itemref://" . $lowid . "/" . $highid . "/" . $ql . "\">" . $itemname . "</a>##end##\n";
		$msg .= "\n";
		$msg .= "##normal## References:##end## ##highlight##\n";
		$aunoURL = "http://auno.org/ao/db.php?id=" . $lowid . "&ql=" . $ql;
		$msg .= "##normal## Auno:##end## " . $this -> bot -> make_chatcommand('start ' . $aunoURL,$itemname) . "\n";
		$aomainframeURL = "http://aomainframe.com/showitem.aspx?AOID=" . $lowid . "&QL=" . $ql;
		$msg .= "##normal## AOMainframe:##end## " . $this -> bot -> make_chatcommand('start ' . $aomainframeURL,$itemname) . "\n";
		return $blob = "Item Information :: " . $this -> bot -> make_blob("click to view", $msg);
	}
}
?>