nonebot-plugin-auto-bot-selector
使用
from nonebot import on_message
from nonebot.exception import ActionFailed
from nonebot_plugin_alconna.uniseg import Target, UniMessage
from nonebot_plugin_auto_bot_selector import get_bots
from nonebot_plugin_auto_bot_selector.expection import NoBotFoundError
from nonebot_plugin_auto_bot_selector.target import PlatformTarget, TargetQQGroup
from nonebot_plugin_auto_bot_selector.utils.alconna import create_target, extract_target
foo = on_message()
@foo.handle()
async def _recive_target(alc_target: Target):
# 使用 alconna 提取目标
abs_target = extract_target(alc_target)
# 手动创建目标
qq_group = TargetQQGroup(group_id=123456)
# do something
await foo.finish(f"用户 {abs_target} 已保存")
async def _send_msg_to_target(abs_target: PlatformTarget, msg: UniMessage):
alc_target = create_target(abs_target)
try:
bots = get_bots(abs_target)
except NoBotFoundError:
return "没有可用的推送 Bot"
for bot in get_bots(abs_target):
try:
await msg.send(target=alc_target, bot=bot)
return "发送成功"
except ActionFailed:
# 发送失败
continue
else:
return "全部推送 Bot 发送失败"
Metadata
Release files for nonebot-plugin-auto-bot-selector 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nonebot_plugin_auto_bot_selector-0.2.1.tar.gz | 9.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nonebot_plugin_auto_bot_selector-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.2 kB
Release files / nonebot_plugin_auto_bot_selector-0.2.1.tar.gz
| Download URL | nonebot_plugin_auto_bot_selector-0.2.1.tar.gz |
|---|---|
| Size | 9.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ed0fa6044256c073a2240c6b6afaff6da7890f616586b8d1741fb0dced7377ef
|
|
BLAKE2b-256 checksum How to use checksums |
b741a42988ffc4b5bdaffcf017a02bd935119db1f8e62904d98d7a938d587e76
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.19
|
Release files / nonebot_plugin_auto_bot_selector-0.2.1-py3-none-any.whl
| Download URL | nonebot_plugin_auto_bot_selector-0.2.1-py3-none-any.whl |
|---|---|
| Size | 14.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
82faef534fabe3e9ef2985869e273e7310c9ce4a7a6c283b24a8ec40829a338f
|
|
BLAKE2b-256 checksum How to use checksums |
f9ee93adb43370628ec165a06c65588d5bbce580e35ceb858d161dda0c5df2a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.19
|