Compare commits

...
11 Commits
8 changed files with 52 additions and 14 deletions
+18 -2
View File
@@ -1,6 +1,15 @@
# StarBot
<div align="center">
一款极速,多功能的哔哩哔哩推送机器人。
![logo](https://bot.starlwr.com/images/static/logo.jpg)
[![PyPI](https://img.shields.io/pypi/v/starbot-bilibili)](https://pypi.org/project/starbot-bilibili)
[![Python](https://img.shields.io/badge/python-3.10%20|%203.11-blue)](https://www.python.org)
[![License](https://img.shields.io/github/license/Starlwr/StarBot)](https://github.com/Starlwr/StarBot/blob/master/LICENSE)
[![STARS](https://img.shields.io/github/stars/Starlwr/StarBot?color=yellow&label=Stars)](https://github.com/Starlwr/StarBot/stargazers)
**一个极速,多功能的哔哩哔哩推送机器人**
</div>
## 特性
@@ -44,3 +53,10 @@ bot.run()
* [Ariadne](https://github.com/GraiaProject/Ariadne): 一个优雅且完备的 Python QQ 自动化框架,基于 Mirai API HTTP v2
* [Fake-QQ-Chat-Window](https://github.com/Redlnn/Fake-QQ-Chat-Window): 伪 QQ 移动客户端聊天窗口,当前官网的推送配置在线预览基于此项目魔改实现
* [为本项目赞赏支持的小伙伴们](https://bot.starlwr.com/about): 名单较长,详细名单可点击链接在官网查看
* [JetBrains](https://www.jetbrains.com/?from=StarBot): 为开源项目免费提供的优秀 IDE
[<img src="https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg"/>](https://www.jetbrains.com/?from=StarBot)
## Star History
[![Star History Chart](https://api.star-history.com/svg?repos=Starlwr/StarBot&type=Date)](https://star-history.com/#Starlwr/StarBot&Date)
+3
View File
@@ -44,6 +44,9 @@ async def bind(app: Ariadne,
uid = remove_command_param_placeholder(uid.display)
# Replace
uid = uid.replace("UID:", "")
if not uid.isdigit() or int(uid) == 0:
await app.send_message(sender, MessageChain(f"请输入正确的UID~\n命令示例:{prefix}绑定 114514"), quote=source)
return
+2 -2
View File
@@ -90,7 +90,7 @@ async def ranking(app: Ariadne,
if length == 0:
await app.send_message(sender, MessageChain(f"{up.uname} 的房间暂无{type_map[_type][2]}数据~"), quote=source)
return
continue
if page > page_length:
await app.send_message(
@@ -98,7 +98,7 @@ async def ranking(app: Ariadne,
MessageChain(f"{up.uname} 的房间{type_map[_type][3]}榜页码范围为 1 ~ {page_length}\n请重新输入正确的页码~"),
quote=source
)
return
continue
data = await type_map[_type][1](up.room_id, start, end)
top_count = (await type_map[_type][1](up.room_id, 0, 0))[0][1]
@@ -80,7 +80,7 @@ async def ranking_double(app: Ariadne,
if length == 0:
await app.send_message(sender, MessageChain(f"{up.uname} 的房间暂无{type_map[_type][2]}数据~"), quote=source)
return
continue
if page > page_length:
await app.send_message(
@@ -88,7 +88,7 @@ async def ranking_double(app: Ariadne,
MessageChain(f"{up.uname} 的房间{type_map[_type][3]}榜页码范围为 1 ~ {page_length}\n请重新输入正确的页码~"),
quote=source
)
return
continue
data = await type_map[_type][1](up.room_id, start, end)
top_count = max(
+2 -2
View File
@@ -26,7 +26,7 @@ class StarBot:
"""
StarBot 类
"""
VERSION = "2.0.7"
VERSION = "2.0.11"
STARBOT_ASCII_LOGO = "\n".join(
(
r" _____ _ ____ _ ",
@@ -35,7 +35,7 @@ class StarBot:
r" \___ \| __/ _` | '__| _ < / _ \| __|",
r" ____) | || (_| | | | |_) | (_) | |_ ",
r" |_____/ \__\__,_|_| |____/ \___/ \__|",
f" StarBot - (v{VERSION}) 2023-10-15",
f" StarBot - (v{VERSION}) 2024-11-09",
r" Github: https://github.com/Starlwr/StarBot",
r"",
r"",
+2
View File
@@ -61,6 +61,8 @@ async def dynamic_spider(datasource: DataSource):
detail = latest_dynamic["cards"][i]
except IndexError:
break
except TypeError:
break
dynamic_id = detail['desc']['dynamic_id']
if await redis.exists_dynamic(dynamic_id):
+21 -4
View File
@@ -11,7 +11,7 @@ from .PicGenerator import Color, PicGenerator
from ..utils import config
from ..utils.network import request
from ..utils.utils import open_url_image, timestamp_format, split_list, limit_str_length, \
mask_round, mask_rounded_rectangle
mask_round, mask_rounded_rectangle, get_credential
class DynamicPicGenerator:
@@ -169,9 +169,26 @@ class DynamicPicGenerator:
"""
mod["img"] = await open_url_image(mod["emoji"]["icon_url"])
modules_url = f"https://api.bilibili.com/x/polymer/web-dynamic/v1/detail?timezone_offset=-480&id={dynamic_id}"
modules = (await request("GET", modules_url))["item"]["modules"]["module_dynamic"]["desc"]
modules = modules["rich_text_nodes"] if modules else []
if dynamic_type == 2 or dynamic_type == 4:
# 有些动态带有标题,不显示标题会缺少上下文
modules_url =f"https://api.bilibili.com/x/polymer/web-dynamic/v1/detail?timezone_offset=-480&id={dynamic_id}&features=itemOpusStyle,opusBigCover,onlyfansVote"
modules = (await request("GET", modules_url, credential=get_credential()))["item"]["modules"]["module_dynamic"]["major"]["opus"]
title = modules["title"]
modules = modules["summary"]
if modules:
modules = modules["rich_text_nodes"]
if title is not None:
modules.insert(0, {
'orig_text': f"{title}\n",
'text': f"{title}\n",
'type': 'RICH_TEXT_NODE_TYPE_TEXT'
})
else:
modules = []
else :
modules_url = f"https://api.bilibili.com/x/polymer/web-dynamic/v1/detail?timezone_offset=-480&id={dynamic_id}"
modules = (await request("GET", modules_url, credential=get_credential()))["item"]["modules"]["module_dynamic"]["desc"]
modules = modules["rich_text_nodes"] if modules else []
# 下载表情
download_picture_tasks = []
+1 -1
View File
@@ -158,7 +158,7 @@ class RankingGenerator:
chart = PicGenerator(width, (face_size * count) + (row_space * (count - 1)))
chart.set_row_space(row_space)
for i in range(count):
bar_width = int(abs(counts[i]) / top_count * top_bar_width)
bar_width = int(abs(counts[i]) / top_count * top_bar_width) if top_count != 0 else 0.1
if bar_width != 0:
if counts[i] > 0:
bar = cls.__get_rank_bar_pic(bar_width, bar_height, start_color, end_color)