Show user modes in channel
This commit is contained in:
parent
1f3b5710f2
commit
b801689eaa
2
build.sh
2
build.sh
|
@ -11,7 +11,7 @@ if ! type handlebars &> /dev/null; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Compile the templates
|
# Compile the templates
|
||||||
handlebars -e tpl -f client/js/shout.templates.js client/templates/
|
handlebars -e tpl -f client/js/shout.templates.js client/views/
|
||||||
|
|
||||||
# Uglify the javascript libraries
|
# Uglify the javascript libraries
|
||||||
# See: Gruntfile.js
|
# See: Gruntfile.js
|
||||||
|
|
|
@ -88,6 +88,7 @@ templates['msg'] = template({"1":function(depth0,helpers,partials,data) {
|
||||||
return " <button class=\"user\" style=\"color: #"
|
return " <button class=\"user\" style=\"color: #"
|
||||||
+ escapeExpression(((helpers.stringcolor || (depth0 && depth0.stringcolor) || helperMissing).call(depth0, (depth0 != null ? depth0.from : depth0), {"name":"stringcolor","hash":{},"data":data})))
|
+ escapeExpression(((helpers.stringcolor || (depth0 && depth0.stringcolor) || helperMissing).call(depth0, (depth0 != null ? depth0.from : depth0), {"name":"stringcolor","hash":{},"data":data})))
|
||||||
+ "\">"
|
+ "\">"
|
||||||
|
+ escapeExpression(((helper = (helper = helpers.mode || (depth0 != null ? depth0.mode : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"mode","hash":{},"data":data}) : helper)))
|
||||||
+ escapeExpression(((helper = (helper = helpers.from || (depth0 != null ? depth0.from : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"from","hash":{},"data":data}) : helper)))
|
+ escapeExpression(((helper = (helper = helpers.from || (depth0 != null ? depth0.from : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"from","hash":{},"data":data}) : helper)))
|
||||||
+ "</button>\n";
|
+ "</button>\n";
|
||||||
},"6":function(depth0,helpers,partials,data) {
|
},"6":function(depth0,helpers,partials,data) {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
</span>
|
</span>
|
||||||
<span class="from">
|
<span class="from">
|
||||||
{{#if from}}
|
{{#if from}}
|
||||||
<button class="user" style="color: #{{stringcolor from}}">{{from}}</button>
|
<button class="user" style="color: #{{stringcolor from}}">{{mode}}{{from}}</button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</span>
|
</span>
|
||||||
<span class="text">
|
<span class="text">
|
|
@ -41,6 +41,15 @@ Chan.prototype.sortUsers = function() {
|
||||||
}, this);
|
}, this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Chan.prototype.getMode = function(name) {
|
||||||
|
var user = _.find(this.users, {name: name});
|
||||||
|
if (user) {
|
||||||
|
return user.mode;
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Chan.prototype.toJSON = function() {
|
Chan.prototype.toJSON = function() {
|
||||||
var clone = _.clone(this);
|
var clone = _.clone(this);
|
||||||
clone.messages = clone.messages.slice(-100);
|
clone.messages = clone.messages.slice(-100);
|
||||||
|
|
|
@ -4,26 +4,34 @@ var Msg = require("../../models/msg");
|
||||||
module.exports = function(irc, network) {
|
module.exports = function(irc, network) {
|
||||||
var client = this;
|
var client = this;
|
||||||
irc.on("kick", function(data) {
|
irc.on("kick", function(data) {
|
||||||
|
var from = data.nick;
|
||||||
var chan = _.findWhere(network.channels, {name: data.channel});
|
var chan = _.findWhere(network.channels, {name: data.channel});
|
||||||
|
var mode = chan.getMode(from);
|
||||||
|
|
||||||
if (typeof chan === "undefined") {
|
if (typeof chan === "undefined") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.client == irc.me) {
|
if (data.client == irc.me) {
|
||||||
chan.users = [];
|
chan.users = [];
|
||||||
} else {
|
} else {
|
||||||
chan.users = _.without(chan.users, _.findWhere(chan.users, {name: data.client}));
|
chan.users = _.without(chan.users, _.findWhere(chan.users, {name: data.client}));
|
||||||
}
|
}
|
||||||
|
|
||||||
client.emit("users", {
|
client.emit("users", {
|
||||||
chan: chan.id,
|
chan: chan.id,
|
||||||
users: chan.users
|
users: chan.users
|
||||||
});
|
});
|
||||||
|
|
||||||
var self = false;
|
var self = false;
|
||||||
if (data.nick.toLowerCase() == irc.me.toLowerCase()) {
|
if (data.nick.toLowerCase() == irc.me.toLowerCase()) {
|
||||||
self = true;
|
self = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var msg = new Msg({
|
var msg = new Msg({
|
||||||
type: Msg.Type.KICK,
|
type: Msg.Type.KICK,
|
||||||
from: data.nick,
|
mode: mode,
|
||||||
|
from: from,
|
||||||
text: data.client,
|
text: data.client,
|
||||||
self: self
|
self: self
|
||||||
});
|
});
|
||||||
|
|
|
@ -48,9 +48,11 @@ module.exports = function(irc, network) {
|
||||||
chan.unread++;
|
chan.unread++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var name = data.from;
|
||||||
var msg = new Msg({
|
var msg = new Msg({
|
||||||
type: type || Msg.Type.MESSAGE,
|
type: type || Msg.Type.MESSAGE,
|
||||||
from: data.from,
|
mode: chan.getMode(name),
|
||||||
|
from: name,
|
||||||
text: text,
|
text: text,
|
||||||
self: self
|
self: self
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,17 +9,18 @@ module.exports = function(irc, network) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
irc.write("NAMES " + data.target);
|
irc.write("NAMES " + data.target);
|
||||||
}, 200);
|
}, 200);
|
||||||
var nick = data.nick;
|
var from = data.nick;
|
||||||
if (nick.indexOf(".") !== -1) {
|
if (from.indexOf(".") !== -1) {
|
||||||
nick = data.target;
|
from = data.target;
|
||||||
}
|
}
|
||||||
var self = false;
|
var self = false;
|
||||||
if (nick.toLowerCase() == irc.me.toLowerCase()) {
|
if (from.toLowerCase() == irc.me.toLowerCase()) {
|
||||||
self = true;
|
self = true;
|
||||||
}
|
}
|
||||||
var msg = new Msg({
|
var msg = new Msg({
|
||||||
type: Msg.Type.MODE,
|
type: Msg.Type.MODE,
|
||||||
from: nick,
|
mode: chan.getMode(from),
|
||||||
|
from: from,
|
||||||
text: data.mode + " " + data.client,
|
text: data.mode + " " + data.client,
|
||||||
self: self
|
self: self
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,13 +8,14 @@ module.exports = function(irc, network) {
|
||||||
if (typeof chan === "undefined") {
|
if (typeof chan === "undefined") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (data.nick == irc.me) {
|
var from = data.nick;
|
||||||
|
if (from == irc.me) {
|
||||||
network.channels = _.without(network.channels, chan);
|
network.channels = _.without(network.channels, chan);
|
||||||
client.emit("part", {
|
client.emit("part", {
|
||||||
chan: chan.id
|
chan: chan.id
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var user = _.findWhere(chan.users, {name: data.nick});
|
var user = _.findWhere(chan.users, {name: from});
|
||||||
chan.users = _.without(chan.users, user);
|
chan.users = _.without(chan.users, user);
|
||||||
client.emit("users", {
|
client.emit("users", {
|
||||||
chan: chan.id,
|
chan: chan.id,
|
||||||
|
@ -22,7 +23,8 @@ module.exports = function(irc, network) {
|
||||||
});
|
});
|
||||||
var msg = new Msg({
|
var msg = new Msg({
|
||||||
type: Msg.Type.PART,
|
type: Msg.Type.PART,
|
||||||
from: data.nick
|
mode: chan.getMode(from),
|
||||||
|
from: from
|
||||||
});
|
});
|
||||||
chan.messages.push(msg);
|
chan.messages.push(msg);
|
||||||
client.emit("msg", {
|
client.emit("msg", {
|
||||||
|
|
|
@ -5,7 +5,8 @@ module.exports = function(irc, network) {
|
||||||
var client = this;
|
var client = this;
|
||||||
irc.on("quit", function(data) {
|
irc.on("quit", function(data) {
|
||||||
network.channels.forEach(function(chan) {
|
network.channels.forEach(function(chan) {
|
||||||
var user = _.findWhere(chan.users, {name: data.nick});
|
var from = data.nick;
|
||||||
|
var user = _.findWhere(chan.users, {name: from});
|
||||||
if (typeof user === "undefined") {
|
if (typeof user === "undefined") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +17,8 @@ module.exports = function(irc, network) {
|
||||||
});
|
});
|
||||||
var msg = new Msg({
|
var msg = new Msg({
|
||||||
type: Msg.Type.QUIT,
|
type: Msg.Type.QUIT,
|
||||||
from: data.nick
|
mode: chan.getMode(from),
|
||||||
|
from: from
|
||||||
});
|
});
|
||||||
chan.messages.push(msg);
|
chan.messages.push(msg);
|
||||||
client.emit("msg", {
|
client.emit("msg", {
|
||||||
|
|
|
@ -15,6 +15,7 @@ module.exports = function(irc, network) {
|
||||||
}
|
}
|
||||||
var msg = new Msg({
|
var msg = new Msg({
|
||||||
type: Msg.Type.TOPIC,
|
type: Msg.Type.TOPIC,
|
||||||
|
mode: chan.getMode(from),
|
||||||
from: from,
|
from: from,
|
||||||
text: data.topic,
|
text: data.topic,
|
||||||
self: self
|
self: self
|
||||||
|
|
Loading…
Reference in New Issue