diff options
author | Attila Molnar <attilamolnar@hush.com> | 2014-04-02 12:50:04 +0200 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2014-04-02 12:50:04 +0200 |
commit | 2465f88a587199a200cdde1a11e0ac7fbd51a0da (patch) | |
tree | 16fe1f66497f61a23f850592a5b31f450aa24e23 /src/coremods | |
parent | a6e68c0d346395630dee9dc69211a284360b6c62 (diff) |
Move User::SendAll() into core_privmsg
This functionality is only used by the PRIVMSG and NOTICE handlers
Diffstat (limited to 'src/coremods')
-rw-r--r-- | src/coremods/core_privmsg.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/coremods/core_privmsg.cpp b/src/coremods/core_privmsg.cpp index fbabc4a5c..34953bbe8 100644 --- a/src/coremods/core_privmsg.cpp +++ b/src/coremods/core_privmsg.cpp @@ -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; |