BeBot - An Anarchy Online and Age Of Conan chat automaton

Development => Module Requests => Topic started by: Bubbagrunt on December 11, 2005, 08:17:02 pm

Title: !inspect command -- please unhack?
Post by: Bubbagrunt on December 11, 2005, 08:17:02 pm
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.

Code: [Select]
<?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
Title: Re: !inspect command -- please unhack?
Post by: Naturalistic on December 11, 2005, 09:17:39 pm
As far as I can remember... !bio <bio-material> works just fine. I think it comes as bio.php

Don't know why you need an !inspect command too :P
Title: Re: !inspect command -- please unhack?
Post by: Bubbagrunt on December 11, 2005, 09:25:02 pm
 :o

Long answer - Damn, didn't see that with the whole guild whining and screaming that I took away their bloody IGN bot (where the command is <pre>inspect).

Short answer - I failed to do my homework and test every command on the bot.

Thanks for the help,
BubbaG
Title: Re: !inspect command -- please unhack?
Post by: Xenixa on December 11, 2005, 09:29:56 pm
Heheh, I was just going to mention that myself about the bio.php that comes with the bot.
Note: It's doesn't identify Gift packages. It should however not be to difficult to modify the exsisting one to Ident those as well.
Title: Re: !inspect command -- please unhack?
Post by: Akarah on December 11, 2005, 09:46:51 pm
you can just add $commands["gc"]["inspect"] to the bio.php and it should work.. i did this for mine (except my guild was used to !id so thats what i added.) and it worked :)
Title: Re: !inspect command -- please unhack?
Post by: Wanuarmi on December 15, 2005, 02:17:52 am
I made mine !clump :P

just change ['bio'] for ['inspect'] or whatever you want the command to be
SimplePortal 2.3.7 © 2008-2024, SimplePortal