From 7266f8681d603c58e1281f3e7e2934d61f910ea4 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 12 Apr 2022 12:48:54 +0100 Subject: Add a numeric builder for the ERR_CHANOPRIVSNEEDED numeric. This should make privilege errors more consistent. --- src/modules/m_timedbans.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/modules/m_timedbans.cpp') diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp index b1432270c..20ce1615a 100644 --- a/src/modules/m_timedbans.cpp +++ b/src/modules/m_timedbans.cpp @@ -93,7 +93,7 @@ class CommandTban : public Command unsigned int cm = channel->GetPrefixValue(user); if (cm < HALFOP_VALUE) { - user->WriteNumeric(ERR_CHANOPRIVSNEEDED, channel->name, "You do not have permission to set bans on this channel"); + user->WriteNumeric(Numerics::ChannelPrivilegesNeeded(channel, HALFOP_VALUE, "set timed bans")); return CMD_FAILURE; } -- cgit v1.3.1-10-gc9f91 From 73a4b470b27872f77922a75a323cc1bab1cae06e Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 12 Apr 2022 21:42:14 +0100 Subject: Use FindNearestPrefixMode instead of looking for the halfop mode. --- src/coremods/core_channel/cmd_invite.cpp | 4 ++-- src/modules/m_timedbans.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/modules/m_timedbans.cpp') diff --git a/src/coremods/core_channel/cmd_invite.cpp b/src/coremods/core_channel/cmd_invite.cpp index 81b56f949..a83fe1c1e 100644 --- a/src/coremods/core_channel/cmd_invite.cpp +++ b/src/coremods/core_channel/cmd_invite.cpp @@ -161,8 +161,8 @@ CmdResult CommandInvite::Handle(User* user, const Params& parameters) case Invite::ANNOUNCE_DYNAMIC: { - PrefixMode* mh = ServerInstance->Modes->FindPrefixMode('h'); - if ((mh) && (mh->name == "halfop")) + PrefixMode* mh = ServerInstance->Modes.FindNearestPrefixMode(HALFOP_VALUE); + if (mh) { prefix = mh->GetPrefix(); minrank = mh->GetPrefixRank(); diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp index 20ce1615a..6c442bba0 100644 --- a/src/modules/m_timedbans.cpp +++ b/src/modules/m_timedbans.cpp @@ -152,8 +152,8 @@ class CommandTban : public Command const std::string message = InspIRCd::Format("Timed ban %s added by %s on %s lasting for %s.", mask.c_str(), user->nick.c_str(), channel->name.c_str(), InspIRCd::DurationString(duration).c_str()); // If halfop is loaded, send notice to halfops and above, otherwise send to ops and above - PrefixMode* mh = ServerInstance->Modes->FindPrefixMode('h'); - char pfxchar = (mh && mh->name == "halfop") ? mh->GetPrefix() : '@'; + PrefixMode* mh = ServerInstance->Modes.FindNearestPrefixMode(HALFOP_VALUE); + char pfxchar = mh ? mh->GetPrefix() : '@'; channel->WriteRemoteNotice(message, pfxchar); } @@ -256,8 +256,8 @@ class ModuleTimedBans : public Module const std::string message = InspIRCd::Format("Timed ban %s set by %s on %s has expired.", mask.c_str(), i->setter.c_str(), cr->name.c_str()); // If halfop is loaded, send notice to halfops and above, otherwise send to ops and above - PrefixMode* mh = ServerInstance->Modes->FindPrefixMode('h'); - char pfxchar = (mh && mh->name == "halfop") ? mh->GetPrefix() : '@'; + PrefixMode* mh = ServerInstance->Modes.FindNearestPrefixMode(HALFOP_VALUE); + char pfxchar = mh ? mh->GetPrefix() : '@'; cr->WriteRemoteNotice(message, pfxchar); } -- cgit v1.3.1-10-gc9f91