]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_services.cpp
Gah, im forgetting to SetMode!
[user/henk/code/inspircd.git] / src / modules / m_services.cpp
index c4f867ac311b2916729932da697bc8179d04002b..c868eefef6d687bf348ff03ae5d80449d4713d25 100644 (file)
@@ -51,15 +51,25 @@ class ModuleServices : public Module
                InsertMode(output, "rRM", 4);
        }
 
+       /* <- :stitch.chatspike.net 307 w00t w00t :is a registered nick */
+       virtual void OnWhois(userrec* source, userrec* dest)
+       {
+               if (dest->modes['r'-65])
+               {
+                       /* user is registered */
+                       WriteServ(source->fd, "307 %s %s :is a registered nick", source->nick, dest->nick);
+               }
+       }
+
        void Implements(char* List)
        {
-               List[I_OnUserPostNick] = List[I_OnUserPreMessage] = List[I_OnExtendedMode] = List[I_On005Numeric] = List[I_OnUserPreNotice] = List[I_OnUserPreJoin] = 1;
+               List[I_OnWhois] = List[I_OnUserPostNick] = List[I_OnUserPreMessage] = List[I_OnExtendedMode] = List[I_On005Numeric] = List[I_OnUserPreNotice] = List[I_OnUserPreJoin] = 1;
        }
 
-       virtual void OnUserPostNick(userrec* user, std::string oldnick)
+       virtual void OnUserPostNick(userrec* user, const std::string &oldnick)
        {
                /* On nickchange, if they have +r, remove it */
-               if (strchr(user->modes,'r'))
+               if (user->modes['r'-65])
                {
                        char* modechange[2];
                        modechange[0] = user->nick;
@@ -118,12 +128,12 @@ class ModuleServices : public Module
                return 0;
        }
 
-       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, char status)
        {
                if (target_type == TYPE_CHANNEL)
                {
                        chanrec* c = (chanrec*)dest;
-                       if ((c->IsCustomModeSet('M')) && (!strchr(user->modes,'r')))
+                       if ((c->IsModeSet('M')) && (!user->modes['r'-65]))
                        {
                                if ((Srv->IsUlined(user->nick)) || (Srv->IsUlined(user->server)) || (!strcmp(user->server,"")))
                                {
@@ -138,7 +148,7 @@ class ModuleServices : public Module
                if (target_type == TYPE_USER)
                {
                        userrec* u = (userrec*)dest;
-                       if ((strchr(u->modes,'R')) && (!strchr(user->modes,'r')))
+                       if ((u->modes['R'-65]) && (user->modes['r'-65]))
                        {
                                if ((Srv->IsUlined(user->nick)) || (Srv->IsUlined(user->server)))
                                {
@@ -153,48 +163,18 @@ class ModuleServices : public Module
                return 0;
        }
        
-       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, char status)
        {
-               if (target_type == TYPE_CHANNEL)
-               {
-                       chanrec* c = (chanrec*)dest;
-                       if ((c->IsCustomModeSet('M')) && (!strchr(user->modes,'r')))
-                       {
-                               if ((Srv->IsUlined(user->nick)) || (Srv->IsUlined(user->server)))
-                               {
-                                       // user is ulined, can speak regardless
-                                       return 0;
-                               }
-                               // user noticing a +M channel and is not registered
-                               Srv->SendServ(user->fd,"477 "+std::string(user->nick)+" "+std::string(c->name)+" :You need a registered nickname to speak on this channel");
-                               return 1;
-                       }
-               }
-               if (target_type == TYPE_USER)
-               {
-                       userrec* u = (userrec*)dest;
-                       if ((strchr(u->modes,'R')) && (!strchr(user->modes,'r')))
-                       {
-                               if ((Srv->IsUlined(user->nick)) || (Srv->IsUlined(user->server)))
-                               {
-                                       // user is ulined, can speak regardless
-                                       return 0;
-                               }
-                               // user noticing a +R user and is not registered
-                               Srv->SendServ(user->fd,"477 "+std::string(user->nick)+" "+std::string(u->nick)+" :You need a registered nickname to message this user");
-                               return 1;
-                       }
-               }
-               return 0;
+               return OnUserPreMessage(user,dest,target_type,text,status);
        }
        
        virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
        {
                if (chan)
                {
-                       if (chan->IsCustomModeSet('R'))
+                       if (chan->IsModeSet('R'))
                        {
-                               if (!strchr(user->modes,'r'))
+                               if (user->modes['r'-65])
                                {
                                        if ((Srv->IsUlined(user->nick)) || (Srv->IsUlined(user->server)))
                                        {