diff options
| author | 2022-04-26 17:05:12 +0100 | |
|---|---|---|
| committer | 2022-04-26 17:09:31 +0100 | |
| commit | 4f58176bc2383aa48314f5f6da07b8cc57012d21 (patch) | |
| tree | c65653b27a1c44d6c3e4c461a5657178b11193d4 /src/modules/m_knock.cpp | |
| parent | Only write to the pid file on boot. (diff) | |
| parent | Implement support for the IRCv3 bot tag. (diff) | |
Merge branch 'insp3' into master.
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 26d4e5a64..5b0f75817 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 { @@ -57,8 +58,10 @@ enum KnockNotify : uint8_t class CommandKnock final : public Command { +private: SimpleChannelMode& noknockmode; ChanModeReference inviteonlymode; + Invite::API inviteapi; public: int notify; @@ -67,6 +70,7 @@ public: : Command(Creator,"KNOCK", 2, 2) , noknockmode(Noknockmode) , inviteonlymode(Creator, "inviteonly") + , inviteapi(Creator) { syntax = { "<channel> :<reason>" }; Penalty = 5; @@ -99,9 +103,33 @@ public: return CmdResult::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 (notify & KN_SEND_NOTICE) { - 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); } @@ -111,7 +139,7 @@ public: 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"); } |
