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