Use away-notify to show user away status change

This commit is contained in:
Max Leiter 2017-07-10 09:01:20 -07:00
parent 3b049f174c
commit 163cfaba3c
11 changed files with 63 additions and 2 deletions

View file

@ -208,6 +208,8 @@ kbd {
#settings .extra-help,
#settings #play::before,
#form #submit::before,
#chat .away .from::before,
#chat .back .from::before,
#chat .invite .from::before,
#chat .join .from::before,
#chat .kick .from::before,
@ -258,6 +260,12 @@ kbd {
#form #submit::before { content: "\f1d8"; /* http://fontawesome.io/icon/paper-plane/ */ }
#chat .away .from::before,
#chat .back .from::before {
content: "\f017"; /* http://fontawesome.io/icon/clock-o/ */
color: #7f8c8d;
}
#chat .invite .from::before {
content: "\f003"; /* http://fontawesome.io/icon/envelope-o/ */
color: #2ecc40;
@ -1157,6 +1165,8 @@ kbd {
}
#chat .condensed .content,
#chat .away .content,
#chat .back .content,
#chat .join .content,
#chat .kick .content,
#chat .mode .content,

View file

@ -225,8 +225,8 @@
<div class="col-sm-12">
<h2>
Status messages
<span class="tooltipped tooltipped-n tooltipped-no-delay" aria-label="Joins, parts, kicks, nick changes, and mode changes">
<button class="extra-help" aria-label="Joins, parts, kicks, nick changes, and mode changes"></button>
<span class="tooltipped tooltipped-n tooltipped-no-delay" aria-label="Joins, parts, kicks, nick changes, away changes, and mode changes">
<button class="extra-help" aria-label="Joins, parts, kicks, nick changes, away changes, and mode changes"></button>
</span>
</h2>
</div>

View file

@ -23,6 +23,12 @@ function updateText(condensed, addedTypes) {
constants.condensedTypes.forEach((type) => {
if (obj[type]) {
switch (type) {
case "away":
strings.push(obj[type] + (obj[type] > 1 ? " users have gone away" : " user has gone away"));
break;
case "back":
strings.push(obj[type] + (obj[type] > 1 ? " users have come back" : " user has come back"));
break;
case "join":
strings.push(obj[type] + (obj[type] > 1 ? " users have joined the channel" : " user has joined the channel"));
break;

View file

@ -60,6 +60,8 @@ const commands = [
];
const actionTypes = [
"away",
"back",
"ban_list",
"invite",
"join",
@ -77,6 +79,8 @@ const actionTypes = [
];
const condensedTypes = [
"away",
"back",
"join",
"part",
"quit",

View file

@ -0,0 +1,3 @@
{{> ../user_name nick=from}}
is away
<i class="away-message">({{{parse text}}})</i>

View file

@ -0,0 +1,2 @@
{{> ../user_name nick=from}}
is back

View file

@ -3,6 +3,8 @@
module.exports = {
actions: {
action: require("./actions/action.tpl"),
away: require("./actions/away.tpl"),
back: require("./actions/back.tpl"),
ban_list: require("./actions/ban_list.tpl"),
channel_list: require("./actions/channel_list.tpl"),
ctcp: require("./actions/ctcp.tpl"),

View file

@ -16,6 +16,7 @@ module.exports = Client;
var id = 0;
var events = [
"away",
"connection",
"unhandled",
"banlist",

View file

@ -29,7 +29,9 @@ class Msg {
Msg.Type = {
UNHANDLED: "unhandled",
AWAY: "away",
ACTION: "action",
BACK: "back",
ERROR: "error",
INVITE: "invite",
JOIN: "join",

View file

@ -7,6 +7,7 @@ module.exports = User;
function User(attr, prefixLookup) {
_.defaults(this, attr, {
modes: [],
away: "",
mode: "",
nick: "",
lastMessage: 0,

View file

@ -0,0 +1,30 @@
"use strict";
const _ = require("lodash");
const Msg = require("../../models/msg");
module.exports = function(irc, network) {
const client = this;
irc.on("away", (data) => {
const away = data.message;
network.channels.forEach((chan) => {
const user = _.find(chan.users, {nick: data.nick});
if (!user || user.away === away) {
return;
}
const msg = new Msg({
type: away ? Msg.Type.AWAY : Msg.Type.BACK,
text: away || "",
time: data.time,
from: data.nick,
mode: user.mode
});
chan.pushMessage(client, msg);
user.away = away;
});
});
};