Merge pull request 'Dora表情包' (#23) from QAQ into master
Reviewed-on: #23
This commit is contained in:
commit
c4fb786d5a
24
main.py
24
main.py
@ -305,9 +305,27 @@ class MyPlugin(Star):
|
|||||||
testNumber = testNumber + 1
|
testNumber = testNumber + 1
|
||||||
yield event.plain_result(f"累积结果: {testNumber}")
|
yield event.plain_result(f"累积结果: {testNumber}")
|
||||||
|
|
||||||
@filter.command("麦否?")
|
import astrbot.api.message_components as Comp
|
||||||
async def QAQtest(self, event: AstrMessageEvent):
|
import aiohttp # 需要异步HTTP客户端
|
||||||
yield event.plain_result("每日一麦")
|
|
||||||
|
@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("部署")
|
@filter.command("部署")
|
||||||
async def bushutest(self, event: AstrMessageEvent):
|
async def bushutest(self, event: AstrMessageEvent):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user