Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correctly deal with blocked users #149

Closed
NanderTGA opened this issue Dec 29, 2023 · 2 comments
Closed

fix: correctly deal with blocked users #149

NanderTGA opened this issue Dec 29, 2023 · 2 comments
Labels

Comments

@NanderTGA
Copy link
Owner

Recently, Yabluzo and other bots on recent versions have started crashing now and then.
I have been aware of this issue for some time now and have been able to log some of the events that caused one of these undefined errors.
These logs indicate that a message event is sometimes handled before the user-join event assigns a new user to client.users.
However, this is impossible because these event handlers are all synchronous and socket.io guarantees that all events are received (and thus have their event handlers run) in the same order they were sent.

My conclusion is that client.users[user] must be undefined for some other reason.
I think this may be related to a recent change that introduced blocking bots using Sheesh's bot API.
I have also noticed that the crashes seem to happen for bots or people who have the same ID as a bot.
I will investigate further.

@NanderTGA NanderTGA pinned this issue Dec 29, 2023
@NanderTGA
Copy link
Owner Author

I think this may be related to my poor handling of user-join and user-leave events for blocked users.
The client.isBlocked function recently started blocking bots too (by default), which explains why this started happening recently.

@NanderTGA NanderTGA changed the title fix: random crashes fix: correctly deal with blocked users Dec 30, 2023
github-actions bot pushed a commit that referenced this issue Jan 29, 2024
# [2.0.0](v1.4.1...v2.0.0) (2024-01-29)

### Bug Fixes

* `welcomeMessage` is ignored and default is used ([8d50887](8d50887)), closes [#150](#150)
* adapt types to match new prefix behavior ([21d1d42](21d1d42))
* add ability to change servers ([b2e5a4d](b2e5a4d))
* all crashes in main event handlers ([b170f30](b170f30))
* array-starts-with importing ([626a03f](626a03f))
* cause property on errors ([b6d1f4a](b6d1f4a))
* Client#name not updating after changing it ([2d07427](2d07427)), closes [#95](#95)
* correct nickname length ([9eeeb44](9eeeb44))
* correctly deal with blocked users ([02ca96c](02ca96c)), closes [#149](#149)
* description formatting in help command ([7d8cfee](7d8cfee))
* disable default welcomeMessage when there's no main prefix ([d9713e5](d9713e5))
* document behavior to disable commands ([a8c3dd2](a8c3dd2))
* don't send error message when no error ([f95ef45](f95ef45))
* eslint false positive ([cbb6ebb](cbb6ebb))
* import fuckery ([bfaf354](bfaf354))
* logic bug in validateNickname ([5061122](5061122))
* make blockSelf default to options.bot ([4183cb6](4183cb6))
* make commands case-insensitive again ([9a0dcdf](9a0dcdf)), closes [#36](#36)
* make validateNickname match server behavior ([22f538a](22f538a))
* missing properties from imported commands ([3ef8b15](3ef8b15))
* **readme:** fix typo ([5efd95e](5efd95e))
* reject promise instead of uncaught error ([d20dac3](d20dac3))
* remove flag types for bridged messages ([debdd91](debdd91))
* remove reference to require ([c35fdca](c35fdca))
* some small bugs + fix eslint errors ([3f80e24](3f80e24))
* **testbot:** prefix t! conflicting with other bot ([c1f2589](c1f2589))
* **testbot:** switch to commonjs ([d132235](d132235))
* **testCommand:** context.reply() inaccuracy ([987ce3d](987ce3d))
* the types I broke with this import mess ([dacf038](dacf038))
* type error ModuleInitializeFunctionReturnType ([792d802](792d802))
* update isBlocked description ([81be86f](81be86f))
* use import() instead of require() ([5f83c3f](5f83c3f))
* use validateNickname properly ([c8edf3e](c8edf3e))
* welcomeMessage not disabling with "" ([5613df7](5613df7)), closes [#134](#134)

* chore!: define public interface + remove CJS ([797c6ca](797c6ca))
* refactor!: rename some functions + add tsdocs ([beea55e](beea55e))
* chore(ci)!: switch to msgroom@nightly ([d3aae1c](d3aae1c))
* feat!: rewrite getCommand and walkCommandOrMap ([02c5240](02c5240))

### Features

* add `escapedName` field to `User` ([d0f1cb7](d0f1cb7)), closes [#125](#125)
* add authOptions ([a6084e1](a6084e1))
* add browser support ([b792d6a](b792d6a))
* add cause to error ([5410bac](5410bac))
* add hidden commands ([c67552a](c67552a)), closes [#110](#110)
* add option to disable unescaping messages ([ded8b23](ded8b23)), closes [#88](#88)
* add pages to the help command ([0a079a7](0a079a7)), closes [#44](#44)
* add possibility to simplify aliases ([fd4cbac](fd4cbac))
* add socketIOOptions ([784e3f6](784e3f6))
* add trimMessage function ([831ac91](831ac91))
* add types with reserved events ([3294b7b](3294b7b))
* add unescaping to sys messages + add jsdocs ([1356dec](1356dec))
* automatically trim each message ([f128d00](f128d00))
* bind `this` in handler to command ([8987c8f](8987c8f)), closes [#124](#124)
* block bots using Sheesh's bot API ([3b80d25](3b80d25))
* deal with message bridging from other platforms ([fe7429d](fe7429d))
* detect bots using bot flag too ([221a73a](221a73a))
* implement proposed option to mark user as bot ([baa3110](baa3110))
* implement warning system, finishing [#6](#6) ([60540d4](60540d4))
* improved prefix processing ([1766972](1766972)), closes [#84](#84)
* let users override helpCommandLimit in arg 2 ([0028027](0028027))
* make pings bold ([0352de3](0352de3))
* separate arguments using quotes ([5c6aa00](5c6aa00)), closes [#60](#60)
* **testbot:** add name command ([57d64ad](57d64ad)), closes [#95](#95)
* **testbot:** alias testing with new ping command ([510b0e5](510b0e5))

### BREAKING CHANGES

* We defined our public interface in package.json.
This was done for clarity.

We also added a list of supported node versions (node 18 or 20+)
* removed CommonJS since it got too difficult to keep it
You shouldn't have been using it with this lib anyway.

Internal change:
Now using the package.json imports field for cleaner and easier imports
* client.addCommandsFromDirectory() is now
client.loadDirectory() and the directory argument can no longer
be left out.
client.addCommandsFromFile() is now client.loadModule()
* Nightly builds are now available at the dist tag nightly.
To switch to nightly builds, run `npm install msgroom@nightly`.
It is now easier to switch between nightly and stable builds,
since you no longer need to change any imports.
* walkCommandOrMap is the new name of walkCommandMapEntry
* getCommand is now async and arguments changed
don't validate command names any longer
* got rid of validateCommandName
modules now don't have to export any commands,
so they can also only define events in one file
normalizeCommand now also does subcommands
@msgroom-js-semantic-release
Copy link

🎉 This issue has been resolved in version 2.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant