Handle parts, quits, topics and topic set by
This commit is contained in:
parent
da425fefaf
commit
e380319400
@ -789,7 +789,8 @@ button,
|
||||
#chat .nick .text,
|
||||
#chat .part .text,
|
||||
#chat .quit .text,
|
||||
#chat .topic .text {
|
||||
#chat .topic .text,
|
||||
#chat .topic_set_by .text {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
|
@ -221,6 +221,7 @@ $(function() {
|
||||
"part",
|
||||
"quit",
|
||||
"topic",
|
||||
"topic_set_by",
|
||||
"action",
|
||||
"whois",
|
||||
].indexOf(type) !== -1) {
|
||||
|
@ -1,8 +1,8 @@
|
||||
{{#if isSetByChan}}
|
||||
The topic is:
|
||||
{{else}}
|
||||
{{#if from}}
|
||||
<a href="#" class="user" data-name="{{from}}">{{mode}}{{from}}</a>
|
||||
has changed the topic to:
|
||||
{{else}}
|
||||
The topic is:
|
||||
{{/if}}
|
||||
|
||||
<span class="new-topic">{{{parse text}}}</span>
|
||||
|
1
client/views/actions/topic_set_by.tpl
Normal file
1
client/views/actions/topic_set_by.tpl
Normal file
@ -0,0 +1 @@
|
||||
Topic set by {{nick}} on {{when}}
|
@ -15,6 +15,7 @@ Msg.Type = {
|
||||
QUIT: "quit",
|
||||
TOGGLE: "toggle",
|
||||
TOPIC: "topic",
|
||||
TOPIC_SET_BY: "topic_set_by",
|
||||
WHOIS: "whois"
|
||||
};
|
||||
|
||||
|
@ -46,7 +46,7 @@ module.exports = function(irc, network) {
|
||||
// Self messages are never highlighted
|
||||
// Non-self messages are highlighted as soon as the nick is detected
|
||||
var highlight = !self && data.msg.split(" ").some(function(w) {
|
||||
return (w.replace(/^@/, "").toLowerCase().indexOf(irc.me.toLowerCase()) === 0);
|
||||
return (w.replace(/^@/, "").toLowerCase().indexOf(irc.user.nick.toLowerCase()) === 0);
|
||||
});
|
||||
|
||||
if (chan.id !== client.activeChannel) {
|
||||
|
@ -4,7 +4,7 @@ var Msg = require("../../models/msg");
|
||||
module.exports = function(irc, network) {
|
||||
var client = this;
|
||||
irc.on("part", function(data) {
|
||||
var chan = _.find(network.channels, {name: data.channels[0]});
|
||||
var chan = _.find(network.channels, {name: data.channel});
|
||||
if (typeof chan === "undefined") {
|
||||
return;
|
||||
}
|
||||
@ -23,9 +23,9 @@ module.exports = function(irc, network) {
|
||||
});
|
||||
var msg = new Msg({
|
||||
type: Msg.Type.PART,
|
||||
mode: chan.getMode(from),
|
||||
mode: user.mode || "",
|
||||
text: data.message || "",
|
||||
hostmask:data.hostmask.username + "@" + data.hostmask.hostname,
|
||||
hostmask: data.ident + "@" + data.hostname,
|
||||
from: from
|
||||
});
|
||||
chan.messages.push(msg);
|
||||
|
@ -16,9 +16,9 @@ module.exports = function(irc, network) {
|
||||
});
|
||||
var msg = new Msg({
|
||||
type: Msg.Type.QUIT,
|
||||
mode: chan.getMode(from),
|
||||
mode: user.mode || "",
|
||||
text: data.message || "",
|
||||
hostmask: data.hostmask.username + "@" + data.hostmask.hostname,
|
||||
hostmask: data.ident + "@" + data.hostname,
|
||||
from: from
|
||||
});
|
||||
chan.messages.push(msg);
|
||||
|
@ -8,26 +8,44 @@ module.exports = function(irc, network) {
|
||||
if (typeof chan === "undefined") {
|
||||
return;
|
||||
}
|
||||
var from = data.nick || chan.name;
|
||||
var topic = data.topic;
|
||||
|
||||
var msg = new Msg({
|
||||
type: Msg.Type.TOPIC,
|
||||
mode: chan.getMode(from),
|
||||
from: from,
|
||||
text: topic,
|
||||
isSetByChan: from === chan.name,
|
||||
self: from === irc.user.nick
|
||||
mode: (data.nick && chan.getMode(data.nick)) || "",
|
||||
from: data.nick,
|
||||
text: data.topic,
|
||||
self: data.nick === irc.user.nick
|
||||
});
|
||||
chan.messages.push(msg);
|
||||
client.emit("msg", {
|
||||
chan: chan.id,
|
||||
msg: msg
|
||||
});
|
||||
chan.topic = topic;
|
||||
|
||||
chan.topic = data.topic;
|
||||
client.emit("topic", {
|
||||
chan: chan.id,
|
||||
topic: chan.topic
|
||||
});
|
||||
});
|
||||
|
||||
irc.on("topicsetby", function(data) {
|
||||
var chan = _.find(network.channels, {name: data.channel});
|
||||
if (typeof chan === "undefined") {
|
||||
return;
|
||||
}
|
||||
|
||||
var msg = new Msg({
|
||||
type: Msg.Type.TOPIC_SET_BY,
|
||||
mode: chan.getMode(data.nick),
|
||||
nick: data.nick,
|
||||
when: data.when,
|
||||
self: data.nick === irc.user.nick
|
||||
});
|
||||
chan.messages.push(msg);
|
||||
client.emit("msg", {
|
||||
chan: chan.id,
|
||||
msg: msg
|
||||
});
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user