Differences
This shows you the differences between two versions of the page.
security_2 [2013/09/12 22:49] |
security_2 [2020/09/12 01:30] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Developers Guide for BeBot' | ||
+ | ===== Using the Security System in your modules ===== | ||
+ | ==== Basic use the Security System in your modules ==== | ||
+ | To make security easy for module developers, the check_access function provides all the security checks you will need. When assigning security to commands, you should **always** use one of the eight access levels, never security groups. This allows the bot user full flexibility with their configuration as org ranks and custom security groups must be assigned access levels. | ||
+ | |||
+ | For example, if your module' | ||
+ | <code php> | ||
+ | if ($this -> bot -> security -> check_access($playername, | ||
+ | return "You are a Leader or higher on < | ||
+ | else | ||
+ | return "You are not a Leader or higher on < | ||
+ | </ | ||
+ | |||
+ | check_access returns TRUE if the player meets or exceeds the level you are checking. A player with an access of LEADER, ADMIN, SUPERADMIN, or OWNER all meet or exceed the leader requirement. | ||
+ | |||
+ | |||
+ | BeBot check' | ||
+ | |||
+ | <code php> | ||
+ | if ($this -> bot -> security -> is_banned($name)) | ||
+ | { | ||
+ | $this -> bot -> send_ban($name, | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | // your code here. | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | When you wish to send notification about a ban, you should **always** use BeBot' | ||
+ | |||
+ | |||
+ | ==== Advanced use the Security System in your modules ==== | ||
+ | |||
+ | The Security Module provides the following functions for modifying the roster and security groups. | ||
+ | |||
+ | * Add a group: | ||
+ | <code php> | ||
+ | add_group($groupname, | ||
+ | </ | ||
+ | * Delete a group: | ||
+ | <code php> | ||
+ | del_group($target); | ||
+ | </ | ||
+ | * Add a user to a group: | ||
+ | <code php> | ||
+ | add_group_member($target, | ||
+ | </ | ||
+ | * Remove a user from a group: | ||
+ | <code php> | ||
+ | del_group_member($target, | ||
+ | </ | ||
+ | * Add a member or guest: | ||
+ | <code php> | ||
+ | add_user($admin, | ||
+ | </ | ||
+ | * Remove a member or guest: | ||
+ | <code php> | ||
+ | del_user($admin, | ||
+ | </ | ||
+ | * Set a ban: | ||
+ | <code php> | ||
+ | set_ban($admin, | ||
+ | </ | ||
+ | * Remove a ban: | ||
+ | <code php> | ||
+ | rem_ban($admin, | ||
+ | </ | ||
+ | * Get group id (returns -1 if group doesn' | ||
+ | <code php> | ||
+ | get_gid($groupname) | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Expert use the Security System in your modules ==== | ||
+ | The cache_mgr($action, | ||
+ | |||
+ | 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: | ||
+ | <code php> | ||
+ | $this -> cache_mgr(" | ||
+ | $this -> cache_mgr(" | ||
+ | </ | ||
+ | * Add and remove a member: | ||
+ | <code php> | ||
+ | $this -> cache_mgr(" | ||
+ | $this -> cache_mgr(" | ||
+ | </ | ||
+ | * Add and remove a ban: | ||
+ | <code php> | ||
+ | $this -> cache_mgr(" | ||
+ | $this -> cache_mgr(" | ||
+ | </ | ||
+ | * Add a group: | ||
+ | <code php> | ||
+ | $tmp = array(" | ||
+ | $this -> cache_mgr(" | ||
+ | </ | ||
+ | * Remove a group: | ||
+ | <code php> | ||
+ | $this -> cache_mgr(" | ||
+ | </ | ||
+ | * Add and remove a group member: | ||
+ | <code php> | ||
+ | $this -> cache_mgr(" | ||
+ | $this -> cache_mgr(" | ||
+ | </ | ||
+ | * Change an org rank's access level: | ||
+ | <code php> | ||
+ | $this -> cache_mgr(" | ||
+ | </ |