diff --git a/client/css/style.css b/client/css/style.css index 5a283571..9fa39d6e 100644 --- a/client/css/style.css +++ b/client/css/style.css @@ -666,6 +666,13 @@ button, .user { #chat.hide-quit .quit { display: none !important; } + +#chat .invite .from:before { + font-family: FontAwesome; + content: "\f003"; + color: #2ECC40; +} + #chat .join .from:before { font-family: FontAwesome; content: "\f090"; diff --git a/client/js/lounge.js b/client/js/lounge.js index 68956b9b..c4157a62 100644 --- a/client/js/lounge.js +++ b/client/js/lounge.js @@ -193,8 +193,10 @@ $(function() { var chan = chat.find(target); var from = data.msg.from; + var msg; if ([ + "invite", "join", "mode", "kick", @@ -205,6 +207,7 @@ $(function() { "action", ].indexOf(type) !== -1) { switch (type) { + case "invite": data.msg.formattedAction = "invited " + data.msg.target + " to"; break; case "join": data.msg.formattedAction = "has joined the channel"; break; case "mode": data.msg.formattedAction = "sets mode"; break; case "kick": data.msg.formattedAction = "has kicked"; break; @@ -215,12 +218,11 @@ $(function() { default: data.msg.formattedAction = ""; } - var action = $(render("msg_action", data.msg)); - return action; + msg = $(render("msg_action", data.msg)); + } else { + msg = $(render("msg", data.msg)); } - var msg = $(render("msg", data.msg)); - var text = msg.find(".text"); if (text.find("i").size() === 1) { text = text.find("i"); diff --git a/src/client.js b/src/client.js index ade5102a..2a071a12 100644 --- a/src/client.js +++ b/src/client.js @@ -17,6 +17,7 @@ var id = 0; var events = [ "ctcp", "error", + "invite", "join", "kick", "mode", diff --git a/src/models/msg.js b/src/models/msg.js index 9759e51a..9fb30e7c 100644 --- a/src/models/msg.js +++ b/src/models/msg.js @@ -4,6 +4,7 @@ var moment = require("moment"); Msg.Type = { ACTION: "action", ERROR: "error", + INVITE: "invite", JOIN: "join", KICK: "kick", MESSAGE: "message", diff --git a/src/plugins/irc-events/invite.js b/src/plugins/irc-events/invite.js new file mode 100644 index 00000000..012da8cc --- /dev/null +++ b/src/plugins/irc-events/invite.js @@ -0,0 +1,29 @@ +var _ = require("lodash"); +var Msg = require("../../models/msg"); + +module.exports = function(irc, network) { + var client = this; + irc.on("invite", function(data) { + var target = data.to; + if (target.toLowerCase() === irc.me.toLowerCase()) { + target = "you"; + } + + var chan = _.findWhere(network.channels, {name: data.channel}); + if (typeof chan === "undefined") { + chan = network.channels[0]; + } + + var msg = new Msg({ + type: Msg.Type.INVITE, + from: data.from, + target: target, + text: data.channel + }); + chan.messages.push(msg); + client.emit("msg", { + chan: chan.id, + msg: msg + }); + }); +};