From abdb186046bcdd83aefbc4171a00bd1ad7ec963c Mon Sep 17 00:00:00 2001 From: brain Date: Sat, 3 Apr 2004 15:46:53 +0000 Subject: Added support for module-defined chanmodes with no parameters Fixed minor typo in example conf Added new stylesheet and docs git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@362 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/modules.h | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'include/modules.h') diff --git a/include/modules.h b/include/modules.h index e9f750693..74d7800d3 100644 --- a/include/modules.h +++ b/include/modules.h @@ -35,6 +35,24 @@ typedef file_cache string_list; #define FOREACH_MOD for (int i = 0; i <= MODCOUNT; i++) modules[i]-> +// This define is similar to the one above but returns a result in MOD_RESULT. +// The first module to return a nonzero result is the value to be accepted, +// and any modules after are ignored. + +// ********************************************************************************************* + +#define FOREACH_RESULT(x) { MOD_RESULT = 0; \ + for (int i = 0; i <= MODCOUNT; i++) { \ + int res = modules[i]->x ; \ + if (res) { \ + MOD_RESULT = res; \ + break; \ + } \ + } \ + } + +// ********************************************************************************************* + extern void createcommand(char* cmd, handlerfunc f, char flags, int minparams); extern void server_mode(char **parameters, int pcnt, userrec *user); @@ -117,7 +135,7 @@ class Module : public classbase * digital signatures and anything else you may want to add. This should be regarded as a pre-processor * and will be called before ANY other operations within the ircd core program. */ - virtual void Module::OnPacketTransmit(char *p); + virtual void OnPacketTransmit(char *p); /** Called after a packet is received from another irc server. * The packet is represented as a char*, as it should be regarded as a buffer, and not a string. @@ -126,7 +144,7 @@ class Module : public classbase * and will be called immediately after the packet is received but before any other operations with the * core of the ircd. */ - virtual void Module::OnPacketReceive(char *p); + virtual void OnPacketReceive(char *p); /** Called on rehash. * This method is called prior to a /REHASH or when a SIGHUP is received from the operating @@ -153,6 +171,19 @@ class Module : public classbase */ virtual bool OnExtendedMode(userrec* user, chanrec* chan, 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 + * 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. + * + * IMPORTANT NOTE! + * + * If the user joins a NEW channel which does not exist yet, OnUserPreJoin will be called BEFORE the channel + * record is created. This will cause chanrec* chan to be NULL. There is very little you can do in form of + * processing on the actual channel record at this point, however the channel NAME will still be passed in + * char* cname, so that you could for example implement a channel blacklist or whitelist, etc. + */ + virtual int Module::OnUserPreJoin(userrec* user, chanrec* chan, char* cname); }; -- cgit v1.2.3