X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcoremods%2Fcore_privmsg.cpp;h=34953bbe81cd1a176c941782cbe474018d8cf0f6;hb=2465f88a587199a200cdde1a11e0ac7fbd51a0da;hp=0cca5677159f33f324a1daaf3f4202cd8d558d3c;hpb=c67d3103e9f7397f0ab9631bf07a5e5547deb2c3;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/coremods/core_privmsg.cpp b/src/coremods/core_privmsg.cpp index 0cca56771..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& parameters, User* user, MessageType mt) { User *dest; @@ -87,7 +105,7 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector& 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; @@ -229,7 +247,7 @@ CmdResult MessageCommandBase::HandleMessage(const std::vector& para if (IS_LOCAL(dest)) { // direct write, same server - user->WriteTo(dest, "%s %s :%s", MessageTypeString[mt], dest->nick.c_str(), text); + dest->WriteFrom(user, "%s %s :%s", MessageTypeString[mt], dest->nick.c_str(), text); } FOREACH_MOD(OnUserMessage, (user, dest, TYPE_USER, text, 0, except_list, mt));