Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f92b4d7136 | ||
|
|
fbc766520a | ||
|
|
6a90fd646e | ||
|
|
b62c95580a | ||
|
|
ad6ba2886f | ||
|
|
2c0a2de421 | ||
|
|
9372bdf00e | ||
|
|
ac6e483dd1 | ||
|
|
a58242147b | ||
|
|
3f098fa399 | ||
|
|
5c8beaf125 |
@@ -1,6 +1,15 @@
|
|||||||
# StarBot
|
<div align="center">
|
||||||
|
|
||||||
一款极速,多功能的哔哩哔哩推送机器人。
|

|
||||||
|
|
||||||
|
[](https://pypi.org/project/starbot-bilibili)
|
||||||
|
[](https://www.python.org)
|
||||||
|
[](https://github.com/Starlwr/StarBot/blob/master/LICENSE)
|
||||||
|
[](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
|
* [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 移动客户端聊天窗口,当前官网的推送配置在线预览基于此项目魔改实现
|
* [Fake-QQ-Chat-Window](https://github.com/Redlnn/Fake-QQ-Chat-Window): 伪 QQ 移动客户端聊天窗口,当前官网的推送配置在线预览基于此项目魔改实现
|
||||||
* [为本项目赞赏支持的小伙伴们](https://bot.starlwr.com/about): 名单较长,详细名单可点击链接在官网查看
|
* [为本项目赞赏支持的小伙伴们](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
|
||||||
|
|
||||||
|
[](https://star-history.com/#Starlwr/StarBot&Date)
|
||||||
@@ -44,6 +44,9 @@ async def bind(app: Ariadne,
|
|||||||
|
|
||||||
uid = remove_command_param_placeholder(uid.display)
|
uid = remove_command_param_placeholder(uid.display)
|
||||||
|
|
||||||
|
# Replace
|
||||||
|
uid = uid.replace("UID:", "")
|
||||||
|
|
||||||
if not uid.isdigit() or int(uid) == 0:
|
if not uid.isdigit() or int(uid) == 0:
|
||||||
await app.send_message(sender, MessageChain(f"请输入正确的UID~\n命令示例:{prefix}绑定 114514"), quote=source)
|
await app.send_message(sender, MessageChain(f"请输入正确的UID~\n命令示例:{prefix}绑定 114514"), quote=source)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ async def ranking(app: Ariadne,
|
|||||||
|
|
||||||
if length == 0:
|
if length == 0:
|
||||||
await app.send_message(sender, MessageChain(f"{up.uname} 的房间暂无{type_map[_type][2]}数据~"), quote=source)
|
await app.send_message(sender, MessageChain(f"{up.uname} 的房间暂无{type_map[_type][2]}数据~"), quote=source)
|
||||||
return
|
continue
|
||||||
|
|
||||||
if page > page_length:
|
if page > page_length:
|
||||||
await app.send_message(
|
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请重新输入正确的页码~"),
|
MessageChain(f"{up.uname} 的房间{type_map[_type][3]}榜页码范围为 1 ~ {page_length}\n请重新输入正确的页码~"),
|
||||||
quote=source
|
quote=source
|
||||||
)
|
)
|
||||||
return
|
continue
|
||||||
|
|
||||||
data = await type_map[_type][1](up.room_id, start, end)
|
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]
|
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:
|
if length == 0:
|
||||||
await app.send_message(sender, MessageChain(f"{up.uname} 的房间暂无{type_map[_type][2]}数据~"), quote=source)
|
await app.send_message(sender, MessageChain(f"{up.uname} 的房间暂无{type_map[_type][2]}数据~"), quote=source)
|
||||||
return
|
continue
|
||||||
|
|
||||||
if page > page_length:
|
if page > page_length:
|
||||||
await app.send_message(
|
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请重新输入正确的页码~"),
|
MessageChain(f"{up.uname} 的房间{type_map[_type][3]}榜页码范围为 1 ~ {page_length}\n请重新输入正确的页码~"),
|
||||||
quote=source
|
quote=source
|
||||||
)
|
)
|
||||||
return
|
continue
|
||||||
|
|
||||||
data = await type_map[_type][1](up.room_id, start, end)
|
data = await type_map[_type][1](up.room_id, start, end)
|
||||||
top_count = max(
|
top_count = max(
|
||||||
|
|||||||
+2
-2
@@ -26,7 +26,7 @@ class StarBot:
|
|||||||
"""
|
"""
|
||||||
StarBot 类
|
StarBot 类
|
||||||
"""
|
"""
|
||||||
VERSION = "2.0.7"
|
VERSION = "2.0.11"
|
||||||
STARBOT_ASCII_LOGO = "\n".join(
|
STARBOT_ASCII_LOGO = "\n".join(
|
||||||
(
|
(
|
||||||
r" _____ _ ____ _ ",
|
r" _____ _ ____ _ ",
|
||||||
@@ -35,7 +35,7 @@ class StarBot:
|
|||||||
r" \___ \| __/ _` | '__| _ < / _ \| __|",
|
r" \___ \| __/ _` | '__| _ < / _ \| __|",
|
||||||
r" ____) | || (_| | | | |_) | (_) | |_ ",
|
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" Github: https://github.com/Starlwr/StarBot",
|
||||||
r"",
|
r"",
|
||||||
r"",
|
r"",
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ async def dynamic_spider(datasource: DataSource):
|
|||||||
detail = latest_dynamic["cards"][i]
|
detail = latest_dynamic["cards"][i]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
break
|
break
|
||||||
|
except TypeError:
|
||||||
|
break
|
||||||
|
|
||||||
dynamic_id = detail['desc']['dynamic_id']
|
dynamic_id = detail['desc']['dynamic_id']
|
||||||
if await redis.exists_dynamic(dynamic_id):
|
if await redis.exists_dynamic(dynamic_id):
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from .PicGenerator import Color, PicGenerator
|
|||||||
from ..utils import config
|
from ..utils import config
|
||||||
from ..utils.network import request
|
from ..utils.network import request
|
||||||
from ..utils.utils import open_url_image, timestamp_format, split_list, limit_str_length, \
|
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:
|
class DynamicPicGenerator:
|
||||||
@@ -169,9 +169,26 @@ class DynamicPicGenerator:
|
|||||||
"""
|
"""
|
||||||
mod["img"] = await open_url_image(mod["emoji"]["icon_url"])
|
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}"
|
if dynamic_type == 2 or dynamic_type == 4:
|
||||||
modules = (await request("GET", modules_url))["item"]["modules"]["module_dynamic"]["desc"]
|
# 有些动态带有标题,不显示标题会缺少上下文
|
||||||
modules = modules["rich_text_nodes"] if modules else []
|
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 = []
|
download_picture_tasks = []
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ class RankingGenerator:
|
|||||||
chart = PicGenerator(width, (face_size * count) + (row_space * (count - 1)))
|
chart = PicGenerator(width, (face_size * count) + (row_space * (count - 1)))
|
||||||
chart.set_row_space(row_space)
|
chart.set_row_space(row_space)
|
||||||
for i in range(count):
|
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 bar_width != 0:
|
||||||
if counts[i] > 0:
|
if counts[i] > 0:
|
||||||
bar = cls.__get_rank_bar_pic(bar_width, bar_height, start_color, end_color)
|
bar = cls.__get_rank_bar_pic(bar_width, bar_height, start_color, end_color)
|
||||||
|
|||||||
Reference in New Issue
Block a user