Contra › class › User System
From Botdom Documentation
Most bots you find will have some form of internal user list, and have access levels. This is also present in Contra, and the User_System class is used to do this.
Contents |
Location
~/core/User_class.php
Properties
protected $list = array(); // The user list and access levels are stored here. protected $owner; // Username for the owner of the bot. protected $Bot; // Instance of the Bot class.
Methods
__construct
This method is called when the class is instantiated. It loads the user access data into the bot and stores it. If there is no data to load, data is created.
Example:
$user = new User_System();
UpdateList
Use this method to save the user data!
Example:
$user->UpdateList();
add
Add a user to the bot's user list.
Parameters: $user - string. Name of the user to add to the list. $privs - mixed. Name or order number of the privilege class to add $user to.
Example:
$user->add('photofroggy', 99);
rem
Remove a user from the bot's user list.
Parameters: $user - string. Name of the user to be removed.
Example:
$user->rem('photofroggy');
has
Check if a user has a certain amount of privileges.
Parameters: $user - string. Name of the user to check privileges of. $privs - mixed. Name or order number of the minimum privileges to return true. If set to false, $user's privileges are returned.
Example:
$user->has('photofroggy', 99);
addCmd
Gives a user access to a specific command, regardless of privilege level.
Parameters: $user - string. Name of the user to give command access to. $command - string. Name of the command to give $user access to.
Example:
$user->addCmd('photofroggy', 'about');
remCmd
Remove a user's override data for a specific command.
Parameters: $user - string. Name of the the user to remove override data for. $command - string. Name of the command to reset.
Example:
$user->remCmd('photofroggy', 'about');
banCmd
Ban someone from using a specific command, regardless of privilege level.
Parameters: $user - string. Name of the user to ban from using $command. $command - string. Name of the command to ban $user from using.
Example:
$user->banCmd('photofroggy', 'about');
hasCmd
Check if a user has access to a specific command.
Parameters: $user - string. Name of the user to check access for. $command - string. Name of the command to check access for.
Example:
$user->hasCmd('photofroggy', 'about'); // If you have been following the docs, I would be banned from using !about by now.
Note: These functions do not work for sub-commands, as they are not managed by the events system.
overrides
Get override data for a specific user, if there is any.
Parameters: $user - string. Name of the user to get override data for.
Example:
$user->overrides('photofroggy');
class_name
Get an internal privilege class name from a privilege class order number.
Parameters: $order - integer. Order number for a privilege class.
Example:
$user->class_name(100); // This would return "Owner"
class_order
Get an internal privilege class order number from a privilege class name.
Parameters: $name - string. Name for a privilege class.
Example:
$user->class_order('Owner'); // This should return 100
add_class
Add a privilege class to the internal user access levels.
Parameters: $name - string. Name for the new privilege class. $order - integer. Order number for the new privilege class.
Example:
$user->add_class('NewClass', 30);
rename_class
Rename an internal privilege class.
Parameters: $pc - mixed. Name or order number of the privilege class. $new - string. New name for the privilege class.
Example:
$user->rename_class(30, 'RenamedIt');
rem_class
Remove an internal privilege class.
Parameters: $pc - mixed. Name or order number of the privilege class.
Example:
$user->rem_class(30);
When a privilege class is removed, the users who were in the privilege class will be made guests.

