about summary refs log tree commit diff stats
path: root/js/blotbotboot/bot.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/blotbotboot/bot.js')
-rw-r--r--js/blotbotboot/bot.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/js/blotbotboot/bot.js b/js/blotbotboot/bot.js
new file mode 100644
index 0000000..dc115fe
--- /dev/null
+++ b/js/blotbotboot/bot.js
@@ -0,0 +1,33 @@
+// includes
+const irc = require("irc");
+const lisp = require("./lisp").lisp;
+
+// create the configuration
+const config = {
+  channels: ["##qrxdkw", "##webpals"],
+  server: "irc.libera.chat",
+  port: 6667,
+  botName: "blotbotboot",
+};
+
+// 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);
+    const ret = lisp.interpret(lisp.parse(code));
+    bot.say(to, ret);
+  }
+});
+
+// run w/
+// $ node bot.js