BeBot - An Anarchy Online and Age Of Conan chat automaton

Archive => Age of Conan Archive => AoC 0.6.x Custom/Unofficial modules => Topic started by: TBK on June 20, 2010, 04:18:18 am

Title: Magic Eightball
Post by: TBK on June 20, 2010, 04:18:18 am
Module to display Magic Eightball quotes.

Usage:

Code: [Select]
!eightball

1. Download the file
2. Move it to custom/module/
3. Restart the bot


Download: http://www.mediafire.com/?mwbmi6sb7lptql2 (http://www.mediafire.com/?mwbmi6sb7lptql2)


Code: [Select]
<?php
/*
* eightball.php - A Social Module
*
* Developed by Sicarius Legion of Amra
* a Age of Conan Guild on the Hyrkania server
*
*/
   
/*
Add a "_" at the beginning of the file (_eightball.php) if you do not want it to be loaded.
*/
 
$eightball = new EightBall($bot);

/*
The Class itself...
*/
class EightBall Extends BaseActiveModule {
var $bot;
var $eightball;
var $returnstr;


    
/*
      Constructor:
        Hands over a referance to the "Bot" class.
    */
    
function __construct (&$bot) {
parent::__construct(&$botget_class($this));

$this -> register_command("all""eightball""MEMBER");

$this -> help['description'] = "Shows eightball quotes.";
$this -> help['command']['eightball']="Use !eightball to generate a random eightball quote";
    }

function command_handler($name$msg$origin) {
$output "";

if (preg_match("/^eightball$/i"$msg$info)) {
$output $this -> get_eightball($name);
}
return $output;
}
   
   
    
/*
      This gets called on a msg in the guildchat with the command
    */
    
function irc($name$msg) {
$returnstr $this -> get_eightball($name);
$this -> bot -> send_gc($returnstr);
$this -> bot -> send_irc("""""3" $returnstr);
    }

  
    
/*
      Build response
    */
    
function get_eightball($name) {
$eightball = array(
"As I see it, yes",
"It is certain",
"It is decidedly so",
"Most likely",
"Outlook good",
"Signs point to yes",
"Without a doubt",
"Yes",
"Yes - definitely",
"You may rely on it",
"Reply hazy, try again",
"Ask again later",
"Better not tell you now",
"Cannot predict now",
"Concentrate and ask again",
"Don't count on it",
"My reply is no",
"My sources say no",
"Outlook not so good",
"Very doubtful"
);

// You can add more possible responses to the array above.
$dmg rand(100,999);
$creds rand(10000,9999999);
$returnstr $eightball[rand(0,sizeof($eightball)-1)];
$returnstr str_replace("*name*",$name,$returnstr);
$returnstr str_replace("*dmg*",$dmg,$returnstr);
$returnstr str_replace("*creds*",$creds,$returnstr);
return $returnstr;     
    }
}
?>

Title: Re: Magic Eightball
Post by: Kyr on June 20, 2010, 07:18:28 am
There's a bug in here that won't affect anything.

Code: [Select]
      $returnstr = str_replace("*dmg*",$dmg,$returnstr);
      $returnstr = str_replace("*creds*",$dmg,$returnstr);

should be
Code: [Select]
      $returnstr = str_replace("*dmg*",$dmg,$returnstr);
      $returnstr = str_replace("*creds*",$creds,$returnstr);

But like I said, it doesn't have any affect unless you add your own return values that actually use these randomly created values.
SimplePortal 2.3.7 © 2008-2024, SimplePortal