BeBot - An Anarchy Online and Age Of Conan chat automaton

Archive => Anarchy Online Archive => 0.2.x Custom/Unofficial Modules => Topic started by: Parfet on February 28, 2007, 05:55:25 pm

Title: website module for bebot with the large colors module
Post by: Parfet on February 28, 2007, 05:55:25 pm
We have in our old bot the ability to call up the org website at will, and I couldn't find such a thing here, so my friend Evereane and I made one.

It requires the larger colors.php file available here, (the one with all the predefined colors), and it doesn't check your string formatting, all it does is store whatever string you feed it into the 'settings' table, and retrieve it on demand, includes a popup with a link for in-game launching.

WebSite_GUILD.php:
Code: [Select]
<?
/*
Website module for BeBot 0.2.x
Requires expanded colors module

Created by Evereane and Parfet (RK2)
*/
$website = new Website($bot);

$commands["tell"]["website"] = &$website;
$commands["pgmsg"]["website"] = &$website;
$commands["gc"]["website"] = &$website;


  /*
    The Class itself...
  */
  class Website
  {
    var $bot;
   

    /*
      Constructor:
        Hands over a referance to the "Bot" class.
    */
    function Website (&$bot)
    {
      $this -> bot = &$bot;
    }



    /*
      This gets called on a tell with the command
    */
    function tell($name, $msg)
    {
        if (preg_match("/^" . $this -> bot -> commpre . "website set (.+)$/i", $msg, $info)) {
$output = $info[1];
$this -> set_website($name, $output);
}
        else
            $this -> bot -> send_tell($name, $this -> get_website($output));
}


    /*
      This gets called on a msg in the privgroup with the command
    */
    function pgmsg($name, $msg)
    {
        if (preg_match("/^" . $this -> bot -> commpre . "website set (.+)$/i", $msg, $info)) {
$output = $info[1];
            $this -> set_website($name, $output);
}
else
            $this -> bot -> send_pgroup($this -> get_website($output));
    }
   
   
   
    /*
      This gets called on a msg in the guildchat with the command
    */
    function gc($name, $msg)
    {
        if (preg_match("/^" . $this -> bot -> commpre . "website set (.+)$/i", $msg, $info)) {
$output = $info[1];
$this -> set_website($name, $output);
}
        else
        $this -> bot -> send_gc($this -> get_website($output));
    }


    /*
        Grabs the website and formats the message
    */
    function get_website($msg)
    {
        $result = $this -> bot -> db -> select("SELECT value FROM settings WHERE setting='website'");
        if (!empty($result[0][0])){
$inside = "<a href='chatcmd:///start " . $result[0][0] . "/'>" . $result[0][0] . "</a>";
        return "Guild Website :: " . $this -> bot -> colors -> colorize('highlight', $result[0][0]) . " :: " . $this -> bot -> make_blob("Click to View", $inside);
        } else {
            return $this -> bot -> colors -> colorize("error", "Guild Website Not Set :: /tell <botname> <pre>website set http://..");
}
    }


    /*
        Sets the website
    */
    function set_website($name, $msg)
    {
if ($this -> bot -> admin -> in_group($name, "admin")) {
            $this -> bot -> db -> query("REPLACE INTO `settings` (`setting`, `value`) VALUES ('website', '" . $msg . "');");
$result = $this -> bot -> db -> select("SELECT value FROM settings WHERE setting='website'");
if (!empty($result[0][0]) and $result[0][0]=$msg){
$this -> bot -> send_tell($name, $this -> bot -> colors -> colorize("green", "Website successfully set as " . $msg));
} else {
$this -> bot -> send_tell($name, $this -> bot -> colors -> colorize("error", "Error updating website, please try again"));
}
}
else {
$this -> bot -> send_tell($name, $this -> bot -> colors -> colorize("error", "You are not authorized to use this command"));
}
}
}
?>
SimplePortal 2.3.7 © 2008-2024, SimplePortal