diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-11-03 01:14:12 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-11-03 01:14:12 +0000 |
commit | 0f74e88f0996acff1580bcf5f2ea3dc986497339 (patch) | |
tree | 68bc797c1a7f54a91d7f3156807556f4e1be2a5d | |
parent | 7746307ab638030a4b0a8c2c3b4c577f380e29bb (diff) |
Move MODENOTICE command to a command module
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11991 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | include/modules.h | 7 | ||||
-rw-r--r-- | include/protocol.h | 6 | ||||
-rw-r--r-- | include/usermanager.h | 10 | ||||
-rw-r--r-- | src/commands/cmd_modenotice.cpp | 45 | ||||
-rw-r--r-- | src/modules/m_spanningtree/protocolinterface.cpp | 8 | ||||
-rw-r--r-- | src/modules/m_spanningtree/protocolinterface.h | 1 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treesocket2.cpp | 9 | ||||
-rw-r--r-- | src/usermanager.cpp | 61 |
8 files changed, 45 insertions, 102 deletions
diff --git a/include/modules.h b/include/modules.h index 26c4ef466..dc59abdd9 100644 --- a/include/modules.h +++ b/include/modules.h @@ -36,13 +36,6 @@ enum ModuleFlags { VF_CORE = 16 // module is a core command, can be assumed loaded on all servers }; -/** Used with SendToMode() - */ -enum WriteModeFlags { - WM_AND = 1, - WM_OR = 2 -}; - /** Used to represent an event type, for user, channel or server */ enum TargetTypeFlags { diff --git a/include/protocol.h b/include/protocol.h index ed53c3cbb..94b34ce39 100644 --- a/include/protocol.h +++ b/include/protocol.h @@ -82,12 +82,6 @@ class ProtocolInterface SendMode(target, n, types); } - /** Send a notice to users with a given mode(s). - * @param modes The modes required for the message to be sent. - * @param text The message to send. - */ - virtual void SendModeNotice(const std::string &modes, const std::string &text) { } - /** Send a notice to users with a given snomask. * @param snomask The snomask required for the message to be sent. * @param text The message to send. diff --git a/include/usermanager.h b/include/usermanager.h index eb3317b63..ba6039250 100644 --- a/include/usermanager.h +++ b/include/usermanager.h @@ -156,16 +156,6 @@ class CoreExport UserManager * @param ... The format arguments */ void ServerPrivmsgAll(const char* text, ...) CUSTOM_PRINTF(2, 3); - - /** Send text to all users with a specific set of modes - * @param modes The modes to check against, without a +, e.g. 'og' - * @param flags one of WM_OR or WM_AND. If you specify WM_OR, any one of the - * mode characters in the first parameter causes receipt of the message, and - * if you specify WM_OR, all the modes must be present. - * @param text The text format string to send - * @param ... The format arguments - */ - void WriteMode(const char* modes, int flags, const char* text, ...) CUSTOM_PRINTF(4, 5); }; #endif 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 = "<modes> <message>"; } + + CmdResult Handle(const std::vector<std::string>& parameters, User *src) + { + int mlen = parameters[0].length(); + for (std::vector<LocalUser*>::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<std::string>& 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<TranslateType> &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<LocalUser*>::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<LocalUser*>::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) |