diff --git a/client/css/style.css b/client/css/style.css
index 4ead5c6c..03cc1fd6 100644
--- a/client/css/style.css
+++ b/client/css/style.css
@@ -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,
diff --git a/client/index.html b/client/index.html
index 44b8efed..1c00c1ca 100644
--- a/client/index.html
+++ b/client/index.html
@@ -225,8 +225,8 @@
Status messages
-
-
+
+
diff --git a/client/js/condensed.js b/client/js/condensed.js
index aa1c8808..8f98fcda 100644
--- a/client/js/condensed.js
+++ b/client/js/condensed.js
@@ -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;
diff --git a/client/js/constants.js b/client/js/constants.js
index 1dedf55f..3f408d0a 100644
--- a/client/js/constants.js
+++ b/client/js/constants.js
@@ -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",
diff --git a/client/views/actions/away.tpl b/client/views/actions/away.tpl
new file mode 100644
index 00000000..f4e52519
--- /dev/null
+++ b/client/views/actions/away.tpl
@@ -0,0 +1,3 @@
+{{> ../user_name nick=from}}
+is away
+({{{parse text}}})
diff --git a/client/views/actions/back.tpl b/client/views/actions/back.tpl
new file mode 100644
index 00000000..cb24ea5e
--- /dev/null
+++ b/client/views/actions/back.tpl
@@ -0,0 +1,2 @@
+{{> ../user_name nick=from}}
+is back
diff --git a/client/views/index.js b/client/views/index.js
index aae3c78b..50f6a93f 100644
--- a/client/views/index.js
+++ b/client/views/index.js
@@ -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"),
diff --git a/src/client.js b/src/client.js
index cb38161d..8d068cb6 100644
--- a/src/client.js
+++ b/src/client.js
@@ -16,6 +16,7 @@ module.exports = Client;
var id = 0;
var events = [
+ "away",
"connection",
"unhandled",
"banlist",
diff --git a/src/models/msg.js b/src/models/msg.js
index 019a7198..fc5e3abd 100644
--- a/src/models/msg.js
+++ b/src/models/msg.js
@@ -29,7 +29,9 @@ class Msg {
Msg.Type = {
UNHANDLED: "unhandled",
+ AWAY: "away",
ACTION: "action",
+ BACK: "back",
ERROR: "error",
INVITE: "invite",
JOIN: "join",
diff --git a/src/models/user.js b/src/models/user.js
index 2f8340f0..a813bacb 100644
--- a/src/models/user.js
+++ b/src/models/user.js
@@ -7,6 +7,7 @@ module.exports = User;
function User(attr, prefixLookup) {
_.defaults(this, attr, {
modes: [],
+ away: "",
mode: "",
nick: "",
lastMessage: 0,
diff --git a/src/plugins/irc-events/away.js b/src/plugins/irc-events/away.js
new file mode 100644
index 00000000..06aa1218
--- /dev/null
+++ b/src/plugins/irc-events/away.js
@@ -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;
+ });
+ });
+};