diff options
| author | 2023-01-16 04:03:17 +0000 | |
|---|---|---|
| committer | 2023-01-16 04:03:17 +0000 | |
| commit | a1e902e417846fec95e44ef553733911399f6cd3 (patch) | |
| tree | 19c78c4e8df2f41cc1166eb47130ef74d7b1a193 /src/modules/m_setidle.cpp | |
| parent | Fix 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.cpp | 23 |
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; } }; |
