summaryrefslogtreecommitdiff
path: root/src/actions/actions.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-02-03 19:38:05 +0300
committerAndrei Karas <akaras@inbox.ru>2016-02-03 19:38:05 +0300
commit41adf75fa42f497e9f0049a786f08f3414ed6cbd (patch)
tree31f06b0aea9041e82a0500629c68d22e4e2af37c /src/actions/actions.cpp
parentfd27023f66223f860715aecbb8660a1d6a1e0d7a (diff)
downloadmv-41adf75fa42f497e9f0049a786f08f3414ed6cbd.tar.gz
mv-41adf75fa42f497e9f0049a786f08f3414ed6cbd.tar.bz2
mv-41adf75fa42f497e9f0049a786f08f3414ed6cbd.tar.xz
mv-41adf75fa42f497e9f0049a786f08f3414ed6cbd.zip
Add chat command /seen for show seen informatin abount nick.
Diffstat (limited to 'src/actions/actions.cpp')
-rw-r--r--src/actions/actions.cpp46
1 files changed, 46 insertions, 0 deletions
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