diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/messages.cpp | 8 | ||||
-rw-r--r-- | src/users.cpp | 18 |
2 files changed, 19 insertions, 7 deletions
diff --git a/src/messages.cpp b/src/messages.cpp index 312b867a3..21850134c 100644 --- a/src/messages.cpp +++ b/src/messages.cpp @@ -25,13 +25,7 @@ using namespace Message; void Away::Run(MessageSource &source, const std::vector<Anope::string> ¶ms, const Anope::map<Anope::string> &tags) { - const Anope::string &msg = !params.empty() ? params[0] : ""; - - FOREACH_MOD(OnUserAway, (source.GetUser(), msg)); - if (!msg.empty()) - Log(source.GetUser(), "away") << "is now away: " << msg; - else - Log(source.GetUser(), "away") << "is no longer away"; + source.GetUser()->SetAway(params.empty() ? "" : params[0]); } void Capab::Run(MessageSource &source, const std::vector<Anope::string> ¶ms, const Anope::map<Anope::string> &tags) diff --git a/src/users.cpp b/src/users.cpp index 63a524488..5887bba2f 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -543,6 +543,24 @@ void User::UpdateHost() } } +void User::SetAway(const Anope::string &msg, time_t ts) +{ + FOREACH_MOD(OnUserAway, (this, msg)); + if (msg.empty()) + { + this->awaymsg.clear(); + this->awaytime = 0; + Log(this, "away") << "is no longer away"; + } + else + { + this->awaymsg = msg; + this->awaytime = ts ? ts : Anope::CurTime; + Log(this, "away") << "is now away: " << msg; + } +} + + bool User::HasMode(const Anope::string &mname) const { return this->modes.count(mname); |