]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/modules.h
Added m_alias module which provides command aliases.
[user/henk/code/inspircd.git] / include / modules.h
index 3e2b8c5bbca360c3fde2deef0346b546962d444a..e6b4739d8c7a34c63414e0ec5b19434a63d5383d 100644 (file)
@@ -30,6 +30,7 @@
 typedef std::deque<std::string> 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);
 };
 
 
@@ -276,6 +288,16 @@ class Server : public classbase
        /** Sends text from a user to another user.
         * This method writes a line of text to a user, with a user's nick/ident
         * /host combination prepended, as used in PRIVMSG etc commands (see RFC 1459)
+        * If you specify NULL as the source, then the data will originate from the
+        * local server, e.g. instead of:
+        *
+        * :user!ident@host TEXT
+        *
+        * The format will become:
+        *
+        * :localserver TEXT
+        *
+        * Which is useful for numerics and server notices to single users, etc.
         */
        virtual void SendTo(userrec* Source, userrec* Dest, std::string s);
        /** Sends text from a user to a channel (mulicast).
@@ -308,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.
         */
@@ -438,6 +464,49 @@ class Server : public classbase
         * action after calling this method is to immediately bail from your handler.
         */
        virtual void QuitUser(userrec* user, std::string reason);
+       
+       /**  Matches text against a glob pattern.
+        * Uses the ircd's internal matching function to match string against a globbing pattern, e.g. *!*@*.com
+        * 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
@@ -449,10 +518,16 @@ class Server : public classbase
 class ConfigReader : public classbase
 {
   protected:
-       /** The filename of the configuration file, as set by the constructor.
+       /** The contents of the configuration file
+        * This protected member should never be accessed by a module (and cannot be accessed unless the
+        * core is changed). It will contain a pointer to the configuration file data with unneeded data
+        * (such as comments) stripped from it.
         */
-       std::string fname;
        std::stringstream *cache;
+       /** Used to store errors
+        */
+       bool error;
+       
   public:
        /** Default constructor.
         * This constructor initialises the ConfigReader class to read the inspircd.conf file
@@ -480,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 &lt;test tag="blah" data="foo"&gt; then this
+        * function would return 2. Spaces and newlines both qualify as valid seperators
+        * between values.
+        */
+       int EnumerateValues(std::string tag, int index);
 };
 
 
@@ -521,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.