mirror of
https://github.com/thelounge/thelounge
synced 2024-11-26 14:00:21 +00:00
dd05ee3a65
Co-authored-by: Eric Nemchik <eric@nemchik.com> Co-authored-by: Pavel Djundik <xPaw@users.noreply.github.com>
52 lines
972 B
TypeScript
52 lines
972 B
TypeScript
import {PluginInputHandler} from "./index";
|
|
import Msg, {MessageType} from "../../models/msg";
|
|
import {ChanType} from "../../models/chan";
|
|
|
|
const commands = ["slap", "me"];
|
|
|
|
const input: PluginInputHandler = function ({irc}, chan, cmd, args) {
|
|
if (chan.type !== ChanType.CHANNEL && chan.type !== ChanType.QUERY) {
|
|
chan.pushMessage(
|
|
this,
|
|
new Msg({
|
|
type: 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 (!irc.network.cap.isEnabled("echo-message")) {
|
|
irc.emit("action", {
|
|
nick: irc.user.nick,
|
|
target: chan.name,
|
|
message: text,
|
|
});
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
return true;
|
|
};
|
|
|
|
export default {
|
|
commands,
|
|
input,
|
|
};
|