diff options
| author | 2022-04-23 09:18:01 +0100 | |
|---|---|---|
| committer | 2022-04-23 09:18:01 +0100 | |
| commit | 455e8dadb217746be0ea9bb7b57ffa88b1d77ebb (patch) | |
| tree | 2c85b5b23b297f0e71701fdc888f8929a7ef6937 /src/modules/m_knock.cpp | |
| parent | Remove a forward declaration for a non-existent type. (diff) | |
Respect the invite announcement level when announcing knocks.
Closes #1976.
Diffstat (limited to 'src/modules/m_knock.cpp')
| -rw-r--r-- | src/modules/m_knock.cpp | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/modules/m_knock.cpp b/src/modules/m_knock.cpp index e7e55f0e9..135d61611 100644 --- a/src/modules/m_knock.cpp +++ b/src/modules/m_knock.cpp @@ -26,6 +26,7 @@ #include "inspircd.h" +#include "modules/invite.h" enum { @@ -43,8 +44,10 @@ enum */ class CommandKnock : public Command { + private: SimpleChannelModeHandler& noknockmode; ChanModeReference inviteonlymode; + Invite::API inviteapi; public: bool sendnotice; @@ -53,6 +56,7 @@ class CommandKnock : public Command : Command(Creator,"KNOCK", 2, 2) , noknockmode(Noknockmode) , inviteonlymode(Creator, "inviteonly") + , inviteapi(Creator) { syntax = "<channel> :<reason>"; Penalty = 5; @@ -85,9 +89,33 @@ class CommandKnock : public Command return CMD_FAILURE; } + // Work out who we should send the knock to. + char status; + switch (inviteapi->GetAnnounceState()) + { + case Invite::ANNOUNCE_ALL: + { + status = 0; + break; + } + + case Invite::ANNOUNCE_DYNAMIC: + { + PrefixMode* mh = ServerInstance->Modes.FindNearestPrefixMode(HALFOP_VALUE); + status = mh->GetPrefix() ? mh->GetPrefix() : '@'; + break; + } + + default: + { + status = '@'; + break; + } + } + if (sendnotice) { - c->WriteNotice(InspIRCd::Format("User %s is KNOCKing on %s (%s)", user->nick.c_str(), c->name.c_str(), parameters[1].c_str())); + c->WriteNotice(InspIRCd::Format("User %s is KNOCKing on %s (%s)", user->nick.c_str(), c->name.c_str(), parameters[1].c_str()), status); user->WriteNotice("KNOCKing on " + c->name); } @@ -97,7 +125,7 @@ class CommandKnock : public Command numeric.push(c->name).push(user->GetFullHost()).push("is KNOCKing: " + parameters[1]); ClientProtocol::Messages::Numeric numericmsg(numeric, c->name); - c->Write(ServerInstance->GetRFCEvents().numeric, numericmsg); + c->Write(ServerInstance->GetRFCEvents().numeric, numericmsg, status); user->WriteNumeric(RPL_KNOCKDLVR, c->name, "KNOCKing on channel"); } |
