X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcoremods%2Fcore_privmsg.cpp;h=692a661b3aea7cd9368df2a0b2259a9fd203df3a;hb=a032cd90ad5582914759e226085efee5aae1a1ef;hp=65609df00acaaaa20029b3d1468a46924a257302;hpb=4567a325b8cfc87ddf1aea1c0db7623d3b068931;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/coremods/core_privmsg.cpp b/src/coremods/core_privmsg.cpp index 65609df00..692a661b3 100644 --- a/src/coremods/core_privmsg.cpp +++ b/src/coremods/core_privmsg.cpp @@ -95,12 +95,24 @@ class MessageCommandBase : public Command 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) - * @param tags Message tags to include in the outgoing protocol message + * @param source The user sending the message. + * @param msg The details of the message to send. */ - static void SendAll(User* user, const std::string& msg, MessageType mt, const ClientProtocol::TagMap& tags); + static void SendAll(User* source, const MessageDetails& details) + { + ClientProtocol::Messages::Privmsg message(ClientProtocol::Messages::Privmsg::nocopy, source, "$*", details.text, details.type); + message.AddTags(details.tags_out); + message.SetSideEffect(true); + ClientProtocol::Event messageevent(ServerInstance->GetRFCEvents().privmsg, message); + + const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers(); + for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); ++i) + { + LocalUser* user = *i; + if ((user->registered == REG_ALL) && (!details.exemptions.count(user))) + user->Send(messageevent); + } + } public: MessageCommandBase(Module* parent, MessageType mt) @@ -128,30 +140,11 @@ class MessageCommandBase : public Command } }; -void MessageCommandBase::SendAll(User* user, const std::string& msg, MessageType mt, const ClientProtocol::TagMap& tags) -{ - ClientProtocol::Messages::Privmsg message(ClientProtocol::Messages::Privmsg::nocopy, user, "$*", msg, mt); - message.AddTags(tags); - message.SetSideEffect(true); - ClientProtocol::Event messageevent(ServerInstance->GetRFCEvents().privmsg, message); - - const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers(); - for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); ++i) - { - if ((*i)->registered == REG_ALL) - (*i)->Send(messageevent); - } -} - CmdResult MessageCommandBase::HandleMessage(User* user, const Params& parameters, MessageType mt) { User *dest; Channel *chan; - LocalUser* localuser = IS_LOCAL(user); - if (localuser) - localuser->idle_lastmsg = ServerInstance->Time(); - if (CommandParser::LoopCall(user, this, parameters, 0)) return CMD_SUCCESS; @@ -175,7 +168,7 @@ CmdResult MessageCommandBase::HandleMessage(User* user, const Params& parameters FOREACH_MOD(OnUserMessage, (user, msgtarget, msgdetails)); if (InspIRCd::Match(ServerInstance->Config->ServerName, servername, NULL)) { - SendAll(user, msgdetails.text, mt, msgdetails.tags_out); + SendAll(user, msgdetails); } FOREACH_MOD(OnUserPostMessage, (user, msgtarget, msgdetails)); return CMD_SUCCESS; @@ -195,7 +188,7 @@ CmdResult MessageCommandBase::HandleMessage(User* user, const Params& parameters if (chan) { - if (localuser && chan->GetPrefixValue(user) < VOICE_VALUE) + if (IS_LOCAL(user) && chan->GetPrefixValue(user) < VOICE_VALUE) { if (chan->IsModeSet(noextmsgmode) && !chan->HasUser(user)) { @@ -259,7 +252,7 @@ CmdResult MessageCommandBase::HandleMessage(User* user, const Params& parameters const char* destnick = parameters[0].c_str(); - if (localuser) + if (IS_LOCAL(user)) { const char* targetserver = strchr(destnick, '@'); @@ -357,6 +350,20 @@ class ModuleCoreMessage : public Module { } + void OnUserPostMessage(User* user, const MessageTarget& target, const MessageDetails& details) CXX11_OVERRIDE + { + // We only handle the idle times of local users. + LocalUser* luser = IS_LOCAL(user); + if (!luser) + return; + + // We don't update the idle time when a CTCP reply is sent. + if (details.type == MSG_NOTICE && details.IsCTCP()) + return; + + luser->idle_lastmsg = ServerInstance->Time(); + } + Version GetVersion() CXX11_OVERRIDE { return Version("PRIVMSG, NOTICE", VF_CORE|VF_VENDOR);