Merge pull request #2523 from Jay2k1/show-self-away

Display visual feedback on self away/back
This commit is contained in:
Pavel Djundik 2018-06-20 19:37:59 +03:00 committed by GitHub
commit c95b09cbac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 8 deletions

View File

@ -1,3 +1,7 @@
{{> ../user_name from}} {{#if self}}
is away {{{parse text}}}
<i class="away-message">({{{parse text}}})</i> {{else}}
{{> ../user_name from}}
is away
<i class="away-message">({{{parse text}}})</i>
{{/if}}

View File

@ -1,2 +1,6 @@
{{> ../user_name from}} {{#if self}}
is back {{{parse text}}}
{{else}}
{{> ../user_name from}}
is back
{{/if}}

View File

@ -4,9 +4,26 @@ const Msg = require("../../models/msg");
module.exports = function(irc, network) { module.exports = function(irc, network) {
const client = this; const client = this;
irc.on("away", (data) => {
irc.on("away", (data) => handleAway(Msg.Type.AWAY, data));
irc.on("back", (data) => handleAway(Msg.Type.BACK, data));
function handleAway(type, data) {
const away = data.message; const away = data.message;
if (data.self) {
const msg = new Msg({
self: true,
type: type,
text: away,
time: data.time,
});
network.channels[0].pushMessage(client, msg, true);
return;
}
network.channels.forEach((chan) => { network.channels.forEach((chan) => {
const user = chan.findUser(data.nick); const user = chan.findUser(data.nick);
@ -15,7 +32,7 @@ module.exports = function(irc, network) {
} }
const msg = new Msg({ const msg = new Msg({
type: away ? Msg.Type.AWAY : Msg.Type.BACK, type: type,
text: away || "", text: away || "",
time: data.time, time: data.time,
from: user, from: user,
@ -24,5 +41,5 @@ module.exports = function(irc, network) {
chan.pushMessage(client, msg); chan.pushMessage(client, msg);
user.away = away; user.away = away;
}); });
}); }
}; };