Description:
This module deciphers what Alien Biomaterial will refine into. I took the base functionality from an IGN module.
Commands:
!inspect <item ref> (Can be used in tells, privategroup and guildchat)
I was wondering if someone was willing to turn this code into a "real" module. It works, but it's an oogly hack I know. Also, I have nowhere to host this right now, as my webserver has temporarily melted.
<?php
/*
* Inspect.php - A Utility Module
* For Bebot - An Anarchy Online Chat Automaton Developed By Blondengy (RK1)
*
* Module migrated to bebot by <some_non_hacker>. Originial by Drevi1
*
* As usual place this file in ./modules
*
*/
/*
Add a "_" at the beginning of the file (_Inspect.php) if you do not want it loaded.
*/
$inspect = new Inspect($bot);
$commands["gc"]["inspect"] = &$inspect;
$commands["tell"]["inspect"] = &$inspect;
$commands["pgmsg"]["inspect"] = &$inspect;
class Inspect
{
var $bot;
var $idn;
/*
Constructor:
Hands over a referance to the "Bot" class.
*/
function Inspect (&$bot)
{
$this -> bot = &$bot;
// load our types
$this -> idn[247102] = "Pristine";
$this -> idn[247104] = "Mutated";
$this -> idn[247105] = "Pristine/Mutated";
$this -> idn[247697] = "Type 76";
$this -> idn[247698] = "Type 76";
$this -> idn[247699] = "Type 112";
$this -> idn[247700] = "Type 112";
$this -> idn[247701] = "Type 240";
$this -> idn[247702] = "Type 240";
$this -> idn[247703] = "Type 880";
$this -> idn[247704] = "Type 880";
$this -> idn[247705] = "Type 992";
$this -> idn[247706] = "Type 992";
$this -> idn[247707] = "Type 1";
$this -> idn[247708] = "Type 1";
$this -> idn[247709] = "Type 2";
$this -> idn[247710] = "Type 2";
$this -> idn[247711] = "Type 4";
$this -> idn[247712] = "Type 4";
$this -> idn[247713] = "Type 5";
$this -> idn[247714] = "Type 5";
$this -> idn[247715] = "Type 12";
$this -> idn[247716] = "Type 12";
$this -> idn[247717] = "Type 3";
$this -> idn[247718] = "Type 3";
$this -> idn[247719] = "Type 13";
$this -> idn[247720] = "Type 13";
$this -> idn[247764] = "Viral Serum";
$this -> idn[254804] = "Viral Serum";
$this -> idn[256035] = "Useless";
$this -> idn[205844] = "Karlsson Propellor Cap";
$this -> idn[205843] = "Monster Sunglasses";
$this -> idn[205842] = "Funny Arrow";
}
/*
This gets called on a tell with the command
*/
function tell($name, $msg)
{
$this -> bot -> send_tell($name, $this -> decode_item($name, $msg));
}
/*
This gets called on a msg in the privgroup with the command
*/
function pgmsg($name, $msg)
{
$this -> bot -> send_pgroup($this -> decode_item($name, $msg));
}
/*
This gets called on a msg in the guildchat with the command
*/
function gc($name, $msg)
{
$this -> bot -> send_gc($this -> decode_item($name, $msg));
}
function decode_item($name, $msg)
{
$regex = '#<a href=[\'"]itemref://([0-9]+)/([0-9]+)/([0-9]+)[\'"]>(.+?)</a>#i';
$words = str_replace($this -> bot -> commpre . "inspect", "", $msg);
$itemlid = trim(preg_replace($regex, '\1', $words));
$itemhid = trim(preg_replace($regex, '\2', $words));
$itemql = trim(preg_replace($regex, '\3', $words));
$itemname = trim(preg_replace($regex, '\4', $words));
$iteminfo = "Low ID: " . $itemlid . " / High ID: " . $itemhid . " - QL: " . $itemql . " - Result: ";
if (!empty($this -> idn[$itemlid]))
{
return $iteminfo . $this -> idn[$itemlid];
}
else
{
return $iteminfo . "Unknown item - not a Biomaterial.";
}
}
}
?>
Thanks,
BubbaG