]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/commands/cmd_notice.cpp
Reduce User* -> Membership* lookups on part and kick
[user/henk/code/inspircd.git] / src / commands / cmd_notice.cpp
index e10d6286d0ec2aae568aa631501666e0536d832a..ec60127b752b21eebf274f20218b00c7c76afa31 100644 (file)
@@ -57,7 +57,9 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use
 
        CUList exempt_list;
 
-       user->idle_lastmsg = ServerInstance->Time();
+       LocalUser* localuser = IS_LOCAL(user);
+       if (localuser)
+               localuser->idle_lastmsg = ServerInstance->Time();
 
        if (ServerInstance->Parser->LoopCall(user, this, parameters, 0))
                return CMD_SUCCESS;
@@ -68,7 +70,7 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use
 
                ModResult MOD_RESULT;
                std::string temp = parameters[1];
-               FIRST_MOD_RESULT(OnUserPreNotice, MOD_RESULT, (user, (void*)parameters[0].c_str(), TYPE_SERVER, temp, 0, exempt_list));
+               FIRST_MOD_RESULT(OnUserPreMessage, MOD_RESULT, (user, (void*)parameters[0].c_str(), TYPE_SERVER, temp, 0, exempt_list, MSG_NOTICE));
                if (MOD_RESULT == MOD_RES_DENY)
                        return CMD_FAILURE;
                const char* text = temp.c_str();
@@ -79,7 +81,7 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use
                {
                        user->SendAll("NOTICE", "%s", text);
                }
-               FOREACH_MOD(I_OnUserNotice,OnUserNotice(user, (void*)parameters[0].c_str(), TYPE_SERVER, text, 0, exempt_list));
+               FOREACH_MOD(I_OnUserMessage,OnUserMessage(user, (void*)parameters[0].c_str(), TYPE_SERVER, text, 0, exempt_list, MSG_NOTICE));
                return CMD_SUCCESS;
        }
        char status = 0;
@@ -98,7 +100,7 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use
 
                if (chan)
                {
-                       if (IS_LOCAL(user))
+                       if (localuser)
                        {
                                if ((chan->IsModeSet('n')) && (!chan->HasUser(user)))
                                {
@@ -110,11 +112,20 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use
                                        user->WriteNumeric(404, "%s %s :Cannot send to channel (+m)", user->nick.c_str(), chan->name.c_str());
                                        return CMD_FAILURE;
                                }
+
+                               if (ServerInstance->Config->RestrictBannedUsers)
+                               {
+                                       if (chan->IsBanned(user))
+                                       {
+                                               user->WriteNumeric(404, "%s %s :Cannot send to channel (you're banned)", user->nick.c_str(), chan->name.c_str());
+                                               return CMD_FAILURE;
+                                       }
+                               }
                        }
                        ModResult MOD_RESULT;
 
                        std::string temp = parameters[1];
-                       FIRST_MOD_RESULT(OnUserPreNotice, MOD_RESULT, (user,chan,TYPE_CHANNEL,temp,status, exempt_list));
+                       FIRST_MOD_RESULT(OnUserPreMessage, MOD_RESULT, (user,chan,TYPE_CHANNEL,temp,status, exempt_list, MSG_NOTICE));
                        if (MOD_RESULT == MOD_RES_DENY)
                                return CMD_FAILURE;
 
@@ -144,7 +155,7 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use
                                chan->WriteAllExcept(user, false, status, exempt_list, "NOTICE %s :%s", chan->name.c_str(), text);
                        }
 
-                       FOREACH_MOD(I_OnUserNotice,OnUserNotice(user,chan,TYPE_CHANNEL,text,status,exempt_list));
+                       FOREACH_MOD(I_OnUserMessage,OnUserMessage(user,chan,TYPE_CHANNEL,text,status,exempt_list,MSG_NOTICE));
                }
                else
                {
@@ -157,7 +168,7 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use
 
        const char* destnick = parameters[0].c_str();
 
-       if (IS_LOCAL(user))
+       if (localuser)
        {
                const char* targetserver = strchr(destnick, '@');
 
@@ -180,7 +191,7 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use
        else
                dest = ServerInstance->FindNick(destnick);
 
-       if (dest)
+       if ((dest) && (dest->registered == REG_ALL))
        {
                if (parameters[1].empty())
                {
@@ -190,7 +201,7 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use
 
                ModResult MOD_RESULT;
                std::string temp = parameters[1];
-               FIRST_MOD_RESULT(OnUserPreNotice, MOD_RESULT, (user,dest,TYPE_USER,temp,0,exempt_list));
+               FIRST_MOD_RESULT(OnUserPreMessage, MOD_RESULT, (user, dest, TYPE_USER, temp, 0, exempt_list, MSG_NOTICE));
                if (MOD_RESULT == MOD_RES_DENY) {
                        return CMD_FAILURE;
                }
@@ -204,7 +215,7 @@ CmdResult CommandNotice::Handle (const std::vector<std::string>& parameters, Use
                        user->WriteTo(dest, "NOTICE %s :%s", dest->nick.c_str(), text);
                }
 
-               FOREACH_MOD(I_OnUserNotice,OnUserNotice(user,dest,TYPE_USER,text,0,exempt_list));
+               FOREACH_MOD(I_OnUserMessage, OnUserMessage(user, dest, TYPE_USER, text, 0, exempt_list, MSG_NOTICE));
        }
        else
        {