twiedenbein-thelounge
Version:
The self-hosted Web IRC client
46 lines (45 loc) • 1.55 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const msg_1 = __importDefault(require("../../models/msg"));
const msg_2 = require("../../../shared/types/msg");
const chan_1 = require("../../../shared/types/chan");
const commands = ["slap", "me"];
const input = function ({ irc }, chan, cmd, args) {
if (chan.type !== chan_1.ChanType.CHANNEL && chan.type !== chan_1.ChanType.QUERY) {
chan.pushMessage(this, new msg_1.default({
type: msg_2.MessageType.ERROR,
text: `${cmd} command can only be used in channels and queries.`,
}));
return;
}
let text;
switch (cmd) {
case "slap":
text = "slaps " + args[0] + " around a bit with a large trout";
/* fall through */
case "me":
if (args.length === 0) {
break;
}
text = text || args.join(" ");
irc.action(chan.name, text);
// If the IRCd does not support echo-message, simulate the message
// being sent back to us.
if (!irc.network.cap.isEnabled("echo-message")) {
irc.emit("action", {
nick: irc.user.nick,
target: chan.name,
message: text,
});
}
break;
}
return true;
};
exports.default = {
commands,
input,
};