neet / masto.js

🐘 Universal Mastodon API client for JavaScript
https://neet.github.io/masto.js/
MIT License
723 stars 47 forks source link

Using with Akkoma #666

Closed Andrmist closed 1 year ago

Andrmist commented 1 year ago

Hi, How can I use this package to create an Akkoma bot? Akkoma has Mastodon API which I want to use, but masto.js gives an error due to different versions

TypeError: Invalid Version: 2.7.2 (compatible; Akkoma 3.3.0)
    at new SemVer (/home/master/work/fedibots/chadbot/node_modules/.pnpm/semver@7.3.8/node_modules/semver/classes/semver.js:38:13)
    at compare (/home/master/work/fedibots/chadbot/node_modules/.pnpm/semver@7.3.8/node_modules/semver/functions/compare.js:3:3)
    at Object.lt (/home/master/work/fedibots/chadbot/node_modules/.pnpm/semver@7.3.8/node_modules/semver/functions/lt.js:2:29)
    at descriptor.value [as streamUser] (/home/master/work/fedibots/chadbot/node_modules/.pnpm/masto@4.4.1/node_modules/masto/dist/index.js:352:33)
    at main (/home/master/work/fedibots/chadbot/dist/index.js:34:36)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
neet commented 1 year ago

Hi @Andrmist Thank you for the report

I've never used Akkoma, but it seems your instance has returned "2.7.2 (compatible; Akkoma 3.3.0)" as their Mastodon version which is not a valid semver. Masto.js requires servers to provide version information for improving backward compatibility and offering more informative error messages.

I can provide an option to disable the version checking in another PR.

neet commented 1 year ago

@Andrmist I published a new beta version that comes with an option to disable version checking. Could you verify the option suppresses the error? You can try it with:

npm install masto@4.5.0-rc1

And then

const masto = await login({ ..., disableVersionCheck: true });
Andrmist commented 1 year ago

Thanks, I'll try when I get home

Andrmist commented 1 year ago

It works like a charm! Thanks a lot for your work result

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 4.5.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: