Editing Security

From Bebot Wiki 2
Jump to navigationJump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 46: Line 46:
 
For example, if your module's commands should only be used by bot leaders you would use the following code:
 
For example, if your module's commands should only be used by bot leaders you would use the following code:
  
    if ($this -> bot -> security -> check_access($playername, "LEADER"))
+
if ($this -> bot -> security -> check_access($playername, "LEADER"))
        return "You are a Leader or higher on <botname>!";
+
    return "You are a Leader or higher on <botname>!";
    else
+
else
        return "You are not a Leader or higher on <botname>";
+
    return "You are not a Leader or higher on <botname>";
  
 
check_access returns TRUE if the player meets or exceeds the level you are checking. A player with an access or leader, admin, superadmin, or owner all meet or exceed the leader requirement.
 
check_access returns TRUE if the player meets or exceeds the level you are checking. A player with an access or leader, admin, superadmin, or owner all meet or exceed the leader requirement.
Line 55: Line 55:
 
BeBot check's it's banlist on all incoming tell, pgroup, and gc commands. If you are taking input from other chat channels, you may want to have a ban check.
 
BeBot check's it's banlist on all incoming tell, pgroup, and gc commands. If you are taking input from other chat channels, you may want to have a ban check.
  
    if ($this -> bot -> security -> is_banned($name))
+
if ($this -> bot -> security -> is_banned($name))
    {
+
{
        $this -> bot -> send_ban($name, "Sorry, you have been banned from <botname> and cannot use that command.");
+
    $this -> bot -> send_ban($name, "Sorry, you have been banned from <botname> and cannot use that command.");
    }
+
}
    else
+
else
    {
+
{
      // your code here.
+
  // your code here.
    }
+
}
  
 
When you wish to send notification about a ban, you should always use BeBot's send_ban function. The send_ban function has built in spam control that will prevent a banned user from filling up your bot's tell queue with outgoing ban notifications.
 
When you wish to send notification about a ban, you should always use BeBot's send_ban function. The send_ban function has built in spam control that will prevent a banned user from filling up your bot's tell queue with outgoing ban notifications.
Line 72: Line 72:
 
The Security Module provides the following functions for modifying the roster and security groups.
 
The Security Module provides the following functions for modifying the roster and security groups.
  
* Add a group:
+
    Add a group:
  
    add_group($groupname, $description);
+
add_group($groupname, $description);
  
* Delete a group:
+
    Delete a group:
  
    del_group($target);
+
del_group($target);
  
* Add a user to a group:
+
    Add a user to a group:
  
    add_group_member($target, $group)
+
add_group_member($target, $group)
  
* Remove a user from a group:
+
    Remove a user from a group:
  
    del_group_member($target, $group)
+
del_group_member($target, $group)
  
* Add a member or guest:
+
    Add a member or guest:
  
    add_user($admin, $target, $level="guest")
+
add_user($admin, $target, $level="guest")
  
* Remove a member or guest:
+
    Remove a member or guest:
  
    del_user($admin, $target)
+
del_user($admin, $target)
  
* Set a ban:
+
    Set a ban:
  
    set_ban($admin, $target)
+
set_ban($admin, $target)
  
* Remove a ban:
+
    Remove a ban:
  
    rem_ban($admin, $target)
+
rem_ban($admin, $target)
  
* Get group id (returns -1 if group doesn't exisit)
+
    Get group id (returns -1 if group doesn't exisit)
  
    get_gid($groupname)
+
get_gid($groupname)
  
 
Expert use the Security System in your modules
 
Expert use the Security System in your modules
Line 114: Line 114:
 
Description of function parameters: $action: add or rem $cache: Which cache to modify (groups, guests, members, banned, groupmem, orgranks) $info: The information to add (or remove) $more: Extra information needed for some actions. (Optional Parameter)
 
Description of function parameters: $action: add or rem $cache: Which cache to modify (groups, guests, members, banned, groupmem, orgranks) $info: The information to add (or remove) $more: Extra information needed for some actions. (Optional Parameter)
  
* Add and remove a guest:
+
    Add and remove a guest:
  
    $this -> cache_mgr("add", "guests", "Glarawyn");
+
$this -> cache_mgr("add", "guests", "Glarawyn");
    $this -> cache_mgr("rem", "guests", "Glarawyn");
+
$this -> cache_mgr("rem", "guests", "Glarawyn");
  
* Add and remove a member:
+
    Add and remove a member:
  
    $this -> cache_mgr("add", "members", "Glarawyn");
+
$this -> cache_mgr("add", "members", "Glarawyn");
    $this -> cache_mgr("rem", "members", "Glarawyn");
+
$this -> cache_mgr("rem", "members", "Glarawyn");
  
* Add and remove a ban:
+
    Add and remove a ban:
  
    $this -> cache_mgr("add", "banned", "Glarawyn");
+
$this -> cache_mgr("add", "banned", "Glarawyn");
    $this -> cache_mgr("rem", "banned", "Glarawyn");
+
$this -> cache_mgr("rem", "banned", "Glarawyn");
  
* Add a group:
+
    Add a group:
  
    $tmp = array("gid" => "10", "name" => "groupname", "description" = "Example Group", "access_level" => 2);
+
$tmp = array("gid" => "10", "name" => "groupname", "description" = "Example Group", "access_level" => 2);
    $this -> cache_mgr("add", "groups", $tmp);
+
$this -> cache_mgr("add", "groups", $tmp);
  
* Remove a group:
+
    Remove a group:
  
    $this -> cache_mgr("rem", "groups", $groupname);
+
$this -> cache_mgr("rem", "groups", $groupname);
  
* Add and remove a group member:
+
    Add and remove a group member:
  
    $this -> cache_mgr("add", "groupmem", $groupname, $membername);
+
$this -> cache_mgr("add", "groupmem", $groupname, $membername);
    $this -> cache_mgr("rem", "groupmem", $groupname, $membername);
+
$this -> cache_mgr("rem", "groupmem", $groupname, $membername);
  
* Change an org rank's access level:
+
    Change an org rank's access level:
  
    $this -> cache_mgr("add", "orgrank", "President", "255");
+
$this -> cache_mgr("add", "orgrank", "President", "255");

Please note that all contributions to Bebot Wiki 2 may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Bebot Wiki 2:Copyrights for details). Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)