From 2244dda56618af046366f2f99122ea83c12f6a48 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Tue, 8 Mar 2016 15:36:25 +0200 Subject: [PATCH] Update commands --- src/plugins/inputs/action.js | 19 +++++++++---------- src/plugins/inputs/invite.js | 4 ++-- src/plugins/inputs/kick.js | 2 +- src/plugins/inputs/mode.js | 7 ++----- src/plugins/inputs/msg.js | 21 ++++++++++++++++----- src/plugins/inputs/notice.js | 15 ++++----------- src/plugins/inputs/raw.js | 2 +- src/plugins/inputs/topic.js | 5 ++--- src/plugins/irc-events/error.js | 2 +- src/plugins/irc-events/part.js | 2 +- 10 files changed, 39 insertions(+), 40 deletions(-) diff --git a/src/plugins/inputs/action.js b/src/plugins/inputs/action.js index cf4b753a..34c8036a 100644 --- a/src/plugins/inputs/action.js +++ b/src/plugins/inputs/action.js @@ -2,25 +2,24 @@ exports.commands = ["slap", "me"]; exports.input = function(network, chan, cmd, args) { var irc = network.irc; + var text; switch (cmd) { case "slap": - var slap = "slaps " + args[0] + " around a bit with a large trout"; + text = "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 - ); - irc.emit("message", { - from: irc.user.nick, - to: chan.name, - message: "\u0001ACTION " + text + text = text || args.join(" "); + + irc.say(chan.name, "\u0001ACTION " + text + "\u0001"); + irc.emit("action", { + nick: irc.user.nick, + target: chan.name, + msg: text }); break; } diff --git a/src/plugins/inputs/invite.js b/src/plugins/inputs/invite.js index b81ae2c8..8eefcbac 100644 --- a/src/plugins/inputs/invite.js +++ b/src/plugins/inputs/invite.js @@ -4,9 +4,9 @@ exports.input = function(network, chan, cmd, args) { var irc = network.irc; if (args.length === 2) { - irc.invite(args[0], args[1]); // Channel provided in the command + irc.raw("INVITE", args[0], args[1]); // Channel provided in the command } else if (args.length === 1 && chan.type === "channel") { - irc.invite(args[0], chan.name); // Current channel + irc.raw("INVITE", args[0], chan.name); // Current channel } return true; diff --git a/src/plugins/inputs/kick.js b/src/plugins/inputs/kick.js index a57d6cd4..47068817 100644 --- a/src/plugins/inputs/kick.js +++ b/src/plugins/inputs/kick.js @@ -3,7 +3,7 @@ exports.commands = ["kick"]; exports.input = function(network, chan, cmd, args) { if (args.length !== 0) { var irc = network.irc; - irc.kick(chan.name, args[0]); + irc.raw("KICK", chan.name, args[0]); } return true; diff --git a/src/plugins/inputs/mode.js b/src/plugins/inputs/mode.js index 5ca106be..b476256d 100644 --- a/src/plugins/inputs/mode.js +++ b/src/plugins/inputs/mode.js @@ -21,12 +21,9 @@ exports.input = function(network, chan, cmd, args) { mode = args[0]; user = args[1]; } + var irc = network.irc; - irc.mode( - chan.name, - mode, - user - ); + irc.raw("MODE", chan.name, mode, user); return true; }; diff --git a/src/plugins/inputs/msg.js b/src/plugins/inputs/msg.js index da3edeb3..4afaa5c4 100644 --- a/src/plugins/inputs/msg.js +++ b/src/plugins/inputs/msg.js @@ -1,11 +1,20 @@ var _ = require("lodash"); +<<<<<<< fbbb3d20d287243d2c3c5525d86801f54f903603 exports.commands = ["msg", "say"]; exports.input = function(network, chan, cmd, args) { +======= +module.exports = function(network, chan, cmd, args) { + if (cmd !== "say" && cmd !== "msg") { + return; + } + +>>>>>>> Update commands if (args.length === 0 || args[0] === "") { return true; } + var irc = network.irc; var target = ""; if (cmd === "msg") { @@ -16,14 +25,16 @@ exports.input = function(network, chan, cmd, args) { } else { target = chan.name; } + var msg = args.join(" "); - irc.send(target, msg); + irc.say(target, msg); + var channel = _.find(network.channels, {name: target}); if (typeof channel !== "undefined") { - irc.emit("message", { - from: irc.user.nick, - to: channel.name, - message: msg + irc.emit("privmsg", { + nick: irc.user.nick, + target: channel.name, + msg: msg }); } diff --git a/src/plugins/inputs/notice.js b/src/plugins/inputs/notice.js index 09445e5c..ca0a5e6c 100644 --- a/src/plugins/inputs/notice.js +++ b/src/plugins/inputs/notice.js @@ -1,5 +1,4 @@ var _ = require("lodash"); -var Msg = require("../../models/msg"); exports.commands = ["notice"]; @@ -18,16 +17,10 @@ exports.input = function(network, chan, cmd, args) { targetChan = chan; } - var msg = new Msg({ - type: Msg.Type.NOTICE, - mode: targetChan.getMode(irc.user.nick), - from: irc.user.nick, - text: message - }); - targetChan.messages.push(msg); - this.emit("msg", { - chan: targetChan.id, - msg: msg + irc.emit("notice", { + nick: irc.user.nick, + target: targetChan.name, + msg: message }); return true; diff --git a/src/plugins/inputs/raw.js b/src/plugins/inputs/raw.js index cab47bd8..b58a993c 100644 --- a/src/plugins/inputs/raw.js +++ b/src/plugins/inputs/raw.js @@ -3,7 +3,7 @@ exports.commands = ["raw", "send", "quote"]; exports.input = function(network, chan, cmd, args) { if (args.length !== 0) { var irc = network.irc; - irc.write(args.join(" ")); + irc.raw(args); } return true; diff --git a/src/plugins/inputs/topic.js b/src/plugins/inputs/topic.js index d342223f..7e9253c0 100644 --- a/src/plugins/inputs/topic.js +++ b/src/plugins/inputs/topic.js @@ -1,12 +1,11 @@ exports.commands = ["topic"]; exports.input = function(network, chan, cmd, args) { - var msg = "TOPIC"; - msg += " " + chan.name; + var msg = chan.name; msg += args[0] ? (" :" + args.join(" ")) : ""; var irc = network.irc; - irc.write(msg); + irc.raw("TOPIC", msg); return true; }; diff --git a/src/plugins/irc-events/error.js b/src/plugins/irc-events/error.js index fd65e494..f26d6836 100644 --- a/src/plugins/irc-events/error.js +++ b/src/plugins/irc-events/error.js @@ -27,6 +27,6 @@ module.exports = function(irc, network) { }); var random = irc.user.nick + Math.floor(10 + (Math.random() * 89)); - irc.raw("NICK", random); + irc.changeNick(random); }); }; diff --git a/src/plugins/irc-events/part.js b/src/plugins/irc-events/part.js index 7006ac0a..ef1e4467 100644 --- a/src/plugins/irc-events/part.js +++ b/src/plugins/irc-events/part.js @@ -23,7 +23,7 @@ module.exports = function(irc, network) { }); var msg = new Msg({ type: Msg.Type.PART, - mode: user.mode || "", + mode: (user && user.mode) || "", text: data.message || "", hostmask: data.ident + "@" + data.hostname, from: from