Vai al contenuto
Monoverse Monoverse IRC community websites by SimosNap
GitHub PULL REQUEST
inspircd/inspircd
B00mX0r 27/11/2017 00:38
OPEN
#1422 Add CHANMSG oper override
master+filter_override master
blocked
This allows for opers to override loaded modules blocking them from sending a message to a channel, such as m_chanfilter or m_muteban.

This implements and resolves https://github.com/inspircd/inspircd/issues/1161.
1 commit 1 file +44 -1 9
src/modules/m_override.cpp +44 -1
@@ -40,6 +40,7 @@ class Override : public SimpleUserModeHandler
class ModuleOverride : public Module
{
+ bool active;
bool RequireKey;
bool NoisyOverride;
bool UmodeEnabled;
@@ -78,7 +79,8 @@ class ModuleOverride : public Module
public:
ModuleOverride()
- : UmodeEnabled(false)
+ : active(false)
+ , UmodeEnabled(false)
, ou(this)
, topiclock(this, "topiclock")
, inviteonly(this, "inviteonly")
@@ -218,6 +220,47 @@ class ModuleOverride : public Module
return MOD_RES_PASSTHRU;
}
+ // Begin override for CHANMSG (bypassing external modules' privmsg restirctions such as muteban and chanfilter)
+ ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE
+ {
+ if (active)
+ return MOD_RES_PASSTHRU;
+
+ ModResult MOD_RESULT;
+
+ if (target_type == TYPE_CHANNEL && user->IsOper() && CanOverride(user, "CHANMSG"))
+ {
+ active = true;
+ FIRST_MOD_RESULT(OnUserPreMessage, MOD_RESULT, (user, dest, target_type, text, status, exempt_list, msgtype));
+ active = false;
+
+ // If there is something stopping us from sending our privmsg to the channel then we override
+ if (MOD_RESULT == MOD_RES_DENY)
+ {
+ Channel* channel = static_cast<Channel*>(dest);
+ ServerInstance->SNO->WriteGlobalSno('v',user->nick+" used oper override to send a message on "+channel->name);
+ return MOD_RES_ALLOW;
+ }
+ // We already ran FIRST_MOD_RESULT, so if there was no MOD_RES_DENY then they were all passthrus, so there's no point in re-running it anyway
+ return MOD_RES_ALLOW;
+ }
+ return MOD_RES_PASSTHRU;
+ }
+
+ // For preventing "cannot send message to channel" errors during CHANMSG override
+ ModResult OnNumeric(User* user, const Numeric::Numeric& numeric) CXX11_OVERRIDE
+ {
+ if (!active || numeric.GetNumeric() != ERR_CANNOTSENDTOCHAN)
+ return MOD_RES_PASSTHRU;
+
+ return MOD_RES_DENY;
+ }
+
+ void Prioritize() CXX11_OVERRIDE
+ {
+ ServerInstance->Modules->SetPriority(this, I_OnUserPreMessage, PRIORITY_FIRST);
+ }
+
Version GetVersion() CXX11_OVERRIDE
{
return Version("Provides support for allowing opers to override certain things",VF_VENDOR);
genius3000 27/11/2017 00:57
COMMENT
CONTRIBUTOR
Just to note it:
> override anything blocking them from sending a message to a channel

isn't entirely true as there are still 3 checks in core_privmsg prior to calling OnUserPreMessage; See [core_privmsg.cpp:L129-L151](https://github.com/inspircd/inspircd/blob/master/src/coremods/core_privmsg.cpp#L129-L151)
The checks are only ran when the user's prefix value is less than the voice value, but that leaves 'noextmsgmode' (+n) without any override.
Vedi commento su GitHub
0 Pong
0

Pong (0)

Ancora nessun Pong.