summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/modules/m_restrictchans.cpp2
-rw-r--r--src/modules/m_restrictmsg.cpp93
2 files changed, 94 insertions, 1 deletions
diff --git a/src/modules/m_restrictchans.cpp b/src/modules/m_restrictchans.cpp
index b834140fe..caced3c56 100644
--- a/src/modules/m_restrictchans.cpp
+++ b/src/modules/m_restrictchans.cpp
@@ -39,7 +39,7 @@ class ModuleRestrictChans : public Module
// channel does not yet exist (record is null, about to be created IF we were to allow it)
if (!chan)
{
- WriteServ(user->fd,"530 %s %s :Only IRC operators may create new channels",user->nick, chan->name,chan->name);
+ WriteServ(user->fd,"530 %s %s :Only IRC operators may create new channels",user->nick,cname,cname);
return 1;
}
}
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;
+}
+