Files
HeXi/hexi/plugins/nonebot_plugin_makeaquote/__init__.py
T
sansenhoshiandClaude b61d09f09f Add HeXi bot codebase: custom plugins, web frontends, tests
- 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>
2026-09-01 13:13:40 +08:00

37 lines
1.0 KiB
Python

from nonebot import logger, on_message, require
require("nonebot_plugin_alconna")
from nonebot_plugin_alconna import UniMessage
from nonebot.adapters.onebot.v11 import Bot, Event
from nonebot.plugin import PluginMetadata
from nonebot.rule import keyword
from .Reply import extract_reply
from .make_a_qoute import generate
__plugin_meta__ = PluginMetadata(
name="语录",
description="生成一条语录",
usage="发送【maq】",
type="application",
)
maq = on_message(keyword("maq"))
@maq.handle()
async def maq_handle(bot: Bot, ev: Event):
event = ev.dict()
try:
if event.get("message_type") != "group":
return
reply = await extract_reply(event, bot)
if reply.message == -1:
await maq.finish("请引用文字消息")
logger.info(f"{reply.user_id}, {reply.user_card}, {reply.message}")
image = await generate(reply)
await UniMessage.image(raw=image.getvalue()).send()
except (KeyError, TypeError) as e:
logger.error(e)
await maq.finish(str(e))