mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-04 02:26:11 +08:00
尝试增加合并消息转发功能 待验证是否可行
This commit is contained in:
parent
67972965ee
commit
5b9e255586
@ -9,10 +9,12 @@ class PlugConfig(BaseSettings):
|
||||
bison_config_path: str = ""
|
||||
bison_use_pic: bool = False
|
||||
bison_use_local: bool = False
|
||||
bison_use_forward_pic = True#当图片超过1张时改为合并消息发送
|
||||
#bison_browser: str = "local:C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
|
||||
bison_browser: str = ""
|
||||
bison_init_filter: bool = True
|
||||
bison_use_queue: bool = True
|
||||
bison_outer_url: str = "http://localhost:8080/bison/"
|
||||
bison_outer_url: str = "http://localhost:15556/bison/"
|
||||
bison_filter_log: bool = False
|
||||
bison_to_me: bool = True
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
from email import message
|
||||
import time
|
||||
from typing import Literal, Union
|
||||
from typing import List, Literal, Union
|
||||
|
||||
from nonebot.adapters import Message, MessageSegment
|
||||
from nonebot.adapters.onebot.v11.bot import Bot
|
||||
@ -19,6 +20,22 @@ async def _do_send(
|
||||
elif user_type == "private":
|
||||
await bot.call_api("send_private_msg", user_id=user, message=msg)
|
||||
|
||||
async def _do_send_forward(
|
||||
bot: "Bot", user: str, msgs: list
|
||||
):
|
||||
group_msg = []
|
||||
bot_info = await bot.call_api("get_login_info")#猜测返回list 第一个为user_id,第二个为nickname
|
||||
for msg in msgs:
|
||||
sub_msg = {
|
||||
"type": "node",
|
||||
"data": {
|
||||
"name": f"{bot_info[0]}",
|
||||
"uin": f"{bot_info[1]}",
|
||||
"content": msg
|
||||
}
|
||||
}
|
||||
group_msg.append(sub_msg)
|
||||
await bot.call_api("send_group_forward_msg", group_id=user, message=group_msg)
|
||||
|
||||
async def do_send_msgs():
|
||||
global LAST_SEND_TIME
|
||||
@ -40,7 +57,10 @@ async def do_send_msgs():
|
||||
|
||||
|
||||
async def send_msgs(bot: Bot, user, user_type: Literal["private", "group"], msgs: list):
|
||||
if plugin_config.bison_use_queue:
|
||||
if plugin_config.bison_use_forward_pic and user_type!="private":
|
||||
if msgs:
|
||||
_do_send_forward(bot, user, msgs)
|
||||
elif plugin_config.bison_use_queue:
|
||||
for msg in msgs:
|
||||
QUEUE.append((bot, user, user_type, msg, 2))
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user