Implemented NOTICE events

This commit is contained in:
Mattias Erming 2014-03-13 01:00:59 +01:00
parent dab3f4350c
commit cea2994aea
1 changed files with 40 additions and 11 deletions

View File

@ -61,7 +61,8 @@ function handleInput(input) {
case "": case "":
var irc = target.network.irc; var irc = target.network.irc;
if (typeof irc !== "undefined") { 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( target.channel.get("messages").add(
new models.Message({ new models.Message({
@ -71,6 +72,24 @@ function handleInput(input) {
); );
break; 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": case "QUERY":
var irc = target.network.irc; var irc = target.network.irc;
if (argv[1] && typeof irc !== "undefined") { if (argv[1] && typeof irc !== "undefined") {
@ -154,15 +173,6 @@ function handleEvent(argv) {
var network = this; var network = this;
var channels = network.get("channels"); 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; var event = argv.command;
switch (event) { switch (event) {
@ -191,6 +201,17 @@ function handleEvent(argv) {
); );
break; 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": case "JOIN":
if (argv.nick == network.get("nick")) { if (argv.nick == network.get("nick")) {
channels.add( channels.add(
@ -293,12 +314,20 @@ function handleEvent(argv) {
case "err_nosuchchannel": case "err_nosuchchannel":
case "err_cannotsendtochan": case "err_cannotsendtochan":
case "err_nosuchnick": case "err_nosuchnick":
network_lobby.add( channels.first().get("messages").add(
new models.Message({ new models.Message({
text: argv.args[2] text: argv.args[2]
}) })
); );
break; break;
default:
channels.first().get("messages").add(
new models.Message({
user: "-!-",
text: argv.args[1]
})
);
} }
// Debug // Debug