Implemented NOTICE events

This commit is contained in:
Mattias Erming 2014-03-13 01:00:59 +01:00
parent dab3f4350c
commit cea2994aea

View File

@ -61,7 +61,8 @@ function handleInput(input) {
case "":
var irc = target.network.irc;
if (typeof irc !== "undefined") {
irc.say(target.channel.get("name"), input.text);
var chan = target.channel.get("name");
irc.say(chan, input.text);
}
target.channel.get("messages").add(
new models.Message({
@ -71,6 +72,24 @@ function handleInput(input) {
);
break;
case "NOTICE":
var irc = target.network.irc;
if (argv[2] && typeof irc !== "undefined") {
var user = argv[1];
var text = argv
.slice(2)
.join(" ");
irc.notice(user, text);
target.channel.get("messages").add(
new models.Message({
user: target.network.get("nick"),
text: "to " + user + ": " + text
})
);
}
break;
case "QUERY":
var irc = target.network.irc;
if (argv[1] && typeof irc !== "undefined") {
@ -154,15 +173,6 @@ function handleEvent(argv) {
var network = this;
var channels = network.get("channels");
// Temp
var network_lobby = channels.first().get("messages");
network_lobby.add(
new models.Message({
user: argv.args[0],
text: argv.args[1]
})
);
var event = argv.command;
switch (event) {
@ -191,6 +201,17 @@ function handleEvent(argv) {
);
break;
case "NOTICE":
var from = argv.nick ? argv.nick : argv.prefix;
var message = new models.Message({
user: from,
text: "notice: " + argv.args[1]
});
channels.each(function(c) {
c.get("messages").add(message);
});
break;
case "JOIN":
if (argv.nick == network.get("nick")) {
channels.add(
@ -293,12 +314,20 @@ function handleEvent(argv) {
case "err_nosuchchannel":
case "err_cannotsendtochan":
case "err_nosuchnick":
network_lobby.add(
channels.first().get("messages").add(
new models.Message({
text: argv.args[2]
})
);
break;
default:
channels.first().get("messages").add(
new models.Message({
user: "-!-",
text: argv.args[1]
})
);
}
// Debug