]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_callerid.cpp
Remove current time parameter of the Timer constructor
[user/henk/code/inspircd.git] / src / modules / m_callerid.cpp
index 1a2fd3a84eda764cfdfd8b12ea1bb9d760588176..6f2c6730085560a8715ffc53fdfa09993c76970f 100644 (file)
@@ -158,13 +158,18 @@ class CommandAccept : public Command
         */
        typedef std::pair<User*, bool> ACCEPTAction;
 
-       static ACCEPTAction GetTargetAndAction(std::string& tok)
+       static ACCEPTAction GetTargetAndAction(std::string& tok, User* cmdfrom = NULL)
        {
                bool remove = (tok[0] == '-');
                if ((remove) || (tok[0] == '+'))
                        tok.erase(tok.begin());
 
-               User* target = ServerInstance->FindNick(tok);
+               User* target;
+               if (!cmdfrom || !IS_LOCAL(cmdfrom))
+                       target = ServerInstance->FindNick(tok);
+               else
+                       target = ServerInstance->FindNickOnly(tok);
+
                if ((!target) || (target->registered != REG_ALL) || (target->quitting) || (IS_SERVER(target)))
                        target = NULL;
 
@@ -216,7 +221,7 @@ public:
                }
 
                std::string tok = parameters[0];
-               ACCEPTAction action = GetTargetAndAction(tok);
+               ACCEPTAction action = GetTargetAndAction(tok, user);
                if (!action.first)
                {
                        user->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", tok.c_str());
@@ -248,7 +253,7 @@ public:
 
                // Find the target
                std::string targetstring = parameters[0];
-               ACCEPTAction action = GetTargetAndAction(targetstring);
+               ACCEPTAction action = GetTargetAndAction(targetstring, user);
                if (!action.first)
                        // Target is a "*" or source is local and the target is a list of nicks
                        return ROUTE_LOCALONLY;
@@ -383,8 +388,12 @@ public:
                tokens["CALLERID"] = "g";
        }
 
-       ModResult PreText(User* user, User* dest, std::string& text)
+       ModResult OnUserPreMessage(User* user, void* voiddest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE
        {
+               if (!IS_LOCAL(user) || target_type != TYPE_USER)
+                       return MOD_RES_PASSTHRU;
+
+               User* dest = static_cast<User*>(voiddest);
                if (!dest->IsModeSet(myumode) || (user == dest))
                        return MOD_RES_PASSTHRU;
 
@@ -411,14 +420,6 @@ public:
                return MOD_RES_PASSTHRU;
        }
 
-       ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE
-       {
-               if (IS_LOCAL(user) && target_type == TYPE_USER)
-                       return PreText(user, (User*)dest, text);
-
-               return MOD_RES_PASSTHRU;
-       }
-
        void OnUserPostNick(User* user, const std::string& oldnick) CXX11_OVERRIDE
        {
                if (!tracknick)