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

View File

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

View File

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

View File

@ -60,6 +60,8 @@ const commands = [
]; ];
const actionTypes = [ const actionTypes = [
"away",
"back",
"ban_list", "ban_list",
"invite", "invite",
"join", "join",
@ -77,6 +79,8 @@ const actionTypes = [
]; ];
const condensedTypes = [ const condensedTypes = [
"away",
"back",
"join", "join",
"part", "part",
"quit", "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 = { module.exports = {
actions: { actions: {
action: require("./actions/action.tpl"), action: require("./actions/action.tpl"),
away: require("./actions/away.tpl"),
back: require("./actions/back.tpl"),
ban_list: require("./actions/ban_list.tpl"), ban_list: require("./actions/ban_list.tpl"),
channel_list: require("./actions/channel_list.tpl"), channel_list: require("./actions/channel_list.tpl"),
ctcp: require("./actions/ctcp.tpl"), ctcp: require("./actions/ctcp.tpl"),

View File

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

View File

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

View File

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