anisus / mucklet-bot

A bot for the mucklet.com APIs.
2 stars 4 forks source link

Issue creating a config file #2

Open makyo opened 9 months ago

makyo commented 9 months ago

I have been looking into creating a bot for reading stories at a natural reading speed, but have had a hard time getting started.

$ node index.js --bot.token=(cat .token) > cfg/config.mucklet.js

Results in the following:

Starting bot failed: SyntaxError: Invalid URL: /ws
    at initAsClient (/home/makyo/work/wolfery-short-story-bot/node_modules/ws/lib/websocket.js:625:13)
    at new WebSocket (/home/makyo/work/wolfery-short-story-bot/node_modules/ws/lib/websocket.js:83:7)
    at Api._client.ResClient.namespace.namespace [as wsFactory] (file:///home/makyo/work/wolfery-short-story-bot/modules/api/Api.js:25:38)
    at connectPromise (/home/makyo/work/wolfery-short-story-bot/node_modules/resclient/lib/class/ResClient.js:260:28)
    at new Promise (<anonymous>)
    at ResClient.connect (/home/makyo/work/wolfery-short-story-bot/node_modules/resclient/lib/class/ResClient.js:255:59)
    at Api.connect (file:///home/makyo/work/wolfery-short-story-bot/modules/api/Api.js:45:23)
    at Bot._tryGetBot (file:///home/makyo/work/wolfery-short-story-bot/modules/bot/Bot.js:82:26)
    at Bot.login (file:///home/makyo/work/wolfery-short-story-bot/modules/bot/Bot.js:37:8)
    at file:///home/makyo/work/wolfery-short-story-bot/index.js:56:28
node:internal/process/promises:289
            triggerUncaughtException(err, true /* fromPromise */);
            ^

SyntaxError: Invalid URL: /ws
    at initAsClient (/home/makyo/work/wolfery-short-story-bot/node_modules/ws/lib/websocket.js:625:13)
    at new WebSocket (/home/makyo/work/wolfery-short-story-bot/node_modules/ws/lib/websocket.js:83:7)
    at Api._client.ResClient.namespace.namespace [as wsFactory] (file:///home/makyo/work/wolfery-short-story-bot/modules/api/Api.js:25:38)
    at connectPromise (/home/makyo/work/wolfery-short-story-bot/node_modules/resclient/lib/class/ResClient.js:260:28)
    at new Promise (<anonymous>)
    at ResClient.connect (/home/makyo/work/wolfery-short-story-bot/node_modules/resclient/lib/class/ResClient.js:255:59)
    at Api.connect (file:///home/makyo/work/wolfery-short-story-bot/modules/api/Api.js:45:23)
    at Bot._tryGetBot (file:///home/makyo/work/wolfery-short-story-bot/modules/bot/Bot.js:82:26)
    at Bot.login (file:///home/makyo/work/wolfery-short-story-bot/modules/bot/Bot.js:37:8)
    at file:///home/makyo/work/wolfery-short-story-bot/index.js:56:28

Node.js v21.6.1

The config file is still created, but running a sample command results in the following:

Loading configuration failed: SyntaxError: Unexpected identifier 'modules'
    at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:168:18)
    at callTranslator (node:internal/modules/esm/loader:279:14)
    at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:285:30)
    at async link (node:internal/modules/esm/module_job:76:21)
anisus commented 9 months ago

Hi @makyo !

Sorry for the delay in answer. You have a greater than (>) too much in that command line. It should be:

$ node index.js --bot.token=(cat .token) cfg/config.mucklet.js

The last argument is the path to the config file for the bot.

If you need any help with the code to create the reader, just ask. This bot code was primarily done to simulate users for load testing, and might need some rework to make it suitable. But I am happy to help out.