collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18365
  • stats Total Topics: 2500
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: Updated Topic.php  (Read 16200 times)

0 Members and 1 Guest are viewing this topic.

Offline Hyde

  • BeBot Apprentice
  • ***
  • Posts: 92
  • Karma: +0/-0
Updated Topic.php
« 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;
    }


?>


« Last Edit: August 23, 2007, 06:38:50 pm by Hyde »
Doctorhyde/Jexyll/Goraud@RK2

Offline Diablo

  • BeBot User
  • **
  • Posts: 67
  • Karma: +0/-0
Re: Updated Topic.php
« Reply #1 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?

Offline Temar

  • Contributor
  • *******
  • Posts: 1140
  • Karma: +0/-0
    • AoFiles
Re: Updated Topic.php
« Reply #2 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($$

Offline Fxrluv

  • BeBot Rookie
  • *
  • Posts: 4
  • Karma: +0/-0
Re: Updated Topic.php
« Reply #3 on: August 23, 2007, 03:09:26 pm »
im a php noob so how should that line end?

Offline Hyde

  • BeBot Apprentice
  • ***
  • Posts: 92
  • Karma: +0/-0
Re: Updated Topic.php
« Reply #4 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.
Doctorhyde/Jexyll/Goraud@RK2

Offline Aesgaard

  • BeBot Apprentice
  • ***
  • Posts: 82
  • Karma: +0/-0
  • .:.Alpha.:.
Re: Updated Topic.php
« Reply #5 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
-*tinkers*-

Offline Diablo

  • BeBot User
  • **
  • Posts: 67
  • Karma: +0/-0
Re: Updated Topic.php
« Reply #6 on: September 07, 2007, 03:43:13 am »
Would anyone have topic module that works in guild chat?

Offline Heffalomp

  • BeBot Apprentice
  • ***
  • Posts: 80
  • Karma: +0/-0
Re: Updated Topic.php
« Reply #7 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;
    }


?>

« Last Edit: September 14, 2007, 01:54:08 am by johskar »
"Ubuntu" is an ancient African word, meaning "I can't configure Slackware"

Offline Diablo

  • BeBot User
  • **
  • Posts: 67
  • Karma: +0/-0
Re: Updated Topic.php
« Reply #8 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.

Offline Temar

  • Contributor
  • *******
  • Posts: 1140
  • Karma: +0/-0
    • AoFiles
Re: Updated Topic.php
« Reply #9 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)
{

Offline Diablo

  • BeBot User
  • **
  • Posts: 67
  • Karma: +0/-0
Re: Updated Topic.php
« Reply #10 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;

Offline Temar

  • Contributor
  • *******
  • Posts: 1140
  • Karma: +0/-0
    • AoFiles
Re: Updated Topic.php
« Reply #11 on: May 04, 2008, 09:15:31 pm »
oh yes commands buddy had to be removed not replaced with that. That does nothing.

Offline mookie

  • BeBot User
  • **
  • Posts: 27
  • Karma: +0/-0
Re: Updated Topic.php
« Reply #12 on: May 27, 2008, 03:35:39 am »
Does anyone have a copy of this that writes to the Database?


Mookie

 

* Recent Posts
0.8.x updates for AO by bitnykk
[June 23, 2024, 03:19:47 pm ]


0.8.x updates for AoC by bitnykk
[June 23, 2024, 03:19:44 pm ]


[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm ]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am ]


Bebot and Rasberry by bitnykk
[November 29, 2023, 11:04:14 pm ]

* Who's Online
  • Dot Guests: 137
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal