blob: 23a45ebd88128abe441e96641327c4071f62eac0 (
plain) (
tree)
|
|
// includes
const irc = require("irc");
const lisp = require("../../lisp/js/lisp").lisp;
// create the configuration
const config = {
channels: ["##qrxdkw", "##webpals"],
server: "irc.libera.chat",
port: 6667,
botName: "huizinga",
};
// create the bot name
let bot = new irc.Client(config.server, config.botName, {
channels: config.channels,
});
// listen for commands
bot.addListener("message", function (from, to, text, message) {
if (text.startsWith(",echo")) {
const content = text.substring(6); // where 6 is the length of the trigger command, !echo + 1 space
bot.say(to, content); // to ensures that the response goes to the channel the message was sent on
} else if (text.startsWith(",pm")) {
bot.say(from, "yes?"); // from makes this response a private message to the sender
} else if (text.startsWith(",lisp")) {
const code = text.substring(6); // FIXME: if lisp crashes so does the bot
const ret = lisp.interpret(lisp.parse(code));
bot.say(to, ret);
}
});
// run w/
// $ node bot.js
|