2022-06-19 00:25:21 +00:00
|
|
|
import {PluginInputHandler} from "./index";
|
|
|
|
import Msg, {MessageType} from "../../models/msg";
|
|
|
|
import {ChanType} from "../../models/chan";
|
2016-10-09 19:14:02 +00:00
|
|
|
|
2022-06-19 00:25:21 +00:00
|
|
|
const commands = ["slap", "me"];
|
2017-03-11 18:09:37 +00:00
|
|
|
|
2022-06-19 00:25:21 +00:00
|
|
|
const input: PluginInputHandler = function ({irc}, chan, cmd, args) {
|
|
|
|
if (chan.type !== ChanType.CHANNEL && chan.type !== ChanType.QUERY) {
|
2019-07-17 09:33:59 +00:00
|
|
|
chan.pushMessage(
|
|
|
|
this,
|
|
|
|
new Msg({
|
2022-06-19 00:25:21 +00:00
|
|
|
type: MessageType.ERROR,
|
2019-07-17 09:33:59 +00:00
|
|
|
text: `${cmd} command can only be used in channels and queries.`,
|
|
|
|
})
|
|
|
|
);
|
2017-03-11 18:09:37 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-01-11 11:33:36 +00:00
|
|
|
let text;
|
2015-09-30 22:39:57 +00:00
|
|
|
|
2014-09-13 21:29:45 +00:00
|
|
|
switch (cmd) {
|
2019-07-17 09:33:59 +00:00
|
|
|
case "slap":
|
|
|
|
text = "slaps " + args[0] + " around a bit with a large trout";
|
2014-09-13 21:29:45 +00:00
|
|
|
/* fall through */
|
2019-07-17 09:33:59 +00:00
|
|
|
case "me":
|
|
|
|
if (args.length === 0) {
|
|
|
|
break;
|
|
|
|
}
|
2015-09-30 22:39:57 +00:00
|
|
|
|
2019-07-17 09:33:59 +00:00
|
|
|
text = text || args.join(" ");
|
2016-03-08 13:36:25 +00:00
|
|
|
|
2019-07-17 09:33:59 +00:00
|
|
|
irc.action(chan.name, text);
|
2016-04-22 16:38:13 +00:00
|
|
|
|
2019-07-17 09:33:59 +00:00
|
|
|
if (!irc.network.cap.isEnabled("echo-message")) {
|
|
|
|
irc.emit("action", {
|
|
|
|
nick: irc.user.nick,
|
|
|
|
target: chan.name,
|
|
|
|
message: text,
|
|
|
|
});
|
|
|
|
}
|
2016-04-22 16:38:13 +00:00
|
|
|
|
2019-07-17 09:33:59 +00:00
|
|
|
break;
|
2014-09-13 21:29:45 +00:00
|
|
|
}
|
2016-03-06 09:24:56 +00:00
|
|
|
|
|
|
|
return true;
|
2014-09-13 21:29:45 +00:00
|
|
|
};
|
2022-06-19 00:25:21 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
commands,
|
|
|
|
input,
|
|
|
|
};
|