Skip to content

fix: 适配跨平台多Bot实例进程 - #6

Open
Misty02600 wants to merge 1 commit into
middlered:feat-scope-permissionfrom
Misty02600:fix-uninfo-entity
Open

fix: 适配跨平台多Bot实例进程#6
Misty02600 wants to merge 1 commit into
middlered:feat-scope-permissionfrom
Misty02600:fix-uninfo-entity

Conversation

@Misty02600

Copy link
Copy Markdown
Contributor

把单个 user_id 和 scene_id 扩充到了能跨平台识别的主键,这样就不会在多 bot 实例的时候存在冲突。

之前之所以想用我在 Uninfo 的分支是因为我觉得有很多跨平台插件都有这个思想,但没有一个统一的主键描述,也没有转化回
Alconna 的 Target 对象的便捷方法。不过我之前考虑确实不太妥,这里就算直接写插件内也不会增加太多代码。

json 序列化和反序列化是随便做的,因为我希望后面可以直接做成数据库

白名单也暂时还没改

@middlered middlered changed the title fix!:适配跨平台多Bot实例进程 fix:适配跨平台多Bot实例进程 Aug 13, 2026
@middlered middlered changed the title fix:适配跨平台多Bot实例进程 fix: 适配跨平台多Bot实例进程 Aug 13, 2026
@middlered
middlered changed the base branch from master to feat-scope-permission August 13, 2026 07:39

@middlered middlered left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

实例化的部分之后等你数据库再看看

EntityKey: TypeAlias = str | UserKey | SceneKey | SceneUserKey


def make_user_key(scope: SupportScope, user_id: str) -> UserKey:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没看懂这么写包了层为了啥,直接实例化不行么

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

而且其实我目目前目测看并没有看到需要用 dataclass 的必要性, NamedTuple 完全可以解决

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你说的对( 我没仔细检查


from nonebot_plugin_uninfo import SceneType, SupportScope

ENTITY_KEY_PREFIX = "limiter-entity:"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

正常的 key 我觉得完全不需要 prefix,也不存别的什么地方

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants