#include <tools.h>
Public Member Functions | |
Tools () | |
Constructor. | |
~Tools () | |
Destructor. | |
Static Public Member Functions | |
static string | asciiToHexa (string) |
Convert an ascii string to an hexadecimal string. | |
static string | hexaToAscii (string) |
Convert an hexadecimal string to an ascii string. | |
static string | intToStr (int) |
Convert a int to a string. | |
static string | doubleToStr (double) |
Convert a double to a string. | |
static double | strToDouble (string) |
Convert a string to a double. | |
static int | strToInt (string) |
Convert a string to a int. | |
static unsigned int | strToUnsignedInt (string) |
Convert a string to an unsigned int. | |
static unsigned int | strtimeToSeconds (string) |
Convert a string time to seconds. | |
static string | to_lower (string) |
Convert a string to lower case. | |
static string | to_upper (string) |
Convert a string to upper case. | |
static int | random (int min, int max) |
Give a random number. | |
static string | vectorToString (vector< string >, string, unsigned int start=0) |
Convert a vector to a string. | |
static vector< string > | stringToVector (string, string, unsigned int start=0) |
Convert a string to a vector. | |
static vector< string > | gatherVectorElements (vector< string >, string, unsigned int) |
Gather vector elements. | |
static string | escapeChar (string, char) |
Escape a char in a string. | |
static void | log (string, string, bool timestamp=true, bool truncate=false) |
Log a string in a file. | |
static string | urlencode (string) |
Encode a string to a URL format. | |
static string | clearAccents (string) |
Clear accents from a sentence. | |
static string | cleanHTML (string) |
Clean HTML code in a string. | |
static bool | isInVector (vector< string >, string) |
Tell if a string is in a vector. | |
static void | delStrFromVector (vector< string > *, string) |
Withdraw a string from a vector. | |
static string | parseQ3Colors (string) |
Parse Quake colors from a string. | |
static bool | ircMaskMatch (string, string) |
Tell if an irc host match to a mask. | |
static int | masksMatch (char *, char *) |
Tell if two masks match. | |
static bool | copyFile (string, string) |
Copy a file. |
Provide different static methods for regular treatment. Those methods can be used everywhere in the code an doesn't need an object instantiation.
Definition at line 47 of file tools.h.
string Tools::asciiToHexa | ( | string | asciiStr | ) | [static] |
string Tools::cleanHTML | ( | string | str | ) | [static] |
Clean HTML code in a string.
Clean all HTML chars in a string : Replace accents marks and delete font marks
str | String with no html tags |
Definition at line 455 of file tools.cpp.
Referenced by danstonchat(), BZRH::getBugInfos(), BZRH::searchBugs(), tele(), and trad().
string Tools::clearAccents | ( | string | str | ) | [static] |
Clear accents from a sentence.
Clear accents from a sentence
str | String to clear |
Definition at line 433 of file tools.cpp.
Referenced by danstonchat(), and tele().
static bool Tools::copyFile | ( | string | , | |
string | ||||
) | [static] |
Copy a file.
void Tools::delStrFromVector | ( | vector< string > * | v, | |
string | str | |||
) | [static] |
Withdraw a string from a vector.
Delete a string from a vector
v | Vector<string> pointer witch must be delete a string | |
str | string to delete |
Definition at line 102 of file tools.cpp.
Referenced by unautoop(), unautovoice(), unprotectmodes(), and unprotecttopic().
string Tools::doubleToStr | ( | double | number | ) | [static] |
Convert a double to a string.
Convert a double to a string
number | double number to convert |
Definition at line 134 of file tools.cpp.
Referenced by Lamoule::get5first(), Lamoule::getInfosPlayer(), and player().
string Tools::escapeChar | ( | string | str, | |
char | c | |||
) | [static] |
vector< string > Tools::gatherVectorElements | ( | vector< string > | v, | |
string | separator, | |||
unsigned int | length | |||
) | [static] |
Gather vector elements.
Gather vector's elements to make a vector with less elements
v | vector for witch gather elements | |
separator | separator for elements | |
length | vector's element length |
Definition at line 336 of file tools.cpp.
Referenced by banlist(), chanlev(), commandsStatus(), listlibs(), listmodules(), onEndOfMOTD(), and superadminlist().
string Tools::hexaToAscii | ( | string | hexaStr | ) | [static] |
string Tools::intToStr | ( | int | number | ) | [static] |
Convert a int to a string.
Convert a int to a string
number | int number to convert |
Definition at line 122 of file tools.cpp.
Referenced by addad(), Advertising::addAdvertise(), BotKernel::addCountDown(), Lamoule::addPlayer(), Survey::finishSurvey(), Lamoule::get5first(), Moderation::getBanList(), Ignore::getIgnoreList(), Lamoule::getInfosPlayer(), getnbcountdowns(), Quotes::getQuote(), hl(), Lamoule::increaseScore(), lamoule(), launchSurvey(), BotKernel::loadPlugins(), online(), q3(), BotKernel::run(), BZRH::searchBugs(), Quotes::searchQuote(), slapme(), Admin::superAdminList(), RemoteControl::tcpServer(), uptime(), warsow(), and whoami().
bool Tools::ircMaskMatch | ( | string | request, | |
string | mask | |||
) | [static] |
Tell if an irc host match to a mask.
Check if an IRC host match to a mask
request | Irc host | |
mask | mask |
Definition at line 521 of file tools.cpp.
Referenced by banmask(), Admin::getUserLevel(), Moderation::isBanned(), Ignore::isIgnored(), and Admin::isSuperAdmin().
bool Tools::isInVector | ( | vector< string > | v, | |
string | str | |||
) | [static] |
Tell if a string is in a vector.
Check if a string is in a vector string
v | vector to check | |
str | string to check |
Definition at line 83 of file tools.cpp.
Referenced by autoop(), autovoice(), LogFactory::cleanLogs(), Moderation::clearOutBans(), Admin::commandOK(), ConfigurationFile::getValue(), LogFactory::hasToBeLogged(), joinHandler(), launchSurvey(), modeHandlerProtect(), protectmodes(), protecttopic(), Plugin::requires(), topicHandler(), unautoop(), unautovoice(), unprotectmodes(), unprotecttopic(), and Survey::vote().
void Tools::log | ( | string | fileName, | |
string | str, | |||
bool | timestamp = true , |
|||
bool | truncate = false | |||
) | [static] |
Log a string in a file.
Log an event in a file, with timestamp
fileName | Log file | |
str | Log event | |
timestamp | tell if a timestamp must appear in the log line | |
truncate | tell if the file must be truncated |
Definition at line 383 of file tools.cpp.
Referenced by BotKernel::run().
int Tools::masksMatch | ( | char * | str1, | |
char * | str2 | |||
) | [static] |
Tell if two masks match.
Check if two masks match Thanks to "BigBourin" (fr) for this function
str1 | first mask | |
str2 | second mask |
Definition at line 536 of file tools.cpp.
Referenced by Admin::getMaskLevel(), and Admin::maskIsSuperAdmin().
string Tools::parseQ3Colors | ( | string | raw | ) | [static] |
Parse Quake colors from a string.
Strip all Quake III Arena color codes from a string
raw | String with q3 color codes |
Definition at line 489 of file tools.cpp.
Referenced by GameServer::parseQ3infos(), GameServer::parseWSWinfos(), q3(), and warsow().
int Tools::random | ( | int | min, | |
int | max | |||
) | [static] |
Give a random number.
Generate a random int between a min and a max value
min | Minimum random value | |
max | Maximum random value |
Definition at line 268 of file tools.cpp.
Referenced by Lamoule::generateScore(), Magic8Ball::getRandomAnswer(), Quotes::getRandomQuote(), lamoule(), randomKick(), and Quotes::searchQuote().
vector< string > Tools::stringToVector | ( | string | str, | |
string | separator, | |||
unsigned int | start = 0 | |||
) | [static] |
Convert a string to a vector.
Split a string in elements inserted in a vector
str | String to split | |
separator | Delimitor for string | |
start | Index of the first element to split |
Definition at line 304 of file tools.cpp.
Referenced by autoop(), autovoice(), danstonchat(), LogFactory::getLoggedChannels(), Fedorafr::getWikiLinks(), LogFactory::hasToBeLogged(), hl(), joinHandler(), launchSurvey(), ConfigurationFile::load(), FedoraProject::loadFasFile(), BotKernel::loadPlugins(), modeHandlerProtect(), onEndOfMOTD(), GameServer::parseQ3infos(), GameServer::parseWSWinfos(), protectmodes(), protecttopic(), q3(), BotKernel::run(), Message::setMessage(), topicHandler(), unautoop(), unautovoice(), unprotectmodes(), unprotecttopic(), and warsow().
unsigned int Tools::strtimeToSeconds | ( | string | strtime | ) | [static] |
Convert a string time to seconds.
Convert a 'string time' to seconds. Exemple : 2d6h2m1s = 194521 seconds d for 'days' h for 'hours' m for 'minuts' s for 'seconds'
strtime | String time to convert |
Definition at line 211 of file tools.cpp.
References strToUnsignedInt().
Referenced by addad(), addIgnore(), addtempsuperadmin(), ban(), banmask(), launchSurvey(), and slapme().
double Tools::strToDouble | ( | string | str | ) | [static] |
Convert a string to a double.
Convert a string to a double if operation fails, result is 0.0
str | string to convert |
Definition at line 147 of file tools.cpp.
Referenced by Lamoule::get5first(), Lamoule::getInfosPlayer(), Lamoule::increaseScore(), player(), and Lamoule::sort().
int Tools::strToInt | ( | string | str | ) | [static] |
Convert a string to a int.
Convert a string to a int if operation fails, result is 0
str | string to convert |
Definition at line 167 of file tools.cpp.
Referenced by adinfos(), Advertising::Advertising(), bandel(), baninfos(), Moderation::banInfos(), chanlev(), Moderation::clearOutBans(), Admin::clearTempAdmins(), BotKernel::connect(), Advertising::deleteOutdatedAds(), delIgnore(), delQuote(), delsuperadmin(), Advertising::getAdvertisesList(), Ignore::getIgnoreList(), Admin::getMaskLevel(), Admin::getUserLevel(), increase(), Lamoule::increaseScore(), lamoule(), nextscore(), onEndOfMOTD(), planet(), player(), purifyFile(), Lamoule::purifyFile(), Ignore::purifyList(), quote(), quoteInfos(), BotKernel::run(), GameServer::sendQuery(), Lamoule::sort(), Admin::superAdminList(), testMsgTimestamp(), top5(), toptotal(), and wiki().
unsigned int Tools::strToUnsignedInt | ( | string | str | ) | [static] |
Convert a string to an unsigned int.
Convert a string to an unsigned int if operation fails, result is 0
str | string to convert |
Definition at line 187 of file tools.cpp.
Referenced by BotKernel::addCountDown(), bannedHandler(), danstonchat(), getMyFirstNick(), launchSurvey(), rejoinChan(), RemoteControl::RemoteControl(), BZRH::searchBugs(), secondaryNick(), strtimeToSeconds(), and topicInfos().
string Tools::to_lower | ( | string | str | ) | [static] |
Convert a string to lower case.
Put an entire string to lower case
str | string to convert |
Definition at line 237 of file tools.cpp.
Referenced by Admin::addChannel(), Ignore::addIgnore(), Admin::addOnlyonCommand(), Admin::addSuperAdmin(), Admin::addTempSuperAdmin(), Admin::addUser(), Admin::chanLevels(), Admin::channelExists(), Admin::commandOK(), Admin::delChannel(), Lamoule::deletePlayer(), Admin::delOnlyonCommand(), Admin::delUser(), Admin::disableCommand(), Admin::enableCommand(), Lamoule::getInfosPlayer(), Admin::getMaskLevel(), Admin::getUserLevel(), Lamoule::increaseScore(), Ignore::isIgnored(), Admin::isSuperAdmin(), Admin::maskIsSuperAdmin(), BotKernel::msgTreatment(), Quotes::searchQuote(), Admin::updateUserLevel(), and Admin::userExists().
string Tools::to_upper | ( | string | str | ) | [static] |
string Tools::urlencode | ( | string | str | ) | [static] |
Encode a string to a URL format.
Convert special chars from a string to be compatible to URL format
str | String to encode |
Definition at line 411 of file tools.cpp.
Referenced by BZRH::getBugInfos(), planet(), BZRH::searchBugs(), trad(), FedoraProject::whoowns(), and wiki().
string Tools::vectorToString | ( | vector< string > | vec, | |
string | separator, | |||
unsigned int | start = 0 | |||
) | [static] |
Convert a vector to a string.
Convert a vector<string> to a string
vec | Vector to convert | |
separator | Elements separator in generated string | |
start | Indice for starting conversion |
Definition at line 280 of file tools.cpp.
Referenced by addad(), addQuote(), ban(), banmask(), bzsearch(), fas(), greplog(), hl(), kick(), kickHandler(), launchSurvey(), leaveChannel(), notice(), partHandler(), planet(), privmsgHandler(), q3(), quitHandler(), raw(), searchQuote(), sendHandler(), slapUser(), tell(), topic(), topicHandler(), topicJoin(), trad(), unautoop(), unautovoice(), unprotectmodes(), unprotecttopic(), warsow(), and wiki().