]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Move User::SendAll() into core_privmsg
authorAttila Molnar <attilamolnar@hush.com>
Wed, 2 Apr 2014 10:50:04 +0000 (12:50 +0200)
committerAttila Molnar <attilamolnar@hush.com>
Wed, 2 Apr 2014 10:50:04 +0000 (12:50 +0200)
This functionality is only used by the PRIVMSG and NOTICE handlers

include/users.h
src/coremods/core_privmsg.cpp
src/users.cpp

index c90d2f26595ed3c70378b05e7a2a36a8d7ca4328..ed1abd37f4fdb071f436bcf0acd98e1caacad14a 100644 (file)
@@ -609,16 +609,6 @@ class CoreExport User : public Extensible
         */
        bool ChangeNick(const std::string& newnick, bool force = false, time_t newts = 0);
 
-       /** Send a command to all local users from this user
-        * The command given must be able to send text with the
-        * first parameter as a servermask (e.g. $*), so basically
-        * you should use PRIVMSG or NOTICE.
-        * @param command the command to send
-        * @param text The text format string to send
-        * @param ... Format arguments
-        */
-       void SendAll(const char* command, const char* text, ...) CUSTOM_PRINTF(3, 4);
-
        /** Remove this user from all channels they are on, and delete any that are now empty.
         * This is used by QUIT, and will not send part messages!
         */
index fbabc4a5c380c94cee0d92b28c272c9984ede955..34953bbe81cd1a176c941782cbe474018d8cf0f6 100644 (file)
@@ -31,6 +31,13 @@ class MessageCommandBase : public Command
        ChanModeReference moderatedmode;
        ChanModeReference noextmsgmode;
 
+       /** Send a PRIVMSG or NOTICE message to all local users from the given user
+        * @param user User sending the message
+        * @param msg The message to send
+        * @param mt Type of the message (MSG_PRIVMSG or MSG_NOTICE)
+        */
+       static void SendAll(User* user, const std::string& msg, MessageType mt);
+
  public:
        MessageCommandBase(Module* parent, MessageType mt)
                : Command(parent, MessageTypeString[mt], 2, 2)
@@ -57,6 +64,17 @@ class MessageCommandBase : public Command
        }
 };
 
+void MessageCommandBase::SendAll(User* user, const std::string& msg, MessageType mt)
+{
+       const std::string message = ":" + user->GetFullHost() + " " + MessageTypeString[mt] + " $* :" + msg;
+       const LocalUserList& list = ServerInstance->Users->local_users;
+       for (LocalUserList::const_iterator i = list.begin(); i != list.end(); ++i)
+       {
+               if ((*i)->registered == REG_ALL)
+                       (*i)->Write(message);
+       }
+}
+
 CmdResult MessageCommandBase::HandleMessage(const std::vector<std::string>& parameters, User* user, MessageType mt)
 {
        User *dest;
@@ -87,7 +105,7 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector<std::string>& para
                FOREACH_MOD(OnText, (user, (void*)parameters[0].c_str(), TYPE_SERVER, text, 0, except_list));
                if (InspIRCd::Match(ServerInstance->Config->ServerName, servermask, NULL))
                {
-                       user->SendAll(MessageTypeString[mt], "%s", text);
+                       SendAll(user, text, mt);
                }
                FOREACH_MOD(OnUserMessage, (user, (void*)parameters[0].c_str(), TYPE_SERVER, text, 0, except_list, mt));
                return CMD_SUCCESS;
index 40147b37ddd06515d6de9fa0e018fc8cf0bfa1b4..28a8bd4ea341e1102c23e920165501a7346232ce 100644 (file)
@@ -1129,19 +1129,6 @@ bool User::ChangeIdent(const std::string& newident)
        return true;
 }
 
-void User::SendAll(const char* command, const char* text, ...)
-{
-       std::string textbuffer;
-       VAFORMAT(textbuffer, text, text);
-       const std::string message = ":" + this->GetFullHost() + " " + command + " $* :" + textbuffer;
-
-       for (LocalUserList::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); i++)
-       {
-               if ((*i)->registered == REG_ALL)
-                       (*i)->Write(message);
-       }
-}
-
 /*
  * Sets a user's connection class.
  * If the class name is provided, it will be used. Otherwise, the class will be guessed using host/ip/ident/etc.