Handle nick
This commit is contained in:
parent
4d986537bc
commit
9ab71b2588
@ -1,3 +1,3 @@
|
|||||||
<a href="#" class="user" data-name="{{from}}">{{mode}}{{from}}</a>
|
<a href="#" class="user" data-name="{{from}}">{{mode}}{{nick}}</a>
|
||||||
is now known as
|
is now known as
|
||||||
<a href="#" class="user" data-name="{{text}}">{{mode}}{{text}}</a>
|
<a href="#" class="user" data-name="{{text}}">{{mode}}{{newnick}}</a>
|
||||||
|
@ -5,11 +5,10 @@ module.exports = function(irc, network) {
|
|||||||
var client = this;
|
var client = this;
|
||||||
irc.on("nick", function(data) {
|
irc.on("nick", function(data) {
|
||||||
var self = false;
|
var self = false;
|
||||||
var nick = data["new"];
|
if (data.nick === irc.user.nick) {
|
||||||
if (nick === irc.user.nick) {
|
|
||||||
var lobby = network.channels[0];
|
var lobby = network.channels[0];
|
||||||
var msg = new Msg({
|
var msg = new Msg({
|
||||||
text: "You're now known as " + nick,
|
text: "You're now known as " + data.newnick,
|
||||||
});
|
});
|
||||||
lobby.messages.push(msg);
|
lobby.messages.push(msg);
|
||||||
client.emit("msg", {
|
client.emit("msg", {
|
||||||
@ -20,23 +19,25 @@ module.exports = function(irc, network) {
|
|||||||
client.save();
|
client.save();
|
||||||
client.emit("nick", {
|
client.emit("nick", {
|
||||||
network: network.id,
|
network: network.id,
|
||||||
nick: nick
|
nick: data.newnick
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
network.channels.forEach(function(chan) {
|
network.channels.forEach(function(chan) {
|
||||||
var user = _.find(chan.users, {name: data.nick});
|
var user = _.find(chan.users, {name: data.nick});
|
||||||
if (typeof user === "undefined") {
|
if (typeof user === "undefined") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
user.name = nick;
|
user.name = data.newnick;
|
||||||
chan.sortUsers();
|
chan.sortUsers();
|
||||||
client.emit("users", {
|
client.emit("users", {
|
||||||
chan: chan.id
|
chan: chan.id
|
||||||
});
|
});
|
||||||
var msg = new Msg({
|
var msg = new Msg({
|
||||||
type: Msg.Type.NICK,
|
type: Msg.Type.NICK,
|
||||||
from: data.nick,
|
mode: chan.getMode(data.newnick),
|
||||||
text: nick,
|
nick: data.nick,
|
||||||
|
newnick: data.newnick,
|
||||||
self: self
|
self: self
|
||||||
});
|
});
|
||||||
chan.messages.push(msg);
|
chan.messages.push(msg);
|
||||||
|
Loading…
Reference in New Issue
Block a user