From 41adf75fa42f497e9f0049a786f08f3414ed6cbd Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 3 Feb 2016 19:38:05 +0300 Subject: Add chat command /seen for show seen informatin abount nick. --- src/actions/actions.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ src/actions/actions.h | 1 + 2 files changed, 47 insertions(+) (limited to 'src/actions') diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp index 169727b2a..472ea2b6d 100644 --- a/src/actions/actions.cpp +++ b/src/actions/actions.cpp @@ -103,6 +103,7 @@ #include "utils/chatutils.h" #include "utils/delete2.h" #include "utils/gettext.h" +#include "utils/files.h" #include "utils/timer.h" #include "utils/mathutils.h" @@ -1719,4 +1720,49 @@ impHandler(barToChat) return false; } +impHandler(seen) +{ + if (!actorManager) + return false; + + const std::string name = event.args; + if (name.empty()) + return false; + + ChatTab *tab = event.tab; + if (!tab) + tab = localChatTab; + if (!tab) + return false; + + std::string dir = settings.usersDir; + dir.append(stringToHexPath(name)).append("/seen.txt"); + if (Files::existsLocal(dir)) + { + StringVect lines; + Files::loadTextFileLocal(dir, lines); + if (lines.size() < 3) + { + // TRANSLATORS: last seen error + tab->chatLog(_("You not saw this nick."), + ChatMsgType::BY_SERVER); + return true; + } + const std::string message = strprintf( + // TRANSLATORS: last seen message + _("Last seen for %s: %s"), + name.c_str(), + lines[2].c_str()); + tab->chatLog(message, ChatMsgType::BY_SERVER); + } + else + { + // TRANSLATORS: last seen error + tab->chatLog(_("You not saw this nick."), + ChatMsgType::BY_SERVER); + } + + return true; +} + } // namespace Actions diff --git a/src/actions/actions.h b/src/actions/actions.h index 5581fee52..7d583527b 100644 --- a/src/actions/actions.h +++ b/src/actions/actions.h @@ -112,6 +112,7 @@ namespace Actions decHandler(craftKey); decHandler(resetGameModifiers); decHandler(barToChat); + decHandler(seen); } // namespace Actions #undef decHandler -- cgit v1.2.3-70-g09d2