diff options
| author | 2018-08-12 14:56:27 +0100 | |
|---|---|---|
| committer | 2018-08-12 15:01:45 +0100 | |
| commit | ba23c2b115ad3bf2632179d283165c1579332fd8 (patch) | |
| tree | 992b199acb6e10e75ab18422147de1cf377a65b4 /src/modules/m_watch.cpp | |
| parent | Pass the Extensible container to ExtensionItem::free(). (diff) | |
Convert AWAY to use cross-module events and clean up slightly.
OnSetAway has been replaced with four events. OnUserPreAway and
OnUserPreBack can be used to deny an away state change and/or
change the away message of a local user. OnUserAway and OnUserBack
allow modules to be notified that a user's away state has changed.
Diffstat (limited to 'src/modules/m_watch.cpp')
| -rw-r--r-- | src/modules/m_watch.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/modules/m_watch.cpp b/src/modules/m_watch.cpp index 82cdcb6f8..8b84132b2 100644 --- a/src/modules/m_watch.cpp +++ b/src/modules/m_watch.cpp @@ -18,6 +18,7 @@ #include "inspircd.h" +#include "modules/away.h" #define INSPIRCD_MONITOR_MANAGER_ONLY #include "m_monitor.cpp" @@ -179,7 +180,9 @@ class CommandWatch : public SplitCommand } }; -class ModuleWatch : public Module +class ModuleWatch + : public Module + , public Away::EventListener { IRCv3::Monitor::Manager manager; CommandWatch cmd; @@ -211,7 +214,8 @@ class ModuleWatch : public Module public: ModuleWatch() - : manager(this, "watch") + : Away::EventListener(this) + , manager(this, "watch") , cmd(this, manager) { } @@ -245,14 +249,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 |
