-/*
-
-
-
-*/
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
+ * E-mail:
+ * <brain@chatspike.net>
+ * <Craig@chatspike.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
#ifndef __PLUGIN_H
#define AC_INVITE 7 // a user is being invited
#define AC_GENERAL_MODE 8 // a user channel mode is being changed
+// used to define a set of behavior bits for a module
+
+#define VF_STATIC 1 // module is static, cannot be /unloadmodule'd
+#define VF_VENDOR 2 // module is a vendor module (came in the original tarball, not 3rd party)
+#define VF_SERVICEPROVIDER 4 // module provides a service to other modules (can be a dependency)
+#define VF_COMMON 8 // module needs to be common on all servers in a mesh to link
+
#include "dynamic.h"
#include "base.h"
#include "ctables.h"
#define FOREACH_RESULT(x) { MOD_RESULT = 0; \
for (int i = 0; i <= MODCOUNT; i++) { \
int res = modules[i]->x ; \
- if (res) { \
+ if (res != 0) { \
MOD_RESULT = res; \
break; \
} \
} \
- }
+ }
// *********************************************************************************************
virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms);
/** Called whenever a user is about to join a channel, before any processing is done.
- * Returning any nonzero value from this function stops the process immediately, causing no
+ * Returning a value of 1 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 mimic +b, +k, +l etc.
+ * notices etc. This is useful for modules which may want to mimic +b, +k, +l etc. Returning -1 from
+ * this function forces the join to be allowed, bypassing restrictions such as banlists, invite, keys etc.
*
* IMPORTANT NOTE!
*
* It is purposefully not possible to modify any info that has already been output, or halt the list.
* You must write a 371 numeric to the user, containing your info in the following format:
*
- * <nick> :information here
+ * <nick> :information here
*/
virtual void OnInfo(userrec* user);
*/
virtual void OnWhois(userrec* source, userrec* dest);
+ /** Called whenever a user is about to invite another user into a channel, before any processing is done.
+ * Returning 1 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 invites to channels.
+ */
+ virtual int OnUserPreInvite(userrec* source,userrec* dest,chanrec* channel);
+
/** 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,
* you must cast dest to a userrec* otherwise you must cast it to a chanrec*, this is the details
* of where the message is destined to be sent.
*/
- virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string text);
+ virtual int OnUserPreMessage(userrec* user,void* dest,int target_type, std::string &text);
/** Called whenever a user is about to NOTICE A user or a channel, before any processing is done.
* Returning any nonzero value from this function stops the process immediately, causing no
* 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 userrec* otherwise you must cast it to a chanrec*, this is the details
* of where the message is destined to be sent.
+ * You may alter the message text as you wish before relinquishing control to the next module
+ * in the chain, and if no other modules block the text this altered form of the text will be sent out
+ * to the user and possibly to other servers.
*/
- virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string text);
+ virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text);
/** Called before any nickchange, local or remote. This can be used to implement Q-lines etc.
* Please note that although you can see remote nickchanges through this function, you should
*/
virtual int OnUserPreNick(userrec* user, std::string newnick);
+ /** Called after any nickchange, local or remote. This can be used to track users after nickchanges
+ * have been applied. Please note that although you can see remote nickchanges through this function, you should
+ * NOT make any changes to the userrec if the user is a remote user as this may cause a desnyc.
+ * check user->server before taking any action (including returning nonzero from the method).
+ * Because this method is called after the nickchange is taken place, no return values are possible
+ * to indicate forbidding of the nick change. Use OnUserPreNick for this.
+ */
+ virtual void OnUserPostNick(userrec* user, std::string oldnick);
+
/** 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.
* 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).
*/
-
virtual int OnAccessCheck(userrec* source,userrec* dest,chanrec* channel,int access_type);
+
/** Called during a netburst to sync user data.
* This is called during the netburst on a per-user basis. You should use this call to up any special
* user-related things which are implemented by your module, e.g. sending listmodes. You may return
* multiple commands in the string_list.
*/
virtual string_list OnChannelSync(chanrec* chan);
+
+ /** Called when a 005 numeric is about to be output.
+ * The module should modify the 005 numeric if needed to indicate its features.
+ */
+ 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. If you do
+ * so youre risking race conditions, desyncs and worse!
+ */
+ virtual int OnKill(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).
+ */
+ virtual void OnLoadModule(Module* mod,std::string name);
};
};
+#define CONF_NOT_A_NUMBER 0x000010
+#define CONF_NOT_UNSIGNED 0x000080
+#define CONF_VALUE_NOT_FOUND 0x000100
+#define CONF_FILE_NOT_FOUND 0x000200
+
/** Allows reading of values from configuration files
* This class allows a module to read from either the main configuration file (inspircd.conf) or from
* a module-specified configuration file. It may either be instantiated with one parameter or none.
* (such as comments) stripped from it.
*/
std::stringstream *cache;
+ std::stringstream *errorlog;
/** Used to store errors
*/
- bool error;
+ bool readerror;
+ long error;
public:
/** Default constructor.
* exist in the config file, index indicates which of the values to retrieve.
*/
std::string ReadValue(std::string tag, std::string name, int index);
+ /** Retrieves a boolean value from the config file.
+ * This method retrieves a boolean value from the config file. Where multiple copies of the tag
+ * exist in the config file, index indicates which of the values to retrieve. The values "1", "yes"
+ * and "true" in the config file count as true to ReadFlag, and any other value counts as false.
+ */
+ bool ReadFlag(std::string tag, std::string name, int index);
+ /** Retrieves an integer value from the config file.
+ * This method retrieves an integer value from the config file. Where multiple copies of the tag
+ * exist in the config file, index indicates which of the values to retrieve. Any invalid integer
+ * values in the tag will cause the objects error value to be set, and any call to GetError() will
+ * return CONF_INVALID_NUMBER to be returned. needs_unsigned is set if the number must be unsigned.
+ * If a signed number is placed into a tag which is specified unsigned, 0 will be returned and GetError()
+ * will return CONF_NOT_UNSIGNED
+ */
+ long ReadInteger(std::string tag, std::string name, int index, bool needs_unsigned);
+ /** Returns the last error to occur.
+ * Valid errors can be found by looking in modules.h. Any nonzero value indicates an error condition.
+ * A call to GetError() resets the error flag back to 0.
+ */
+ long GetError();
/** Counts the number of times a given tag appears in the config file.
* This method counts the number of times a tag appears in a config file, for use where
* there are several tags of the same kind, e.g. with opers and connect types. It can be
* file does not exist or could not be opened.
*/
bool Verify();
+ /** Dumps the list of errors in a config file to an output location. If bail is true,
+ * then the program will abort. If bail is false and user points to a valid user
+ * record, the error report will be spooled to the given user by means of NOTICE.
+ * if bool is false AND user is false, the error report will be spooled to all opers
+ * by means of a NOTICE to all opers.
+ */
+ void DumpErrors(bool bail,userrec* user);
/** Returns the number of items within a tag.
* For example if the tag was <test tag="blah" data="foo"> then this