mirror of
https://github.com/thelounge/thelounge
synced 2024-11-22 20:13:07 +00:00
Merge pull request #721 from thelounge/astorije/whois-idle
Add human-readable idle time in whois info
This commit is contained in:
commit
c0fa58a8b0
4 changed files with 25 additions and 0 deletions
|
@ -33,3 +33,9 @@
|
|||
is away <i>({{whois.away}})</i>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if whois.idle}}
|
||||
<div>
|
||||
<span role="button" class="user {{colorClass whois.nick}}" data-name="{{whois.nick}}">{{whois.nick}}</span>
|
||||
has been idle since {{localetime whois.idleTime}}.
|
||||
</div>
|
||||
{{/if}}
|
||||
|
|
|
@ -52,6 +52,7 @@ var inputs = [
|
|||
"raw",
|
||||
"topic",
|
||||
"list",
|
||||
"whois"
|
||||
].reduce(function(plugins, name) {
|
||||
var path = "./plugins/inputs/" + name;
|
||||
var plugin = require(path);
|
||||
|
|
15
src/plugins/inputs/whois.js
Normal file
15
src/plugins/inputs/whois.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
"use strict";
|
||||
|
||||
exports.commands = ["whois"];
|
||||
|
||||
exports.input = function(network, chan, cmd, args) {
|
||||
if (args.length === 1) {
|
||||
// This queries server of the other user and not of the current user, which
|
||||
// does not know idle time.
|
||||
// See http://superuser.com/a/272069/208074.
|
||||
network.irc.raw("WHOIS", args[0], args[0]);
|
||||
} else {
|
||||
// Re-assembling the command parsed in client.js
|
||||
network.irc.raw(`${cmd} ${args.join(" ")}`);
|
||||
}
|
||||
};
|
|
@ -27,6 +27,9 @@ module.exports = function(irc, network) {
|
|||
text: "No such nick: " + data.nick
|
||||
});
|
||||
} else {
|
||||
// Absolute datetime in milliseconds since nick is idle
|
||||
data.idleTime = Date.now() - data.idle * 1000;
|
||||
|
||||
msg = new Msg({
|
||||
type: Msg.Type.WHOIS,
|
||||
whois: data
|
||||
|
|
Loading…
Reference in a new issue