Added kick

This commit is contained in:
Mattias Erming 2014-04-06 17:46:42 +02:00
parent a23a446145
commit b5f85b422a
2 changed files with 39 additions and 21 deletions

View File

@ -16,7 +16,7 @@ models.User = Backbone.Model.extend({
models.Users = Backbone.Collection.extend({ models.Users = Backbone.Collection.extend({
model: models.User, model: models.User,
sort: function(options) { sort: function() {
this.models = _.sortBy( this.models = _.sortBy(
this.models, this.models,
function(user) { function(user) {

View File

@ -133,7 +133,7 @@ function input(json) {
case "part": case "part":
case "nick": case "nick":
if (client && args[1]) { if (client && args[1]) {
client[cmd](args[1]); client[cmd].apply(client, args.slice(1));
} }
break; break;
@ -150,11 +150,17 @@ function input(json) {
case "query": case "query":
case "whois": case "whois":
if (client && args[1]) { if (client && args[1]) {
client["whois"](args[1]); client.whois(args[1]);
} }
break; break;
case "kick": case "kick":
if (client && args[1]) {
client.kick(channel.get("name"), args[1]);
}
break;
case "mode":
break; break;
case "quit": case "quit":
@ -180,7 +186,37 @@ function event(event, data) {
}); });
break; break;
case "part":
var chan = channels.findWhere({name: data[0].channels[0]});
if (data[0].nick == this.get("client").me) {
channels.remove(chan);
return;
}
var users = chan.get("users");
users.remove(users.findWhere({name: data[0].nick}));
chan.addMessage({
from: data[0].nick,
type: "part",
});
break;
case "kick": case "kick":
var chan = channels.findWhere({name: data[0].channel});
var users = chan.get("users");
if (data[0].client == this.get("client").me) {
users.reset();
} else {
users.remove(
users.findWhere({name: data[0].client})
);
}
chan.addMessage({
from: data[0].nick,
message: data[0].client,
type: "kick",
});
break; break;
case "motd": case "motd":
@ -238,23 +274,6 @@ function event(event, data) {
channels.first().addMessage(data[0]); channels.first().addMessage(data[0]);
break; break;
case "part":
var i = data[0].channels.length;
while (i--) {
var chan = channels.findWhere({name: data[0].channels[i]});
if (data[0].nick == this.get("client").me) {
channels.remove(chan);
return;
}
var users = chan.get("users");
users.remove(users.findWhere({name: data[0].nick}));
chan.addMessage({
from: data[0].nick,
type: "part",
});
}
break;
case "quit": case "quit":
channels.each(function(chan) { channels.each(function(chan) {
var users = chan.get("users"); var users = chan.get("users");
@ -290,7 +309,6 @@ function event(event, data) {
break; break;
case "whois": case "whois":
// If this value is null, an error has occured.
if (data[1] == null) { if (data[1] == null) {
channels.first().addMessage({ channels.first().addMessage({
type: "error", type: "error",