Moderation Class Reference

Channel moderation. More...

#include <moderation.h>

Inheritance diagram for Moderation:

Plugin

List of all members.

Public Member Functions

 Moderation (BotKernel *)
 Constructor.
bool addBan (string, string, unsigned int, string, string)
 add a ban on a channel
string delBan (string, unsigned int)
 del a ban on a channel
bool isBanned (string, string)
 tell if a user is banned
vector< string > getBanList (string)
 give ban list on a channel
vector< string > banInfos (string, unsigned int)
 give details about a ban
vector< string > clearList (string)
 clear all bans for a channel and return them (to apply it on the chan)
vector< string > clearOutBans (vector< string >)
 CLear all outdated bans for all channels and return them (to apply it on chans).
bool checkAccess (string, string, unsigned int, BotKernel *)
 Check access on a chan for a user.
bool hasOpPrivileges (string, string, string, BotKernel *)
 Check if a user is opped, has level >= 2 or is super admin.
vector< string * > getChanUsersList (string, BotKernel *)
 Get a channel users list.
bool checkMode (string, string, char, BotKernel *)
 Check if a user has the given mode on a given channel using UsersInfos module.
unsigned int getRejoinAttempts (string)
 Get rejoin attempts number for a channel.
void bumpRejoinAttempts (string)
 Bump rejoin attempts for a channel.
void clearRejoinAttempts (string)
 Clear attempts for a channel.

Private Member Functions

void initFile ()
 Initialize the XML file.

Private Attributes

TiXmlDocument * doc
 Represent the xml document.
TiXmlNode * root
 Represent documents's root.
map< string, int > rejoinAttempts
 Stores rejoin attempts.


Detailed Description

Channel moderation.

This plugin allow channels moderation (op, voice, kick,bans etc ...) with acces (if admin plugin is loaded)

Definition at line 53 of file moderation.h.


Constructor & Destructor Documentation

Moderation::Moderation ( BotKernel b  ) 


Member Function Documentation

bool Moderation::addBan ( string  channel,
string  mask,
unsigned int  duration,
string  by,
string  reason 
)

add a ban on a channel

Add a ban for a host on a given channel Stores the ban in a XML file

Parameters:
channel Channel on witch the user is banned
mask User's mask : nick!ident@host
duration ban time (seconds)
by banner mask
reason Reason for the ban
Returns:
true if the user has been banned, else false

Definition at line 115 of file moderation.cpp.

References doc, and isBanned().

Referenced by ban(), and banmask().

vector< string > Moderation::banInfos ( string  channel,
unsigned int  index 
)

give details about a ban

Return informations about a ban

Parameters:
channel Ban channel
index Ban index
Returns:
A vector containing informations

Definition at line 222 of file moderation.cpp.

References doc, and Tools::strToInt().

Referenced by baninfos().

void Moderation::bumpRejoinAttempts ( string  channel  ) 

Bump rejoin attempts for a channel.

Bump rejoin attempts for a channel

Parameters:
channel Channel for which we want to bump attempts number

Definition at line 447 of file moderation.cpp.

References rejoinAttempts.

Referenced by rejoinChan().

bool Moderation::checkAccess ( string  channel,
string  mask,
unsigned int  level,
BotKernel b 
)

Check access on a chan for a user.

.Check if a user has the given access on the given channel. The mode is the access one, in the xml file, not the one on the channel

Parameters:
channel Channel where to check access
mask Mask to check
level Level to check
b Pointer to the bot kerne
Returns:
True if the user has the given access, else false

Definition at line 325 of file moderation.cpp.

References BotKernel::getPlugin(), Admin::getUserLevel(), and pPlugin::object.

Referenced by modeHandlerProtect(), protectmodes(), protecttopic(), topicHandler(), unprotectmodes(), and unprotecttopic().

bool Moderation::checkMode ( string  channel,
string  nick,
char  mode,
BotKernel b 
)

Check if a user has the given mode on a given channel using UsersInfos module.

Check if a user has the given mode on a given channel using UsersInfos module

Parameters:
mode Mode to test for the user
channel Channel to check
nick Nick to check
b Pointer to the bot kernel
Precondition:
"UsersInfos must be loaded
Returns:
True if the user has the mode, else false

Definition at line 381 of file moderation.cpp.

References BotKernel::getPlugin(), UsersInfos::hasMode(), and pPlugin::object.

Referenced by clearOutBans(), kickHandler(), opall(), partHandler(), quitHandler(), unopall(), unvoiceall(), and voiceall().

vector< string > Moderation::clearList ( string  channel  ) 

clear all bans for a channel and return them (to apply it on the chan)

Clear all bans for a given channel even if they are not out dated Return them to be deleted on the channel

Parameters:
channel Channel where delete bans
Returns:
A vector containing the deleted bans

Definition at line 255 of file moderation.cpp.

References doc.

Referenced by unbanall().

vector< string > Moderation::clearOutBans ( vector< string >  myChans  ) 

CLear all outdated bans for all channels and return them (to apply it on chans).

Clear all outdated bans Return them to be deleted on the channel

Parameters:
myChans Chans where the bot is (whithout '#' first char), to be sure to not delete bans where the bot is not present
Returns:
A vector containing the deleted bans

Definition at line 280 of file moderation.cpp.

References doc, Tools::isInVector(), Tools::strToInt(), and IRCProtocol::unban().

Referenced by clearOutBans().

void Moderation::clearRejoinAttempts ( string  channel  ) 

Clear attempts for a channel.

Clear attempts for a channel

Parameters:
channel Channel for which we want to clear rejoin attempts

Definition at line 462 of file moderation.cpp.

References rejoinAttempts.

Referenced by joinHandler().

string Moderation::delBan ( string  channel,
unsigned int  index 
)

del a ban on a channel

Delete a ban and return the mask (to delete it on the chan)

Parameters:
channel Channel where delete the ban
index Ban index
Returns:
ban's mask deleted, or empty string if ban not found

Definition at line 174 of file moderation.cpp.

References doc.

Referenced by bandel().

vector< string > Moderation::getBanList ( string  channel  ) 

give ban list on a channel

Return ban list for a given channel

Parameters:
channel Channel to list
Returns:
A vector containing ban list

Definition at line 198 of file moderation.cpp.

References doc, and Tools::intToStr().

Referenced by banlist().

vector< string * > Moderation::getChanUsersList ( string  channel,
BotKernel b 
)

Get a channel users list.

Get a channel users list using "usersinfos" plugin Users a stored in a string tab like that : tab[0]=nick; tab[1]=host; tab[2]=ident; tab[3]=status;

Parameters:
channel Channel to get the list
b Pointer to the bot kernel
Precondition:
UsersInfos module must be loaded
Returns:
A vector containing the users list

Definition at line 409 of file moderation.cpp.

References BotKernel::getPlugin(), UsersInfos::getUsers(), and pPlugin::object.

Referenced by banmask(), kickall(), opall(), randomKick(), unopall(), unvoiceall(), and voiceall().

unsigned int Moderation::getRejoinAttempts ( string  channel  ) 

Get rejoin attempts number for a channel.

Get rejoin attempts number for a channel

Parameters:
channel Channel for which we want to get rejoin attempts number
Returns:
Rejoin attempts number

Definition at line 432 of file moderation.cpp.

References rejoinAttempts.

Referenced by rejoinChan().

bool Moderation::hasOpPrivileges ( string  channel,
string  mask,
string  nick,
BotKernel b 
)

Check if a user is opped, has level >= 2 or is super admin.

Check if a user is opped, has level >= 2 or is super admin using "admin" and "usersinfos" modules

Parameters:
channel Channel where to check access
mask Mask to check access on the given channel
nick Nick to check access on the given channel
b Pointer to the bot kernel
Returns:
True if the user, has op privileges, else false
Precondition:
Admin and UsersInfos module must be loaded

Definition at line 348 of file moderation.cpp.

References BotKernel::getPlugin(), Admin::getUserLevel(), UsersInfos::hasMode(), Admin::isSuperAdmin(), and pPlugin::object.

Referenced by autoop(), autovoice(), ban(), bandel(), baninfos(), banlist(), banmask(), kick(), kickall(), masskick(), op(), opall(), randomKick(), topic(), unautoop(), unautovoice(), unbanall(), unop(), unopall(), unvoice(), unvoiceall(), voice(), and voiceall().

void Moderation::initFile (  )  [private]

Initialize the XML file.

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

Definition at line 95 of file moderation.cpp.

References doc, and root.

Referenced by Moderation().

bool Moderation::isBanned ( string  channel,
string  mask 
)

tell if a user is banned

Tell if a user is banned on a ginven channel

Parameters:
channel Channel to test
mask User's mask
Returns:
True is the user is banned, else false

Definition at line 152 of file moderation.cpp.

References doc, and Tools::ircMaskMatch().

Referenced by addBan(), and joinHandler().


Member Data Documentation

TiXmlDocument* Moderation::doc [private]

Represent the xml document.

Definition at line 57 of file moderation.h.

Referenced by addBan(), banInfos(), clearList(), clearOutBans(), delBan(), getBanList(), initFile(), isBanned(), and Moderation().

map<string,int> Moderation::rejoinAttempts [private]

Stores rejoin attempts.

Definition at line 63 of file moderation.h.

Referenced by bumpRejoinAttempts(), clearRejoinAttempts(), and getRejoinAttempts().

TiXmlNode* Moderation::root [private]

Represent documents's root.

Definition at line 59 of file moderation.h.

Referenced by initFile(), and Moderation().


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

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