feat: QQ支持at发送方和画画指令支持

This commit is contained in:
Soulter
2023-04-21 01:00:31 +08:00
parent d912b990e4
commit 7e1e51c450
2 changed files with 28 additions and 11 deletions
+5 -1
View File
@@ -362,7 +362,11 @@ def send_message(platform, message, res, msg_ref = None, image = None, gocq_loop
qqchannel_bot.send_qq_msg(message, res, image_mode=True, msg_ref=msg_ref)
else:
qqchannel_bot.send_qq_msg(message, res, msg_ref=msg_ref)
if platform == PLATFORM_GOCQ: asyncio.run_coroutine_threadsafe(gocq_bot.send_qq_msg(message, res), gocq_loop).result()
if platform == PLATFORM_GOCQ:
if image != None:
asyncio.run_coroutine_threadsafe(gocq_bot.send_qq_msg(message, image, image_mode=True), gocq_loop).result()
else:
asyncio.run_coroutine_threadsafe(gocq_bot.send_qq_msg(message, res), gocq_loop).result()
'''
处理消息
+23 -10
View File
@@ -1,18 +1,31 @@
from nakuru.entities.components import Plain
from nakuru.entities.components import Plain, At, Image
class QQ:
def run_bot(self, gocq):
self.client = gocq
self.client.run()
async def send_qq_msg(self, source, res):
async def send_qq_msg(self, source, res, image_mode = False):
print("[System-Info] 回复QQ消息中..."+res)
# 通过消息链处理
if source.type == "GroupMessage":
await self.client.sendGroupMessage(source.group_id, [
Plain(text=res)
])
elif source.type == "FriendMessage":
await self.client.sendFriendMessage(source.user_id, [
Plain(text=res)
])
if not image_mode:
if source.type == "GroupMessage":
await self.client.sendGroupMessage(source.group_id, [
At(target=source.user_id),
Plain(text=res)
])
elif source.type == "FriendMessage":
await self.client.sendFriendMessage(source.user_id, [
Plain(text=res)
])
else:
if source.type == "GroupMessage":
await self.client.sendGroupMessage(source.group_id, [
At(target=source.user_id),
Plain(text="好的,我根据你的需要为你生成了一张图片😊")
Image.fromURL(url=res)
])
elif source.type == "FriendMessage":
await self.client.sendFriendMessage(source.user_id, [
Image.fromURL(url=res)
])