Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

[2.0] m_quietban #7

Closed
wants to merge 1 commit into from

3 participants

Shawn Smith Attila Molnar Peter Powell
Shawn Smith

This module adds a channel list mode, +q, to act as a 'quiet' ban mode. Users matching a +q will be allowed to join the channel but unable to message or notice it.

Masks are accepted in a glob-matching style; nick!user@host.

Attila Molnar
Owner

why not an extban?

Shawn Smith

Some people prefer to have a mode for it instead of using extbans.

Shawn Smith

Also there's already a version of this that supplies an extban instead of a modeletter, m_muteban.

Shawn Smith Added m_quietban for 2.0
This module adds +q style quiet bans for networks that don't use the 'owner' mode
497ad7b
Shawn Smith

Updated it slightly to make it throw an error with m_chanprotect.

Attila Molnar
Owner

i dont see why there is a need for duplicated functionality

Peter Powell

I agree with @attilamolnar. We should avoid using modes where extbans are more suitable. Didn't notice this was extras, disregard my post.

Shawn Smith

That's why this is in the extras repo and not the main one.

Attila Molnar

added

Attila Molnar attilamolnar closed this November 26, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Aug 16, 2012
Shawn Smith Added m_quietban for 2.0
This module adds +q style quiet bans for networks that don't use the 'owner' mode
497ad7b
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 123 additions and 0 deletions. Show diff stats Hide diff stats

  1. 123  2.0/m_quietban.cpp
123  2.0/m_quietban.cpp
... ...
@@ -0,0 +1,123 @@
  1
+/*
  2
+ * InspIRCd -- Internet Relay Chat Daemon
  3
+ *
  4
+ *   Copyright (C) 2012 Shawn Smith <shawn@inspircd.org>
  5
+ *
  6
+ * This file is part of InspIRCd.  InspIRCd is free software: you can
  7
+ * redistribute it and/or modify it under the terms of the GNU General Public
  8
+ * License as published by the Free Software Foundation, version 2.
  9
+ *
  10
+ * This program is distributed in the hope that it will be useful, but WITHOUT
  11
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  12
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
  13
+ * details.
  14
+ *
  15
+ * You should have received a copy of the GNU General Public License
  16
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17
+ */
  18
+
  19
+#include "inspircd.h"
  20
+#include "u_listmode.h"
  21
+
  22
+/* $ModAuthor: Shawn Smith */
  23
+/* $ModAuthorMail: shawn@inspircd.org */
  24
+/* $ModDesc: Provides channel mode +q for 'quiet' bans. */
  25
+/* $ModDepends: core 2.0-2.1 */
  26
+/* $ModConflicts: m_muteban.so */
  27
+/* $ModConflicts: m_chanprotect.so */
  28
+
  29
+/* This module was based heavily off of m_banexception.cpp
  30
+	which was in turn adapted from m_exception, which was also based
  31
+	on m_chanprotect and m_silence. */
  32
+
  33
+/** Handles +q channel mode
  34
+*/
  35
+class QuietBan : public ListModeBase
  36
+{
  37
+	public:
  38
+		QuietBan(Module* Creator) : ListModeBase(Creator, "quietban", 'q', "End of Channel Quiet List", 728, 729, true) { }
  39
+
  40
+};
  41
+
  42
+class ModuleQuietBan : public Module
  43
+{
  44
+	QuietBan qb;
  45
+
  46
+	public:
  47
+		ModuleQuietBan() : qb(this)
  48
+		{
  49
+			if (ServerInstance->Modules->Find("m_muteban.so") || ServerInstance->Modules->Find("m_chanprotect.so"))
  50
+				throw ModuleException("Can not load with: m_muteban.so or m_chanprotect.so.");
  51
+
  52
+			if (!ServerInstance->Modes->AddMode(&qb))
  53
+				throw ModuleException("Could not add new modes!");
  54
+
  55
+			/* Pupulate Implements list with the events for a List Mode */
  56
+			qb.DoImplements(this);
  57
+
  58
+			Implementation list[] = { I_OnUserPreNotice, I_OnUserPreMessage };
  59
+			ServerInstance->Modules->Attach(list, this, 2);
  60
+		}
  61
+
  62
+		virtual ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string &text, char status, CUList &exempt_list)
  63
+		{
  64
+			if (target_type == TYPE_CHANNEL)
  65
+			{
  66
+				Channel* chan = (Channel*)dest;
  67
+
  68
+				/* If the user is +v or higher they can speak regardless. */
  69
+				if (chan->GetPrefixValue(user) >= VOICE_VALUE)
  70
+					return MOD_RES_PASSTHRU;
  71
+
  72
+				/* Get the list of +q's */
  73
+				modelist *list = qb.extItem.get(chan);
  74
+
  75
+				/* No list, continue. */
  76
+				if (!list)
  77
+					return MOD_RES_PASSTHRU;
  78
+
  79
+				/* Copied from m_banredirect.cpp */
  80
+				std::string ipmask(user->nick);
  81
+				ipmask.append(1, '!').append(user->MakeHostIP());
  82
+
  83
+				/* If this matches then they match a +q, don't allow them to speak. */
  84
+				for (modelist::iterator it = list->begin(); it != list->end(); it++)
  85
+					if (InspIRCd::Match(user->GetFullHost(), it->mask) ||
  86
+						InspIRCd::Match(user->GetFullRealHost(), it->mask) ||
  87
+						InspIRCd::MatchCIDR(ipmask, it->mask))
  88
+					{
  89
+						/* lol 404 */
  90
+						user->WriteNumeric(404, "%s %s :Cannot send to channel (you're muted (+q))", user->nick.c_str(), chan->name.c_str());
  91
+						return MOD_RES_DENY;
  92
+					}
  93
+			}
  94
+
  95
+			return MOD_RES_PASSTHRU;
  96
+		}
  97
+
  98
+		virtual ModResult OnUserPreNotice(User* user, void* dest, int target_type, std::string &text, char status, CUList &exempt_list)
  99
+		{
  100
+			return OnUserPreMessage(user, dest, target_type, text, status, exempt_list);
  101
+		}
  102
+
  103
+		void OnCleanup(int target_type, void* item)
  104
+		{
  105
+			qb.DoCleanup(target_type, item);
  106
+		}
  107
+
  108
+		void OnRehash(User* user)
  109
+		{
  110
+			qb.DoRehash();
  111
+		}
  112
+
  113
+		void OnSyncChannel(Channel* chan, Module* proto, void* opaque)
  114
+		{
  115
+			qb.DoSyncChannel(chan, proto, opaque);
  116
+		}
  117
+		Version GetVersion()
  118
+		{
  119
+			return Version("Provides cahnnel mode +q for 'quiet' bans.", VF_OPTCOMMON);
  120
+		}
  121
+};
  122
+
  123
+MODULE_INIT(ModuleQuietBan)
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.