X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_callerid.cpp;h=6f2c6730085560a8715ffc53fdfa09993c76970f;hb=acccaa39641500b8a691db4136e6571102a438ed;hp=1a2fd3a84eda764cfdfd8b12ea1bb9d760588176;hpb=b7d84270bce15507775c7ec216dc1d5ad8b02a53;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp index 1a2fd3a84..6f2c67300 100644 --- a/src/modules/m_callerid.cpp +++ b/src/modules/m_callerid.cpp @@ -158,13 +158,18 @@ class CommandAccept : public Command */ typedef std::pair 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(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)