From 0f74e88f0996acff1580bcf5f2ea3dc986497339 Mon Sep 17 00:00:00 2001 From: danieldg Date: Tue, 3 Nov 2009 01:14:12 +0000 Subject: Move MODENOTICE command to a command module git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11991 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/commands/cmd_modenotice.cpp | 45 +++++++++++++++++ src/modules/m_spanningtree/protocolinterface.cpp | 8 ---- src/modules/m_spanningtree/protocolinterface.h | 1 - src/modules/m_spanningtree/treesocket2.cpp | 9 ---- src/usermanager.cpp | 61 ------------------------ 5 files changed, 45 insertions(+), 79 deletions(-) create mode 100644 src/commands/cmd_modenotice.cpp (limited to 'src') diff --git a/src/commands/cmd_modenotice.cpp b/src/commands/cmd_modenotice.cpp new file mode 100644 index 000000000..3cf4e28d0 --- /dev/null +++ b/src/commands/cmd_modenotice.cpp @@ -0,0 +1,45 @@ +/* +------------------------------------+ + * | Inspire Internet Relay Chat Daemon | + * +------------------------------------+ + * + * InspIRCd: (C) 2002-2009 InspIRCd Development Team + * See: http://wiki.inspircd.org/Credits + * + * This program is free but copyrighted software; see + * the file COPYING for details. + * + * --------------------------------------------------- + */ + +#include "inspircd.h" + +class CommandModeNotice : public Command +{ + public: + CommandModeNotice(Module* parent) : Command(parent,"MODENOTICE",2,2) { syntax = " "; } + + CmdResult Handle(const std::vector& parameters, User *src) + { + int mlen = parameters[0].length(); + for (std::vector::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); i++) + { + User* user = *i; + for (int n = 0; n < mlen; n++) + { + if (!user->IsModeSet(parameters[0][n])) + goto next_user; + } + user->Write(":%s NOTICE %s :*** From %s: %s", ServerInstance->Config->ServerName.c_str(), + user->nick.c_str(), src->nick.c_str(), parameters[1].c_str()); +next_user: ; + } + return CMD_SUCCESS; + } + + RouteDescriptor GetRouting(User* user, const std::vector& parameters) + { + return ROUTE_BROADCAST; + } +}; + +COMMAND_INIT(CommandModeNotice) diff --git a/src/modules/m_spanningtree/protocolinterface.cpp b/src/modules/m_spanningtree/protocolinterface.cpp index 2e3237efd..843361e9e 100644 --- a/src/modules/m_spanningtree/protocolinterface.cpp +++ b/src/modules/m_spanningtree/protocolinterface.cpp @@ -94,14 +94,6 @@ void SpanningTreeProtocolInterface::SendMode(const std::string &target, const pa } } -void SpanningTreeProtocolInterface::SendModeNotice(const std::string &modes, const std::string &text) -{ - parameterlist p; - p.push_back(modes); - p.push_back(":" + text); - Utils->DoOneToMany(ServerInstance->Config->GetSID(), "MODENOTICE", p); -} - void SpanningTreeProtocolInterface::SendSNONotice(const std::string &snomask, const std::string &text) { parameterlist p; diff --git a/src/modules/m_spanningtree/protocolinterface.h b/src/modules/m_spanningtree/protocolinterface.h index 74120ad47..9ba9f2d2f 100644 --- a/src/modules/m_spanningtree/protocolinterface.h +++ b/src/modules/m_spanningtree/protocolinterface.h @@ -17,7 +17,6 @@ class SpanningTreeProtocolInterface : public ProtocolInterface virtual void SendMetaData(Extensible* target, const std::string &key, const std::string &data); virtual void SendTopic(Channel* channel, std::string &topic); virtual void SendMode(const std::string &target, const parameterlist &modedata, const std::vector &types); - virtual void SendModeNotice(const std::string &modes, const std::string &text); virtual void SendSNONotice(const std::string &snomask, const std::string &text); virtual void PushToClient(User* target, const std::string &rawline); virtual void SendChannelPrivmsg(Channel* target, char status, const std::string &text); diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp index 4b5a35d49..918ce2164 100644 --- a/src/modules/m_spanningtree/treesocket2.cpp +++ b/src/modules/m_spanningtree/treesocket2.cpp @@ -422,15 +422,6 @@ void TreeSocket::ProcessConnectedLine(std::string& prefix, std::string& command, this->Squit(Utils->FindServer(params[0]),params[1]); } } - else if (command == "MODENOTICE") - { - if (params.size() >= 2) - { - ServerInstance->Users->WriteMode(params[0].c_str(), WM_AND, "*** From %s: %s", - who->nick.c_str(), params[1].c_str()); - } - Utils->DoOneToAllButSender(prefix, command, params, prefix); - } else if (command == "SNONOTICE") { if (params.size() >= 2) diff --git a/src/usermanager.cpp b/src/usermanager.cpp index 05f5d2c9d..f78ebeb57 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -386,67 +386,6 @@ void UserManager::ServerPrivmsgAll(const char* text, ...) } } -void UserManager::WriteMode(const char* modes, int flags, const char* text, ...) -{ - char textbuffer[MAXBUF]; - int modelen; - va_list argsPtr; - - if (!text || !modes || !flags) - { - ServerInstance->Logs->Log("USERS", DEFAULT,"*** BUG *** WriteMode was given an invalid parameter"); - return; - } - - va_start(argsPtr, text); - vsnprintf(textbuffer, MAXBUF, text, argsPtr); - va_end(argsPtr); - modelen = strlen(modes); - - if (flags == WM_AND) - { - for (std::vector::const_iterator i = local_users.begin(); i != local_users.end(); i++) - { - User* t = *i; - bool send_to_user = true; - - for (int n = 0; n < modelen; n++) - { - if (!t->IsModeSet(modes[n])) - { - send_to_user = false; - break; - } - } - if (send_to_user) - { - t->WriteServ("NOTICE %s :%s", t->nick.c_str(), textbuffer); - } - } - } - else if (flags == WM_OR) - { - for (std::vector::const_iterator i = local_users.begin(); i != local_users.end(); i++) - { - User* t = *i; - bool send_to_user = false; - - for (int n = 0; n < modelen; n++) - { - if (t->IsModeSet(modes[n])) - { - send_to_user = true; - break; - } - } - - if (send_to_user) - { - t->WriteServ("NOTICE %s :%s", t->nick.c_str(), textbuffer); - } - } - } -} /* return how many users have a given mode e.g. 'a' */ int UserManager::ModeCount(const char mode) -- cgit v1.2.3