Admin Class Reference

Bot access management. More...

#include <admin.h>

Inheritance diagram for Admin:

Plugin

List of all members.

Public Member Functions

 Admin (BotKernel *)
 Constructor.
bool addChannel (string)
 Add a channel managed by the bot.
bool delChannel (string)
 Remove a channel managed by the bot.
bool channelExists (string)
 Tell if a channel is registred.
vector< string > getChannelsList ()
 Return channel list.
bool addSuperAdmin (string)
 Add a super admin.
bool addTempSuperAdmin (string, unsigned int)
 Add a temporary super admin.
void clearTempAdmins ()
 Clear timed out temporary super admins.
bool delSuperAdmin (unsigned int)
 Del a super admin.
bool isSuperAdmin (string)
 Tell if a user is a super admin.
bool maskIsSuperAdmin (string)
 Tell if a mask is super admin.
vector< string > superAdminList ()
 Give the super admin hosts list.
bool addUser (string, string, unsigned int)
 Add a user to a channel.
bool delUser (string, string)
 Del a user from a channel.
bool userExists (string, string)
 Tell if a user exists for a channel.
bool updateUserLevel (string, string, unsigned int)
 Update a user level.
unsigned int getUserLevel (string, string)
 Get a user level for a channel.
unsigned int getMaskLevel (string, string)
 Get mask level for a channel.
vector< string > chanLevels (string)
 Give all the access for a channel.
void enableCommand (string, string)
 Enable a command on a channel.
void disableCommand (string, string)
 Disable a command on a channel.
void addOnlyonCommand (string, string)
 Allow a command on a specific channel (disable for others).
void delOnlyonCommand (string, string)
 Remove a Onlyon command.
bool commandOK (string, string)
 Tell if a command is can be executed on a channel.
vector< string > commandsStatus ()
 Give commands status (onlyon or disabled).

Private Member Functions

void initFile ()
 Initialize the XML file.

Private Attributes

TiXmlDocument * doc
 Represent the xml document.
TiXmlNode * root
 Represent documents's root.


Detailed Description

Bot access management.

This plugin stores (with an xml file) bot accounts (by host) and provides stuff for administration

Definition at line 50 of file admin.h.


Constructor & Destructor Documentation

Admin::Admin ( BotKernel b  ) 


Member Function Documentation

bool Admin::addChannel ( string  channel  ) 

Add a channel managed by the bot.

Add a channel managed by the bot

Parameters:
channel Channel name that you want to add
Returns:
true if the channel has been added, else false

Definition at line 111 of file admin.cpp.

References channelExists(), doc, root, and Tools::to_lower().

Referenced by addUser().

void Admin::addOnlyonCommand ( string  command,
string  channel 
)

Allow a command on a specific channel (disable for others).

Allow a command on a specific channel (disable for others)

Parameters:
command Onlyon command
channel Channel where to enable only the command
Returns:
true if operation OK, else false

Definition at line 625 of file admin.cpp.

References doc, root, and Tools::to_lower().

Referenced by addOnlyon().

bool Admin::addSuperAdmin ( string  mask  ) 

Add a super admin.

Add a super admin for the bot

Parameters:
mask Super admin's mask
Returns:
True if the admin has been added, else false

Definition at line 171 of file admin.cpp.

References doc, isSuperAdmin(), root, and Tools::to_lower().

Referenced by addsuperadmin().

bool Admin::addTempSuperAdmin ( string  mask,
unsigned int  duration 
)

Add a temporary super admin.

Add a temporary super admin for the bot

Parameters:
mask Super admin's mask
duration Super admin time (in seconds)
Returns:
True if the admin has been added, else false

Definition at line 192 of file admin.cpp.

References doc, isSuperAdmin(), root, and Tools::to_lower().

Referenced by addtempsuperadmin().

bool Admin::addUser ( string  channel,
string  mask,
unsigned int  level 
)

Add a user to a channel.

Add a user to a channel

Parameters:
channel Channel where to add the user
mask User's mask
level User's level
Returns:
True if the user has benn added, else false

Definition at line 333 of file admin.cpp.

References addChannel(), channelExists(), doc, root, Tools::to_lower(), and userExists().

Referenced by updateUserLevel().

vector< string > Admin::chanLevels ( string  channel  ) 

Give all the access for a channel.

Give all the access of a channel

Parameters:
channel Channel for the one you want the access list
Returns:
A vector containing access for the given channel

Definition at line 576 of file admin.cpp.

References root, and Tools::to_lower().

Referenced by chanlev().

bool Admin::channelExists ( string  channel  ) 

Tell if a channel is registred.

Tell if a channel is registred

Parameters:
channel Channel name that you want to test existance
Returns:
true if the channel exists, else false

Definition at line 153 of file admin.cpp.

References root, and Tools::to_lower().

Referenced by addChannel(), and addUser().

void Admin::clearTempAdmins (  ) 

Clear timed out temporary super admins.

Return Clear outdated temporary super admins

Definition at line 308 of file admin.cpp.

References doc, and Tools::strToInt().

bool Admin::commandOK ( string  command,
string  channel 
)

Tell if a command is can be executed on a channel.

Tell if a command can be executed on a channel Check if the command is disabled or is not a "only on" one.

Parameters:
command Command to check
channel Channel to check
Returns:
True if the command is ok, else false

Definition at line 695 of file admin.cpp.

References Tools::isInVector(), root, and Tools::to_lower().

Referenced by allowedCommandCheck().

vector< string > Admin::commandsStatus (  ) 

Give commands status (onlyon or disabled).

Give commands status (onlyon or disabled)

Returns:
A vector containing commands status

Definition at line 725 of file admin.cpp.

References root.

Referenced by commandsStatus().

bool Admin::delChannel ( string  channel  ) 

Remove a channel managed by the bot.

Remove a channel managed by the bot

Parameters:
channel Channel name that you want to delete
Returns:
true if the channel has been deleted, else false

Definition at line 130 of file admin.cpp.

References doc, root, and Tools::to_lower().

Referenced by delUser().

void Admin::delOnlyonCommand ( string  command,
string  channel 
)

Remove a Onlyon command.

Remove a Onlyon command

Parameters:
command Command on unonlyon
channel Channel where the command is no more onlyon

Definition at line 639 of file admin.cpp.

References doc, root, and Tools::to_lower().

Referenced by delOnlyon().

bool Admin::delSuperAdmin ( unsigned int  index  ) 

Del a super admin.

Del a super admin

Parameters:
index Super admin index
Returns:
True is the users has been deleted, else false

Definition at line 215 of file admin.cpp.

References doc.

Referenced by delsuperadmin().

bool Admin::delUser ( string  channel,
string  mask 
)

Del a user from a channel.

Del a user from a channel

Parameters:
channel Channel where to del the user
mask User's mask to delete
Returns:
True if the user has been added, else false

Definition at line 405 of file admin.cpp.

References delChannel(), doc, root, and Tools::to_lower().

Referenced by updateUserLevel().

void Admin::disableCommand ( string  command,
string  channel 
)

Disable a command on a channel.

Disable a command on a channel

Parameters:
command Command to disable
channel Channel where to disable the command

Definition at line 679 of file admin.cpp.

References doc, root, and Tools::to_lower().

Referenced by disable().

void Admin::enableCommand ( string  command,
string  channel 
)

Enable a command on a channel.

Enable a command on a channel

Parameters:
command Command to enable
channel Channel where to enable the command

Definition at line 659 of file admin.cpp.

References doc, root, and Tools::to_lower().

Referenced by enable().

vector< string > Admin::getChannelsList (  ) 

Return channel list.

Return channel list

Returns:
A vector containing

Definition at line 605 of file admin.cpp.

References root.

Referenced by whoami().

unsigned int Admin::getMaskLevel ( string  channel,
string  mask 
)

Get mask level for a channel.

Get mask level for a channel 0 for nothing 1 for voice 2 for op 3 for master 4 for owner

Parameters:
channel User's channel
mask User's mask
Returns:
User's level (0 if non existing)

Definition at line 536 of file admin.cpp.

References Tools::masksMatch(), root, Tools::strToInt(), and Tools::to_lower().

Referenced by modeHandler().

unsigned int Admin::getUserLevel ( string  channel,
string  mask 
)

Get a user level for a channel.

Get a user level for a channel 0 for nothing 1 for voice 2 for op 3 for master 4 for owner

Parameters:
channel User's channel
mask User's mask
Returns:
User's level (0 if non existing)

Definition at line 499 of file admin.cpp.

References Tools::ircMaskMatch(), root, Tools::strToInt(), and Tools::to_lower().

Referenced by chanlev(), Moderation::checkAccess(), Moderation::hasOpPrivileges(), invite(), joinHandler(), kickHandler(), modeHandler(), and whoami().

void Admin::initFile (  )  [private]

Initialize the XML file.

Initilaize the XML file by creating root and first childs (file empty structure)

Definition at line 90 of file admin.cpp.

References doc, and root.

Referenced by Admin().

bool Admin::isSuperAdmin ( string  mask  ) 

bool Admin::maskIsSuperAdmin ( string  mask  ) 

Tell if a mask is super admin.

Tell is a mask is a super admin

Parameters:
mask Mask to test
Returns:
true is it's a superadmin else false

Definition at line 253 of file admin.cpp.

References Tools::masksMatch(), root, and Tools::to_lower().

Referenced by modeHandler().

vector< string > Admin::superAdminList (  ) 

Give the super admin hosts list.

Return the list of the super admins

Returns:
a vector of string containing super admins' hosts

Definition at line 280 of file admin.cpp.

References doc, Tools::intToStr(), and Tools::strToInt().

Referenced by superadminlist().

bool Admin::updateUserLevel ( string  channel,
string  mask,
unsigned int  level 
)

Update a user level.

Update a User's level

Parameters:
channel user's channel
mask user's mask
level New user's level

Definition at line 444 of file admin.cpp.

References addUser(), delUser(), doc, root, Tools::to_lower(), and userExists().

Referenced by chanlev().

bool Admin::userExists ( string  channel,
string  mask 
)

Tell if a user exists for a channel.

Tell if a user exists for a channel The user is recognized by a host

Parameters:
channel Channel where we want to make the test
mask User's mask
Returns:
True if the user exists for the given channel, else false

Definition at line 373 of file admin.cpp.

References root, and Tools::to_lower().

Referenced by addUser(), and updateUserLevel().


Member Data Documentation

TiXmlDocument* Admin::doc [private]

TiXmlNode* Admin::root [private]


The documentation for this class was generated from the following files:

Generated on Sun Aug 16 15:28:33 2009 for trustyRC by  doxygen 1.5.8