nonebot多平台账户信息绑定
Project description
适配支持
- onebotv11
- telegram
- discord
- kook(开黑啦)
- villa(大别野)
- 飞书
使用说明
用户使用说明
命令 | 限制 | 含义 |
---|---|---|
'bind' | 群聊或私聊 | 将其他通用账户绑定至当前通用账户 |
'bindinfo' | 仅私聊 | 查看当前通用账户的平台账户绑定信息 |
'rebind' | 仅私聊 | 取消本平台账户和通用账户的绑定,并形成一个新的通用账户 |
'bind -group' | 群聊或私聊 | 将其他通用群组绑定至当前通用群组 |
'bindinfo -group' | 仅私聊 | 查看当前通用群组的平台群组绑定信息 |
'rebind -group' | 仅私聊 | 取消本平台群组和通用尊祖的绑定,并形成一个新的通用群组 |
配置项
配置名 | 默认 | 含义 |
---|---|---|
bind_superuser | [] | bind的superuser,用以管理群组绑定,注意填写的值应该是通过bindinfo查询出的id,而不是你的某个社交平台的账户 |
bind_group_admin | False | 是否允许某社交平台的群组的管理员直接管理其群组绑定,不管他是否是bind_superuser |
具体使用请看下图流程示例(群聊绑定同理)
(如果是在群聊中发起的绑定,不会显示下面的绑定信息,只会显示其他内容)
开发者说明
主要提供两个依赖注入
- GetUser:返回一个User实例,其属性id为一个通用账户的唯一标识,其属性platform_users中包含绑定的所有平台账户的信息
- GetGroup:返回一个Group实例,其属性id为一个通用群组的唯一标识,其属性platform_groups中包含所有绑定的平台群组的信息( 其中groupid是对应平台群组的id)(如果不想在匹配非群组消息时跳过matcher,请使用Optional类型注释)
示例代码如下
from typing import Annotated
from nonebot import require
require('nonebot_plugin_bind')
from nonebot_plugin_bind import GetUser, GetGroup, GetGroupId, User, Group
# 此处省略了部分import
bind_info = on_alconna(Alconna(Command_Start, "bindinfo", Option("-group")))
@bind_info.assign("$main")
async def bind_info_(
event: Event, bot: Bot, matcher: Matcher, user: Annotated[User, GetUser()]
):
user_str = "\n".join(
pg + " √" if event.get_user_id() in pg else pg for pg in str(user).split("\n")
)
if _is_private_(event, bot):
await matcher.finish(f"当前通用账户的绑定的平台账户如下:\n{str(user_str)}")
else:
await matcher.finish("账户绑定信息只能在私聊中查看")
@bind_info.assign("group")
async def bind_info_group(
matcher: Matcher,
group: Optional[Group] = GetGroup(),
groupid: Optional[str] = GetGroupId(),
):
# 如果在私聊中发送此命令,得到的group会是None,groupid也是如此
if group is None:
await matcher.finish("本命令只能在各平台的群聊中使用,私聊中无法使用")
group_str = "\n".join(
pg + " √" if groupid in pg else pg for pg in str(group).split("\n")
)
await matcher.send(f"当前通用群组的绑定的平台群组如下:\n{group_str}")
_bind_ = on_alconna(
Alconna(Command_Start, "bind", Option("token", Args["token_value", str]))
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for nonebot_plugin_bind-0.1.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5dd63b9572f1eaaa5755319e7a0f3d39442e9c040c5b05ac7a75b8b3cbf7837f |
|
MD5 | 6d442285511526cc1a91569864d7a192 |
|
BLAKE2b-256 | 206e3ddea40714b9bd14669d25d4887fbd93135021412b29afaf282ca7244e89 |
Close
Hashes for nonebot_plugin_bind-0.1.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d5f5b9d0b0cfeb6707b7d9feae6af6e4577b2bbaa2c83d2f9e27f179e93191e |
|
MD5 | d166b8f410b226936ed0922dbe2125bd |
|
BLAKE2b-256 | 71bb885b449ca39b8d3f46093c31e03bb6fea31a37de7180a3081b81e9e35c6b |