summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-11-03 01:14:12 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-11-03 01:14:12 +0000
commit0f74e88f0996acff1580bcf5f2ea3dc986497339 (patch)
tree68bc797c1a7f54a91d7f3156807556f4e1be2a5d /src
parent7746307ab638030a4b0a8c2c3b4c577f380e29bb (diff)
Move MODENOTICE command to a command module
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11991 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/commands/cmd_modenotice.cpp45
-rw-r--r--src/modules/m_spanningtree/protocolinterface.cpp8
-rw-r--r--src/modules/m_spanningtree/protocolinterface.h1
-rw-r--r--src/modules/m_spanningtree/treesocket2.cpp9
-rw-r--r--src/usermanager.cpp61
5 files changed, 45 insertions, 79 deletions
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)