mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 02:59:01 -04:00
Respect the invite announcement level when announcing knocks.
Closes #1976.
This commit is contained in:
parent
c886bc0395
commit
455e8dadb2
@ -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");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user