Added /whois command

This commit is contained in:
Mattias Erming 2014-03-14 14:24:47 +01:00
parent cc4b6cdfe5
commit 5a7a93947f
1 changed files with 50 additions and 13 deletions

View File

@ -167,6 +167,13 @@ function handleInput(input) {
}
break;
case "WHOIS":
var irc = network.irc;
if (typeof irc !== "undefined") {
irc.send(cmd, argv[1] || target.channel.get("name"));
}
break;
default:
channel.get("messages").add(
new models.Message({
@ -187,16 +194,6 @@ function handleEvent(argv) {
switch (event) {
case "ERROR":
var args = argv.args;
channels.first().get("messages").add(
new models.Message({
text: args[args.length - 1],
type: "error"
})
);
break;
case "PRIVMSG":
var target = argv.args[0];
if (target.charAt(0) != "#") {
@ -229,6 +226,7 @@ function handleEvent(argv) {
text: "notice: " + argv.args[1],
type: "notice"
});
channels.each(function(channel) {
channel.get("messages").add(message);
});
@ -254,6 +252,7 @@ function handleEvent(argv) {
})
);
}
messages.add(
new models.Message({
user: argv.nick,
@ -290,6 +289,7 @@ function handleEvent(argv) {
user: argv.nick,
text: "changed name to " + argv.args[0]
});
channels.each(function(channel) {
var user = channel.get("users").findWhere({name: argv.nick});
if (typeof user !== "undefined") {
@ -297,6 +297,7 @@ function handleEvent(argv) {
channel.get("messages").add(message);
}
});
if (argv.nick == network.get("nick")) {
network.set("nick", argv.args[0]);
}
@ -305,6 +306,7 @@ function handleEvent(argv) {
case "TOPIC":
var channel = channels.findWhere({name: argv.args[0]});
var messages = channel.get("messages");
messages.add(
new models.Message({
user: argv.nick,
@ -331,6 +333,7 @@ function handleEvent(argv) {
case "rpl_namreply":
var names = argv.args[3].split(' ');
var channel = network.get("channels").findWhere({name: argv.args[2]});
if (typeof channel === "undefined") {
channel = channels.add(
new models.Channel({
@ -355,6 +358,7 @@ function handleEvent(argv) {
case "rpl_endofnames":
var channel = network.get("channels").findWhere({name: argv.args[1]});
var users = channel.get("users");
users.trigger(
"add", {}, users
);
@ -373,6 +377,39 @@ function handleEvent(argv) {
);
break;
case "rpl_whoisuser":
case "rpl_whoischannels":
case "rpl_whoisserver":
case "rpl_endofwhois":
var channel = channels.findWhere({name: argv.args[1]});
var message = argv.args.slice(2).join(" ");
if (typeof channel == "undefined") {
channel = channels.add(
new models.Channel({
name: argv.args[1]
})
);
}
channel.get("messages").add(
new models.Message({
user: argv.args[1],
text: message
})
);
break;
case "ERROR":
var args = argv.args;
channels.first().get("messages").add(
new models.Message({
text: args[args.length - 1],
type: "error"
})
);
break;
}
// Debug