]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Move MODENOTICE command to a command module
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 3 Nov 2009 01:14:12 +0000 (01:14 +0000)
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 3 Nov 2009 01:14:12 +0000 (01:14 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11991 e03df62e-2008-0410-955e-edbf42e46eb7

include/modules.h
include/protocol.h
include/usermanager.h
src/commands/cmd_modenotice.cpp [new file with mode: 0644]
src/modules/m_spanningtree/protocolinterface.cpp
src/modules/m_spanningtree/protocolinterface.h
src/modules/m_spanningtree/treesocket2.cpp
src/usermanager.cpp

index 26c4ef46658ef4407347498b8efd20dd0f23654e..dc59abdd91514be96dcfd3305293641ec3690377 100644 (file)
@@ -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 {
index ed53c3cbbd2bca6efe1ab8b9e9b779f3dccfa6f3..94b34ce390e13e3916216f93cddc0b113470d9de 100644 (file)
@@ -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.
index eb3317b633141fa16aca7560eac811dd725c043f..ba6039250752fedd1a09f64d9cff58414ffe6f3d 100644 (file)
@@ -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 (file)
index 0000000..3cf4e28
--- /dev/null
@@ -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)
index 2e3237efd89095662c8349e7930210fda4e893c8..843361e9e43d7043b55cdbddb8d118efe169dfe3 100644 (file)
@@ -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;
index 74120ad47fee050d48acf4aa5dfe82567c80a679..9ba9f2d2fdcb9246da6bbf372b84a3eae915a8a7 100644 (file)
@@ -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);
index 4b5a35d498e7cc5ac0dcb090c0d5f819459f12be..918ce21645a88fe151448f26dd607e5ace7e5d83 100644 (file)
@@ -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)
index 05f5d2c9dbcaa0c7437c6c44ad540214db513c9a..f78ebeb57cc87787ca4aa782edc1d4276542022e 100644 (file)
@@ -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)