mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-10-02 02:00:01 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
065432448f | ||
|
|
5d45a9c28a | ||
|
|
7db5b3b5c0 | ||
|
|
5eb64060dc | ||
|
|
2c4877b9f8 | ||
|
|
218dad3b86 | ||
|
|
974c6b106a | ||
|
|
954b281b69 | ||
|
|
b1b15b63a1 |
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||

|

|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
# 绪山真寻Bot
|
# 绪山真寻Bot
|
||||||
****
|
****
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ def hello() -> str:
|
|||||||
(
|
(
|
||||||
"哦豁?!",
|
"哦豁?!",
|
||||||
"你好!Ov<",
|
"你好!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:
|
async with sess.get(check_url, timeout=2, params=params) as response:
|
||||||
data = await response.json()
|
data = await response.json()
|
||||||
if data["code"] == 200:
|
if data["code"] == 200:
|
||||||
if data["conclusion_type"] == 2:
|
if data['data']["conclusion_type"] == 2:
|
||||||
return ''
|
return ''
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"检测违规文本错误...e:{e}")
|
logger.error(f"检测违规文本错误...{type(e)}:{e}")
|
||||||
return text
|
return text
|
||||||
|
|||||||
@@ -80,7 +80,6 @@ async def _(bot: Bot, event: MessageEvent, state: T_State):
|
|||||||
if sub_type in ["season", "动漫", "番剧"]:
|
if sub_type in ["season", "动漫", "番剧"]:
|
||||||
rst = "*以为您找到以下番剧,请输入Id选择:*\n"
|
rst = "*以为您找到以下番剧,请输入Id选择:*\n"
|
||||||
state["season_data"] = await get_media_id(id_)
|
state["season_data"] = await get_media_id(id_)
|
||||||
print(state["season_data"])
|
|
||||||
if len(state["season_data"]) == 0:
|
if len(state["season_data"]) == 0:
|
||||||
await add_sub.finish(f"未找到番剧:{msg}")
|
await add_sub.finish(f"未找到番剧:{msg}")
|
||||||
for i, x in enumerate(state["season_data"]):
|
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))
|
await add_sub.send(await add_season_sub(id_, sub_user))
|
||||||
else:
|
else:
|
||||||
await add_sub.finish("参数错误,第一参数必须为:主播/up/番剧!")
|
await add_sub.finish("参数错误,第一参数必须为:主播/up/番剧!")
|
||||||
sub_manager.reload_flag = True
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f"(USER {event.user_id}, GROUP "
|
f"(USER {event.user_id}, GROUP "
|
||||||
f"{event.group_id if isinstance(event, GroupMessageEvent) else 'private'})"
|
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'\t当前集数:{x.season_current_episode}\n' \
|
||||||
f'------------------\n'
|
f'------------------\n'
|
||||||
live_rst = '当前订阅的直播:\n' + live_rst if live_rst else live_rst
|
live_rst = '当前订阅的直播:\n' + live_rst if live_rst else live_rst
|
||||||
up_rst = '当前订阅的UP:\n' if up_rst else up_rst
|
up_rst = '当前订阅的UP:\n' + up_rst if up_rst else up_rst
|
||||||
season_rst = '当前订阅的番剧:\n' if season_rst else season_rst
|
season_rst = '当前订阅的番剧:\n' + season_rst if season_rst else season_rst
|
||||||
if not live_rst and not up_rst and not season_rst:
|
if not live_rst and not up_rst and not season_rst:
|
||||||
live_rst = '您目前没有任何订阅...'
|
live_rst = '您目前没有任何订阅...'
|
||||||
await show_sub_info.send(live_rst + up_rst + season_rst)
|
await show_sub_info.send(live_rst + up_rst + season_rst)
|
||||||
|
|||||||
@@ -335,45 +335,52 @@ async def get_user_dynamic(
|
|||||||
|
|
||||||
class SubManager:
|
class SubManager:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.reload_flag = True
|
|
||||||
self.live_data = []
|
self.live_data = []
|
||||||
self.up_data = []
|
self.up_data = []
|
||||||
self.season_data = []
|
self.season_data = []
|
||||||
self.sub_list = []
|
self.current_index = -1
|
||||||
|
|
||||||
async def reload_sub_data(self):
|
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,
|
_live_data,
|
||||||
self.up_data,
|
_up_data,
|
||||||
self.season_data,
|
_season_data,
|
||||||
) = await BilibiliSub.get_all_sub_data()
|
) = await BilibiliSub.get_all_sub_data()
|
||||||
for x, i, j in zip(self.live_data, self.up_data, self.season_data):
|
if not self.live_data:
|
||||||
self.sub_list.append(x)
|
self.live_data = _live_data
|
||||||
self.sub_list.append(i)
|
if not self.up_data:
|
||||||
self.sub_list.append(j)
|
self.up_data = _up_data
|
||||||
self.reload_flag = False
|
if not self.season_data:
|
||||||
|
self.season_data = _season_data
|
||||||
def append(self, data: BilibiliSub):
|
|
||||||
"""
|
|
||||||
增加新数据
|
|
||||||
:param data: 数据
|
|
||||||
"""
|
|
||||||
self.sub_list.append(data)
|
|
||||||
|
|
||||||
async def random_sub_data(self) -> Optional[BilibiliSub]:
|
async def random_sub_data(self) -> Optional[BilibiliSub]:
|
||||||
"""
|
"""
|
||||||
随机获取一条数据
|
随机获取一条数据
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
if not self.sub_list:
|
sub = None
|
||||||
await self.reload_sub_data()
|
self.current_index += 1
|
||||||
if self.sub_list:
|
if self.current_index == 0:
|
||||||
sub = random.choice(self.sub_list)
|
if self.live_data:
|
||||||
self.sub_list.remove(sub)
|
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 sub
|
||||||
return None
|
await self.reload_sub_data()
|
||||||
|
return await self.random_sub_data()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -89,10 +89,12 @@ async def check_update(bot: Bot) -> 'int, str':
|
|||||||
update_info = data["body"]
|
update_info = data["body"]
|
||||||
width = 0
|
width = 0
|
||||||
height = len(update_info.split('\n')) * 24
|
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)
|
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.text((10, 10), update_info)
|
||||||
A.save(f'{IMAGE_PATH}/update_info.png')
|
A.save(f'{IMAGE_PATH}/update_info.png')
|
||||||
await bot.send_private_msg(
|
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)
|
info_list, code = await search_pixiv_urls(keyword, num, page, r18)
|
||||||
if code != 200:
|
if code != 200:
|
||||||
await pixiv_keyword.finish(info_list[0])
|
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)
|
await send_image(info_list, pixiv_keyword, bot, event)
|
||||||
logger.info(
|
logger.info(
|
||||||
f"(USER {event.user_id}, GROUP {event.group_id if isinstance(event, GroupMessageEvent) else 'private'})"
|
f"(USER {event.user_id}, GROUP {event.group_id if isinstance(event, GroupMessageEvent) else 'private'})"
|
||||||
|
|||||||
+3
-2
@@ -55,6 +55,8 @@
|
|||||||
"plugins/super_help/__init__.py",
|
"plugins/super_help/__init__.py",
|
||||||
"plugins/update_gocqhttp/__init__.py",
|
"plugins/update_gocqhttp/__init__.py",
|
||||||
"plugins/what_anime/__init__.py",
|
"plugins/what_anime/__init__.py",
|
||||||
|
"plugins/bilibili_sub",
|
||||||
|
"models/bilibili_sub.py",
|
||||||
"services/log.py",
|
"services/log.py",
|
||||||
"update_info.json",
|
"update_info.json",
|
||||||
"utils/browser.py",
|
"utils/browser.py",
|
||||||
@@ -66,11 +68,10 @@
|
|||||||
"utils/utils.py"
|
"utils/utils.py"
|
||||||
],
|
],
|
||||||
"add_file": [
|
"add_file": [
|
||||||
"__version__",
|
|
||||||
"models/bilibili_sub.py",
|
|
||||||
"models/omega_pixiv_illusts.py",
|
"models/omega_pixiv_illusts.py",
|
||||||
"models/sign_group_user.py",
|
"models/sign_group_user.py",
|
||||||
"plugins/bilibili_sub",
|
"plugins/bilibili_sub",
|
||||||
|
"models/bilibili_sub.py",
|
||||||
"plugins/database_scripts.py",
|
"plugins/database_scripts.py",
|
||||||
"plugins/sign_in/config.py",
|
"plugins/sign_in/config.py",
|
||||||
"plugins/sign_in/random_event.py",
|
"plugins/sign_in/random_event.py",
|
||||||
|
|||||||
Reference in New Issue
Block a user