mirror of
https://github.com/thelounge/thelounge
synced 2024-11-23 12:33:07 +00:00
Show user modes in channel
This commit is contained in:
parent
1f3b5710f2
commit
b801689eaa
15 changed files with 40 additions and 14 deletions
2
build.sh
2
build.sh
|
@ -11,7 +11,7 @@ if ! type handlebars &> /dev/null; then
|
|||
fi
|
||||
|
||||
# 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
|
||||
# See: Gruntfile.js
|
||||
|
|
|
@ -88,6 +88,7 @@ templates['msg'] = template({"1":function(depth0,helpers,partials,data) {
|
|||
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(((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)))
|
||||
+ "</button>\n";
|
||||
},"6":function(depth0,helpers,partials,data) {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
</span>
|
||||
<span class="from">
|
||||
{{#if from}}
|
||||
<button class="user" style="color: #{{stringcolor from}}">{{from}}</button>
|
||||
<button class="user" style="color: #{{stringcolor from}}">{{mode}}{{from}}</button>
|
||||
{{/if}}
|
||||
</span>
|
||||
<span class="text">
|
|
@ -41,6 +41,15 @@ Chan.prototype.sortUsers = function() {
|
|||
}, this);
|
||||
};
|
||||
|
||||
Chan.prototype.getMode = function(name) {
|
||||
var user = _.find(this.users, {name: name});
|
||||
if (user) {
|
||||
return user.mode;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
Chan.prototype.toJSON = function() {
|
||||
var clone = _.clone(this);
|
||||
clone.messages = clone.messages.slice(-100);
|
||||
|
|
|
@ -4,26 +4,34 @@ var Msg = require("../../models/msg");
|
|||
module.exports = function(irc, network) {
|
||||
var client = this;
|
||||
irc.on("kick", function(data) {
|
||||
var from = data.nick;
|
||||
var chan = _.findWhere(network.channels, {name: data.channel});
|
||||
var mode = chan.getMode(from);
|
||||
|
||||
if (typeof chan === "undefined") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.client == irc.me) {
|
||||
chan.users = [];
|
||||
} else {
|
||||
chan.users = _.without(chan.users, _.findWhere(chan.users, {name: data.client}));
|
||||
}
|
||||
|
||||
client.emit("users", {
|
||||
chan: chan.id,
|
||||
users: chan.users
|
||||
});
|
||||
|
||||
var self = false;
|
||||
if (data.nick.toLowerCase() == irc.me.toLowerCase()) {
|
||||
self = true;
|
||||
}
|
||||
|
||||
var msg = new Msg({
|
||||
type: Msg.Type.KICK,
|
||||
from: data.nick,
|
||||
mode: mode,
|
||||
from: from,
|
||||
text: data.client,
|
||||
self: self
|
||||
});
|
||||
|
|
|
@ -48,9 +48,11 @@ module.exports = function(irc, network) {
|
|||
chan.unread++;
|
||||
}
|
||||
|
||||
var name = data.from;
|
||||
var msg = new Msg({
|
||||
type: type || Msg.Type.MESSAGE,
|
||||
from: data.from,
|
||||
mode: chan.getMode(name),
|
||||
from: name,
|
||||
text: text,
|
||||
self: self
|
||||
});
|
||||
|
|
|
@ -9,17 +9,18 @@ module.exports = function(irc, network) {
|
|||
setTimeout(function() {
|
||||
irc.write("NAMES " + data.target);
|
||||
}, 200);
|
||||
var nick = data.nick;
|
||||
if (nick.indexOf(".") !== -1) {
|
||||
nick = data.target;
|
||||
var from = data.nick;
|
||||
if (from.indexOf(".") !== -1) {
|
||||
from = data.target;
|
||||
}
|
||||
var self = false;
|
||||
if (nick.toLowerCase() == irc.me.toLowerCase()) {
|
||||
if (from.toLowerCase() == irc.me.toLowerCase()) {
|
||||
self = true;
|
||||
}
|
||||
var msg = new Msg({
|
||||
type: Msg.Type.MODE,
|
||||
from: nick,
|
||||
mode: chan.getMode(from),
|
||||
from: from,
|
||||
text: data.mode + " " + data.client,
|
||||
self: self
|
||||
});
|
||||
|
|
|
@ -8,13 +8,14 @@ module.exports = function(irc, network) {
|
|||
if (typeof chan === "undefined") {
|
||||
return;
|
||||
}
|
||||
if (data.nick == irc.me) {
|
||||
var from = data.nick;
|
||||
if (from == irc.me) {
|
||||
network.channels = _.without(network.channels, chan);
|
||||
client.emit("part", {
|
||||
chan: chan.id
|
||||
});
|
||||
} else {
|
||||
var user = _.findWhere(chan.users, {name: data.nick});
|
||||
var user = _.findWhere(chan.users, {name: from});
|
||||
chan.users = _.without(chan.users, user);
|
||||
client.emit("users", {
|
||||
chan: chan.id,
|
||||
|
@ -22,7 +23,8 @@ module.exports = function(irc, network) {
|
|||
});
|
||||
var msg = new Msg({
|
||||
type: Msg.Type.PART,
|
||||
from: data.nick
|
||||
mode: chan.getMode(from),
|
||||
from: from
|
||||
});
|
||||
chan.messages.push(msg);
|
||||
client.emit("msg", {
|
||||
|
|
|
@ -5,7 +5,8 @@ module.exports = function(irc, network) {
|
|||
var client = this;
|
||||
irc.on("quit", function(data) {
|
||||
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") {
|
||||
return;
|
||||
}
|
||||
|
@ -16,7 +17,8 @@ module.exports = function(irc, network) {
|
|||
});
|
||||
var msg = new Msg({
|
||||
type: Msg.Type.QUIT,
|
||||
from: data.nick
|
||||
mode: chan.getMode(from),
|
||||
from: from
|
||||
});
|
||||
chan.messages.push(msg);
|
||||
client.emit("msg", {
|
||||
|
|
|
@ -15,6 +15,7 @@ module.exports = function(irc, network) {
|
|||
}
|
||||
var msg = new Msg({
|
||||
type: Msg.Type.TOPIC,
|
||||
mode: chan.getMode(from),
|
||||
from: from,
|
||||
text: data.topic,
|
||||
self: self
|
||||
|
|
Loading…
Reference in a new issue