L* R*
HOME FORUM DOWNLOADS
Content
  Links
     Browse SVN
     SVN Commit log
     Documentation (Wiki)
  Developers
     Taskmanager
User
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 01, 2008, 11:10:41 PM

Login with username, password and session length
Search



Advanced search
Support GoPHP5.org
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Modules > 0.4.x Custom/Unofficial Modules > Topic: Updated Topic.php
Pages: [1]   Go Down
« previous next »
Print
Author Topic: Updated Topic.php  (Read 1000 times)
0 Members and 1 Guest are viewing this topic.
Hyde
Rookie
**
Offline Offline

Posts: 46


Updated Topic.php
« on: August 19, 2007, 01: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:
<?
/*
* 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, 11:38:50 AM by Hyde » Logged

Doctorhyde/Jexyll/Goraud@RK2
Diablo
Rookie
**
Offline Offline

Posts: 67


Re: Updated Topic.php
« Reply #1 on: August 22, 2007, 05:18:53 PM »

Im getting error on the function show topic is something missing on the end of that line?
Logged
Temar
BeBot Developer
Grandmaster
********
Offline Offline

Gender: Male
Posts: 877



WWW
Re: Updated Topic.php
« Reply #2 on: August 22, 2007, 07:09:03 PM »

yes it seems to have been cut off
the 1st line in the function ends like this
Code:
Highlight((isset($$
Logged

MSN messenger: chris_smith96 at hotmain dot com
Xfire: chriss96
Fxrluv
Freshman
*
Offline Offline

Posts: 4


Re: Updated Topic.php
« Reply #3 on: August 23, 2007, 08:09:26 AM »

im a php noob so how should that line end?
Logged
Hyde
Rookie
**
Offline Offline

Posts: 46


Re: Updated Topic.php
« Reply #4 on: August 23, 2007, 11:39:13 AM »

Sorry for that, was a bad paste. I've redone it ... let me know if its still b0rken.
Logged

Doctorhyde/Jexyll/Goraud@RK2
Aesgaard
Rookie
**
Offline Offline

Gender: Male
Posts: 73


.:.Alpha.:.


Re: Updated Topic.php
« Reply #5 on: September 02, 2007, 06:48:27 AM »

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
Logged

-*tinkers*-
Diablo
Rookie
**
Offline Offline

Posts: 67


Re: Updated Topic.php
« Reply #6 on: September 06, 2007, 08:43:13 PM »

Would anyone have topic module that works in guild chat?
Logged
johskar
Rookie
**
Offline Offline

Posts: 50


Re: Updated Topic.php
« Reply #7 on: September 11, 2007, 11:32:06 AM »

Remove
Code:
include_once("Colors.inc");
from the code and it works quite well...

and This version, supports guildchat too:
Code:
<?
/*
* 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 13, 2007, 06:54:08 PM by johskar » Logged
Diablo
Rookie
**
Offline Offline

Posts: 67


Re: Updated Topic.php
« Reply #8 on: April 30, 2008, 08:23:25 PM »

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.
Logged
Temar
BeBot Developer
Grandmaster
********
Offline Offline

Gender: Male
Posts: 877



WWW
Re: Updated Topic.php
« Reply #9 on: May 01, 2008, 12: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:
$this -> bot -> logon_notifies -> register($this);

and change function buddy to

Code:
function notify($name)
{
Logged

MSN messenger: chris_smith96 at hotmain dot com
Xfire: chriss96
Diablo
Rookie
**
Offline Offline

Posts: 67


Re: Updated Topic.php
« Reply #10 on: May 04, 2008, 01:33:30 PM »

Thanks that worked also had to change one more line.
Code:
$commands["buddy"][] = &$topic;
to
Code:
$commands["notify"][] = &$topic;
Logged
Temar
BeBot Developer
Grandmaster
********
Offline Offline

Gender: Male
Posts: 877



WWW
Re: Updated Topic.php
« Reply #11 on: May 04, 2008, 02:15:31 PM »

oh yes commands buddy had to be removed not replaced with that. That does nothing.
Logged

MSN messenger: chris_smith96 at hotmain dot com
Xfire: chriss96
mookie
Rookie
**
Offline Offline

Posts: 27


Re: Updated Topic.php
« Reply #12 on: May 26, 2008, 08:35:39 PM »

Does anyone have a copy of this that writes to the Database?


Mookie
Logged
Pages: [1]   Go Up
Print
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Modules > 0.4.x Custom/Unofficial Modules > Topic: Updated Topic.php
« previous next »
 
Jump to:  

Recent
[request] Raid timers
by Elesar1
[Today at 04:41:09 PM]

Shared DB online list
by Temar
[Today at 01:55:47 AM]

relay colors
by Temar
[Today at 01:54:56 AM]

BeBot v0.6.0 released
by Alreadythere
[November 30, 2008, 05:32:00 PM]

Change to Bid.php
by Temar
[November 30, 2008, 11:41:44 AM]

OnlineOrg
by Jiheld
[November 29, 2008, 12:44:27 PM]

Silly Newbie Question.
by Temar
[November 29, 2008, 12:00:02 PM]

massive_pvp_time_table 1
by gerborg
[November 29, 2008, 06:55:35 AM]

Bot not see Guild Chat
by Delvar
[November 28, 2008, 08:30:34 AM]

Starting Bot
by Allisande
[November 28, 2008, 07:08:21 AM]
Stats
Members
Total Members: 1243
Latest: Whackoeng
Stats
Total Posts: 11144
Total Topics: 1505
Online Today: 21
Online Ever: 168
(July 01, 2007, 09:30:02 PM)
Users Online
Users: 1
Guests: 15
Total: 16
clashbot

Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC
TinyPortal v0.9.8 © Bloc | NewDef design by Bloc
Page created in 0.39 seconds with 29 queries. (Pretty URLs adds 0.038s, 4q)
Loading...