zhenxun_bot/plugins/alapi/comments_163.py

47 lines
1.5 KiB
Python
Raw Normal View History

2021-06-24 15:32:06 +08:00
from nonebot import on_command
2021-08-17 23:17:08 +08:00
from nonebot.adapters.cqhttp import Bot, MessageEvent, GroupMessageEvent
2021-06-24 15:32:06 +08:00
from nonebot.typing import T_State
2021-08-17 23:17:08 +08:00
from .data_source import get_data
2021-06-24 15:32:06 +08:00
from services.log import logger
2021-10-03 14:24:07 +08:00
__zx_plugin_name__ = "网易云热评"
__plugin_usage__ = """
usage
到点了还是防不了下塔
指令
网易云热评/到点了/12点了
""".strip()
__plugin_des__ = "生了个人,我很抱歉"
__plugin_cmd__ = ["网易云热评", "到点了", "12点了"]
__plugin_version__ = 0.1
__plugin_author__ = "HibiKier"
__plugin_settings__ = {
"level": 5,
"default_status": True,
"limit_superuser": False,
"cmd": ["网易云热评", "网易云评论", "到点了", "12点了"],
}
2021-06-24 15:32:06 +08:00
2021-10-03 14:24:07 +08:00
comments_163 = on_command(
"网易云热评", aliases={"网易云评论", "到点了", "12点了"}, priority=5, block=True
)
2021-06-24 15:32:06 +08:00
2021-10-03 14:24:07 +08:00
comments_163_url = "https://v2.alapi.cn/api/comment"
2021-06-24 15:32:06 +08:00
@comments_163.handle()
async def _(bot: Bot, event: MessageEvent, state: T_State):
2021-11-04 16:11:50 +08:00
data, code = await get_data(comments_163_url)
2021-06-24 15:32:06 +08:00
if code != 200:
await comments_163.finish(data, at_sender=True)
2021-10-03 14:24:07 +08:00
data = data["data"]
comment = data["comment_content"]
song_name = data["title"]
await comments_163.send(f"{comment}\n\t——《{song_name}")
2021-06-24 15:32:06 +08:00
logger.info(
2021-08-17 23:17:08 +08:00
f"(USER {event.user_id}, GROUP {event.group_id if isinstance(event, GroupMessageEvent) else 'private'})"
2021-10-03 14:24:07 +08:00
f" 发送网易云热评: {comment} \n\t\t————{song_name}"
)