Implemented the rest of the input plugins

This commit is contained in:
Mattias Erming 2014-07-04 00:49:15 +02:00
parent 9e41d4d746
commit dbcf26d1bd
17 changed files with 142 additions and 20 deletions

View File

@ -239,7 +239,9 @@ button {
#messages .nick .type, #messages .nick .type,
#messages .kick .type, #messages .kick .type,
#messages .quit .type, #messages .quit .type,
#messages .quit .type { #messages .quit .type,
#messages .notice .type,
#messages .topic .type {
display: inline; display: inline;
} }
#meta { #meta {

View File

@ -102,11 +102,12 @@ $(function() {
}); });
socket.on("part", function(data) { socket.on("part", function(data) {
console.log(data); networks.find(".chan[data-id='" + data.chan + "']").remove();
}); });
socket.on("quit", function(data) { socket.on("quit", function(data) {
console.log(data); console.log(data);
networks.find(".network[data-id='" + data.network + "']").remove();
}); });
socket.on("users", function(data) { socket.on("users", function(data) {

View File

@ -1,3 +1,38 @@
var Msg = require("../../models/msg");
module.exports = function(network, chan, cmd, args) { module.exports = function(network, chan, cmd, args) {
console.log("action"); if (cmd != "slap" && cmd != "me") {
return;
}
var client = this;
var irc = network.irc;
switch (cmd) {
case "slap":
var slap = "slaps " + args[0] + " around a bit with a large trout";
/* fall through */
case "me":
if (args.length === 0) {
break;
}
var text = slap || args.join(" ");
irc.action(
chan.name,
text
);
var msg = new Msg({
type: Msg.Type.ACTION,
from: irc.me,
text: text
});
chan.messages.push(msg);
client.emit("msg", {
chan: chan.id,
msg: msg
});
break;
}
}; };

View File

@ -1,3 +1,3 @@
module.exports = function(network, chan, cmd, args) { module.exports = function(network, chan, cmd, args) {
console.log("connect"); // Not yet implemented.
}; };

View File

@ -1,3 +1,9 @@
module.exports = function(network, chan, cmd, args) { module.exports = function(network, chan, cmd, args) {
console.log("invite"); if (cmd != "invite") {
return;
}
var irc = network.irc;
if (args.length === 2) {
irc.invite(args[0], args[1]);
}
}; };

View File

@ -1,8 +1,8 @@
module.exports = function(network, chan, cmd, args) { module.exports = function(network, chan, cmd, args) {
if (cmd != "join") { if (cmd != "join") {
return return;
} }
if (args.length != 0) { if (args.length !== 0) {
var irc = network.irc; var irc = network.irc;
irc.join(args); irc.join(args);
} }

View File

@ -1,3 +1,9 @@
module.exports = function(network, chan, cmd, args) { module.exports = function(network, chan, cmd, args) {
console.log("kick"); if (cmd != "kick") {
return;
}
if (args.length !== 0) {
var irc = network.irc;
irc.kick(chan.name, args[0]);
}
}; };

View File

@ -1,3 +1,30 @@
module.exports = function(network, chan, cmd, args) { module.exports = function(network, chan, cmd, args) {
console.log("mode"); if (cmd != "mode" && cmd != "op" && cmd != "voice" && cmd != "deop" && cmd != "devoice") {
return;
} else if (args.length === 0) {
return;
}
var mode;
var user;
if (cmd != "mode") {
user = args[0];
mode = {
"op": "+o",
"voice": "+v",
"deop": "-o",
"devoice": "-v"
}[cmd];
} else if (args.length === 1) {
return;
} else {
mode = args[0];
user = args[1];
}
var irc = network.irc;
irc.mode(
chan.name,
mode,
user
);
}; };

View File

@ -3,7 +3,7 @@ var Msg = require("../../models/msg");
module.exports = function(network, chan, cmd, args) { module.exports = function(network, chan, cmd, args) {
if (cmd != "say" && cmd != "msg") { if (cmd != "say" && cmd != "msg") {
return return;
} }
var client = this; var client = this;
@ -13,9 +13,9 @@ module.exports = function(network, chan, cmd, args) {
return; return;
} }
var target = args[0].charAt(0) == "#" ? args[0] : "#" + chan.name; var target = args[0].charAt(0) == "#" ? args[0] : chan.name;
if (target !== chan.name) { if (target !== chan.name) {
targetChan = _.findWhere(network.channels, { chan = _.findWhere(network.channels, {
name: target name: target
}); });
} }

View File

@ -1,3 +1,9 @@
module.exports = function(network, chan, cmd, args) { module.exports = function(network, chan, cmd, args) {
console.log("nick"); if (cmd != "nick") {
return;
}
if (args.length !== 0) {
var irc = network.irc;
irc.nick(args[0]);
}
}; };

View File

@ -1,3 +1,7 @@
module.exports = function(network, chan, cmd, args) { module.exports = function(network, chan, cmd, args) {
console.log("notice"); if (cmd != "notice" || !args[1]) {
return;
}
var irc = network.irc;
irc.notice(args[0], args.slice(1).join(" "));
}; };

View File

@ -4,7 +4,7 @@ module.exports = function(network, chan, cmd, args) {
} }
var irc = network.irc; var irc = network.irc;
if (args.length === 0) { if (args.length === 0) {
args.push("#" + chan.name); args.push(chan.name);
} }
irc.part(args); irc.part(args);
}; };

View File

@ -1,3 +1,17 @@
var _ = require("lodash");
module.exports = function(network, chan, cmd, args) { module.exports = function(network, chan, cmd, args) {
console.log("quit"); if (cmd != "quit" && cmd != "disconnect") {
return;
}
var client = this;
var irc = network.irc;
client.networks = _.without(client.networks, network);
client.emit("quit", {
network: network.id
});
irc.quit();
}; };

View File

@ -1,3 +1,9 @@
module.exports = function(network, chan, cmd, args) { module.exports = function(network, chan, cmd, args) {
console.log("raw"); if (cmd != "raw") {
return;
}
if (args.length !== 0) {
var irc = network.irc;
irc.write(args.join(" "));
}
}; };

View File

@ -1,3 +1,12 @@
module.exports = function(network, chan, cmd, args) { module.exports = function(network, chan, cmd, args) {
console.log("topic"); if (cmd != "topic") {
return;
}
var msg = "TOPIC";
msg += " " + chan.name;
msg += args[0] ? (" :" + args.join(" ")) : "";
var irc = network.irc;
irc.write(msg);
}; };

View File

@ -1,3 +1,9 @@
module.exports = function(network, chan, cmd, args) { module.exports = function(network, chan, cmd, args) {
console.log("whois"); if (cmd != "whois" && cmd != "query") {
return;
}
if (args.length !== 0) {
var irc = network.irc;
irc.whois(args[0]);
}
}; };

View File

@ -9,7 +9,7 @@ module.exports = function(irc, network) {
var msg = new Msg({ var msg = new Msg({
text: "You're now known as " + data["new"], text: "You're now known as " + data["new"],
}); });
chan.messages.push(msg); lobby.messages.push(msg);
client.emit("msg", { client.emit("msg", {
chan: lobby.id, chan: lobby.id,
msg: msg msg: msg