X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_watch.cpp;h=803bd2c40f2f540470d771c130a5a2e9f9652734;hb=HEAD;hp=7fa8ad8f48cc1f010dfa96be2bb4f6069255423b;hpb=d23c030c9a8fd58807438245a004e4aa5b7288ba;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_watch.cpp b/src/modules/m_watch.cpp index 7fa8ad8f4..803bd2c40 100644 --- a/src/modules/m_watch.cpp +++ b/src/modules/m_watch.cpp @@ -1,6 +1,8 @@ /* * InspIRCd -- Internet Relay Chat Daemon * + * Copyright (C) 2019 Robby + * Copyright (C) 2017-2018 Sadie Powell * Copyright (C) 2016 Attila Molnar * * This file is part of InspIRCd. InspIRCd is free software: you can @@ -18,6 +20,7 @@ #include "inspircd.h" +#include "modules/away.h" #define INSPIRCD_MONITOR_MANAGER_ONLY #include "m_monitor.cpp" @@ -36,7 +39,8 @@ enum RPL_ENDOFWATCHLIST = 607, // RPL_CLEARWATCH = 608, // unused RPL_NOWISAWAY = 609, - ERR_TOOMANYWATCH = 512 + ERR_TOOMANYWATCH = 512, + ERR_INVALIDWATCHNICK = 942 }; class CommandWatch : public SplitCommand @@ -72,7 +76,7 @@ class CommandWatch : public SplitCommand } else if (result == IRCv3::Monitor::Manager::WR_INVALIDNICK) { - user->WriteNumeric(942, nick, "Invalid nickname"); + user->WriteNumeric(ERR_INVALIDWATCHNICK, nick, "Invalid nickname"); return; } else if (result != IRCv3::Monitor::Manager::WR_OK) @@ -131,10 +135,10 @@ class CommandWatch : public SplitCommand , manager(managerref) { allow_empty_last_param = false; - syntax = "[|->]"; + syntax = "C|L|l|S|(+|-) [(+|-)]+"; } - CmdResult HandleLocal(const std::vector& parameters, LocalUser* user) + CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE { if (parameters.empty()) { @@ -178,7 +182,9 @@ class CommandWatch : public SplitCommand } }; -class ModuleWatch : public Module +class ModuleWatch + : public Module + , public Away::EventListener { IRCv3::Monitor::Manager manager; CommandWatch cmd; @@ -210,7 +216,8 @@ class ModuleWatch : public Module public: ModuleWatch() - : manager(this, "watch") + : Away::EventListener(this) + , manager(this, "watch") , cmd(this, manager) { } @@ -218,7 +225,7 @@ class ModuleWatch : public Module void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("watch"); - cmd.maxwatch = tag->getInt("maxwatch", 30, 1); + cmd.maxwatch = tag->getUInt("maxwatch", 30, 1); } void OnPostConnect(User* user) CXX11_OVERRIDE @@ -244,14 +251,14 @@ class ModuleWatch : public Module Offline(user, user->nick); } - ModResult OnSetAway(User* user, const std::string& awaymsg) CXX11_OVERRIDE + void OnUserAway(User* user) CXX11_OVERRIDE { - if (awaymsg.empty()) - SendAlert(user, user->nick, RPL_NOTAWAY, "is no longer away", ServerInstance->Time()); - else - SendAlert(user, user->nick, RPL_GONEAWAY, awaymsg.c_str(), user->awaytime); + SendAlert(user, user->nick, RPL_GONEAWAY, user->awaymsg.c_str(), user->awaytime); + } - return MOD_RES_PASSTHRU; + void OnUserBack(User* user) CXX11_OVERRIDE + { + SendAlert(user, user->nick, RPL_NOTAWAY, "is no longer away", ServerInstance->Time()); } void On005Numeric(std::map& tokens) CXX11_OVERRIDE @@ -261,7 +268,7 @@ class ModuleWatch : public Module Version GetVersion() CXX11_OVERRIDE { - return Version("Provides WATCH support", VF_VENDOR); + return Version("Adds the /WATCH command which allows users to find out when their friends are connected to the server.", VF_VENDOR); } };