X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fmodules.h;h=e6b4739d8c7a34c63414e0ec5b19434a63d5383d;hb=deb5dd0dd3b9aeacc544080569c57dacb6cad9de;hp=8f95e4e86efa2f826639945317853b9b881b6e90;hpb=78cd2581e957e05246029b76c2da4ca1261d7d3f;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/modules.h b/include/modules.h index 8f95e4e86..e6b4739d8 100644 --- a/include/modules.h +++ b/include/modules.h @@ -30,6 +30,7 @@ typedef std::deque file_cache; typedef file_cache string_list; + // This #define allows us to call a method in all // loaded modules in a readable simple way, e.g.: // 'FOREACH_MOD OnConnect(user);' @@ -158,9 +159,11 @@ class Module : public classbase * This method is the lowest level of handler available to a module. It will be called with raw * data which is passing through a connected socket. If you wish, you may munge this data by changing * the string parameter "raw". If you do this, after your function exits it will immediately be - * cut down to 510 characters plus a carriage return and linefeed. + * cut down to 510 characters plus a carriage return and linefeed. For INBOUND messages only (where + * inbound is set to true) the value of user will be the userrec of the connection sending the + * data. This is not possible for outbound data because the data may be being routed to multiple targets. */ - virtual void OnServerRaw(std::string &raw, bool inbound); + virtual void OnServerRaw(std::string &raw, bool inbound, userrec* user); /** Called whenever an extended mode is to be processed. * The type parameter is MT_SERVER, MT_CLIENT or MT_CHANNEL, dependent on where the mode is being @@ -229,6 +232,15 @@ class Module : public classbase * of where the message is destined to be sent. */ 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 + * 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). + * If your method returns nonzero, the nickchange is silently forbidden, and it is down to your + * module to generate some meaninful output. + */ + virtual int OnUserPreNick(userrec* user, std::string newnick); }; @@ -318,6 +330,10 @@ class Server : public classbase * Nicks for unregistered connections will return false. */ virtual bool IsNick(std::string nick); + /** Returns a count of the number of users on a channel. + * This will NEVER be 0, as if the chanrec exists, it will have at least one user in the channel. + */ + virtual int CountUsers(chanrec* c); /** Attempts to look up a nick and return a pointer to it. * This function will return NULL if the nick does not exist. */ @@ -454,6 +470,43 @@ class Server : public classbase * Returns true if the literal successfully matches the pattern, false if otherwise. */ virtual bool MatchText(std::string sliteral, std::string spattern); + + /** Calls the handler for a command, either implemented by the core or by another module. + * You can use this function to trigger other commands in the ircd, such as PRIVMSG, JOIN, + * KICK etc, or even as a method of callback. By defining command names that are untypeable + * for users on irc (e.g. those which contain a \r or \n) you may use them as callback identifiers. + * The first parameter to this method is the name of the command handler you wish to call, e.g. + * PRIVMSG. This will be a command handler previously registered by the core or wih AddCommand(). + * The second parameter is an array of parameters, and the third parameter is a count of parameters + * in the array. If you do not pass enough parameters to meet the minimum needed by the handler, the + * functiom will silently ignore it. The final parameter is the user executing the command handler, + * used for privilage checks, etc. + */ + virtual void CallCommandHandler(std::string commandname, char** parameters, int pcnt, userrec* user); + + /** Change displayed hostname of a user. + * You should always call this method to change a user's host rather than writing directly to the + * dhost member of userrec, as any change applied via this method will be propogated to any + * linked servers. + */ + virtual void ChangeHost(userrec* user, std::string host); + + /** Change GECOS (fullname) of a user. + * You should always call this method to change a user's GECOS rather than writing directly to the + * fullname member of userrec, as any change applied via this method will be propogated to any + * linked servers. + */ + virtual void ChangeGECOS(userrec* user, std::string gecos); + + /** Returns true if the servername you give is ulined. + * ULined servers have extra privilages. They are allowed to change nicknames on remote servers, + * change modes of clients which are on remote servers and set modes of channels where there are + * no channel operators for that channel on the ulined server, amongst other things. Ulined server + * data is also broadcast across the mesh at all times as opposed to selectively messaged in the + * case of normal servers, as many ulined server types (such as services) do not support meshed + * links and must operate in this manner. + */ + virtual bool IsUlined(std::string server); }; /** Allows reading of values from configuration files @@ -471,6 +524,10 @@ class ConfigReader : public classbase * (such as comments) stripped from it. */ std::stringstream *cache; + /** Used to store errors + */ + bool error; + public: /** Default constructor. * This constructor initialises the ConfigReader class to read the inspircd.conf file @@ -498,9 +555,17 @@ class ConfigReader : public classbase */ int Enumerate(std::string tag); /** Returns true if a config file is valid. - * This method is unimplemented and will always return true. + * This method is partially implemented and will only return false if the config + * file does not exist or could not be opened. */ bool Verify(); + + /** Returns the number of items within a tag. + * For example if the tag was <test tag="blah" data="foo"> then this + * function would return 2. Spaces and newlines both qualify as valid seperators + * between values. + */ + int EnumerateValues(std::string tag, int index); }; @@ -539,6 +604,9 @@ class FileReader : public classbase */ void LoadFile(std::string filename); + /** Returns true if the file exists + * This function will return false if the file could not be opened. + */ bool Exists(); /** Retrieve one line from the file.