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_ircv3.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_ircv3.cpp')
| -rw-r--r-- | src/modules/m_ircv3.cpp | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/src/modules/m_ircv3.cpp b/src/modules/m_ircv3.cpp index bbf3d7bc4..92e8a0881 100644 --- a/src/modules/m_ircv3.cpp +++ b/src/modules/m_ircv3.cpp @@ -18,10 +18,14 @@ #include "inspircd.h" #include "modules/account.h" +#include "modules/away.h" #include "modules/cap.h" #include "modules/ircv3.h" -class ModuleIRCv3 : public Module, public AccountEventListener +class ModuleIRCv3 + : public Module + , public AccountEventListener + , public Away::EventListener { Cap::Capability cap_accountnotify; Cap::Capability cap_awaynotify; @@ -32,9 +36,10 @@ class ModuleIRCv3 : public Module, public AccountEventListener public: ModuleIRCv3() : AccountEventListener(this) - , cap_accountnotify(this, "account-notify"), - cap_awaynotify(this, "away-notify"), - cap_extendedjoin(this, "extended-join") + , Away::EventListener(this) + , cap_accountnotify(this, "account-notify") + , cap_awaynotify(this, "away-notify") + , cap_extendedjoin(this, "extended-join") { } @@ -133,19 +138,24 @@ class ModuleIRCv3 : public Module, public AccountEventListener } } - ModResult OnSetAway(User* user, const std::string &awaymsg) CXX11_OVERRIDE + void OnUserAway(User* user) CXX11_OVERRIDE { - if (cap_awaynotify.IsActive()) - { - // Going away: n!u@h AWAY :reason - // Back from away: n!u@h AWAY - std::string line = ":" + user->GetFullHost() + " AWAY"; - if (!awaymsg.empty()) - line += " :" + awaymsg; + if (!cap_awaynotify.IsActive()) + return; - IRCv3::WriteNeighborsWithCap(user, line, cap_awaynotify); - } - return MOD_RES_PASSTHRU; + // Going away: n!u@h AWAY :reason + const std::string line = ":" + user->GetFullHost() + " AWAY :" + user->awaymsg; + IRCv3::WriteNeighborsWithCap(user, line, cap_awaynotify); + } + + void OnUserBack(User* user) CXX11_OVERRIDE + { + if (!cap_awaynotify.IsActive()) + return; + + // Back from away: n!u@h AWAY + const std::string line = ":" + user->GetFullHost() + " AWAY"; + IRCv3::WriteNeighborsWithCap(user, line, cap_awaynotify); } void OnPostJoin(Membership *memb) CXX11_OVERRIDE |
