mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-09-29 00:32:06 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
065432448f | ||
|
|
5d45a9c28a | ||
|
|
7db5b3b5c0 | ||
|
|
5eb64060dc | ||
|
|
2c4877b9f8 | ||
|
|
218dad3b86 | ||
|
|
974c6b106a | ||
|
|
954b281b69 | ||
|
|
b1b15b63a1 | ||
|
|
49567aa958 | ||
|
|
a7a470066b | ||
|
|
4e3010d75e | ||
|
|
cbacd726ef | ||
|
|
58a1fc1ca0 | ||
|
|
a704f88d75 | ||
|
|
10d0ad7d47 |
@@ -2,7 +2,7 @@
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
# 绪山真寻Bot
|
||||
****
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
__version__: v0.0.4.0
|
||||
__version__: v0.0.4.3
|
||||
|
||||
@@ -132,7 +132,7 @@ def hello() -> str:
|
||||
(
|
||||
"哦豁?!",
|
||||
"你好!Ov<",
|
||||
f"库库库,呼唤{list(get_bot().config.nickname)[0]}做什么呢",
|
||||
f"库库库,呼唤{NICKNAME}做什么呢",
|
||||
"我在呢!",
|
||||
"呼呼,叫俺干嘛",
|
||||
)
|
||||
@@ -170,8 +170,8 @@ async def check_text(text: str, sess: ClientSession) -> str:
|
||||
async with sess.get(check_url, timeout=2, params=params) as response:
|
||||
data = await response.json()
|
||||
if data["code"] == 200:
|
||||
if data["conclusion_type"] == 2:
|
||||
if data['data']["conclusion_type"] == 2:
|
||||
return ''
|
||||
except Exception as e:
|
||||
logger.error(f"检测违规文本错误...e:{e}")
|
||||
logger.error(f"检测违规文本错误...{type(e)}:{e}")
|
||||
return text
|
||||
|
||||
@@ -80,7 +80,6 @@ async def _(bot: Bot, event: MessageEvent, state: T_State):
|
||||
if sub_type in ["season", "动漫", "番剧"]:
|
||||
rst = "*以为您找到以下番剧,请输入Id选择:*\n"
|
||||
state["season_data"] = await get_media_id(id_)
|
||||
print(state["season_data"])
|
||||
if len(state["season_data"]) == 0:
|
||||
await add_sub.finish(f"未找到番剧:{msg}")
|
||||
for i, x in enumerate(state["season_data"]):
|
||||
@@ -105,7 +104,6 @@ async def _(bot: Bot, event: MessageEvent, state: T_State):
|
||||
await add_sub.send(await add_season_sub(id_, sub_user))
|
||||
else:
|
||||
await add_sub.finish("参数错误,第一参数必须为:主播/up/番剧!")
|
||||
sub_manager.reload_flag = True
|
||||
logger.info(
|
||||
f"(USER {event.user_id}, GROUP "
|
||||
f"{event.group_id if isinstance(event, GroupMessageEvent) else 'private'})"
|
||||
@@ -151,8 +149,8 @@ async def _(bot: Bot, event: MessageEvent, state: T_State):
|
||||
f'\t当前集数:{x.season_current_episode}\n' \
|
||||
f'------------------\n'
|
||||
live_rst = '当前订阅的直播:\n' + live_rst if live_rst else live_rst
|
||||
up_rst = '当前订阅的UP:\n' if up_rst else up_rst
|
||||
season_rst = '当前订阅的番剧:\n' if season_rst else season_rst
|
||||
up_rst = '当前订阅的UP:\n' + up_rst if up_rst else up_rst
|
||||
season_rst = '当前订阅的番剧:\n' + season_rst if season_rst else season_rst
|
||||
if not live_rst and not up_rst and not season_rst:
|
||||
live_rst = '您目前没有任何订阅...'
|
||||
await show_sub_info.send(live_rst + up_rst + season_rst)
|
||||
|
||||
@@ -335,45 +335,52 @@ async def get_user_dynamic(
|
||||
|
||||
class SubManager:
|
||||
def __init__(self):
|
||||
self.reload_flag = True
|
||||
self.live_data = []
|
||||
self.up_data = []
|
||||
self.season_data = []
|
||||
self.sub_list = []
|
||||
self.current_index = -1
|
||||
|
||||
async def reload_sub_data(self):
|
||||
"""
|
||||
重载数据
|
||||
"""
|
||||
if self.reload_flag or not self.sub_list:
|
||||
if not self.live_data or not self.up_data or not self.season_data:
|
||||
(
|
||||
self.live_data,
|
||||
self.up_data,
|
||||
self.season_data,
|
||||
_live_data,
|
||||
_up_data,
|
||||
_season_data,
|
||||
) = await BilibiliSub.get_all_sub_data()
|
||||
for x, i, j in zip(self.live_data, self.up_data, self.season_data):
|
||||
self.sub_list.append(x)
|
||||
self.sub_list.append(i)
|
||||
self.sub_list.append(j)
|
||||
self.reload_flag = False
|
||||
|
||||
def append(self, data: BilibiliSub):
|
||||
"""
|
||||
增加新数据
|
||||
:param data: 数据
|
||||
"""
|
||||
self.sub_list.append(data)
|
||||
if not self.live_data:
|
||||
self.live_data = _live_data
|
||||
if not self.up_data:
|
||||
self.up_data = _up_data
|
||||
if not self.season_data:
|
||||
self.season_data = _season_data
|
||||
|
||||
async def random_sub_data(self) -> Optional[BilibiliSub]:
|
||||
"""
|
||||
随机获取一条数据
|
||||
:return:
|
||||
"""
|
||||
if not self.sub_list:
|
||||
await self.reload_sub_data()
|
||||
if self.sub_list:
|
||||
sub = random.choice(self.sub_list)
|
||||
self.sub_list.remove(sub)
|
||||
sub = None
|
||||
self.current_index += 1
|
||||
if self.current_index == 0:
|
||||
if self.live_data:
|
||||
sub = random.choice(self.live_data)
|
||||
self.live_data.remove(sub)
|
||||
elif self.current_index == 1:
|
||||
if self.up_data:
|
||||
sub = random.choice(self.up_data)
|
||||
self.up_data.remove(sub)
|
||||
elif self.current_index == 2:
|
||||
if self.season_data:
|
||||
sub = random.choice(self.season_data)
|
||||
self.season_data.remove(sub)
|
||||
else:
|
||||
self.current_index = -1
|
||||
if sub:
|
||||
return sub
|
||||
return None
|
||||
await self.reload_sub_data()
|
||||
return await self.random_sub_data()
|
||||
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ restart = on_command('重启', aliases={'restart'}, permission=SUPERUSER, rule=t
|
||||
@update_zhenxun.handle()
|
||||
async def _(bot: Bot, event: MessageEvent, state: T_State):
|
||||
try:
|
||||
error, code = await check_update(bot)
|
||||
code, error = await check_update(bot)
|
||||
if error:
|
||||
logger.error(f'更新真寻未知错误 {error}')
|
||||
await bot.send_private_msg(
|
||||
|
||||
@@ -89,10 +89,12 @@ async def check_update(bot: Bot) -> 'int, str':
|
||||
update_info = data["body"]
|
||||
width = 0
|
||||
height = len(update_info.split('\n')) * 24
|
||||
for m in update_info.split('\n'):
|
||||
if len(m) * 20 > width:
|
||||
width = len(m) * 18
|
||||
A = CreateImg(width, height, font_size=20)
|
||||
for m in update_info.split('\n'):
|
||||
w, h = A.getsize(m)
|
||||
if w > width:
|
||||
width = w
|
||||
A = CreateImg(width + 50, height, font_size=20)
|
||||
A.text((10, 10), update_info)
|
||||
A.save(f'{IMAGE_PATH}/update_info.png')
|
||||
await bot.send_private_msg(
|
||||
@@ -115,6 +117,7 @@ async def check_update(bot: Bot) -> 'int, str':
|
||||
user_id=int(list(bot.config.superusers)[0]),
|
||||
message=f"自动获取真寻版本成功:{latest_version},当前版本为最新版,无需更新...",
|
||||
)
|
||||
return 200, ''
|
||||
else:
|
||||
logger.warning("自动获取真寻版本失败....")
|
||||
await bot.send_private_msg(
|
||||
|
||||
@@ -131,6 +131,8 @@ async def _(bot: Bot, event: MessageEvent, state: T_State):
|
||||
info_list, code = await search_pixiv_urls(keyword, num, page, r18)
|
||||
if code != 200:
|
||||
await pixiv_keyword.finish(info_list[0])
|
||||
if not info_list:
|
||||
await pixiv_keyword.finish("没有找到啊,等等再试试吧~V", at_sender=True)
|
||||
await send_image(info_list, pixiv_keyword, bot, event)
|
||||
logger.info(
|
||||
f"(USER {event.user_id}, GROUP {event.group_id if isinstance(event, GroupMessageEvent) else 'private'})"
|
||||
|
||||
+6
-4
@@ -55,6 +55,8 @@
|
||||
"plugins/super_help/__init__.py",
|
||||
"plugins/update_gocqhttp/__init__.py",
|
||||
"plugins/what_anime/__init__.py",
|
||||
"plugins/bilibili_sub",
|
||||
"models/bilibili_sub.py",
|
||||
"services/log.py",
|
||||
"update_info.json",
|
||||
"utils/browser.py",
|
||||
@@ -66,16 +68,16 @@
|
||||
"utils/utils.py"
|
||||
],
|
||||
"add_file": [
|
||||
"__version__",
|
||||
"models/bilibili_sub.py",
|
||||
"models/omega_pixiv_illusts.py",
|
||||
"models/sign_group_user.py",
|
||||
"plugins/bilibili_sub",
|
||||
"models/bilibili_sub.py",
|
||||
"plugins/database_scripts.py",
|
||||
"plugins/sign_in/config.py",
|
||||
"plugins/sign_in/random_event.py",
|
||||
"plugins/sign_in/utils.py",
|
||||
"plugins/withdraw.py",
|
||||
"resources/img/sign/sign_res"
|
||||
"resources/img/sign"
|
||||
],
|
||||
"delete_file": ["plugins/nonebot_plugin_withdraw"]
|
||||
"delete_file": ["plugins/nonebot_plugin_withdraw", "models/sigin_group_user.py"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user