InspIRCd
2.0
|
#include <mode.h>
Public Member Functions | |
ModeParser () | |
User * | SanityChecks (User *user, const char *dest, Channel *chan, int status) |
const std::string & | GetLastParse () |
const std::vector< std::string > & | GetLastParseParams () |
const std::vector< TranslateType > & | GetLastParseTranslate () |
bool | AddMode (ModeHandler *mh) |
bool | DelMode (ModeHandler *mh) |
bool | AddModeWatcher (ModeWatcher *mw) |
bool | DelModeWatcher (ModeWatcher *mw) |
void | Process (const std::vector< std::string > ¶meters, User *user, bool merge=false) |
ModeHandler * | FindMode (unsigned const char modeletter, ModeType mt) |
ModeHandler * | FindPrefix (unsigned const char pfxletter) |
std::string | UserModeList () |
std::string | ChannelModeList () |
std::string | ParaModeList () |
std::string | GiveModeList (ModeMasks m) |
std::string | BuildPrefixes (bool lettersAndModes=true) |
Static Public Member Functions | |
static void | CleanMask (std::string &mask) |
static bool | PrefixComparison (ModeHandler *one, ModeHandler *two) |
The mode parser handles routing of modes and handling of mode strings. It marshalls, controls and maintains both ModeWatcher and ModeHandler classes, parses client to server MODE strings for user and channel modes, and performs processing for the 004 mode list numeric, amongst other things.
ModeParser::ModeParser | ( | ) |
The constructor initializes all the RFC basic modes by using ModeParserAddMode().
bool ModeParser::AddMode | ( | ModeHandler * | mh | ) |
Add a mode to the mode parser.
bool ModeParser::AddModeWatcher | ( | ModeWatcher * | mw | ) |
Add a mode watcher. A mode watcher is triggered before and after a mode handler is triggered. See the documentation of class ModeWatcher for more information.
mw | The ModeWatcher you want to add |
std::string ModeParser::BuildPrefixes | ( | bool | lettersAndModes = true | ) |
This returns the PREFIX=(ohv)%+ section of the 005 numeric, or just the "@%+" part if the parameter false
std::string ModeParser::ChannelModeList | ( | ) |
Returns a list of channel mode characters which are listmodes. This is used in the 004 numeric when users connect.
|
static |
Tidy a banmask. This makes a banmask 'acceptable' if fields are left out. E.g.
nick -> nick!*@*
nick!ident -> [email protected]*
host.name -> !@host.name
ident -> * @hos t.nam e[email protected]
This method can be used on both IPV4 and IPV6 user masks.
bool ModeParser::DelMode | ( | ModeHandler * | mh | ) |
Delete a mode from the mode parser. When a mode is deleted, the mode handler will be called for every user (if it is a user mode) or for every channel (if it is a channel mode) to unset the mode on all objects. This prevents modes staying in the system which no longer exist.
mh | The mode handler to remove |
bool ModeParser::DelModeWatcher | ( | ModeWatcher * | mw | ) |
Delete a mode watcher. A mode watcher is triggered before and after a mode handler is triggered. See the documentation of class ModeWatcher for more information.
mw | The ModeWatcher you want to delete |
ModeHandler * ModeParser::FindMode | ( | unsigned const char | modeletter, |
ModeType | mt | ||
) |
Find the mode handler for a given mode and type.
modeletter | mode letter to search for |
mt | type of mode to search for, user or channel |
ModeHandler * ModeParser::FindPrefix | ( | unsigned const char | pfxletter | ) |
Find a mode handler by its prefix. If there is no mode handler with the given prefix, NULL will be returned.
pfxletter | The prefix to find, e.g. '@' |
const std::string & ModeParser::GetLastParse | ( | ) |
Get the last string to be processed, as it was sent to the user or channel. Use this to display a string you just sent to be parsed, as the actual output may be different to what you sent after it has been 'cleaned up' by the parser.
std::string ModeParser::GiveModeList | ( | ModeMasks | m | ) |
Generates a list of modes, comma seperated by type: 1; Listmodes EXCEPT those with a prefix 2; Modes that take a param when adding or removing 3; Modes that only take a param when adding 4; Modes that dont take a param
std::string ModeParser::ParaModeList | ( | ) |
Returns a list of channel mode characters which take parameters. This is used in the 004 numeric when users connect.
void ModeParser::Process | ( | const std::vector< std::string > & | parameters, |
User * | user, | ||
bool | merge = false |
||
) |
Process a set of mode changes from a server or user.
parameters | The parameters of the mode change, in the format they would be from a MODE command. |
user | The user setting or removing the modes. When the modes are set by a server, an 'uninitialized' User is used, where *user::nick == NULL and *user->server == NULL. |
merge | Should the mode parameters be merged? |
Used to check if user 'd' should be allowed to do operation 'MASK' on channel 'chan'. for example, should 'user A' be able to 'op' on 'channel B'.
std::string ModeParser::UserModeList | ( | ) |
Returns a list of mode characters which are usermodes. This is used in the 004 numeric when users connect.