X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fmodules.h;h=caea6e4210ebd6f909c91da9f39e8a9923f80d29;hb=38c9d65253a67dbe13c77792027a9db601735813;hp=866bed269a7f4a9422213e0be0e5598e4a5783a6;hpb=8e475017a6f87ac936993fa9791a6634683dd512;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/modules.h b/include/modules.h index 866bed269..caea6e421 100644 --- a/include/modules.h +++ b/include/modules.h @@ -1,8 +1,18 @@ -/* - - - -*/ +/* +------------------------------------+ + * | Inspire Internet Relay Chat Daemon | + * +------------------------------------+ + * + * Inspire is copyright (C) 2002-2004 ChatSpike-Dev. + * E-mail: + * + * + * + * Written by Craig Edwards, Craig McLure, and others. + * This program is free but copyrighted software; see + * the file COPYING for details. + * + * --------------------------------------------------- + */ #ifndef __PLUGIN_H @@ -50,6 +60,10 @@ typedef std::deque file_cache; typedef file_cache string_list; +/** Holds a list of users in a channel + */ +typedef std::deque chanuserlist; + // This #define allows us to call a method in all // loaded modules in a readable simple way, e.g.: @@ -66,12 +80,12 @@ typedef file_cache string_list; #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; \ } \ } \ - } + } // ********************************************************************************************* @@ -197,9 +211,10 @@ class Module : public classbase 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! * @@ -223,7 +238,7 @@ class Module : public classbase * 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: * - * :information here + * <nick> :information here */ virtual void OnInfo(userrec* user); @@ -233,6 +248,13 @@ class Module : public classbase */ 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, @@ -266,7 +288,7 @@ class Module : public classbase * 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:
+ * 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
@@ -275,7 +297,7 @@ class Module : public classbase * AC_HALFOP (5) - a user is being halfopped
* AC_DEHALFOP (6) - a user is being dehalfopped
* AC_INVITE (7) - a user is being invited
- * AC_GENERAL_MODE (8) - a user channel mode is being changed
+ * AC_GENERAL_MODE (8) - a user channel mode is being changed

* 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 @@ -283,7 +305,21 @@ class Module : public classbase * 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 OnUserSync(userrec* user); + + /** Called during a netburst to sync channel data. + * This is called during the netburst on a per-channel basis. You should use this call to up any special + * channel-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); }; @@ -577,8 +613,19 @@ class Server : public classbase * links and must operate in this manner. */ virtual bool IsUlined(std::string server); + + /** Fetches the userlist of a channel. This function must be here and not a member of userrec or + * chanrec due to include constraints. + */ + virtual chanuserlist GetUsers(chanrec* chan); + }; +#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. @@ -596,7 +643,8 @@ class ConfigReader : public classbase std::stringstream *cache; /** Used to store errors */ - bool error; + bool readerror; + long error; public: /** Default constructor. @@ -617,6 +665,26 @@ class ConfigReader : public classbase * 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