mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-05 03:39:59 +08:00
update v0.0.5.0
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
import nonebot
|
||||
|
||||
nonebot.load_plugins("plugins/alapi")
|
||||
@@ -5,32 +5,44 @@ from configs.config import ALAPI_TOKEN
|
||||
from .data_source import get_data
|
||||
from services.log import logger
|
||||
|
||||
__plugin_name__ = '网易云热评'
|
||||
__plugin_usage__ = '用法: 生了个人,我很抱歉'
|
||||
|
||||
comments_163 = on_command("网易云热评", aliases={'网易云评论', '到点了', '12点了'}, priority=5, block=True)
|
||||
__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点了"],
|
||||
}
|
||||
|
||||
|
||||
comments_163_url = 'https://v2.alapi.cn/api/comment'
|
||||
comments_163 = on_command(
|
||||
"网易云热评", aliases={"网易云评论", "到点了", "12点了"}, priority=5, block=True
|
||||
)
|
||||
|
||||
|
||||
comments_163_url = "https://v2.alapi.cn/api/comment"
|
||||
|
||||
|
||||
@comments_163.handle()
|
||||
async def _(bot: Bot, event: MessageEvent, state: T_State):
|
||||
params = {
|
||||
'token': ALAPI_TOKEN
|
||||
}
|
||||
params = {"token": ALAPI_TOKEN}
|
||||
data, code = await get_data(comments_163_url, params)
|
||||
if code != 200:
|
||||
await comments_163.finish(data, at_sender=True)
|
||||
data = data['data']
|
||||
comment = data['comment_content']
|
||||
song_name = data['title']
|
||||
await comments_163.send(f'{comment}\n\t——《{song_name}》')
|
||||
data = data["data"]
|
||||
comment = data["comment_content"]
|
||||
song_name = data["title"]
|
||||
await comments_163.send(f"{comment}\n\t——《{song_name}》")
|
||||
logger.info(
|
||||
f"(USER {event.user_id}, GROUP {event.group_id if isinstance(event, GroupMessageEvent) else 'private'})"
|
||||
f" 发送网易云热评: {comment} \n\t\t————{song_name}")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
f" 发送网易云热评: {comment} \n\t\t————{song_name}"
|
||||
)
|
||||
|
||||
+16
-3
@@ -7,9 +7,22 @@ from utils.utils import get_message_text
|
||||
from .data_source import get_data
|
||||
from services.log import logger
|
||||
|
||||
__plugin_name__ = 'b封面'
|
||||
__plugin_usage__ = '用法: b封面 (链接,av,bv,cv,直播id)\n\t' \
|
||||
'示例:b封面 av86863038'
|
||||
__zx_plugin_name__ = 'b封面'
|
||||
__plugin_usage__ = """usage:
|
||||
b封面 [链接/av/bv/cv/直播id]
|
||||
示例:b封面 av86863038
|
||||
"""
|
||||
__plugin_des__ = '快捷的b站视频封面获取方式'
|
||||
__plugin_cmd__ = ['b封面/B封面']
|
||||
__plugin_type__ = ('一些工具',)
|
||||
__plugin_version__ = 0.1
|
||||
__plugin_author__ = 'HibiKier'
|
||||
__plugin_settings__ = {
|
||||
"level": 5,
|
||||
"default_status": True,
|
||||
"limit_superuser": False,
|
||||
"cmd": ["b封面", 'B封面'],
|
||||
}
|
||||
|
||||
|
||||
cover = on_command('b封面', aliases={'B封面'}, priority=5, block=True)
|
||||
|
||||
@@ -2,10 +2,16 @@ from nonebot.adapters.cqhttp import MessageSegment
|
||||
from utils.image_utils import CreateImg
|
||||
from utils.message_builder import image
|
||||
from configs.path_config import IMAGE_PATH
|
||||
from typing import Union
|
||||
import aiohttp
|
||||
|
||||
|
||||
async def get_data(url: str, params: dict):
|
||||
async def get_data(url: str, params: dict) -> 'Union[dict, str], int':
|
||||
"""
|
||||
获取ALAPI数据
|
||||
:param url: 请求链接
|
||||
:param params: 参数
|
||||
"""
|
||||
async with aiohttp.ClientSession() as session:
|
||||
try:
|
||||
async with session.get(
|
||||
@@ -22,7 +28,11 @@ async def get_data(url: str, params: dict):
|
||||
return "超时了....", 998
|
||||
|
||||
|
||||
def gen_wbtop_pic(data) -> MessageSegment:
|
||||
def gen_wbtop_pic(data: dict) -> MessageSegment:
|
||||
"""
|
||||
生成微博热搜图片
|
||||
:param data: 微博热搜数据
|
||||
"""
|
||||
bk = CreateImg(700, 32 * 50 + 280, 700, 32, color='#797979')
|
||||
wbtop_bk = CreateImg(700, 280, background=f'{IMAGE_PATH}/other/webtop.png')
|
||||
bk.paste(wbtop_bk)
|
||||
|
||||
+15
-3
@@ -5,9 +5,21 @@ from configs.config import ALAPI_TOKEN
|
||||
from services.log import logger
|
||||
from .data_source import get_data
|
||||
|
||||
__plugin_name__ = '古诗'
|
||||
__plugin_usage__ = '用法: 无'
|
||||
|
||||
__zx_plugin_name__ = '古诗'
|
||||
__plugin_usage__ = """usage:
|
||||
平白无故念首诗
|
||||
示例:念诗/来首诗/念首诗
|
||||
"""
|
||||
__plugin_des__ = '为什么突然文艺起来了!'
|
||||
__plugin_cmd__ = ['念诗/来首诗/念首诗']
|
||||
__plugin_version__ = 0.1
|
||||
__plugin_author__ = 'HibiKier'
|
||||
__plugin_settings__ = {
|
||||
"level": 5,
|
||||
"default_status": True,
|
||||
"limit_superuser": False,
|
||||
"cmd": ['念诗', '来首诗', '念首诗'],
|
||||
}
|
||||
|
||||
poetry = on_command("念诗", aliases={'来首诗', '念首诗'}, priority=5, block=True)
|
||||
|
||||
|
||||
+21
-5
@@ -10,9 +10,25 @@ from configs.path_config import IMAGE_PATH
|
||||
from utils.message_builder import image
|
||||
import asyncio
|
||||
|
||||
__plugin_name__ = '微博热搜'
|
||||
__plugin_usage__ = '用法: 无'
|
||||
|
||||
__zx_plugin_name__ = '微博热搜'
|
||||
__plugin_usage__ = """
|
||||
usage:
|
||||
在QQ上吃个瓜
|
||||
指令:
|
||||
微博热搜:发送实时热搜
|
||||
微博热搜 [id]:截图该热搜页面
|
||||
示例:微博热搜 5
|
||||
""".strip()
|
||||
__plugin_des__ = '刚买完瓜,在吃瓜现场'
|
||||
__plugin_cmd__ = ['微博热搜', '微博热搜 [id]']
|
||||
__plugin_version__ = 0.1
|
||||
__plugin_author__ = 'HibiKier'
|
||||
__plugin_settings__ = {
|
||||
"level": 5,
|
||||
"default_status": True,
|
||||
"limit_superuser": False,
|
||||
"cmd": ['微博热搜'],
|
||||
}
|
||||
|
||||
wbtop = on_command("wbtop", aliases={'微博热搜'}, priority=5, block=True)
|
||||
|
||||
@@ -52,9 +68,9 @@ async def _(bot: Bot, event: MessageEvent, state: T_State):
|
||||
await page.goto(url, wait_until='networkidle', timeout=10000)
|
||||
await page.set_viewport_size({"width": 2560, "height": 1080})
|
||||
div = await page.query_selector("#pl_feedlist_index")
|
||||
await div.screenshot(path=f'{IMAGE_PATH}/temp/webtop_{event.user_id}.png', timeout=100000)
|
||||
await div.screenshot(path=f'{IMAGE_PATH}/temp/wbtop_{event.user_id}.png', timeout=100000)
|
||||
await page.close()
|
||||
await wbtop.send(image(f'webtop_{event.user_id}.png', 'temp'))
|
||||
await wbtop.send(image(f'wbtop_{event.user_id}.png', 'temp'))
|
||||
except Exception as e:
|
||||
logger.error(f'微博热搜截图出错... {type(e)}: {e}')
|
||||
if page:
|
||||
|
||||
Reference in New Issue
Block a user