fix: 适配跨平台多Bot实例进程 - #6
Open
Misty02600 wants to merge 1 commit into
Open
Conversation
middlered
requested changes
Aug 13, 2026
| EntityKey: TypeAlias = str | UserKey | SceneKey | SceneUserKey | ||
|
|
||
|
|
||
| def make_user_key(scope: SupportScope, user_id: str) -> UserKey: |
Owner
There was a problem hiding this comment.
而且其实我目目前目测看并没有看到需要用 dataclass 的必要性, NamedTuple 完全可以解决
|
|
||
| from nonebot_plugin_uninfo import SceneType, SupportScope | ||
|
|
||
| ENTITY_KEY_PREFIX = "limiter-entity:" |
Owner
There was a problem hiding this comment.
正常的 key 我觉得完全不需要 prefix,也不存别的什么地方
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
把单个 user_id 和 scene_id 扩充到了能跨平台识别的主键,这样就不会在多 bot 实例的时候存在冲突。
之前之所以想用我在 Uninfo 的分支是因为我觉得有很多跨平台插件都有这个思想,但没有一个统一的主键描述,也没有转化回
Alconna 的 Target 对象的便捷方法。不过我之前考虑确实不太妥,这里就算直接写插件内也不会增加太多代码。
json 序列化和反序列化是随便做的,因为我希望后面可以直接做成数据库
白名单也暂时还没改