Added /nick command
This commit is contained in:
parent
cea2994aea
commit
bc5e5ee5fc
@ -50,13 +50,13 @@ models.Channel = Backbone.Model.extend({
|
||||
|
||||
this.set("users", new models.UserCollection());
|
||||
this.get("users").on(
|
||||
"add remove",
|
||||
function(model, collection) {
|
||||
"add change remove",
|
||||
function() {
|
||||
// Bubble event
|
||||
this.trigger(
|
||||
"users", {
|
||||
target: this.get("id"),
|
||||
data: collection
|
||||
data: this.get("users")
|
||||
}
|
||||
);
|
||||
},
|
||||
@ -66,12 +66,12 @@ models.Channel = Backbone.Model.extend({
|
||||
this.set("messages", new models.MessageCollection());
|
||||
this.get("messages").on(
|
||||
"add",
|
||||
function(model, collection) {
|
||||
function() {
|
||||
// Bubble event
|
||||
this.trigger(
|
||||
"messages", {
|
||||
target: this.get("id"),
|
||||
data: collection.last()
|
||||
data: this.get("messages").last()
|
||||
}
|
||||
);
|
||||
},
|
||||
|
@ -20,11 +20,12 @@ Server.prototype.listen = function(port) {
|
||||
this.networks.on(
|
||||
"all",
|
||||
function(type, data) {
|
||||
if (type == "users" || type == "messages") {
|
||||
self.sockets.emit(type, data);
|
||||
} else {
|
||||
self.sockets.emit("networks", self.networks);
|
||||
if (type != "users" && type != "messages") {
|
||||
type = "networks";
|
||||
data = self.networks;
|
||||
}
|
||||
self.sockets
|
||||
.emit(type, data);
|
||||
}
|
||||
);
|
||||
|
||||
@ -126,6 +127,13 @@ function handleInput(input) {
|
||||
}
|
||||
break;
|
||||
|
||||
case "NICK":
|
||||
var irc = target.network.irc;
|
||||
if (argv[1] && typeof irc !== "undefined") {
|
||||
irc.send("NICK", argv[1]);
|
||||
}
|
||||
break;
|
||||
|
||||
case "TOPIC":
|
||||
var irc = target.network.irc;
|
||||
if (typeof irc !== "undefined") {
|
||||
@ -207,8 +215,8 @@ function handleEvent(argv) {
|
||||
user: from,
|
||||
text: "notice: " + argv.args[1]
|
||||
});
|
||||
channels.each(function(c) {
|
||||
c.get("messages").add(message);
|
||||
channels.each(function(channel) {
|
||||
channel.get("messages").add(message);
|
||||
});
|
||||
break;
|
||||
|
||||
@ -258,6 +266,23 @@ function handleEvent(argv) {
|
||||
}
|
||||
break;
|
||||
|
||||
case "NICK":
|
||||
var message = new models.Message({
|
||||
user: argv.nick,
|
||||
text: "changed name to " + argv.args[0]
|
||||
});
|
||||
if (network.get("nick") == argv.nick) {
|
||||
network.set("nick", argv.nick);
|
||||
}
|
||||
channels.each(function(channel) {
|
||||
var user = channel.get("users").findWhere({name: argv.nick});
|
||||
if (typeof user !== "undefined") {
|
||||
user.set("name", argv.args[0]);
|
||||
channel.get("messages").add(message);
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
case "TOPIC":
|
||||
var channel = channels.findWhere({name: argv.args[0]});
|
||||
var messages = channel.get("messages");
|
||||
@ -309,6 +334,7 @@ function handleEvent(argv) {
|
||||
);
|
||||
break;
|
||||
|
||||
case "err_nicknameinuse":
|
||||
case "err_chanoprivsneeded":
|
||||
case "err_notonchannel":
|
||||
case "err_nosuchchannel":
|
||||
@ -316,7 +342,7 @@ function handleEvent(argv) {
|
||||
case "err_nosuchnick":
|
||||
channels.first().get("messages").add(
|
||||
new models.Message({
|
||||
text: argv.args[2]
|
||||
text: argv.args.slice(2).join(" ")
|
||||
})
|
||||
);
|
||||
break;
|
||||
@ -325,7 +351,7 @@ function handleEvent(argv) {
|
||||
channels.first().get("messages").add(
|
||||
new models.Message({
|
||||
user: "-!-",
|
||||
text: argv.args[1]
|
||||
text: argv.args.slice(1).join(" ")
|
||||
})
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user