+ /** Called when a 005 numeric is about to be output.
+ * The module should modify the 005 numeric if needed to indicate its features.
+ * @param output The 005 string to be modified if neccessary.
+ */
+ virtual void On005Numeric(std::string &output);
+
+ /** Called when a client is disconnected by KILL.
+ * If a client is killed by a server, e.g. a nickname collision or protocol error,
+ * source is NULL.
+ * Return 1 from this function to prevent the kill, and 0 from this function to allow
+ * it as normal. If you prevent the kill no output will be sent to the client, it is
+ * down to your module to generate this information.
+ * NOTE: It is NOT advisable to stop kills which originate from servers or remote users.
+ * If you do so youre risking race conditions, desyncs and worse!
+ * @param source The user sending the KILL
+ * @param dest The user being killed
+ * @param reason The kill reason
+ * @return 1 to prevent the kill, 0 to allow
+ */
+ virtual int OnKill(userrec* source, userrec* dest, std::string reason);
+
+ /** Called when an oper wants to disconnect a remote user via KILL
+ * @param source The user sending the KILL
+ * @param dest The user being killed
+ * @param reason The kill reason
+ */
+ virtual void OnRemoteKill(userrec* source, userrec* dest, std::string reason);
+
+ /** Called whenever a module is loaded.
+ * mod will contain a pointer to the module, and string will contain its name,
+ * for example m_widgets.so. This function is primary for dependency checking,
+ * your module may decide to enable some extra features if it sees that you have
+ * for example loaded "m_killwidgets.so" with "m_makewidgets.so". It is highly
+ * recommended that modules do *NOT* bail if they cannot satisfy dependencies,
+ * but instead operate under reduced functionality, unless the dependency is
+ * absolutely neccessary (e.g. a module that extends the features of another
+ * module).
+ * @param mod A pointer to the new module
+ * @param name The new module's filename
+ */
+ virtual void OnLoadModule(Module* mod,std::string name);
+
+ /** Called whenever a module is unloaded.
+ * mod will contain a pointer to the module, and string will contain its name,
+ * for example m_widgets.so. This function is primary for dependency checking,
+ * your module may decide to enable some extra features if it sees that you have
+ * for example loaded "m_killwidgets.so" with "m_makewidgets.so". It is highly
+ * recommended that modules do *NOT* bail if they cannot satisfy dependencies,
+ * but instead operate under reduced functionality, unless the dependency is
+ * absolutely neccessary (e.g. a module that extends the features of another
+ * module).
+ * @param mod Pointer to the module being unloaded (still valid)
+ * @param name The filename of the module being unloaded
+ */
+ virtual void OnUnloadModule(Module* mod,std::string name);
+
+ /** 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.
+ * @param curtime The current timer derived from time(2)
+ */
+ virtual void OnBackgroundTimer(time_t curtime);
+
+ /** Called whenever a list is needed for a listmode.
+ * For example, when a /MODE #channel +b (without any other parameters) is called,
+ * if a module was handling +b this function would be called. The function can then
+ * output any lists it wishes to. Please note that all modules will see all mode
+ * characters to provide the ability to extend each other, so please only output
+ * a list if the mode character given matches the one(s) you want to handle.
+ * @param user The user requesting the list
+ * @param channel The channel the list is for
+ * @param mode The listmode which a list is being requested on
+ */
+ virtual void OnSendList(userrec* user, chanrec* channel, char mode);
+
+ /** 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, but it will not occur for invalid commands (e.g. ones which do not
+ * exist within the command table). 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
+ * Server::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!)
+ * @param command The command being executed
+ * @param parameters An array of array of characters containing the parameters for the command
+ * @param pcnt The nuimber of parameters passed to the command
+ * @param user the user issuing the command
+ * @param 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.
+ * @return 1 to block the command, 0 to allow
+ */
+ virtual int OnPreCommand(std::string command, char **parameters, int pcnt, userrec *user, bool validated);
+
+ /** 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. For example a module which implements ident
+ * lookups will continue to return false for a user until their ident lookup is completed.
+ * Note that the registration timeout for a user overrides these checks, if the registration
+ * timeout is reached, the user is disconnected even if modules report that the user is
+ * not ready to connect.
+ * @param user The user to check
+ * @return true to indicate readiness, false if otherwise
+ */
+ virtual bool OnCheckReady(userrec* user);
+
+ /** Called whenever a user is about to register their connection (e.g. before the user
+ * is sent the MOTD etc). Modules can use this method if they are performing a function
+ * which must be done before the actual connection is completed (e.g. ident lookups,
+ * dnsbl lookups, etc).
+ * Note that you should NOT delete the user record here by causing a disconnection!
+ * Use OnUserConnect for that instead.
+ * @param user The user registering
+ */
+ virtual void OnUserRegister(userrec* user);
+
+ /** Called whenever a mode character is processed.
+ * Return 1 from this function to block the mode character from being processed entirely,
+ * so that you may perform your own code instead. Note that this method allows you to override
+ * modes defined by other modes, but this is NOT RECOMMENDED!
+ * @param user The user who is sending the mode
+ * @param chan The channel the mode is being sent to
+ * @param mode The mode character being set
+ * @param param The parameter for the mode or an empty string
+ * @param adding true of the mode is being added, false if it is being removed
+ * @param pcnt The parameter count for the mode (0 or 1)
+ * @return 1 to deny the mode, 0 to allow
+ */
+ virtual int OnRawMode(userrec* user, chanrec* chan, char mode, std::string param, bool adding, int pcnt);
+
+ /** Called whenever a user joins a channel, to determine if invite checks should go ahead or not.
+ * This method will always be called for each join, wether or not the channel is actually +i, and
+ * determines the outcome of an if statement around the whole section of invite checking code.
+ * return 1 to explicitly allow the join to go ahead or 0 to ignore the event.
+ * @param user The user joining the channel
+ * @param chan The channel being joined
+ * @return 1 to explicitly allow the join, 0 to proceed as normal
+ */
+ virtual int OnCheckInvite(userrec* user, chanrec* chan);
+
+ /** Called whenever a user joins a channel, to determine if key checks should go ahead or not.
+ * This method will always be called for each join, wether or not the channel is actually +k, and
+ * determines the outcome of an if statement around the whole section of key checking code.
+ * if the user specified no key, the keygiven string will be a valid but empty value.
+ * return 1 to explicitly allow the join to go ahead or 0 to ignore the event.
+ * @param user The user joining the channel
+ * @param chan The channel being joined
+ * @return 1 to explicitly allow the join, 0 to proceed as normal
+ */
+ virtual int OnCheckKey(userrec* user, chanrec* chan, std::string keygiven);
+
+ /** Called whenever a user joins a channel, to determine if channel limit checks should go ahead or not.
+ * This method will always be called for each join, wether or not the channel is actually +l, and
+ * determines the outcome of an if statement around the whole section of channel limit checking code.
+ * return 1 to explicitly allow the join to go ahead or 0 to ignore the event.
+ * @param user The user joining the channel
+ * @param chan The channel being joined
+ * @return 1 to explicitly allow the join, 0 to proceed as normal
+ */
+ virtual int OnCheckLimit(userrec* user, chanrec* chan);
+
+ /** Called whenever a user joins a channel, to determine if banlist checks should go ahead or not.
+ * This method will always be called for each join, wether or not the user actually matches a channel ban, and
+ * determines the outcome of an if statement around the whole section of ban checking code.
+ * return 1 to explicitly allow the join to go ahead or 0 to ignore the event.
+ * @param user The user joining the channel
+ * @param chan The channel being joined
+ * @return 1 to explicitly allow the join, 0 to proceed as normal
+ */
+ virtual int OnCheckBan(userrec* user, chanrec* chan);
+
+ /** Called on all /STATS commands
+ * This method is triggered for all /STATS use, including stats symbols handled by the core.
+ * @param symbol the symbol provided to /STATS
+ * @user the user issuing the /STATS command
+ * @return 1 to block the /STATS from being processed by the core, 0 to allow it
+ */
+ virtual int OnStats(char symbol, userrec* user);
+
+ /** Called whenever a change of a local users displayed host is attempted.
+ * Return 1 to deny the host change, or 0 to allow it.
+ * @param user The user whos host will be changed
+ * @param newhost The new hostname
+ * @return 1 to deny the host change, 0 to allow
+ */
+ virtual int OnChangeLocalUserHost(userrec* user, std::string newhost);
+
+ /** 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.
+ * @param user The user whos GECOS will be changed
+ * @param newhost The new GECOS
+ * @return 1 to deny the GECOS change, 0 to allow
+ */
+ virtual int OnChangeLocalUserGECOS(userrec* user, std::string newhost);
+
+ /** Called whenever a topic is changed by a local user.
+ * Return 1 to deny the topic change, or 0 to allow it.
+ * @param user The user changing the topic
+ * @param chan The channels who's topic is being changed
+ * @param topic The actual topic text
+ * @param 1 to block the topic change, 0 to allow
+ */
+ virtual int OnLocalTopicChange(userrec* user, chanrec* chan, std::string topic);
+
+ /** Called whenever a local topic has been changed.
+ * To block topic changes you must use OnLocalTopicChange instead.
+ * @param user The user changing the topic
+ * @param chan The channels who's topic is being changed
+ * @param topic The actual topic text
+ */
+ virtual void OnPostLocalTopicChange(userrec* user, chanrec* chan, std::string topic);
+
+ /** Called whenever an Event class is sent to all module by another module.
+ * Please see the documentation of Event::Send() for further information. The Event sent can
+ * always be assumed to be non-NULL, you should *always* check the value of Event::GetEventID()
+ * before doing anything to the event data, and you should *not* change the event data in any way!
+ * @param event The Event class being received
+ */
+ virtual void OnEvent(Event* event);
+
+ /** Called whenever a Request class is sent to your module by another module.
+ * Please see the documentation of Request::Send() for further information. The Request sent
+ * can always be assumed to be non-NULL, you should not change the request object or its data.
+ * Your method may return arbitary data in the char* result which the requesting module
+ * may be able to use for pre-determined purposes (e.g. the results of an SQL query, etc).
+ * @param request The Request class being received
+ */
+ virtual char* OnRequest(Request* request);
+
+ /** Called whenever an oper password is to be compared to what a user has input.
+ * The password field (from the config file) is in 'password' and is to be compared against
+ * 'input'. This method allows for encryption of oper passwords and much more besides.
+ * You should return a nonzero value if you want to allow the comparison or zero if you wish
+ * to do nothing.
+ * @param password The oper's password
+ * @param input The password entered
+ * @return 1 to match the passwords, 0 to do nothing
+ */
+ virtual int OnOperCompare(std::string password, std::string input);
+
+ /** Called whenever a user is given usermode +o, anywhere on the network.
+ * You cannot override this and prevent it from happening as it is already happened and
+ * such a task must be performed by another server. You can however bounce modes by sending
+ * servermodes out to reverse mode changes.
+ * @param user The user who is opering
+ */
+ virtual void OnGlobalOper(userrec* user);
+
+ /** Called whenever a user connects, anywhere on the network.
+ * This event is informational only. You should not change any user information in this
+ * event. To do so, use the OnUserConnect method to change the state of local users.
+ * @param user The user who is connecting
+ */
+ virtual void OnGlobalConnect(userrec* user);
+
+ /** 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.
+ * @param source The user adding the ban
+ * @param channel The channel the ban is being added to
+ * @param banmask The ban mask being added
+ * @return 1 to block the ban, 0 to continue as normal
+ */
+ virtual int OnAddBan(userrec* source, chanrec* channel,std::string banmask);
+
+ /** Called whenever a ban is removed from a channel's list.
+ * Return a non-zero value to 'eat' the mode change and prevent the ban from being removed.
+ * @param source The user deleting the ban
+ * @param channel The channel the ban is being deleted from
+ * @param banmask The ban mask being deleted
+ * @return 1 to block the unban, 0 to continue as normal
+ */
+ virtual int OnDelBan(userrec* source, chanrec* channel,std::string banmask);
+
+ /** Called immediately after any connection is accepted. This is intended for raw socket
+ * processing (e.g. modules which wrap the tcp connection within another library) and provides
+ * no information relating to a user record as the connection has not been assigned yet.
+ * There are no return values from this call as all modules get an opportunity if required to
+ * process the connection.
+ * @param fd The file descriptor returned from accept()
+ * @param ip The IP address of the connecting user
+ * @param localport The local port number the user connected to
+ */
+ virtual void OnRawSocketAccept(int fd, std::string ip, int localport);
+
+ /** Called immediately before any write() operation on a user's socket in the core. Because
+ * this event is a low level event no user information is associated with it. It is intended
+ * for use by modules which may wrap connections within another API such as SSL for example.
+ * return a non-zero result if you have handled the write operation, in which case the core
+ * will not call write().
+ * @param fd The file descriptor of the socket
+ * @param buffer A char* buffer being written
+ * @param Number of characters to write
+ * @return Number of characters actually written or 0 if you didn't handle the operation
+ */
+ virtual int OnRawSocketWrite(int fd, char* buffer, int count);
+
+ /** Called immediately before any socket is closed. When this event is called, shutdown()
+ * has not yet been called on the socket.
+ * @param fd The file descriptor of the socket prior to close()
+ */
+ virtual void OnRawSocketClose(int fd);
+
+ /** Called immediately before any read() operation on a client socket in the core.
+ * This occurs AFTER the select() or poll() so there is always data waiting to be read
+ * when this event occurs.
+ * Your event should return 1 if it has handled the reading itself, which prevents the core
+ * just using read(). You should place any data read into buffer, up to but NOT GREATER THAN
+ * the value of count. The value of readresult must be identical to an actual result that might
+ * be returned from the read() system call, for example, number of bytes read upon success,
+ * 0 upon EOF or closed socket, and -1 for error. If your function returns a nonzero value,
+ * you MUST set readresult.
+ * @param fd The file descriptor of the socket
+ * @param buffer A char* buffer being read to
+ * @param count The size of the buffer
+ * @param readresult The amount of characters read, or 0
+ * @return nonzero if the event was handled, in which case readresult must be valid on exit
+ */
+ virtual int OnRawSocketRead(int fd, char* buffer, unsigned int count, int &readresult);