diff options
author | elioat <elioat@tilde.institute> | 2023-12-22 15:47:51 -0500 |
---|---|---|
committer | elioat <elioat@tilde.institute> | 2023-12-22 15:47:51 -0500 |
commit | ab720e80246f9ac84c8f20fbac322a448618546b (patch) | |
tree | e263b3d5a24b3781ac9ceb8c1091337e7b827ef0 /js | |
parent | 738767daa114003f565d16480be0badc6c4ced0a (diff) | |
download | tour-ab720e80246f9ac84c8f20fbac322a448618546b.tar.gz |
javascript
adding an irc bot...maybe for making games with
Diffstat (limited to 'js')
-rw-r--r-- | js/irc/bot.js | 33 | ||||
-rw-r--r-- | js/irc/package-lock.json | 112 | ||||
-rw-r--r-- | js/irc/package.json | 14 |
3 files changed, 159 insertions, 0 deletions
diff --git a/js/irc/bot.js b/js/irc/bot.js new file mode 100644 index 0000000..23a45eb --- /dev/null +++ b/js/irc/bot.js @@ -0,0 +1,33 @@ +// 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 diff --git a/js/irc/package-lock.json b/js/irc/package-lock.json new file mode 100644 index 0000000..17d41c7 --- /dev/null +++ b/js/irc/package-lock.json @@ -0,0 +1,112 @@ +{ + "name": "huizinga", + "version": "1.0.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "huizinga", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "irc": "^0.5.2" + } + }, + "node_modules/iconv": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/iconv/-/iconv-2.2.3.tgz", + "integrity": "sha512-evIiYeKdt5nEGYKNkQcGPQy781sYgbBKi3gEkt1s4CwteCdOHSjGGRyyp6lP8inYFZwvzG3lgjXEvGUC8nqQ5A==", + "hasInstallScript": true, + "optional": true, + "dependencies": { + "nan": "^2.3.5" + }, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/irc": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/irc/-/irc-0.5.2.tgz", + "integrity": "sha512-KnrvkV05Y71SWmRWHtnlWEIH7LA/YeDul6l7tncCGLNEw4B6Obtmkatb3ACnSLj0kOJ6UBiuhss9e+eRG3zlxw==", + "dependencies": { + "irc-colors": "^1.1.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "optionalDependencies": { + "iconv": "~2.2.1", + "node-icu-charset-detector": "~0.2.0" + } + }, + "node_modules/irc-colors": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/irc-colors/-/irc-colors-1.5.0.tgz", + "integrity": "sha512-HtszKchBQTcqw1DC09uD7i7vvMayHGM1OCo6AHt5pkgZEyo99ClhHTMJdf+Ezc9ovuNNxcH89QfyclGthjZJOw==", + "engines": { + "node": ">=6" + } + }, + "node_modules/nan": { + "version": "2.18.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.18.0.tgz", + "integrity": "sha512-W7tfG7vMOGtD30sHoZSSc/JVYiyDPEyQVso/Zz+/uQd0B0L46gtC+pHha5FFMRpil6fm/AoEcRWyOVi4+E/f8w==", + "optional": true + }, + "node_modules/node-icu-charset-detector": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/node-icu-charset-detector/-/node-icu-charset-detector-0.2.0.tgz", + "integrity": "sha512-DYOFJ3NfKdxEi9hPbmoCss6WydGhJsxpSleUlZfAWEbZt3AU7JuxailgA9tnqQdsHiujfUY9VtDfWD9m0+ThtQ==", + "hasInstallScript": true, + "optional": true, + "dependencies": { + "nan": "^2.3.3" + }, + "engines": { + "node": ">=0.6" + } + } + }, + "dependencies": { + "iconv": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/iconv/-/iconv-2.2.3.tgz", + "integrity": "sha512-evIiYeKdt5nEGYKNkQcGPQy781sYgbBKi3gEkt1s4CwteCdOHSjGGRyyp6lP8inYFZwvzG3lgjXEvGUC8nqQ5A==", + "optional": true, + "requires": { + "nan": "^2.3.5" + } + }, + "irc": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/irc/-/irc-0.5.2.tgz", + "integrity": "sha512-KnrvkV05Y71SWmRWHtnlWEIH7LA/YeDul6l7tncCGLNEw4B6Obtmkatb3ACnSLj0kOJ6UBiuhss9e+eRG3zlxw==", + "requires": { + "iconv": "~2.2.1", + "irc-colors": "^1.1.0", + "node-icu-charset-detector": "~0.2.0" + } + }, + "irc-colors": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/irc-colors/-/irc-colors-1.5.0.tgz", + "integrity": "sha512-HtszKchBQTcqw1DC09uD7i7vvMayHGM1OCo6AHt5pkgZEyo99ClhHTMJdf+Ezc9ovuNNxcH89QfyclGthjZJOw==" + }, + "nan": { + "version": "2.18.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.18.0.tgz", + "integrity": "sha512-W7tfG7vMOGtD30sHoZSSc/JVYiyDPEyQVso/Zz+/uQd0B0L46gtC+pHha5FFMRpil6fm/AoEcRWyOVi4+E/f8w==", + "optional": true + }, + "node-icu-charset-detector": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/node-icu-charset-detector/-/node-icu-charset-detector-0.2.0.tgz", + "integrity": "sha512-DYOFJ3NfKdxEi9hPbmoCss6WydGhJsxpSleUlZfAWEbZt3AU7JuxailgA9tnqQdsHiujfUY9VtDfWD9m0+ThtQ==", + "optional": true, + "requires": { + "nan": "^2.3.3" + } + } + } +} diff --git a/js/irc/package.json b/js/irc/package.json new file mode 100644 index 0000000..51a87ea --- /dev/null +++ b/js/irc/package.json @@ -0,0 +1,14 @@ +{ + "name": "huizinga", + "version": "1.0.0", + "description": "an irc bot, maybe for a game", + "main": "bot.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "dependencies": { + "irc": "^0.5.2" + } +} |