summaryrefslogtreecommitdiff
path: root/src/modules/m_spanningtree/away.cpp
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2018-08-12 14:56:27 +0100
committerPeter Powell <petpow@saberuk.com>2018-08-12 15:01:45 +0100
commitba23c2b115ad3bf2632179d283165c1579332fd8 (patch)
tree992b199acb6e10e75ab18422147de1cf377a65b4 /src/modules/m_spanningtree/away.cpp
parentf8a9b6ba4ae0b4b3c7b2a408332230dd82eb4608 (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_spanningtree/away.cpp')
-rw-r--r--src/modules/m_spanningtree/away.cpp16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/modules/m_spanningtree/away.cpp b/src/modules/m_spanningtree/away.cpp
index e65b3099b..282f52a35 100644
--- a/src/modules/m_spanningtree/away.cpp
+++ b/src/modules/m_spanningtree/away.cpp
@@ -27,19 +27,19 @@ CmdResult CommandAway::HandleRemote(::RemoteUser* u, Params& params)
{
if (!params.empty())
{
- FOREACH_MOD(OnSetAway, (u, params.back()));
-
if (params.size() > 1)
u->awaytime = ConvToInt(params[0]);
else
u->awaytime = ServerInstance->Time();
u->awaymsg = params.back();
+ FOREACH_MOD_CUSTOM(awayevprov, Away::EventListener, OnUserAway, (u));
}
else
{
- FOREACH_MOD(OnSetAway, (u, ""));
+ u->awaytime = 0;
u->awaymsg.clear();
+ FOREACH_MOD_CUSTOM(awayevprov, Away::EventListener, OnUserBack, (u));
}
return CMD_SUCCESS;
}
@@ -47,12 +47,6 @@ CmdResult CommandAway::HandleRemote(::RemoteUser* u, Params& params)
CommandAway::Builder::Builder(User* user)
: CmdBuilder(user, "AWAY")
{
- push_int(user->awaytime).push_last(user->awaymsg);
-}
-
-CommandAway::Builder::Builder(User* user, const std::string& msg)
- : CmdBuilder(user, "AWAY")
-{
- if (!msg.empty())
- push_int(ServerInstance->Time()).push_last(msg);
+ if (user->awaymsg.empty())
+ push_int(user->awaytime).push_last(user->awaymsg);
}