thelounge/src/plugins/inputs/action.js

46 lines
841 B
JavaScript
Raw Normal View History

"use strict";
var Chan = require("../../models/chan");
var Msg = require("../../models/msg");
exports.commands = ["slap", "me"];
2015-10-01 00:39:57 +02:00
exports.input = function({irc}, chan, cmd, args) {
if (chan.type !== Chan.Type.CHANNEL && chan.type !== Chan.Type.QUERY) {
chan.pushMessage(this, new Msg({
type: Msg.Type.ERROR,
text: `${cmd} command can only be used in channels and queries.`,
}));
return;
}
2016-03-08 14:36:25 +01:00
var text;
2015-10-01 00:39:57 +02:00
2014-09-13 23:29:45 +02:00
switch (cmd) {
case "slap":
2016-03-08 14:36:25 +01:00
text = "slaps " + args[0] + " around a bit with a large trout";
2014-09-13 23:29:45 +02:00
/* fall through */
case "me":
if (args.length === 0) {
break;
}
2015-10-01 00:39:57 +02:00
2016-03-08 14:36:25 +01:00
text = text || args.join(" ");
2016-05-06 19:51:38 +02:00
irc.action(chan.name, text);
2016-04-22 18:38:13 +02:00
if (!irc.network.cap.isEnabled("echo-message")) {
2016-04-22 18:38:13 +02:00
irc.emit("action", {
nick: irc.user.nick,
target: chan.name,
message: text,
2016-04-22 18:38:13 +02:00
});
}
2014-09-13 23:29:45 +02:00
break;
}
2016-03-06 10:24:56 +01:00
return true;
2014-09-13 23:29:45 +02:00
};