summaryrefslogtreecommitdiff
path: root/src/modules/m_restrictmsg.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-03-28 01:11:48 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-03-28 01:11:48 +0000
commit3156ab273687038ecae4004a524de4bb7bed3c03 (patch)
treebb0c5b79722ec3c358d13c5d6b6639e72d7df5c2 /src/modules/m_restrictmsg.cpp
parentc0a87dd9fc50b12f4b80699e55040648a979fdb5 (diff)
Added a module at request of [ed] which stops anyone messaging all but opers
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@925 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_restrictmsg.cpp')
-rw-r--r--src/modules/m_restrictmsg.cpp93
1 files changed, 93 insertions, 0 deletions
diff --git a/src/modules/m_restrictmsg.cpp b/src/modules/m_restrictmsg.cpp
new file mode 100644
index 000000000..d340cad77
--- /dev/null
+++ b/src/modules/m_restrictmsg.cpp
@@ -0,0 +1,93 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
+ * E-mail:
+ * <brain@chatspike.net>
+ * <Craig@chatspike.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+#include <stdio.h>
+#include <string>
+#include <vector>
+#include "users.h"
+#include "channels.h"
+#include "modules.h"
+
+/* $ModDesc: Forbids users from messaging each other. Users may still message opers and opers may message other opers. */
+
+
+class ModuleRestrictMsg : public Module
+{
+ Server *Srv;
+ public:
+
+ ModuleRestrictMsg()
+ {
+ Srv = new Server;
+ }
+
+ virtual int OnUserPreNotice(userrec* user,void* dest,int target_type, std::string &text)
+ {
+ if (target_type == TYPE_USER)
+ {
+ userrec* u = (userrec*)dest;
+ if (strchr(u->modes,'o')) || (strchr(user->modes,'o')))
+ {
+ // message allowed if:
+ // (1) the sender is opered
+ // (2) the recipient is opered
+ // (3) both are opered
+ // anything else, blocked.
+ return 0;
+ }
+ WriteServ(user->fd,"531 %s %s :You are not permitted to send private messages to this user",user->nick,u->nick);
+ return 1;
+ }
+ // however, we must allow channel messages...
+ return 0;
+ }
+
+ virtual ~ModuleRestrictMsg()
+ {
+ delete Srv;
+ }
+
+ virtual Version GetVersion()
+ {
+ return Version(1,0,0,0);
+ }
+};
+
+
+class ModuleRestrictMsgFactory : public ModuleFactory
+{
+ public:
+ ModuleRestrictMsgFactory()
+ {
+ }
+
+ ~ModuleRestrictMsgFactory()
+ {
+ }
+
+ virtual Module * CreateModule()
+ {
+ return new ModuleRestrictMsg;
+ }
+
+};
+
+
+extern "C" void * init_module( void )
+{
+ return new ModuleRestrictMsgFactory;
+}
+