#include <moderation.h>
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. |
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.
Moderation::Moderation | ( | BotKernel * | b | ) |
Constructor.
Constructor
Definition at line 34 of file moderation.cpp.
References Plugin::addRequirement(), Plugin::author, Plugin::bindFunction(), Plugin::description, doc, BotKernel::getDatasDir(), IN_COMMAND_HANDLER, IN_LOOP, IN_TYPE_HANDLER, initFile(), Plugin::name, root, and Plugin::version.
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
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 |
Definition at line 115 of file moderation.cpp.
References doc, and isBanned().
vector< string > Moderation::banInfos | ( | string | channel, | |
unsigned int | index | |||
) |
give details about a ban
Return informations about a ban
channel | Ban channel | |
index | Ban index |
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
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
channel | Channel where to check access | |
mask | Mask to check | |
level | Level to check | |
b | Pointer to the bot kerne |
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
mode | Mode to test for the user | |
channel | Channel to check | |
nick | Nick to check | |
b | Pointer to the bot kernel |
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
channel | Channel where delete 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
myChans | Chans where the bot is (whithout '#' first char), to be sure to not delete bans where the bot is not present |
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
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)
channel | Channel where delete the ban | |
index | Ban index |
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
channel | Channel to 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;
channel | Channel to get the list | |
b | Pointer to the bot kernel |
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
channel | Channel for which we want to get 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
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 |
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.
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
channel | Channel to test | |
mask | User's mask |
Definition at line 152 of file moderation.cpp.
References doc, and Tools::ircMaskMatch().
Referenced by addBan(), and joinHandler().
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().