]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_watch.cpp
Sync helpop chmodes s and p with docs
[user/henk/code/inspircd.git] / src / modules / m_watch.cpp
index 82cdcb6f820fe19a012c8712bb833a1eb3ed9abe..803bd2c40f2f540470d771c130a5a2e9f9652734 100644 (file)
@@ -1,6 +1,8 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
+ *   Copyright (C) 2019 Robby <robby@chatbelgie.be>
+ *   Copyright (C) 2017-2018 Sadie Powell <sadie@witchery.services>
  *   Copyright (C) 2016 Attila Molnar <attilamolnar@hush.com>
  *
  * 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"
@@ -132,7 +135,7 @@ class CommandWatch : public SplitCommand
                , manager(managerref)
        {
                allow_empty_last_param = false;
-               syntax = "[<C|L|S|l|+<nick1>|-<nick>>]";
+               syntax = "C|L|l|S|(+|-)<nick> [(+|-)<nick>]+";
        }
 
        CmdResult HandleLocal(LocalUser* user, const Params& parameters) CXX11_OVERRIDE
@@ -179,7 +182,9 @@ class CommandWatch : public SplitCommand
        }
 };
 
-class ModuleWatch : public Module
+class ModuleWatch
+       : public Module
+       , public Away::EventListener
 {
        IRCv3::Monitor::Manager manager;
        CommandWatch cmd;
@@ -211,7 +216,8 @@ class ModuleWatch : public Module
 
  public:
        ModuleWatch()
-               : manager(this, "watch")
+               : Away::EventListener(this)
+               , manager(this, "watch")
                , cmd(this, manager)
        {
        }
@@ -245,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<std::string, std::string>& tokens) CXX11_OVERRIDE
@@ -262,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);
        }
 };