mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-04 19:29:59 +08:00
✨ 移除saa依赖
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
from nonebot import on_regex
|
||||
from nonebot.plugin import PluginMetadata
|
||||
from nonebot_plugin_alconna import Alconna, Arparma, on_alconna
|
||||
from nonebot_plugin_saa import Text
|
||||
from nonebot_plugin_session import EventSession
|
||||
|
||||
from zhenxun.configs.utils import PluginExtraData
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils.message import MessageUtils
|
||||
|
||||
from ._data_source import get_data
|
||||
|
||||
@@ -43,11 +43,13 @@ _matcher.shortcut(
|
||||
async def _(session: EventSession, arparma: Arparma):
|
||||
data, code = await get_data(comments_163_url)
|
||||
if code != 200 and isinstance(data, str):
|
||||
await Text(data).finish(reply=True)
|
||||
await MessageUtils.build_message(data).finish(reply_to=True)
|
||||
data = data["data"] # type: ignore
|
||||
comment = data["comment_content"] # type: ignore
|
||||
song_name = data["title"] # type: ignore
|
||||
await Text(f"{comment}\n\t——《{song_name}》").send(reply=True)
|
||||
await MessageUtils.build_message(f"{comment}\n\t——《{song_name}》").send(
|
||||
reply_to=True
|
||||
)
|
||||
logger.info(
|
||||
f" 发送网易云热评: {comment} \n\t\t————{song_name}",
|
||||
arparma.header_result,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from nonebot.plugin import PluginMetadata
|
||||
from nonebot_plugin_alconna import Alconna, Arparma, on_alconna
|
||||
from nonebot_plugin_saa import Text
|
||||
from nonebot_plugin_session import EventSession
|
||||
|
||||
from zhenxun.configs.utils import PluginExtraData
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils.message import MessageUtils
|
||||
|
||||
from ._data_source import get_data
|
||||
|
||||
@@ -36,13 +36,13 @@ async def _(session: EventSession, arparma: Arparma):
|
||||
try:
|
||||
data, code = await get_data(url)
|
||||
if code != 200 and isinstance(data, str):
|
||||
await Text(data).finish(reply=True)
|
||||
await Text(data["data"]["content"]).send(reply=True) # type: ignore
|
||||
await MessageUtils.build_message(data).finish(reply_to=True)
|
||||
await MessageUtils.build_message(data["data"]["content"]).send(reply_to=True) # type: ignore
|
||||
logger.info(
|
||||
f" 发送鸡汤:" + data["data"]["content"], # type:ignore
|
||||
arparma.header_result,
|
||||
session=session,
|
||||
)
|
||||
except Exception as e:
|
||||
await Text("鸡汤煮坏掉了...").send()
|
||||
await MessageUtils.build_message("鸡汤煮坏掉了...").send()
|
||||
logger.error(f"鸡汤煮坏掉了", e=e)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from nonebot.plugin import PluginMetadata
|
||||
from nonebot_plugin_alconna import Alconna, Arparma, on_alconna
|
||||
from nonebot_plugin_saa import Text
|
||||
from nonebot_plugin_session import EventSession
|
||||
|
||||
from zhenxun.configs.utils import PluginExtraData
|
||||
from zhenxun.services.log import logger
|
||||
from zhenxun.utils.message import MessageUtils
|
||||
|
||||
from ._data_source import get_data
|
||||
|
||||
@@ -42,12 +42,14 @@ poetry_url = "https://v2.alapi.cn/api/shici"
|
||||
async def _(session: EventSession, arparma: Arparma):
|
||||
data, code = await get_data(poetry_url)
|
||||
if code != 200 and isinstance(data, str):
|
||||
await Text(data).finish(reply=True)
|
||||
await MessageUtils.build_message(data).finish(reply_to=True)
|
||||
data = data["data"] # type: ignore
|
||||
content = data["content"] # type: ignore
|
||||
title = data["origin"] # type: ignore
|
||||
author = data["author"] # type: ignore
|
||||
await Text(f"{content}\n\t——{author}《{title}》").send(reply=True)
|
||||
await MessageUtils.build_message(f"{content}\n\t——{author}《{title}》").send(
|
||||
reply_to=True
|
||||
)
|
||||
logger.info(
|
||||
f" 发送古诗: f'{content}\n\t--{author}《{title}》'",
|
||||
arparma.header_result,
|
||||
|
||||
Reference in New Issue
Block a user