- hexi core: message handling, rate limiting, cooldown, plugin manager - Custom plugins: BF stats, daily check-in, quotes, persona cards, etc. - Community plugins vendored under hexi/plugins with local fixes - Web admin frontends (learning-chat, persona-admin), unified hexi/web - Tests for rate_limit/cooldown/memes/persona; poetry.lock Co-Authored-By: Claude <noreply@anthropic.com>
46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
import httpx
|
|
from nonebot import logger, on_command
|
|
from nonebot.adapters import Message
|
|
from nonebot.matcher import Matcher
|
|
from nonebot.params import CommandArg
|
|
from nonebot.adapters.onebot.v11 import MessageEvent, Bot, MessageSegment
|
|
import re
|
|
import json
|
|
|
|
from nonebot.plugin import PluginMetadata
|
|
|
|
__plugin_meta__ = PluginMetadata(
|
|
name="网抑云",
|
|
description="随机一条网易云热评",
|
|
usage="/网抑云 | 网易云热评 | emo:随机一条网易云热评",
|
|
type="application",
|
|
)
|
|
|
|
__help_version__ = '0.1.0'
|
|
__help_plugin_name__ = "网抑云"
|
|
__usage__ = """一开口就老网抑云了
|
|
|
|
指令:/网抑云|网易云热评:随机一条网易云热评"""
|
|
|
|
hitokoto_matcher = on_command("网抑云", aliases={"网易云热评", "emo"})
|
|
|
|
|
|
@hitokoto_matcher.handle()
|
|
async def hitokoto(event: MessageEvent):
|
|
async with httpx.AsyncClient() as client:
|
|
response = await client.get("https://v.api.aa1.cn/api/api-wenan-wangyiyunreping/index.php?aa1=text")
|
|
if response.is_error:
|
|
logger.error("获取网抑云失败")
|
|
return
|
|
# 提取 JSON 部分
|
|
pattern = r'<p>(.*?)</p>'
|
|
match = re.search(pattern, response.text)
|
|
|
|
if match:
|
|
data = match.group(1)
|
|
logger.info(f"解析后的数据:{data}")
|
|
mes = (MessageSegment.reply(event.message_id), data.split("——")[0])
|
|
await hitokoto_matcher.finish(mes)
|
|
else:
|
|
logger.warning("未找到 匹配 部分")
|