BeBot - An Anarchy Online and Age Of Conan chat automaton

Archive => Anarchy Online Archive => 0.4.x Custom/Unofficial Modules => Topic started by: Hyde on August 19, 2007, 08:05:54 am

Title: Updated Topic.php
Post by: Hyde on August 19, 2007, 08:05:54 am
I know that !topic has been a bit odd in the past with various versions of BeBot. I grabbed all the ones I found and "fixed" the one that seems to be least messy for my purposes.

Again not claiming authorship, just modified some pieces to make it work with BeBot 4.1 and made a change so that its less spammy when people join the bot.

Code: [Select]
<?
/*
* Topic Module for BE Bot <http://bebot.fieses.net>
* Module coded by Craized <http://www.craized.net>
... Modifications 2007-08-18 by Doctorhyde@RK2
  * Topic is now sent to you in a /tell when you join, not spammed in the
    channel. If you say "!topic" in the channel it will display normally.
  * Updated to use the 'Colors.inc' file (note: symlink or copy 'Colors.inc'
    from your "modules" to "custom/modules" if you're putting this script
    in "custom/modules").
  * Updated to use the "security -> check_access()" function instead of the
    "admin -> in_group()" function.
*/

/*
Add a "_" at the beginning of the file (_Topic.php) if you do not want it to be loaded.
*/

include_once("Colors.inc");

$topic = new Topic($bot);

$commands['pgmsg']['topic'] = &$topic;
$commands["pgjoin"][] = &$topic;

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

    /*
    Constructor:
    Hands over a referance to the "Bot" class.
    */
    function Topic (&$bot) {
        $this -> bot = &$bot;
        $this -> name = '';
    }
    /*
    This gets called on a tell with the command
    */
    function pgmsg($name, $msg) {
        if (preg_match('/^'.$this -> bot -> commpre.'topic$/i', $msg)) $c = $this -> show_topic();
        else if (preg_match('/^'.$this -> bot -> commpre.'topic clear$/i', $msg)) $c = $this -> clear($name);
        else if (preg_match('/^'.$this -> bot -> commpre.'topic (.+)/i', $msg, $info)) $c = $this -> set($name, $info['1']);
        $this -> bot -> send_pgroup($c);
    }
   
    function pgjoin($name) {
        $c = $this -> show_topic();
        $this -> bot -> send_tell($name, $c, 1);
    }
   
    function show_topic() {
        $c = (isset($this -> topic) ? 'Topic: '.Highlight($this -> topic).' [By '.Highlight($this -> name).'] ' : '').'('.Highlight(count($this -> bot -> commands['pgmsg']['online'] -> pgroup)).'/'.Highlight($this -> bot -> commands['pgmsg']['maxplayers'] -> maxplayers).' | Leader: '.Highlight((isset($this -> bot -> commands['pgmsg']['leader'] -> raidleader) ? $this -> bot -> commands['pgmsg']['leader'] -> raidleader : 'None')).'| Lock: '.Highlight(($this -> bot -> commands['pgmsg']['invite'] -> lock)).' | Invites: '.Highlight($this -> bot -> commands['pgmsg']['faction'] -> faction).')';
        return $c;
    }
   
    function set($name, $msg) {
        if($this -> bot -> commands['pgmsg']['leader'] -> raidleader == $name || $this -> bot -> security -> check_access($name, 'admin')) {
            $this -> topic = $msg;
            $this -> name = $name;
            $c = 'Topic has been set to '.Highlight($this -> topic).' by '.Highlight($name).'.';
        } else $c = 'You do not have permission to change the topic.';
        return $c;
    }
   
    function clear($name) {
        if($this -> bot -> commands['pgmsg']['leader'] -> raidleader == $name || $this -> bot -> security -> check_access($name, 'admin')) {
            unset($this -> topic);
            $this -> name = '';
            $c = 'Topic has been cleared by '.Highlight($name).'.';
        } else $c = 'You do not have permission to change the topic.';
        return $c;
    }


?>


Title: Re: Updated Topic.php
Post by: Diablo on August 23, 2007, 12:18:53 am
Im getting error on the function show topic is something missing on the end of that line?
Title: Re: Updated Topic.php
Post by: Temar on August 23, 2007, 02:09:03 am
yes it seems to have been cut off
the 1st line in the function ends like this
Code: [Select]
Highlight((isset($$
Title: Re: Updated Topic.php
Post by: Fxrluv on August 23, 2007, 03:09:26 pm
im a php noob so how should that line end?
Title: Re: Updated Topic.php
Post by: Hyde on August 23, 2007, 06:39:13 pm
Sorry for that, was a bad paste. I've redone it ... let me know if its still b0rken.
Title: Re: Updated Topic.php
Post by: Aesgaard on September 02, 2007, 01:48:27 pm
I copied the colors file and the topic file into my custom\modules folder and it gave "allready defined" (bot crash), I then tried to remove the colors file from the modules folder and only have it in the custom\modules and that gave errors with other modules, please explain how to install this, keeping the topic module in the module folder only gives me /tell botname !help
Title: Re: Updated Topic.php
Post by: Diablo on September 07, 2007, 03:43:13 am
Would anyone have topic module that works in guild chat?
Title: Re: Updated Topic.php
Post by: Heffalomp on September 11, 2007, 06:32:06 pm
Remove
Code: [Select]
include_once("Colors.inc");
from the code and it works quite well...

and This version, supports guildchat too:
Code: [Select]
<?
/*
* Topic Module for BE Bot <http://bebot.fieses.net>
* Module coded by Craized <http://www.craized.net>
... Modifications 2007-08-18 by Doctorhyde@RK2
  * Topic is now sent to you in a /tell when you join, not spammed in the
    channel. If you say "!topic" in the channel it will display normally.
  * Updated to use the 'Colors.inc' file (note: symlink or copy 'Colors.inc'
    from your "modules" to "custom/modules" if you're putting this script
    in "custom/modules").
  * Updated to use the "security -> check_access()" function instead of the
    "admin -> in_group()" function.
... Modifications 2007-09-11 by Heffalomp@RK2
  * added guildchat, help and access stuff. Removed color.inc cause it didn't work
     (not so good at putting words on stuff I do xD)
*/

/*
Add a "_" at the beginning of the file (_Topic.php) if you do not want it to be loaded.
*/

// include_once("Colors2.inc");

$topic = new Topic($bot);

$commands['pgmsg']['topic'] = &$topic;
$commands['gc']['topic'] = &$topic;
//$commands["pgjoin"][] = &$topic;
$commands["buddy"][] = &$topic;

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

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

// Set default access
                $this -> bot -> accesscontrol -> create("all", "topic", "LEADER");

$this -> bot -> settings -> create ("Topic", "set", "LEADER", "Who should be able to set topic", "ADMIN;LEADER;MEMBER;GUEST;ANONYMOUS");
$this -> bot -> settings -> create ("Topic", "clear", "LEADER", "Who should be able to clear topic", "ADMIN;LEADER;MEMBER;GUEST;ANONYMOUS");

$this -> help['description'] = 'Sets and shows the current topic.';
$this -> help['command']['topic']="Shows current topic.";
$this -> help['command']['topic <message>']="Adds <message> as the current topic.";
$this -> help['command']['topici clear']="Clears current topic.";
$this -> help['notes'] = "This command sets and clears the toppic for the bot.)";
}
    /*
    This gets called on a tell with the command
    */
    function pgmsg($name, $msg) {
        if (preg_match('/^'.$this -> bot -> commpre.'topic$/i', $msg)) $c = $this -> show_topic();
        else if (preg_match('/^'.$this -> bot -> commpre.'topic clear$/i', $msg)) $c = $this -> clear($name);
        else if (preg_match('/^'.$this -> bot -> commpre.'topic (.+)/i', $msg, $info)) $c = $this -> set($name, $info['1']);
        $this -> bot -> send_pgroup($c);
    }
function gc($name, $msg) {
        if (preg_match('/^'.$this -> bot -> commpre.'topic$/i', $msg)) $c = $this -> show_topic();
        else if (preg_match('/^'.$this -> bot -> commpre.'topic clear$/i', $msg)) $c = $this -> clear($name);
        else if (preg_match('/^'.$this -> bot -> commpre.'topic (.+)/i', $msg, $info)) $c = $this -> set($name, $info['1']);
        $this -> bot -> send_gc($c);
}

   
//    function pgjoin($name) {
//        $c = $this -> show_topic();
//        $this -> bot -> send_tell($name, $c, 1);
//    }
   
function buddy($name) {
$c = $this -> show_topic();
$this -> bot -> send_tell($name, $c, 1);
}

    function show_topic() {
        $c = (isset($this -> topic) ? 'Topic: '.Highlight($this -> topic).' [By '.Highlight($this -> name).'] ' : '').'('.Highlight(count($this -> bot -> commands['pgmsg']['online'] -> pgroup)).'/'.Highlight($this -> bot -> commands['pgmsg']['maxplayers'] -> maxplayers).' | Leader: '.Highlight((isset($this -> bot -> commands['pgmsg']['leader'] -> raidleader) ? $this -> bot -> commands['pgmsg']['leader'] -> raidleader : 'None')).'| Lock: '.Highlight(($this -> bot -> commands['pgmsg']['invite'] -> lock)).' | Invites: '.Highlight($this -> bot -> commands['pgmsg']['faction'] -> faction).')';
        return $c;
    }
   
    function set($name, $msg) {
      $admin=$this -> bot -> settings -> get('Topic', 'set');
if ($this -> bot -> security -> check_access($name, $admin)){
$this -> topic = $msg;
            $this -> name = $name;
            $c = 'Topic has been set to '.Highlight($this -> topic).' by '.Highlight($name).'.';
        } else $c = 'You do not have permission to change the topic.';
        return $c;
    }
   
    function clear($name) {
        $admin=$this -> bot -> settings -> get('Topic', 'set');
if ($this -> bot -> security -> check_access($name, $admin)){
            unset($this -> topic);
            $this -> name = '';
            $c = 'Topic has been cleared by '.Highlight($name).'.';
} else $c = 'You do not have permission to change the topic.';
        return $c;
    }


?>

Title: Re: Updated Topic.php
Post by: Diablo on May 01, 2008, 03:23:25 am
Someone noticed today with this module running if you do !is <char> on someone it sends a tell to that <char> with topic info in it. Not sure if anyone has this problem but if so maybe someone has fix so topic module doesnt send info to people when they log off and when someone does !is command. Im guessing the !is command adds the person to friends list of bot or something and that why they are getting the topic sent to them. Thanks for any help.
Title: Re: Updated Topic.php
Post by: Temar on May 01, 2008, 07:26:48 am
yes that is why
the function buddy will be called on buddy action, (which !is does) regardless of there member status

you should use notify instead

inside the constructor (function Topic)

Code: [Select]
$this -> bot -> logon_notifies -> register($this);

and change function buddy to

Code: [Select]
function notify($name)
{
Title: Re: Updated Topic.php
Post by: Diablo on May 04, 2008, 08:33:30 pm
Thanks that worked also had to change one more line.
Code: [Select]
$commands["buddy"][] = &$topic;to
Code: [Select]
$commands["notify"][] = &$topic;
Title: Re: Updated Topic.php
Post by: Temar on May 04, 2008, 09:15:31 pm
oh yes commands buddy had to be removed not replaced with that. That does nothing.
Title: Re: Updated Topic.php
Post by: mookie on May 27, 2008, 03:35:39 am
Does anyone have a copy of this that writes to the Database?


Mookie
SimplePortal 2.3.7 © 2008-2024, SimplePortal