aboutsummaryrefslogtreecommitdiff
path: root/src/modules/m_setidle.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2023-01-16 04:03:17 +0000
committerGravatar Sadie Powell2023-01-16 04:03:17 +0000
commita1e902e417846fec95e44ef553733911399f6cd3 (patch)
tree19c78c4e8df2f41cc1166eb47130ef74d7b1a193 /src/modules/m_setidle.cpp
parentFix some issues reported by scan-build. (diff)
Convert the setidle module to use standard replies.
Diffstat (limited to 'src/modules/m_setidle.cpp')
-rw-r--r--src/modules/m_setidle.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/modules/m_setidle.cpp b/src/modules/m_setidle.cpp
index e798e1a40..19a77e6eb 100644
--- a/src/modules/m_setidle.cpp
+++ b/src/modules/m_setidle.cpp
@@ -26,20 +26,22 @@
#include "inspircd.h"
-
-enum
-{
- // InspIRCd-specific.
- ERR_INVALIDIDLETIME = 948,
- RPL_IDLETIMESET = 944
-};
+#include "modules/ircv3_replies.h"
class CommandSetidle final
: public SplitCommand
{
+private:
+ IRCv3::Replies::Fail failrpl;
+ IRCv3::Replies::Fail noterpl;
+ IRCv3::Replies::CapReference stdrplcap;
+
public:
CommandSetidle(Module* Creator)
: SplitCommand(Creator, "SETIDLE", 1)
+ , failrpl(Creator)
+ , noterpl(Creator)
+ , stdrplcap(Creator)
{
access_needed = CmdAccess::OPERATOR;
syntax = { "<duration>" };
@@ -50,16 +52,17 @@ public:
unsigned long idle;
if (!InspIRCd::Duration(parameters[0], idle))
{
- user->WriteNumeric(ERR_INVALIDIDLETIME, "Invalid idle time.");
+ failrpl.SendIfCap(user, stdrplcap, this, "INVALID_IDLE_TIME", parameters[0], "Invalid idle time.");
return CmdResult::FAILURE;
}
+
user->idle_lastmsg = (ServerInstance->Time() - idle);
// minor tweak - we cant have signon time shorter than our idle time!
if (user->signon > user->idle_lastmsg)
user->signon = user->idle_lastmsg;
- ServerInstance->SNO.WriteToSnoMask('a', user->nick+" used SETIDLE to set their idle time to "+ConvToStr(idle)+" seconds");
- user->WriteNumeric(RPL_IDLETIMESET, "Idle time set.");
+ ServerInstance->SNO.WriteToSnoMask('a', user->nick+" used SETIDLE to set their idle time to "+ConvToStr(idle)+" seconds");
+ noterpl.SendIfCap(user, stdrplcap, this, "IDLE_TIME_SET", user->idle_lastmsg, "Idle time set.");
return CmdResult::SUCCESS;
}
};