perf: 更好的插件处理逻辑和更开放的插件功能
This commit is contained in:
+14
-2
@@ -5,8 +5,20 @@ class QQ:
|
||||
self.client = gocq
|
||||
self.client.run()
|
||||
|
||||
async def send_qq_msg(self, source, res, image_mode = False):
|
||||
print("[System-Info] 回复QQ消息中..."+res)
|
||||
async def send_qq_msg(self,
|
||||
source,
|
||||
res,
|
||||
image_mode: bool = False):
|
||||
"""
|
||||
res可以是一个数组,也就是gocq的消息链.
|
||||
"""
|
||||
|
||||
# print(res)
|
||||
print("[System-Info] 回复QQ消息中..."+str(res))
|
||||
|
||||
if isinstance(res, list) and len(res) > 0:
|
||||
await self.client.sendGroupMessage(source.group_id, res)
|
||||
return
|
||||
# 通过消息链处理
|
||||
if not image_mode:
|
||||
if source.type == "GroupMessage":
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import io
|
||||
import botpy
|
||||
from PIL import Image
|
||||
from botpy.message import Message, DirectMessage
|
||||
import re
|
||||
import asyncio
|
||||
import requests
|
||||
@@ -15,13 +16,13 @@ class QQChan():
|
||||
self.client.run(appid=appid, token=token)
|
||||
|
||||
def send_qq_msg(self, message, res, image_mode=False, msg_ref = None):
|
||||
print("[System-Info] 回复QQ频道消息中..."+res)
|
||||
print("[System-Info] 回复QQ频道消息中..."+str(res))
|
||||
if not image_mode:
|
||||
try:
|
||||
if msg_ref is not None:
|
||||
reply_res = asyncio.run_coroutine_threadsafe(message.reply(content=res, message_reference = msg_ref), self.client.loop)
|
||||
reply_res = asyncio.run_coroutine_threadsafe(message.reply(content=str(res), message_reference = msg_ref), self.client.loop)
|
||||
else:
|
||||
reply_res = asyncio.run_coroutine_threadsafe(message.reply(content=res), self.client.loop)
|
||||
reply_res = asyncio.run_coroutine_threadsafe(message.reply(content=str(res)), self.client.loop)
|
||||
reply_res.result()
|
||||
except BaseException as e:
|
||||
# 分割过长的消息
|
||||
|
||||
Reference in New Issue
Block a user