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

Module Class Reference

Base class for all InspIRCd modules This class is the base class for InspIRCd modules. More...

#include <modules.h>

Inheritance diagram for Module:

Inheritance graph
[legend]
Collaboration diagram for Module:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Module (InspIRCd *Me)
 Default constructor.
virtual ~Module ()
 Default destructor.
virtual void Prioritize ()
virtual Version GetVersion ()
 Returns the version number of a Module.
virtual void OnUserConnect (User *user)
 Called when a user connects.
virtual void OnUserQuit (User *user, const std::string &message, const std::string &oper_message)
 Called when a user quits.
virtual void OnUserDisconnect (User *user)
 Called whenever a user's socket is closed.
virtual int OnChannelPreDelete (Channel *chan)
 Called whenever a channel is about to be deleted.
virtual void OnChannelDelete (Channel *chan)
 Called whenever a channel is deleted, either by QUIT, KICK or PART.
virtual void OnUserJoin (User *user, Channel *channel, bool sync, bool &silent)
 Called when a user joins a channel.
virtual void OnPostJoin (User *user, Channel *channel)
 Called after a user joins a channel Identical to OnUserJoin, but called immediately afterwards, when any linking module has seen the join.
virtual void OnUserPart (User *user, Channel *channel, std::string &partmessage, bool &silent)
 Called when a user parts a channel.
virtual void OnRehash (User *user, const std::string &parameter)
 Called on rehash.
virtual void OnServerRaw (std::string &raw, bool inbound, User *user)
 Called when a raw command is transmitted or received.
virtual int OnSendSnotice (char &snomask, std::string &type, const std::string &message)
 Called whenever a snotice is about to be sent to a snomask.
virtual int OnUserPreJoin (User *user, Channel *chan, const char *cname, std::string &privs, const std::string &keygiven)
 Called whenever a user is about to join a channel, before any processing is done.
virtual int OnUserPreKick (User *source, User *user, Channel *chan, const std::string &reason)
 Called whenever a user is about to be kicked.
virtual void OnUserKick (User *source, User *user, Channel *chan, const std::string &reason, bool &silent)
 Called whenever a user is kicked.
virtual void OnOper (User *user, const std::string &opertype)
 Called whenever a user opers locally.
virtual void OnPostOper (User *user, const std::string &opername, const std::string &opertype)
 Called after a user opers locally.
virtual void OnInfo (User *user)
 Called whenever a user types /INFO.
virtual void OnWhois (User *source, User *dest)
 Called whenever a /WHOIS is performed on a local user.
virtual int OnUserPreInvite (User *source, User *dest, Channel *channel, time_t timeout)
 Called whenever a user is about to invite another user into a channel, before any processing is done.
virtual void OnUserInvite (User *source, User *dest, Channel *channel, time_t timeout)
 Called after a user has been successfully invited to a channel.
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.
virtual int OnUserPreNotice (User *user, void *dest, int target_type, std::string &text, char status, CUList &exempt_list)
 Called whenever a user is about to NOTICE A user or a channel, before any processing is done.
virtual void OnBuildExemptList (MessageType message_type, Channel *chan, User *sender, char status, CUList &exempt_list, const std::string &text)
 Called whenever the server wants to build the exemption list for a channel, but is not directly doing a PRIVMSG or NOTICE.
virtual int OnUserPreNick (User *user, const std::string &newnick)
 Called before any nickchange, local or remote.
virtual void OnUserMessage (User *user, void *dest, int target_type, const std::string &text, char status, const CUList &exempt_list)
 Called after any PRIVMSG sent from a user.
virtual void OnUserNotice (User *user, void *dest, int target_type, const std::string &text, char status, const CUList &exempt_list)
 Called after any NOTICE sent from a user.
virtual void OnText (User *user, void *dest, int target_type, const std::string &text, char status, CUList &exempt_list)
 Called immediately before any NOTICE or PRIVMSG sent from a user, local or remote.
virtual void OnMode (User *user, void *dest, int target_type, const std::string &text)
 Called after every MODE command sent from a user The dest variable contains a User* if target_type is TYPE_USER and a Channel* if target_type is TYPE_CHANNEL.
virtual void OnGetServerDescription (const std::string &servername, std::string &description)
 Allows modules to alter or create server descriptions Whenever a module requires a server description, for example for display in WHOIS, this function is called in all modules.
virtual void OnSyncUser (User *user, Module *proto, void *opaque)
 Allows modules to synchronize data which relates to users during a netburst.
virtual void OnSyncChannel (Channel *chan, Module *proto, void *opaque)
 Allows modules to synchronize data which relates to channels during a netburst.
virtual void OnSyncChannelMetaData (Channel *chan, Module *proto, void *opaque, const std::string &extname, bool displayable=false)
virtual void OnSyncUserMetaData (User *user, Module *proto, void *opaque, const std::string &extname, bool displayable=false)
virtual void OnSyncOtherMetaData (Module *proto, void *opaque, bool displayable=false)
virtual void OnDecodeMetaData (int target_type, void *target, const std::string &extname, const std::string &extdata)
 Allows module data, sent via ProtoSendMetaData, to be decoded again by a receiving module.
virtual void ProtoSendMode (void *opaque, int target_type, void *target, const std::string &modeline)
 Implemented by modules which provide the ability to link servers.
virtual void ProtoSendMetaData (void *opaque, int target_type, void *target, const std::string &extname, const std::string &extdata)
 Implemented by modules which provide the ability to link servers.
virtual void OnWallops (User *user, const std::string &text)
 Called after every WALLOPS command.
virtual void OnChangeHost (User *user, const std::string &newhost)
 Called whenever a user's hostname is changed.
virtual void OnChangeName (User *user, const std::string &gecos)
 Called whenever a user's GECOS (realname) is changed.
virtual void OnAddLine (User *source, XLine *line)
 Called whenever an xline is added by a local user.
virtual void OnDelLine (User *source, XLine *line)
 Called whenever an xline is deleted MANUALLY.
virtual void OnExpireLine (XLine *line)
 Called whenever an xline expires.
virtual void OnCleanup (int target_type, void *item)
 Called before your module is unloaded to clean up Extensibles.
virtual void OnUserPostNick (User *user, const std::string &oldnick)
 Called after any nickchange, local or remote.
virtual int OnAccessCheck (User *source, User *dest, Channel *channel, int access_type)
 Called before an action which requires a channel privilage check.
virtual void On005Numeric (std::string &output)
 Called when a 005 numeric is about to be output.
virtual int OnKill (User *source, User *dest, const std::string &reason)
 Called when a client is disconnected by KILL.
virtual void OnRemoteKill (User *source, User *dest, const std::string &reason, const std::string &operreason)
 Called when an oper wants to disconnect a remote user via KILL.
virtual void OnLoadModule (Module *mod, const std::string &name)
 Called whenever a module is loaded.
virtual void OnUnloadModule (Module *mod, const std::string &name)
 Called whenever a module is unloaded.
virtual void OnBackgroundTimer (time_t curtime)
 Called once every five seconds for background processing.
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 void OnPostCommand (const std::string &command, const std::vector< std::string > &parameters, User *user, CmdResult result, const std::string &original_line)
 Called after any command has been executed.
virtual bool OnCheckReady (User *user)
 Called to check if a user who is connecting can now be allowed to register If any modules return false for this function, the user is held in the waiting state until all modules return true.
virtual int OnUserRegister (User *user)
 Called whenever a user is about to register their connection (e.g.
virtual int OnCheckInvite (User *user, Channel *chan)
 Called whenever a user joins a channel, to determine if invite checks should go ahead or not.
virtual int OnRawMode (User *user, Channel *chan, const char mode, const std::string &param, bool adding, int pcnt, bool servermode=true)
 Called whenever a mode character is processed.
virtual int OnCheckKey (User *user, Channel *chan, const std::string &keygiven)
 Called whenever a user joins a channel, to determine if key checks should go ahead or not.
virtual int OnCheckLimit (User *user, Channel *chan)
 Called whenever a user joins a channel, to determine if channel limit checks should go ahead or not.
virtual int OnCheckBan (User *user, Channel *chan)
 Called whenever a user joins a channel, to determine if banlist checks should go ahead or not.
virtual int OnCheckExtBan (User *u, Channel *c, char type)
virtual int OnCheckStringExtBan (const std::string &s, Channel *c, char type)
 Called whenever checking whether or not a string is extbanned.
virtual int OnStats (char symbol, User *user, string_list &results)
 Called on all /STATS commands This method is triggered for all /STATS use, including stats symbols handled by the core.
virtual int OnChangeLocalUserHost (User *user, const std::string &newhost)
 Called whenever a change of a local users displayed host is attempted.
virtual int OnChangeLocalUserGECOS (User *user, const std::string &newhost)
 Called whenever a change of a local users GECOS (fullname field) is attempted.
virtual int OnLocalTopicChange (User *user, Channel *chan, const std::string &topic)
 Called whenever a topic is changed by a local user.
virtual void OnPostLocalTopicChange (User *user, Channel *chan, const std::string &topic)
 Called whenever a local topic has been changed.
virtual void OnEvent (Event *event)
 Called whenever an Event class is sent to all module by another module.
virtual const char * OnRequest (Request *request)
 Called whenever a Request class is sent to your module by another module.
virtual int OnPassCompare (Extensible *ex, const std::string &password, const std::string &input, const std::string &hashtype)
 Called whenever a password check is to be made.
virtual void OnGlobalOper (User *user)
 Called whenever a user is given usermode +o, anywhere on the network.
virtual void OnPostConnect (User *user)
 Called after a user has fully connected and all modules have executed OnUserConnect This event is informational only.
virtual int OnAddBan (User *source, Channel *channel, const std::string &banmask)
 Called whenever a ban is added to a channel's list.
virtual int OnDelBan (User *source, Channel *channel, const std::string &banmask)
 Called whenever a ban is removed from a channel's list.
virtual void OnHookUserIO (User *user, const std::string &targetip)
virtual void OnRawSocketAccept (int fd, const std::string &ip, int localport)
 Called immediately after any connection is accepted.
virtual int OnRawSocketWrite (int fd, const char *buffer, int count)
 Called immediately before any write() operation on a user's socket in the core.
virtual void OnRawSocketClose (int fd)
 Called immediately before any socket is closed.
virtual void OnRawSocketConnect (int fd)
 Called immediately upon connection of an outbound BufferedSocket which has been hooked by a module.
virtual int OnRawSocketRead (int fd, char *buffer, unsigned int count, int &readresult)
 Called immediately before any read() operation on a client socket in the core.
virtual int OnSetAway (User *user, const std::string &awaymsg)
 Called whenever a user sets away or returns from being away.
virtual int OnUserList (User *user, Channel *Ptr, CUList *&userlist)
 Called whenever a NAMES list is requested.
virtual int OnWhoisLine (User *user, User *dest, int &numeric, std::string &text)
 Called whenever a line of WHOIS output is sent to a user.
virtual void OnGarbageCollect ()
 Called at intervals for modules to garbage-collect any hashes etc.
virtual void OnBufferFlushed (User *user)
 Called whenever a user's write buffer has been completely sent.
virtual void OnRunTestSuite ()
 Add test suite hooks here.
virtual void OnNamesListItem (User *issuer, User *user, Channel *channel, std::string &prefixes, std::string &nick)
 Called for every item in a NAMES list, so that modules may reformat portions of it as they see fit.
virtual int OnNumeric (User *user, unsigned int numeric, const std::string &text)
virtual bool OnHostCycle (User *user)
 Called for every time the user's host or ident changes, to indicate wether or not the 'Changing host' message should be sent, if enabled.

Protected Attributes

InspIRCdServerInstance
 Creator/owner pointer.

Detailed Description

Base class for all InspIRCd modules This class is the base class for InspIRCd modules.

All modules must inherit from this class, its methods will be called when irc server events occur. class inherited from module must be instantiated by the ModuleFactory class (see relevent section) for the module to be initialised.

Definition at line 414 of file modules.h.


Constructor & Destructor Documentation

Module::Module InspIRCd Me  ) 
 

Default constructor.

Creates a module class.

Parameters:
Me An instance of the InspIRCd class which will be saved into ServerInstance for your use
Exceptions:
ModuleException Throwing this class, or any class derived from ModuleException, causes loading of the module to abort.

Definition at line 106 of file modules.cpp.

Module::~Module  )  [virtual]
 

Default destructor.

destroys a module class

Definition at line 107 of file modules.cpp.


Member Function Documentation

Version Module::GetVersion  )  [virtual]
 

Returns the version number of a Module.

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

Reimplemented in ModuleAbbreviation, ModuleAlias, ModuleAllowInvite, Modulealltime, ModuleAntiBear, ModuleAntiBottler, ModuleAuditorium, ModuleBanException, ModuleBanRedirect, ModuleBlockAmsg, ModuleBlockCAPS, ModuleBlockColour, ModuleBotMode, ModuleCallerID, ModuleCAP, ModuleCBan, ModuleCensor, ModuleCgiIRC, ModuleChanCreate, ModuleChanFilter, ModuleChanLog, ModuleBadChannelExtban, ModuleChanProtect, ModuleCheck, ModuleChgHost, ModuleChgIdent, ModuleChgName, ModuleCloaking, ModuleClones, ModuleClose, ModulePrivacyMode, ModuleConnJoin, ModuleModesOnConnect, ModuleWaitPong, ModuleQuitBan, ModuleConnFlood, ModuleCustomTitle, ModuleCycle, ModuleDCCAllow, ModuleDeaf, ModuleDelayJoin, ModuleDenyChannels, ModuleDeVoice, ModuleDNSBL, FilterBase, ModuleFoobar, ModuleGecosBan, ModuleGlobalLoad, ModuleGlobops, ModuleHelpop, ModuleHideChans, ModuleHideOper, ModuleHostChange, ModuleHttpServer, ModuleHTTPAccessList, ModuleHttpStats, ModuleHttpStats, ModuleIdent, ModuleInvisible, ModuleInviteException, ModuleJoinFlood, ModuleJumpServer, ModuleKickNoRejoin, ModuleKnock, ModuleLockserv, ModuleMapHide, ModuleMD5, ModuleMsgFlood, ModuleQuietBan, ModuleNamesX, ModuleNickFlood, ModuleNickLock, ModuleNoCTCP, ModuleNoKicks, ModuleNoNickChange, ModuleNoNotice, ModulePartMsgBan, ModuleOperChans, ModuleOperFlood, ModuleGecosBan, ModuleOperjoin, ModuleOperLevels, ModuleOperLog, ModuleModesOnOper, ModuleOpermotd, ModuleOverride, ModuleOperHash, ModulePermanentChannels, ModuleRandQuote, ModuleRedirect, ModuleRegexGlob, ModuleRegOnlyCreate, ModuleRemove, ModuleRestrictBanned, ModuleRestrictChans, ModuleRestrictMsg, ModuleRIPEMD160, ModuleRLine, ModuleRpcJson, ModuleRPCTest, ModuleSafeList, ModuleSajoin, ModuleSaMode, ModuleSanick, ModuleSapart, ModuleSaquit, ModuleSASL, ModuleSATopic, ModuleSecureList, ModuleSeeNicks, ModuleServerBan, ModuleServices, ModuleServicesAccount, ModuleServProtectMode, ModuleSetHost, ModuleSetIdent, ModuleSetIdle, ModuleSetName, ModuleSHA256, ModuleShowwhois, ModuleShun, ModuleSilence, ModuleSpy, ModuleSSLDummy, ModuleSSLModes, ModuleStripColor, ModuleSVSHold, ModuleSWhois, ModuleTaxonomy, ModuleTestCommand, ModuleTimedBans, ModuleTLine, ModuleUHNames, ModuleUninvite, ModuleUserIP, ModuleVHost, Modulewatch, ModuleXLineDB, ModuleGeoIP, ModuleLDAPAuth, ModuleLDAPAuth, ModuleMsSQL, ModuleSQL, ModulePgSQL, ModuleRegexPCRE, ModuleRegexPOSIX, ModuleRegexTRE, ModuleSQLAuth, ModuleSQLite3, ModuleSQLLog, ModuleSQLOper, ModuleSQLutils, ModuleSSLGnuTLS, ModuleSSLOpenSSL, ModuleOperSSLCert, ModuleSSLInfo, ModuleTestClient, ModuleZLib, and ModuleSpanningTree.

Definition at line 120 of file modules.cpp.

References VF_VENDOR.

Referenced by ModuleManager::Load(), TreeSocket::Modules(), and ModuleHttpStats::OnEvent().

void Module::On005Numeric std::string output  )  [virtual]
 

Called when a 005 numeric is about to be output.

The module should modify the 005 numeric if needed to indicate its features.

Parameters:
output The 005 string to be modified if neccessary.

Reimplemented in ModuleAllowInvite, ModuleBanException, ModuleBlockCAPS, ModuleBlockColour, ModuleCallerID, ModuleBadChannelExtban, ModuleGecosBan, ModuleInviteException, ModuleQuietBan, ModuleNamesX, ModuleNoCTCP, ModuleNoKicks, ModuleNoNickChange, ModuleNoNotice, ModulePartMsgBan, ModuleGecosBan, ModuleOperLog, ModuleOverride, ModuleRemove, ModuleSafeList, ModuleSecureList, ModuleServerBan, ModuleServicesAccount, ModuleSilence, ModuleStripColor, ModuleUHNames, ModuleUserIP, Modulewatch, ModuleSSLGnuTLS, and ModuleSSLOpenSSL.

Definition at line 131 of file modules.cpp.

int Module::OnAccessCheck User source,
User dest,
Channel channel,
int  access_type
[virtual]
 

Called before an action which requires a channel privilage check.

This function is called before many functions which check a users status on a channel, for example before opping a user, deopping a user, kicking a user, etc. There are several values for access_type which indicate for what reason access is being checked. These are:

AC_KICK (0) - A user is being kicked
AC_DEOP (1) - a user is being deopped
AC_OP (2) - a user is being opped
AC_VOICE (3) - a user is being voiced
AC_DEVOICE (4) - a user is being devoiced
AC_HALFOP (5) - a user is being halfopped
AC_DEHALFOP (6) - a user is being dehalfopped
AC_INVITE () - a user is being invited
AC_GENERAL_MODE (8) - a user channel mode is being changed<br>
Upon returning from your function you must return either ACR_DEFAULT, to indicate the module wishes to do nothing, or ACR_DENY where approprate to deny the action, and ACR_ALLOW where appropriate to allow the action. Please note that in the case of some access checks (such as AC_GENERAL_MODE) access may be denied 'upstream' causing other checks such as AC_DEOP to not be reached. Be very careful with use of the AC_GENERAL_MODE type, as it may inadvertently override the behaviour of other modules. When the access_type is AC_GENERAL_MODE, the destination of the mode will be NULL (as it has not yet been determined).

Parameters:
source The source of the access check
dest The destination of the access check
channel The channel which is being checked
access_type See above

Reimplemented in ModuleChanProtect, ModuleNoKicks, and ModuleOverride.

Definition at line 130 of file modules.cpp.

References ACR_DEFAULT.

int Module::OnAddBan User source,
Channel channel,
const std::string banmask
[virtual]
 

Called whenever a ban is added to a channel's list.

Return a non-zero value to 'eat' the mode change and prevent the ban from being added.

Parameters:
source The user adding the ban
channel The channel the ban is being added to
banmask The ban mask being added
Returns:
1 to block the ban, 0 to continue as normal

Definition at line 158 of file modules.cpp.

void Module::OnAddLine User source,
XLine line
[virtual]
 

Called whenever an xline is added by a local user.

This method is triggered after the line is added.

Parameters:
source The sender of the line or NULL for local server
line The xline being added

Reimplemented in ModuleXLineDB, and ModuleSpanningTree.

Definition at line 182 of file modules.cpp.

void Module::OnBackgroundTimer time_t  curtime  )  [virtual]
 

Called once every five seconds for background processing.

This timer can be used to control timed features. Its period is not accurate enough to be used as a clock, but it is gauranteed to be called at least once in any five second period, directly from the main loop of the server.

Parameters:
curtime The current timer derived from time(2)

Reimplemented in ModuleTimedBans, ModuleTestClient, and ModuleSpanningTree.

Definition at line 135 of file modules.cpp.

void Module::OnBufferFlushed User user  )  [virtual]
 

Called whenever a user's write buffer has been completely sent.

This is called when the user's write buffer is completely empty, and there are no more pending bytes to be written and no pending write events in the socket engine's queue. This may be used to refill the buffer with data which is being spooled in a controlled manner, e.g. LIST lines.

Parameters:
user The user who's buffer is now empty.

Reimplemented in ModuleSafeList, ModuleSSLGnuTLS, and ModuleSSLOpenSSL.

Definition at line 193 of file modules.cpp.

void Module::OnBuildExemptList MessageType  message_type,
Channel chan,
User sender,
char  status,
CUList exempt_list,
const std::string text
[virtual]
 

Called whenever the server wants to build the exemption list for a channel, but is not directly doing a PRIVMSG or NOTICE.

For example, the spanningtree protocol will call this event when passing a privmsg on (but not processing it directly).

Parameters:
message_type The message type, either MSG_PRIVMSG or MSG_NOTICE
chan The channel to build the exempt list of
sender The original sender of the PRIVMSG or NOTICE
status The status char to be used for the channel list
exempt_list The exempt list to be populated
text The original message text causing the exempt list to be built

Reimplemented in ModuleDeaf, and ModuleSilence.

Definition at line 191 of file modules.cpp.

void Module::OnChangeHost User user,
const std::string newhost
[virtual]
 

Called whenever a user's hostname is changed.

This event triggers after the host has been set.

Parameters:
user The user whos host is being changed
newhost The new hostname being set

Reimplemented in ModuleSpanningTree.

Definition at line 180 of file modules.cpp.

int Module::OnChangeLocalUserGECOS User user,
const std::string newhost
[virtual]
 

Called whenever a change of a local users GECOS (fullname field) is attempted.

return 1 to deny the name change, or 0 to allow it.

Parameters:
user The user whos GECOS will be changed
newhost The new GECOS
Returns:
1 to deny the GECOS change, 0 to allow

Definition at line 151 of file modules.cpp.

int Module::OnChangeLocalUserHost User user,
const std::string newhost
[virtual]
 

Called whenever a change of a local users displayed host is attempted.

Return 1 to deny the host change, or 0 to allow it.

Parameters:
user The user whos host will be changed
newhost The new hostname
Returns:
1 to deny the host change, 0 to allow

Definition at line 150 of file modules.cpp.

void Module::OnChangeName User user,
const std::string gecos
[virtual]
 

Called whenever a user's GECOS (realname) is changed.

This event triggers after the name has been set.

Parameters:
user The user who's GECOS is being changed
gecos The new GECOS being set on the user

Reimplemented in ModuleSpanningTree.

Definition at line 181 of file modules.cpp.

void Module::OnChannelDelete Channel chan  )  [virtual]
 

Called whenever a channel is deleted, either by QUIT, KICK or PART.

Parameters:
chan The channel being deleted

Reimplemented in ModuleBanException,