From 263c2476fcf018e2bbac48eaadc6398d3ffbc7a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CQAQ=E2=80=9D?= <“1540691861@qq.com”> Date: Thu, 22 May 2025 17:41:15 +0800 Subject: [PATCH] =?UTF-8?q?Dora=E8=A1=A8=E6=83=85=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index c0fe886..999b0a6 100644 --- a/main.py +++ b/main.py @@ -305,9 +305,27 @@ class MyPlugin(Star): testNumber = testNumber + 1 yield event.plain_result(f"累积结果: {testNumber}") - @filter.command("麦否?") - async def QAQtest(self, event: AstrMessageEvent): - yield event.plain_result("每日一麦") + import astrbot.api.message_components as Comp + import aiohttp # 需要异步HTTP客户端 + + @filter.command("Dora") + async def Dora(self, event: AstrMessageEvent): + async with aiohttp.ClientSession() as session: + async with session.get('https://www.doro.asia/api/random-sticker') as resp: + if resp.status == 200: + data = await resp.json() + if data.get('success', False): + image_url = data['sticker']['url'] + chain = [ + Comp.At(qq=event.get_sender_id()), # At 消息发送者 + Comp.Plain("Dora:"), + Comp.Image.fromURL(image_url), # 使用API返回的图片URL + ] + yield event.chain_result(chain) + else: + yield "获取表情包失败" + else: + yield "API请求失败" @filter.command("部署") async def bushutest(self, event: AstrMessageEvent):