The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

ModuleAlias Class Reference

Inheritance diagram for ModuleAlias:

Inheritance graph
[legend]
Collaboration diagram for ModuleAlias:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ModuleAlias (InspIRCd *Me)
virtual ~ModuleAlias ()
virtual Version GetVersion ()
 Returns the version number of a Module.
std::string GetVar (std::string varname, const std::string &original_line)
void SearchAndReplace (std::string &newline, const std::string &find, const std::string &replace)
virtual int OnPreCommand (std::string &command, std::vector< std::string > &parameters, User *user, bool validated, const std::string &original_line)
 Called whenever any command is about to be executed.
virtual int OnUserPreMessage (User *user, void *dest, int target_type, std::string &text, char status, CUList &exempt_list)
 Called whenever a user is about to PRIVMSG A user or a channel, before any processing is done.
int DoAlias (User *user, Channel *c, Alias *a, const std::string compare, const std::string safe)
void DoCommand (std::string newline, User *user, Channel *c, const std::string &original_line)
virtual void OnRehash (User *user, const std::string &parameter)
 Called on rehash.

Private Member Functions

virtual void ReadAliases ()

Private Attributes

std::multimap< std::string,
Alias
Aliases

Detailed Description

Definition at line 51 of file m_alias.cpp.


Constructor & Destructor Documentation

ModuleAlias::ModuleAlias InspIRCd Me  )  [inline]
 

Definition at line 85 of file m_alias.cpp.

References ModuleManager::Attach(), I_OnPreCommand, I_OnRehash, I_OnUserPreMessage, InspIRCd::Modules, and ReadAliases().

virtual ModuleAlias::~ModuleAlias  )  [inline, virtual]
 

Definition at line 95 of file m_alias.cpp.


Member Function Documentation

int ModuleAlias::DoAlias User user,
Channel c,
Alias a,
const std::string  compare,
const std::string  safe
[inline]
 

Definition at line 260 of file m_alias.cpp.

References Alias::AliasedCommand, case_sensitive_map, Alias::CaseSensitive, DoCommand(), InspIRCd::FindNick(), Alias::format, irc::sepstream::GetToken(), IS_OPER, InspIRCd::Match(), User::nick, Alias::OperOnly, Alias::ReplaceFormat, Alias::RequiredNick, User::server, Module::ServerInstance, InspIRCd::SNO, InspIRCd::ULine(), Alias::ULineOnly, User::WriteNumeric(), and SnomaskManager::WriteToSnoMask().

Referenced by OnPreCommand(), and OnUserPreMessage().

void ModuleAlias::DoCommand std::string  newline,
User user,
Channel c,
const std::string original_line
[inline]
 

Definition at line 322 of file m_alias.cpp.

References CommandParser::CallHandler(), ConvToStr(), User::dhost, irc::tokenstream::GetToken(), GetVar(), User::host, User::ident, MAXPARAMETERS, Channel::name, User::nick, InspIRCd::Parser, SearchAndReplace(), and Module::ServerInstance.

Referenced by DoAlias().

std::string ModuleAlias::GetVar std::string  varname,
const std::string original_line
[inline]
 

Definition at line 104 of file m_alias.cpp.

References irc::sepstream::GetToken().

Referenced by DoCommand().

virtual Version ModuleAlias::GetVersion  )  [inline, virtual]
 

Returns the version number of a Module.

The method should return a Version object with its version information assigned via Version::Version

Reimplemented from Module.

Definition at line 99 of file m_alias.cpp.

References API_VERSION, and VF_VENDOR.

virtual int ModuleAlias::OnPreCommand std::string command,
std::vector< std::string > &  parameters,
User user,
bool  validated,
const std::string original_line
[inline, virtual]
 

Called whenever any command is about to be executed.

This event occurs for all registered commands, wether they are registered in the core, or another module, and for invalid commands. Invalid commands may only be sent to this function when the value of validated is false. By returning 1 from this method you may prevent the command being executed. If you do this, no output is created by the core, and it is down to your module to produce any output neccessary. Note that unless you return 1, you should not destroy any structures (e.g. by using InspIRCd::QuitUser) otherwise when the command's handler function executes after your method returns, it will be passed an invalid pointer to the user object and crash!)

Parameters:
command The command being executed
parameters An array of array of characters containing the parameters for the command
pcnt The nuimber of parameters passed to the command
user the user issuing the command
validated True if the command has passed all checks, e.g. it is recognised, has enough parameters, the user has permission to execute it, etc. You should only change the parameter list and command string if validated == false (e.g. before the command lookup occurs).
original_line The entire original line as passed to the parser from the user
Returns:
1 to block the command, 0 to allow

Reimplemented from Module.

Definition at line 140 of file m_alias.cpp.

References Aliases, DoAlias(), REG_ALL, User::registered, and SearchAndReplace().

virtual void ModuleAlias::OnRehash User user,
const std::string parameter
[inline, virtual]
 

Called on rehash.

This method is called prior to a /REHASH or when a SIGHUP is received from the operating system. You should use it to reload any files so that your module keeps in step with the rest of the application. If a parameter is given, the core has done nothing. The module receiving the event can decide if this parameter has any relevence to it.

Parameters:
user The user performing the rehash, if any -- if this is server initiated, the value of this variable will be NULL.
parameter The (optional) parameter given to REHASH from the user.

Reimplemented from Module.

Definition at line 379 of file m_alias.cpp.

References ReadAliases().

virtual int ModuleAlias::OnUserPreMessage User user,
void *  dest,
int  target_type,
std::string text,
char  status,
CUList exempt_list
[inline, virtual]
 

Called whenever a user is about to PRIVMSG A user or a channel, before any processing is done.

Returning any nonzero value from this function stops the process immediately, causing no output to be sent to the user by the core. If you do this you must produce your own numerics, notices etc. This is useful for modules which may want to filter or redirect messages. target_type can be one of TYPE_USER or TYPE_CHANNEL. If the target_type value is a user, you must cast dest to a User* otherwise you must cast it to a Channel*, this is the details of where the message is destined to be sent.

Parameters:
user The user sending the message
dest The target of the message (Channel* or User*)
target_type The type of target (TYPE_USER or TYPE_CHANNEL)
text Changeable text being sent by the user
status The status being used, e.g. PRIVMSG #chan has status== '@', 0 to send to everyone.
exempt_list A list of users not to send to. For channel messages, this will usually contain just the sender. It will be ignored for private messages.
Returns:
1 to deny the NOTICE, 0 to allow it

Reimplemented from Module.

Definition at line 184 of file m_alias.cpp.

References Aliases, DEBUG, DoAlias(), irc::sepstream::GetToken(), IS_LOCAL, LogManager::Log(), InspIRCd::Logs, SearchAndReplace(), Module::ServerInstance, and TYPE_CHANNEL.

virtual void ModuleAlias::ReadAliases  )  [inline, private, virtual]
 

Definition at line 60 of file m_alias.cpp.

References Alias::AliasedCommand, Aliases, Alias::CaseSensitive, Alias::ChannelCommand, Alias::format, Alias::OperOnly, Alias::ReplaceFormat, Alias::RequiredNick, Module::ServerInstance, Alias::ULineOnly, and Alias::UserCommand.

Referenced by ModuleAlias(), and OnRehash().

void ModuleAlias::SearchAndReplace std::string newline,
const std::string find,
const std::string replace
[inline]
 

Definition at line 129 of file m_alias.cpp.

Referenced by DoCommand(), OnPreCommand(), and OnUserPreMessage().


Member Data Documentation

std::multimap<std::string, Alias> ModuleAlias::Aliases [private]
 

Definition at line 58 of file m_alias.cpp.

Referenced by OnPreCommand(), OnUserPreMessage(), and ReadAliases().


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