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

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

Author Topic: Feedback requested: message handeling  (Read 2639 times)

0 Members and 1 Guest are viewing this topic.

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Feedback requested: message handeling
« on: May 25, 2006, 12:29:06 pm »
Im currently looking at improving how modules handle and recieve incoming messages.
Reasoning:
Currently we have 4 message handlers, one for
  • tells
  • pgroup
  • guildchat
  • non member tells
Now each of these message handlers in a module today has a separate function to handle each type of handler, which usually means we have 3 or 4 functions containing essentially the same code.
In some cases we even have very nasty code repetition inside these functions. This adds imho uneccecary clutter and complexity.
It could even be argued that it would be better to have just a single handler inside the modules and give that handler a way to tell the incoming handler types apart.

Another issue is access control. RightsManagement is a good foundation imho, but most of the modules are still not modified to take it into account and do their own checks.
I am aware that the bots is_member and related commands for getting access levels needs to be improved, so we can leave that one alone for now.
I have talked to Vhab briefly on the subject and it makes more sense for the module to register default access levels when hooking.
This would also allow us to read access levels from RightsManagement only on startup which eliminates the current MySQL query which happens on each recieved command as the bot looksup permissions.

Anyways, before i really start changing stuff around, i want to hear feedback, ideas and even code if you want.
If you want to see what i consider a horror example on what the current situation is giving have a look at:
http://svn.shadow-realm.org/index.py/BeBot/trunk/modules/Roster_RAID.php?revision=115&view=markup

I am currently playing around with ideas on how to clean it up, and this is what i have right now (this is without changing how modules hook into the core)
Code: [Select]
<?php
/*
* Roster.php - Handle member roster
*
* BeBot - An Anarchy Online Chat Automaton
* Copyright (C) 2004 Jonas Jax
*
* Developed by Blondengy (RK1)
* Special thanks goes out to Khalem (RK1) for his support.
*
* File last changed at $LastChangedDate: 2006-05-25 07:19:12 +0000 (to, 25 mai 2006) $
* Revision: $Id: Roster_RAID.php 115 2006-05-25 07:19:12 +0000 (to, 25 mai 2006) shadowmaster $
*/

/*
Prepare MySQL database
*/
$db -> query("CREATE TABLE IF NOT EXISTS members
                (id INT NOT NULL PRIMARY KEY,
                nickname VARCHAR(25),
                firstname VARCHAR(25),
                lastname VARCHAR(25),
                rank TINYINT,
                rank_name VARCHAR(20),
                level INT,
                profession VARCHAR(15),
                gender VARCHAR(10),
                breed VARCHAR(10),
                guild VARCHAR(35),
                pic VARCHAR(100),
                lvlrange VARCHAR(10),
updated INT,
                ailevel INT,
                aititle VARCHAR(25))"
);

$db -> query("CREATE TABLE IF NOT EXISTS member_settings
                (id INT NOT NULL PRIMARY KEY,
                on_list INT(1) DEFAULT '0',
                notify INT(1) DEFAULT '1')"
);


$roster = new Roster($bot);
$commands["tell"]["member"] = &$roster;
$commands["tell"]["rosterupdate"] = &$roster;
$commands["tell"]["notify"] = &$roster;
$commands["tell2"]["member"] = &$roster;
$commands["tell"]["members"] = &$roster;
$commands["pgmsg"]["member"] = &$roster;
$commands["pgmsg"]["members"] = &$roster;
$commands["pgjoin"][] = &$roster;

$cron["24hour"][] = &$roster;

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


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

/*
This is the general message handler
$type: 1 = tell, 2 = pgroup, 3 = gc
*/
function handler($name$msg$type);
{
$return false;
$command strtolower($msg[0]);
if ($command "member")
{
if ("/^" $this -> bot -> commpre "member (del|rem) (.+)$/i"$msg$info)
{
$return $this -> member_del ($name$info[1], $type);
}
else if ("/^" $this -> bot -> commpre "member add (.+)$/i"$msg$info)
{
$return $this -> member_add ($name$info[0], $type);
}
else if (preg_match("/^" $this -> bot -> commpre "member (.+)$/i"$msg$info))
{
$return $this -> member_add ($name$info[0], $type);
}
}
else if ($command "members")
{
if (preg_match("/^" $this -> bot -> commpre "members list$/i"$msg))
{
$return $this -> list_members($name$type);
}
else if (preg_match("/^" $this -> bot -> commpre "members$/i"$msg))
{
$result $this -> bot -> db -> select("SELECT count(*) FROM members");
$return $this -> members_count($name$type);
}
}
else if ($command "members")
{
if(preg_match("/^" $this -> bot -> commpre "notify (on|off)$/i"$msg$info))
{
$return $this -> set_notify($namestrtolower($info[1]), $type);
}
else if(preg_match("/^" $this -> bot -> commpre "notify/i"$msg$info))
{
$return "Please use /tell <botname> <pre>notify (on|off)";
}
}

switch($type)
{
case '1':
if ($return)
{
$this -> bot -> send_tell($name$return);
}
else
{
$this -> bot -> send_help($name);
}
case '2':
if ($return)
{
$this -> bot -> send_pgroup(return);
}
else
{
$this -> bot -> send_help($name);
}
default:
$this -> bot -> send_tell($name"Broken plugin, type: $type is unknown to me");
}

}

/*
This gets called on a tell with the command
*/
function tell($name$msg)
{
$this -> handler ($name$msg1);
}



/*
This gets called on a tell with the command from person outside guild
*/
function tell2($name$msg)
{
if ($this -> bot -> admin -> in_group($name"superadmin"))
$this -> tell($name$msg);
}



/*
This gets called on a priv group msg with the command
*/
function pgmsg($name$msg)
{
$this -> handler ($name$msg2);
}

/*
This gets called if someone joins the privgroup
*/
function pgjoin($name)
{
if ($this -> bot -> is_member($name) == 1)
{
$result $this -> bot -> db -> select("SELECT updated FROM whois WHERE id = " .
$this -> bot -> aoc -> get_uid($name));
if ((time() - $result[0][0]) > (60 60 24))
{
$members $this -> bot -> whois ($name);
}
}
}



/*
* Sets the notify state
*/
function set_notify($name$status)
{
$id $this -> bot -> aoc -> get_uid($name);
if ($status == "off")
{
$this -> bot -> aoc -> buddy_remove($id);
$this -> bot -> db -> query("UPDATE member_settings SET on_list = '0', notify = '0' WHERE id = '".$id."'");
}
else
$this -> bot -> db -> query("UPDATE member_settings SET notify = '1' WHERE id = '".$id."'");

return "Notify has been switched <font color=#ffff00>" $status "</font>.";
}

/*
* Update the roster of the bot
* This may take a while and goes heavy on the MySQL server
* so please use with care (in other words: only when updating the bot)
*/
function update_roster()
{
// Set all people as not on list
$this -> bot -> db -> query("UPDATE member_settings SET on_list = '0'");

// Select all members
$result $this -> bot -> db -> select("SELECT id FROM members");
for ($i 0$i count($result); $i++)
{
// Remove everyone from list
if ($this -> bot -> aoc -> buddy_exists($result[$i][0]))
$this -> bot -> aoc -> buddy_remove($result[$i][0]);

// Add them to member_settings list if they're not on it already.
$res $this -> bot -> db -> select("SELECT id FROM member_settings WHERE id = '" $result[$i][0] . "'");
if (empty($res[0][0]))
$this -> bot -> db -> query("INSERT INTO member_settings (id) VALUES ('" $result[$i][0] . "')");
}

// Add 600 people onto members-list...
$result $this -> bot -> db -> select("SELECT members.id, nickname FROM members, member_settings WHERE members.id = member_settings.id AND member_settings.notify = 1 ORDER  BY updated DESC  LIMIT 0 , 600");
for ($i 0$i count($result); $i++)
{
if ($id $this -> bot -> aoc -> get_uid($result[$i][1]))
{
if ($id != $result[$i][0])
{
$this -> bot -> send_pgroup("The character <font color=#ffff00>" $result[$i][1] . "</font> has rerolled. Correcting Member-ID.");
$this -> bot -> db -> query("UPDATE members SET id = '" $id "' WHERE id = '" $result[$i][0] . "'");
$this -> bot -> db -> query("UPDATE raid_points SET id = '" $id "' WHERE id = '" $result[$i][0] . "'");
$this -> bot -> db -> query("UPDATE member_settings SET id = '" $id "' WHERE id = '" $result[$i][0] . "'");
}
$this -> bot -> aoc -> buddy_add($id);
$this -> bot -> db -> query("UPDATE member_settings SET on_list = '1' WHERE id = '" $result[$i][0] . "'");
}
else
$this -> bot -> send_pgroup("The character <font color=#ffff00>" $result[$i][1] . "</font> might have been deleted but is still on the members list.");
}
}



/*
* Update the roster every 24h
*/
function cron()
{
$this -> bot -> log("CRON""ROSTER""Updating buddylist");
$num 0;

// Select oldest update
$oldest $this -> bot -> db -> select("SELECT MIN(updated) FROM members, member_settings WHERE members.id = member_settings.id AND on_list = '1'");
$oldest $oldest[0][0];

// Select all not on buddylist with notify on with newer update
$new $this -> bot -> db -> select("SELECT members.id, nickname FROM members, member_settings WHERE members.id = member_settings.id AND on_list = '0' AND notify = '1' AND updated > '".$oldest."'");

// If changes have accured...
if (!empty($new[0][0]))
{
$num count($new);
$start 600 $num;

// Select all those on buddy list to be removed
$remove $this -> bot -> db -> select("SELECT members.id, nickname FROM members, member_settings WHERE members.id = member_settings.id AND member_settings.notify = 1 ORDER  BY updated DESC  LIMIT $start , $num");

// Remove them
if (!empty($remove))
{
for ($i 0$i count($remove); $i++)
{
$this -> bot -> log ("BUDDY""REM"$remove[$i][1]);
$this -> bot -> aoc -> buddy_remove($remove[$i][1]);
$this -> bot -> db -> query("UPDATE member_settings SET on_list = '0' WHERE id = '" $remove[$i][0] . "'");
}
}
// Add the new ones
for ($i 0$i count($new); $i++)
{
$this -> bot -> log ("BUDDY""ADD"$new[$i][1]);
$this -> bot -> aoc -> buddy_add($new[$i][0]);
$this -> bot -> db -> query("UPDATE member_settings SET on_list = '1' WHERE id = '" $new[$i][0] . "'");
}
}
$this -> bot -> log("CRON""ROSTER""Done updating buddylist: " $num" new people getting messages.");
}


function member_add($name$var$type)
{
$result $this -> bot -> db -> select("SELECT nickname FROM members WHERE id = " $this -> bot -> aoc -> get_uid($info[1]));
if (empty($result))
{
if (!$this -> bot -> aoc -> get_uid($var))
$this -> bot -> send_pgroup("Player <font color=#ffff00>" $info[1] . "</font> does not exist");
else
{
$members $this -> bot -> whois ($var);

$this -> bot -> db -> query("INSERT INTO members (id, nickname, firstname, lastname, rank, rank_name, level, profession, gender, breed, pic, guild, updated, ailevel, aititle)
                          VALUES ('" 
$members["id"] . "', '" $members["nick"] . "', '" $members["firstname"] . "',
                                  '" 
$members["lastname"] . "', '" $members["rank_id"] . "', '" $members["rank"] . "',
                                  '" 
$members["level"] . "', '" $members["profession"] . "', '" $members["gender"] . "',
                                  '" 
$members["breed"] . "', '" $members["pictureurl"] . "', '" $members["guild"] . "',
                                  " 
time() . ", '" $members["at_id"] . "', '" $members["at"] . "'
                                  )"
);

$this -> bot -> db -> query("INSERT INTO raid_points (id, points) VALUES (" $members["id"] . ", 0)");
$this -> bot -> db -> query("INSERT INTO member_settings (id) VALUES (" $members["id"] . ")");
$this -> bot -> send_tell($var"<font color=#ffff00>" $name "</font> has added you to the bot.");
return "Player <font color=#ffff00>" $var "</font> has been added to the bot.";
}
}
else
{
return "<font color=#ffff00>" $result[0][0] . "</font> is already a member.";
}
}

function member_del($name$var$type)
{
$result $this -> bot -> db -> select("SELECT nickname FROM members WHERE id = " $this -> bot -> aoc -> get_uid($var));
if (!empty($result))
{
$id $this -> bot -> aoc -> get_uid($var);
$this -> bot -> db -> query("DELETE FROM members WHERE id = " $id);
$this -> bot -> db -> query("DELETE FROM raid_points WHERE id = " $id);
$this -> bot -> db -> query("DELETE FROM member_settings WHERE id = " $id);
$this -> bot -> aoc -> buddy_remove($id);

if ($this -> bot -> aoc -> get_uid($var))
{
$this -> bot -> send_tell($var"<font color=#ffff00>" $name "</font> has removed you from the bot.");
}
return "<font color=#ffff00>" $var "</font> has been removed from member list.";
}
else
{
return "<font color=#ffff00>" $var "</font> is not a member.";
}
}

function members_list($name$type)
{
$result $this -> bot -> db -> select("SELECT nickname, guild FROM members ORDER BY guild DESC");
$msg "";
for ($i 0$i count($result); $i++)
{
$msg .= $result[$i][0] . " (" $result[$i][1] . ")\n";
}
return $this -> bot -> make_blob("Members"$msg);
}

function members_count($name$type)
{
$result $this -> bot -> db -> select("SELECT count(*) FROM members");
return "There are <font color=#ffff00>" $result[0][0] . "</font> members on <botname>'s roster.";
}
}
?>

BeBot Founder and Fixer Kingpin

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: Feedback requested: message handeling
« Reply #1 on: May 25, 2006, 01:36:54 pm »
Ok, here some (first) thoughts:

1) Perhaps we should keep 4 handler, but in a slightly different way: tells, pgmsg, gc and global (any one of the 3). This would allow differentiation where it's wanted, and centralization where it's mode senseful. And add a global send() function, that takes the target channel as parameter.

2) Personally I like that I can change the rights during runtime. But yes, the queries done are a waste. It would make more sense to cache the current rights once queried, and only update the table and cache if some changes occur. Default rights should definitly be added, best over some $this -> bot -> rights -> define_rights() function.

3) The is_member function needs a serious overhaul as you stated. It needs more differentiation, and I think it should be moved out of the Bot class into a core module. This would allow easier custumization for bot owners without changing any of the real core functionality.

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: Feedback requested: message handeling
« Reply #2 on: May 25, 2006, 02:31:25 pm »
Ok, here some (first) thoughts:

1) Perhaps we should keep 4 handler, but in a slightly different way: tells, pgmsg, gc and global (any one of the 3). This would allow differentiation where it's wanted, and centralization where it's mode senseful. And add a global send() function, that takes the target channel as parameter.

What i have in mind right now (thanks a lot for ideas Vhab) is a single command list for plugins to register with.
This would in turn call say handler() in the plugin with
  • Name/Source
  • Type (Tell, Pgroup, GC)
  • Command
  • Command args

Quote
2) Personally I like that I can change the rights during runtime. But yes, the queries done are a waste. It would make more sense to cache the current rights once queried, and only update the table and cache if some changes occur. Default rights should definitly be added, best over some $this -> bot -> rights -> define_rights() function.
Runtime updates can still occur, you just have to update the entry in the in memory permissions list in addition to the database
Default user levels can be set in the actual hooking so that when the module registers a handler it would do something like:
$commands["whois"]["guests"] = &$roster;

Quote
3) The is_member function needs a serious overhaul as you stated. It needs more differentiation, and I think it should be moved out of the Bot class into a core module. This would allow easier custumization for bot owners without changing any of the real core functionality.

Im looking at moving more stuff into core modules right now. And i would also like to separate actual user availible command handlers into their own modules instead of having them reside in the core modules, thus keeping the core modules an extention of Bot.php containing only functions to be called.
BeBot Founder and Fixer Kingpin

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: Feedback requested: message handeling
« Reply #3 on: May 25, 2006, 04:20:46 pm »
What i have in mind right now (thanks a lot for ideas Vhab) is a single command list for plugins to register with.
This would in turn call say handler() in the plugin with
  • Name/Source
  • Type (Tell, Pgroup, GC)
  • Command
  • Command args
I see two ways of doing it, both with advantages and disadvantages:
  • one halder() for all commands of a module
  • single handler for a single command only, like if $commands["whois"] = &$whois is the define, the function $whois -> whois() is called
Both would get the same parameters, $name of caller, full command, and channel of origin. Single handler would make for cleaner structured code, global handler could save some overhead of similar commands.

Quote
Runtime updates can still occur, you just have to update the entry in the in memory permissions list in addition to the database
Default user levels can be set in the actual hooking so that when the module registers a handler it would do something like:
$commands["whois"]["guests"] = &$roster;
Considering the possible problems with function calls in the init phase of the modules I guess a defined array that get's parsed after startup is the best choice. The parsing should just take existing access rights in the database over predefined in the array, people may not like the predefines.

Quote
Im looking at moving more stuff into core modules right now. And i would also like to separate actual user availible command handlers into their own modules instead of having them reside in the core modules, thus keeping the core modules an extention of Bot.php containing only functions to be called.
So basically all under core/ only offers functions, and all that reacts directly to commands is under module?
Would be a nice clean split tbh, hadn't thought that far.

Offline Glarawyn

  • BeBot Hero
  • ******
  • Posts: 521
  • Karma: +0/-0
Re: Feedback requested: message handeling
« Reply #4 on: May 26, 2006, 06:44:52 pm »
Currently we have 4 message handlers, one for
  • tells
  • pgroup
  • guildchat
  • non member tells
Now each of these message handlers in a module today has a separate function to handle each type of handler, which usually means we have 3 or 4 functions containing essentially the same code.

To address this, I've been adding another function that is called by the handlers. All the code that was being repeated on one funciton. I borrowed the idea from someone else's module (don't remember who), but it's worked well for me.

For example:
Code: [Select]
    /*
    This gets called on a tell with the command
    */
    function tell($name, $msg)
    { // Start function tell()
        $this -> process_command($name, $msg);
    } // End function tell()
    /*
        This function handles all the inputs and returns output
        sutible for send_tell, send_pgroup, and send_gc.
    */
    function process_command($name, $msg)
    { // Start function process_command()
       if (preg_match("/^" . $this -> bot -> commpre . "orders$/i", $msg))
       {
           if ($this -> check_security($name, "TRAINEE"))
               $this -> clear_orders($name); // Clear orders
       }
       elseif (preg_match("/^" . $this -> bot -> commpre . "orders (.+)$/i", $msg, $info))
       {
            if ($this -> check_security($name, "TRAINEE"))
                $this -> new_orders($name, $info[1]); // Set orders to info[1].
       }
       else
            $this -> bot -> send_help($name);
    } // End function process_command()

Also note the use of check_security in process_command (see below).

Are you thinking of changing how commands are registered? At times it's nice to write something that is tell, org chat, or private group only. :)

Quote
It could even be argued that it would be better to have just a single handler inside the modules and give that handler a way to tell the incoming handler types apart.

Again something I've done by passing a vairable to the extra function. It works well most of the time. This method would also work well with a global output handler.


Quote
Another issue is access control. RightsManagement is a good foundation imho, but most of the modules are still not modified to take it into account and do their own checks.

I don't use it because since it's not distributed with the current stable bot. I write modules so they can be dropped into any series 0.2.X BeBot and work. I'll take advantage of anything that makes it into the core of the bot. IMHO, users should not have to modify the bot core to use a module.


Quote
I am aware that the bots is_member and related commands for getting access levels needs to be improved, so we can leave that one alone for now.

This is my security band-aid that I've used in a few of my modules. I like it for being simple. Send it the username and the security group, and get back a true if they pass the security check (they are in that group or a higher group) or false if not.

Code: [Select]
    /*
        Check Security
            Returns TRUE if $name is in $level or above.
            Otherwise Returns False.
    */
    function check_security($name, $level)
    {
        $name = ucfirst(strtolower($name));
        $level = strtoupper($level);

        switch ($level)
        {
            case "GUEST":
                if ( ($this -> bot -> is_member($name) == 2)
                      || ($this -> bot -> admin -> is_member($name) == 1) )
                    return TRUE;
                    break;
            case "MEMBER":
                if ($this -> bot -> is_member($name) == 1)
                // is_member($name) : returns if person is a member of the bot (true = member, 2 = guest, false = unknown)
                    return TRUE;
                 else
                    return FALSE;
                break;
            case "RAIDLEADER":
                if ($this -> bot -> admin -> in_group($name, "raidleader")
                    || $this -> bot -> admin -> in_group($name, "admin")
                    || $this -> bot -> admin -> in_group($name, "superadmin"))
                    return TRUE;
                else
                    return FALSE;
                break;
            case "ADMIN":
                if ($this -> bot -> admin -> in_group($name, "admin")
                    || $this -> bot -> admin -> in_group($name, "superadmin"))
                    return TRUE;
                else
                    return FALSE;
                break;
            case "SUPERADMIN":
                if ($this -> bot -> admin -> in_group($name, "superadmin"))
                    return TRUE;
                else
                    return FALSE;
                break;
            default:
                return FALSE;
                break;
        }
    }

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: Feedback requested: message handeling
« Reply #5 on: May 26, 2006, 08:43:30 pm »
Are you thinking of changing how commands are registered? At times it's nice to write something that is tell, org chat, or private group only. :)

It may or may not happen. Although i am currently leaning slighty in favour of doing it, combining everything into a single command handler in the bot core, and then giving the module the opportunity to select what channels to act upon the command in.

The only real drawback to this aside from that every module will need slight modification, is that you can no longer set access per command per channel.
We would still be able to say that members have access to any commands in gc, pgroup and tells, but guests only in tells. And from there it would be up to the rightsmanagement to determine if the user should be allowed to access it or not (And of course you would have a default setting either in the actual hook or as a separate function)

Quote
Again something I've done by passing a vairable to the extra function. It works well most of the time. This method would also work well with a global output handler.

This is also what i did in my example in the first post, and regardless of what i end up with, any channel will be calling a single function in the module probably named handler() which also includes a $type variable that tells the module what channel the request came from.


Quote
I don't use it because since it's not distributed with the current stable bot. I write modules so they can be dropped into any series 0.2.X BeBot and work. I'll take advantage of anything that makes it into the core of the bot. IMHO, users should not have to modify the bot core to use a module.

I should probably have made this clear from the getgo, but this change would only happen in the 0.3 branch.
Having worked with software development projects for some time i am strongly opposed to changing the API in minor patch releases, it simply should not be done because it confuses the users and frustrates developers even more.
This is also the reason i am taking my time with 0.3 before it becomes the new stable release as 0.4 (or 1.0) because i want to get these major changes out of the way.


Quote
This is my security band-aid that I've used in a few of my modules. I like it for being simple. Send it the username and the security group, and get back a true if they pass the security check (they are in that group or a higher group) or false if not.

Code: [Select]
    /*
        Check Security
            Returns TRUE if $name is in $level or above.
            Otherwise Returns False.
    */
    function check_security($name, $level)
    {
        $name = ucfirst(strtolower($name));
        $level = strtoupper($level);

        switch ($level)
        {
            case "GUEST":
                if ( ($this -> bot -> is_member($name) == 2)
                      || ($this -> bot -> admin -> is_member($name) == 1) )
                    return TRUE;
                    break;
            case "MEMBER":
                if ($this -> bot -> is_member($name) == 1)
                // is_member($name) : returns if person is a member of the bot (true = member, 2 = guest, false = unknown)
                    return TRUE;
                 else
                    return FALSE;
                break;
            case "RAIDLEADER":
                if ($this -> bot -> admin -> in_group($name, "raidleader")
                    || $this -> bot -> admin -> in_group($name, "admin")
                    || $this -> bot -> admin -> in_group($name, "superadmin"))
                    return TRUE;
                else
                    return FALSE;
                break;
            case "ADMIN":
                if ($this -> bot -> admin -> in_group($name, "admin")
                    || $this -> bot -> admin -> in_group($name, "superadmin"))
                    return TRUE;
                else
                    return FALSE;
                break;
            case "SUPERADMIN":
                if ($this -> bot -> admin -> in_group($name, "superadmin"))
                    return TRUE;
                else
                    return FALSE;
                break;
            default:
                return FALSE;
                break;
        }
    }
I was actually planning something similiar, although i am hoping to more or less eliminate the need to do access control inside a module almost entirely.
This will most likely mean that in addition to registering a default access level, it should also be possible to make sure a command cannot be allowed below a certain level. For example shutdown and restart commands should always be limited to at least higher than member (to allow for custom admin groups control)
BeBot Founder and Fixer Kingpin

 

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


0.8.x updates for AoC by bitnykk
[January 30, 2024, 11:16:08 pm]


0.8.x updates for AO by bitnykk
[January 30, 2024, 11:15:37 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: 749
  • 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