Compare commits

...
16 Commits
Author SHA1 Message Date
HibiKier 065432448f Merge pull request #40 from Ailitonia/patch-1
Fix: Check info_list to avoid TypeError
2021-09-07 11:11:38 +08:00
HibiKier 5d45a9c28a Update README.md 2021-09-07 11:08:43 +08:00
Ailitonia 7db5b3b5c0 Fix: Check info_list to avoid TypeError 2021-09-07 02:08:56 +08:00
HibiKier 5eb64060dc Update data_source.py 2021-09-06 21:14:26 +08:00
HibiKier 2c4877b9f8 Update update_info.json 2021-09-06 21:10:44 +08:00
HibiKier 218dad3b86 fix bilibili_sub 2021-09-06 21:03:50 +08:00
HibiKier 974c6b106a Update update_info.json 2021-09-06 20:42:06 +08:00
HibiKier 954b281b69 Update data_source.py 2021-09-06 18:09:16 +08:00
HibiKier b1b15b63a1 Update data_source.py 2021-09-06 18:03:21 +08:00
HibiKier 49567aa958 Update __version__ 2021-09-05 13:57:27 +08:00
HibiKier a7a470066b Update update_info.json 2021-09-05 13:57:06 +08:00
HibiKier 4e3010d75e Update data_source.py 2021-09-05 13:56:29 +08:00
HibiKier cbacd726ef Update __init__.py 2021-09-05 13:54:55 +08:00
HibiKier 58a1fc1ca0 Update __version__ 2021-09-05 13:06:41 +08:00
HibiKier a704f88d75 Update update_info.json 2021-09-05 13:05:06 +08:00
HibiKier 10d0ad7d47 Update update_info.json 2021-09-05 12:15:47 +08:00
9 changed files with 53 additions and 41 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
![maven](https://img.shields.io/badge/python-3.8%2B-blue)
![maven](https://img.shields.io/badge/nonebot-2.0.0-yellow)
![maven](https://img.shields.io/badge/go--cqhttp-0.9.40--fix4-red)
![maven](https://img.shields.io/badge/go--cqhttp-1.0.0-red)
# 绪山真寻Bot
****
+1 -1
View File
@@ -1 +1 @@
__version__: v0.0.4.0
__version__: v0.0.4.3
+3 -3
View File
@@ -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
+2 -4
View File
@@ -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)
+31 -24
View File
@@ -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()
+1 -1
View File
@@ -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(
+6 -3
View File
@@ -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(
+2
View File
@@ -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
View File
@@ -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"]
}