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 .nick .text,
|
||||||
#chat .part .text,
|
#chat .part .text,
|
||||||
#chat .quit .text,
|
#chat .quit .text,
|
||||||
#chat .topic .text {
|
#chat .topic .text,
|
||||||
|
#chat .topic_set_by .text {
|
||||||
color: #999;
|
color: #999;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,6 +221,7 @@ $(function() {
|
|||||||
"part",
|
"part",
|
||||||
"quit",
|
"quit",
|
||||||
"topic",
|
"topic",
|
||||||
|
"topic_set_by",
|
||||||
"action",
|
"action",
|
||||||
"whois",
|
"whois",
|
||||||
].indexOf(type) !== -1) {
|
].indexOf(type) !== -1) {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{{#if isSetByChan}}
|
{{#if from}}
|
||||||
The topic is:
|
|
||||||
{{else}}
|
|
||||||
<a href="#" class="user" data-name="{{from}}">{{mode}}{{from}}</a>
|
<a href="#" class="user" data-name="{{from}}">{{mode}}{{from}}</a>
|
||||||
has changed the topic to:
|
has changed the topic to:
|
||||||
|
{{else}}
|
||||||
|
The topic is:
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
<span class="new-topic">{{{parse text}}}</span>
|
<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",
|
QUIT: "quit",
|
||||||
TOGGLE: "toggle",
|
TOGGLE: "toggle",
|
||||||
TOPIC: "topic",
|
TOPIC: "topic",
|
||||||
|
TOPIC_SET_BY: "topic_set_by",
|
||||||
WHOIS: "whois"
|
WHOIS: "whois"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ module.exports = function(irc, network) {
|
|||||||
// Self messages are never highlighted
|
// Self messages are never highlighted
|
||||||
// Non-self messages are highlighted as soon as the nick is detected
|
// Non-self messages are highlighted as soon as the nick is detected
|
||||||
var highlight = !self && data.msg.split(" ").some(function(w) {
|
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) {
|
if (chan.id !== client.activeChannel) {
|
||||||
|
@ -4,7 +4,7 @@ var Msg = require("../../models/msg");
|
|||||||
module.exports = function(irc, network) {
|
module.exports = function(irc, network) {
|
||||||
var client = this;
|
var client = this;
|
||||||
irc.on("part", function(data) {
|
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") {
|
if (typeof chan === "undefined") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -23,9 +23,9 @@ module.exports = function(irc, network) {
|
|||||||
});
|
});
|
||||||
var msg = new Msg({
|
var msg = new Msg({
|
||||||
type: Msg.Type.PART,
|
type: Msg.Type.PART,
|
||||||
mode: chan.getMode(from),
|
mode: user.mode || "",
|
||||||
text: data.message || "",
|
text: data.message || "",
|
||||||
hostmask:data.hostmask.username + "@" + data.hostmask.hostname,
|
hostmask: data.ident + "@" + data.hostname,
|
||||||
from: from
|
from: from
|
||||||
});
|
});
|
||||||
chan.messages.push(msg);
|
chan.messages.push(msg);
|
||||||
|
@ -16,9 +16,9 @@ module.exports = function(irc, network) {
|
|||||||
});
|
});
|
||||||
var msg = new Msg({
|
var msg = new Msg({
|
||||||
type: Msg.Type.QUIT,
|
type: Msg.Type.QUIT,
|
||||||
mode: chan.getMode(from),
|
mode: user.mode || "",
|
||||||
text: data.message || "",
|
text: data.message || "",
|
||||||
hostmask: data.hostmask.username + "@" + data.hostmask.hostname,
|
hostmask: data.ident + "@" + data.hostname,
|
||||||
from: from
|
from: from
|
||||||
});
|
});
|
||||||
chan.messages.push(msg);
|
chan.messages.push(msg);
|
||||||
|
@ -8,26 +8,44 @@ module.exports = function(irc, network) {
|
|||||||
if (typeof chan === "undefined") {
|
if (typeof chan === "undefined") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var from = data.nick || chan.name;
|
|
||||||
var topic = data.topic;
|
|
||||||
|
|
||||||
var msg = new Msg({
|
var msg = new Msg({
|
||||||
type: Msg.Type.TOPIC,
|
type: Msg.Type.TOPIC,
|
||||||
mode: chan.getMode(from),
|
mode: (data.nick && chan.getMode(data.nick)) || "",
|
||||||
from: from,
|
from: data.nick,
|
||||||
text: topic,
|
text: data.topic,
|
||||||
isSetByChan: from === chan.name,
|
self: data.nick === irc.user.nick
|
||||||
self: from === irc.user.nick
|
|
||||||
});
|
});
|
||||||
chan.messages.push(msg);
|
chan.messages.push(msg);
|
||||||
client.emit("msg", {
|
client.emit("msg", {
|
||||||
chan: chan.id,
|
chan: chan.id,
|
||||||
msg: msg
|
msg: msg
|
||||||
});
|
});
|
||||||
chan.topic = topic;
|
|
||||||
|
chan.topic = data.topic;
|
||||||
client.emit("topic", {
|
client.emit("topic", {
|
||||||
chan: chan.id,
|
chan: chan.id,
|
||||||
topic: chan.topic
|
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