summaryrefslogtreecommitdiff
path: root/src
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
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')
-rw-r--r--src/actions/actions.cpp46
-rw-r--r--src/actions/actions.h1
-rw-r--r--src/dyetool/actions/actions.cpp1
-rw-r--r--src/enums/input/inputaction.h1
-rw-r--r--src/input/inputactionmap.h6
5 files changed, 55 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
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
diff --git a/src/dyetool/actions/actions.cpp b/src/dyetool/actions/actions.cpp
index 834f7d2f9..bcb5bb98d 100644
--- a/src/dyetool/actions/actions.cpp
+++ b/src/dyetool/actions/actions.cpp
@@ -109,5 +109,6 @@ impHandlerVoid(testInfo)
impHandlerVoid(craftKey)
impHandlerVoid(resetGameModifiers)
impHandlerVoid(barToChat)
+impHandlerVoid(seen)
} // namespace Actions
diff --git a/src/enums/input/inputaction.h b/src/enums/input/inputaction.h
index f6837109e..68a11baa3 100644
--- a/src/enums/input/inputaction.h
+++ b/src/enums/input/inputaction.h
@@ -624,6 +624,7 @@ enumStart(InputAction)
IGNORE_PICKUP,
RESET_MODIFIERS,
BAR_TO_CHAT,
+ SEEN,
TOTAL
}
enumEnd(InputAction);
diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h
index b8f89c7cd..91b8d8368 100644
--- a/src/input/inputactionmap.h
+++ b/src/input/inputactionmap.h
@@ -5233,6 +5233,12 @@ static const InputActionData inputActionData
"bartochat",
UseArgs_true,
Protected_true},
+ {"keySeenCmd",
+ defaultAction(&Actions::seen),
+ InputCondition::INGAME,
+ "seen|lastseen",
+ UseArgs_true,
+ Protected_true},
};
#undef defaultAction