diff --git a/README.md b/README.md index 51e95be..3076449 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ ## 简介✨ -通过米游社接口,查询uid的游戏信息,并附带各种娱乐功能。 +原神多功能机器人,通过米游社接口查询uid的游戏信息,并提供WIKI查询和各种各样的好玩的功能。 ## 功能示例💖 @@ -113,6 +113,7 @@ javascript:(function(){prompt(document.domain,document.cookie)})(); - 3.30 个人信息卡片新增层岩巨渊和神里绫人信息 - 3.31 实时便签加入参量质变仪信息 - 4.11 改用数据库进行数据存储,优化代码 +- 4.14 新增每日天赋突破材料表查询 ## ToDo🕛 @@ -143,4 +144,4 @@ javascript:(function(){prompt(document.domain,document.cookie)})(); - [hoshino-installer](https://github.com/pcrbot/hoshino-installer) - 一键安装脚本参考 - [bluemushoom](https://bbs.nga.cn/nuke.php?func=ucp&uid=62861898) - 全角色收益曲线和参考面板攻略图来源 - [genshin-gacha-export](https://github.com/sunfkny/genshin-gacha-export) - 抽卡记录导出参考 -- [Adachi-BOT](https://github.com/Arondight/Adachi-BOT) - 部分资源来源 +- [Adachi-BOT](https://github.com/SilveryStar/Adachi-BOT) - 部分资源来源 diff --git a/hoshino/modules/Genshin_Paimon/db_util.py b/hoshino/modules/Genshin_Paimon/db_util.py index 9a20907..e7103ce 100644 --- a/hoshino/modules/Genshin_Paimon/db_util.py +++ b/hoshino/modules/Genshin_Paimon/db_util.py @@ -22,7 +22,7 @@ def reload_public_cookie(is_drop=True): with open(os.path.join(os.path.dirname(__file__), 'user_data', 'user_cookies.json'), 'r', encoding='utf-8') as f: data = json.load(f) for d in data['通用']: - cursor.execute('INSERT IGNORE INTO public_cookies VALUES (?, ?, "OK");', (d['no'], d['cookie'])) + cursor.execute('INSERT OR IGNORE INTO public_cookies VALUES (?, ?, "OK");', (d['no'], d['cookie'])) conn.commit() conn.close() logger.info('---公共cookie池载入成功!---') @@ -104,7 +104,7 @@ async def insert_public_cookie(cookie): cookie TEXT, status TEXT );''') - cursor.execute('INSERT IGNORE INTO public_cookies (cookie, status) VALUES (?,"OK");', (cookie,)) + cursor.execute('INSERT OR IGNORE INTO public_cookies (cookie, status) VALUES (?,"OK");', (cookie,)) conn.commit() conn.close() diff --git a/hoshino/modules/Genshin_Paimon/gacha_log_export/__init__.py b/hoshino/modules/Genshin_Paimon/gacha_log_export/__init__.py index ef3a0ca..e388bd2 100644 --- a/hoshino/modules/Genshin_Paimon/gacha_log_export/__init__.py +++ b/hoshino/modules/Genshin_Paimon/gacha_log_export/__init__.py @@ -27,7 +27,7 @@ async def ckjl(bot,ev): return uid, msg, user_id, use_cache = await get_uid_in_msg(ev) if not uid: - await bot.send(ev,'请把uid给派蒙哦,比如获取抽卡记录100000001 链接',at_sender=True) + await bot.send(ev,'请把uid给派蒙哦,比如导出抽卡记录100000001 xlsx',at_sender=True) return find_filetype = r'(?Pxlsx|json)' match = re.search(find_filetype, msg) diff --git a/hoshino/modules/Genshin_Paimon/game_guild/__init__.py b/hoshino/modules/Genshin_Paimon/game_guild/__init__.py index 6ab0c24..8e97aba 100644 --- a/hoshino/modules/Genshin_Paimon/game_guild/__init__.py +++ b/hoshino/modules/Genshin_Paimon/game_guild/__init__.py @@ -6,6 +6,8 @@ from ..character_alias import get_id_by_alias from .blue import get_blue_pic from ..util import pil2b64 from hoshino.util import filt_message +import re +import time help_msg=''' 1.[xx角色攻略]查看西风驿站出品的角色一图流攻略 @@ -13,6 +15,7 @@ help_msg=''' 3.[xx参考面板]查看blue菌hehe出品的参考面板攻略 4.[xx收益曲线]查看blue菌hehe出品的收益曲线攻略 *感谢来自大佬们的授权。角色支持别名查询 +5.[今日/明日/周x材料]查看每日角色天赋材料和武器突破材料表 ''' sv = Service('派蒙WIKI', bundle='派蒙', help_=help_msg) @@ -84,4 +87,37 @@ async def genshinAttribute2(bot,ev): pic = Image.open(os.path.join(res_path, 'blue', f'{realname}.png')) pic = pil2b64(pic, 85) pic = MessageSegment.image(pic) - await bot.send(ev,pic,at_sender=True) \ No newline at end of file + await bot.send(ev,pic,at_sender=True) + +@sv.on_suffix(('材料', '天赋材料', '角色天赋材料', '突破材料', '武器突破材料')) +async def daily_material(bot, ev): + week = ev.message.extract_plain_text().strip() + if not week: + return + find_week = re.search(r'(?P今日|今天|现在|明天|明日|后天|后日|周一|周二|周三|周四|周五|周六|周日)', week) + if not find_week: + return + else: + if find_week.group('week') in ['今日', '今天', '现在']: + week = time.strftime("%w") + elif find_week.group('week') in ['明日', '明天']: + week = str(int(time.strftime("%w")) + 1) + elif find_week.group('week') in ['后日', '后天']: + week = str(int(time.strftime("%w")) + 2) + elif find_week.group('week') in ['周一', '周四']: + week = '1' + elif find_week.group('week') in ['周二', '周五']: + week = '2' + elif find_week.group('week') in ['周三', '周六']: + week = '3' + else: + week = '0' + if week == "0": + await bot.send(ev, '周日所有材料都可以刷哦!', at_sender = True) + elif week in ['1', '4']: + await bot.send(ev,f'[CQ:image,file=file:///{os.path.join(res_path, "daily_material","周一周四.jpg")}]',at_sender=True) + elif week in ['2', '5']: + await bot.send(ev,f'[CQ:image,file=file:///{os.path.join(res_path, "daily_material","周二周五.jpg")}]',at_sender=True) + else: + await bot.send(ev,f'[CQ:image,file=file:///{os.path.join(res_path, "daily_material","周三周六.jpg")}]',at_sender=True) + \ No newline at end of file diff --git a/hoshino/modules/Genshin_Paimon/get_data.py b/hoshino/modules/Genshin_Paimon/get_data.py index a0641b2..47b4772 100644 --- a/hoshino/modules/Genshin_Paimon/get_data.py +++ b/hoshino/modules/Genshin_Paimon/get_data.py @@ -17,7 +17,7 @@ async def get_abyss_data(user_id, uid, schedule_type = "1", use_cache=True): while True: cookie = await get_use_cookie(user_id, uid=uid, action='查询深渊') if not cookie: - return '现在派蒙没有可以用的cookie哦,请让主人 添加公共ck 吧!' + return '现在派蒙没有可以用的cookie哦,可能是:\n1.公共cookie全都达到了每日30次上限\n2.公共池全都失效了或没有cookie\n让管理员使用 添加公共ck 吧!' headers = get_headers(q=f'role_id={uid}&schedule_type={schedule_type}&server={server_id}', cookie=cookie['cookie']) res = await aiorequests.get(url=url, headers=headers, params=params) data = await res.json() @@ -30,7 +30,7 @@ async def get_daily_note_data(uid): url ="https://api-takumi.mihoyo.com/game_record/app/genshin/api/dailyNote" cookie = await get_own_cookie(uid, action='查询实时便签') if not cookie: - return f'你的uid{uid}没有绑定对应的cookie哦,先用ysb给派蒙绑定吧!' + return f'你的uid{uid}没有绑定对应的cookie,使用ysb绑定才能用实时便签哦!' await update_cookie_cache(cookie['cookie'], uid, 'uid') headers = get_headers(q=f'role_id={uid}&server={server_id}', cookie=cookie['cookie']) params = { @@ -51,7 +51,7 @@ async def get_player_card_data(user_id, uid, use_cache=True): while True: cookie = await get_use_cookie(user_id, uid=uid, action='查询原神卡片') if not cookie: - return '现在派蒙没有可以用的cookie哦,请让主人 添加公共ck 吧!' + return '现在派蒙没有可以用的cookie哦,可能是:\n1.公共cookie全都达到了每日30次上限\n2.公共池全都失效了或没有cookie\n让管理员使用 添加公共ck 吧!' headers = get_headers(q=f'role_id={uid}&server={server_id}', cookie=cookie['cookie']) res = await aiorequests.get(url=url, headers=headers, params=params) data = await res.json() @@ -70,7 +70,7 @@ async def get_chara_detail_data(user_id, uid, use_cache=True): while True: cookie = await get_use_cookie(user_id, uid=uid, action='查询角色详情') if not cookie: - return '现在派蒙没有可以用的cookie哦,请让主人 添加公共ck 吧!' + return '现在派蒙没有可以用的cookie哦,可能是:\n1.公共cookie全都达到了每日30次上限\n2.公共池全都失效了或没有cookie\n让管理员使用 添加公共ck 吧!' headers = get_headers(b=json_data, cookie=cookie['cookie']) res = await aiorequests.post(url=url, headers=headers, json=json_data) data = await res.json() @@ -102,7 +102,7 @@ async def get_monthinfo_data(uid, month, use_cache=True): url = 'https://hk4e-api.mihoyo.com/event/ys_ledger/monthInfo' cookie = await get_own_cookie(uid, action='查询每月札记') if not cookie: - return f'你的uid{uid}没有绑定对应的cookie哦,先用ysb给派蒙绑定吧!' + return f'你的uid{uid}没有绑定对应的cookie,使用ysb绑定才能用每月札记哦!' await update_cookie_cache(cookie['cookie'], uid, 'uid') headers = get_headers(q=f'month={month}&bind_uid={uid}&bind_region={server_id}', cookie=cookie['cookie']) params = { diff --git a/hoshino/modules/Genshin_Paimon/player_card/__init__.py b/hoshino/modules/Genshin_Paimon/player_card/__init__.py index 2764676..de44d52 100644 --- a/hoshino/modules/Genshin_Paimon/player_card/__init__.py +++ b/hoshino/modules/Genshin_Paimon/player_card/__init__.py @@ -19,7 +19,7 @@ sv = Service('派蒙原神信息查询', bundle='派蒙', help_=help_msg) async def player_card(bot,ev): uid, msg, user_id, use_cache = await get_uid_in_msg(ev) if not uid: - await bot.send(ev,'请把正确的uid给派蒙哦,例如sy100123456!',at_sender=True) + await bot.send(ev,'请把正确的uid给派蒙哦,例如ys100123456!',at_sender=True) return try: data = await get_player_card_data(user_id, uid, use_cache=use_cache) @@ -42,7 +42,7 @@ async def player_card(bot,ev): async def all_characters(bot,ev): uid, msg, user_id, use_cache = await get_uid_in_msg(ev) if not uid: - await bot.send(ev,'请把正确的uid给派蒙哦,例如sy100123456!',at_sender=True) + await bot.send(ev,'请把正确的uid给派蒙哦,例如ysa100123456!',at_sender=True) return try: chara_data = await get_chara_detail_data(user_id, uid, use_cache=use_cache) @@ -58,7 +58,7 @@ async def all_characters(bot,ev): async def my_characters(bot,ev): uid, msg, user_id, use_cache = await get_uid_in_msg(ev) if not uid: - await bot.send(ev,'请把正确的uid给派蒙哦,例如sy100123456!',at_sender=True) + await bot.send(ev,'请把正确的uid给派蒙哦,例如ysc100123456钟离',at_sender=True) return if not msg: await bot.send(ev,f'要把角色名给派蒙呀!例如ysc100123456钟离',at_sender=True) diff --git a/hoshino/modules/Genshin_Paimon/player_card/get_img.py b/hoshino/modules/Genshin_Paimon/player_card/get_img.py index 017a919..f89907d 100644 --- a/hoshino/modules/Genshin_Paimon/player_card/get_img.py +++ b/hoshino/modules/Genshin_Paimon/player_card/get_img.py @@ -218,7 +218,8 @@ async def draw_player_card(data, chara_data, uid, nickname="旅行者"): # 世界探索 await draw_world_data(bg_draw,data) # 角色 - if chara_data: + nocha = '' + if chara_data['data']: chara_data = chara_data['data']['avatars'] w = 1045 i = 0 @@ -231,8 +232,10 @@ async def draw_player_card(data, chara_data, uid, nickname="旅行者"): bg_img.alpha_composite(chara_card.resize((180, 249)), (840 + (i - 4) * 205, 974)) elif i > 8: break + else: + nocha = '*这uid关闭了角色详情显示,派蒙看不到哦' bg_img = pil2b64(bg_img, 80) - bg_img = MessageSegment.image(bg_img) + bg_img = MessageSegment.image(bg_img) + nocha return bg_img diff --git a/hoshino/modules/Genshin_Paimon/res/daily_material/周一周四.jpg b/hoshino/modules/Genshin_Paimon/res/daily_material/周一周四.jpg new file mode 100644 index 0000000..0b3ba24 Binary files /dev/null and b/hoshino/modules/Genshin_Paimon/res/daily_material/周一周四.jpg differ diff --git a/hoshino/modules/Genshin_Paimon/res/daily_material/周三周六.jpg b/hoshino/modules/Genshin_Paimon/res/daily_material/周三周六.jpg new file mode 100644 index 0000000..68c8815 Binary files /dev/null and b/hoshino/modules/Genshin_Paimon/res/daily_material/周三周六.jpg differ diff --git a/hoshino/modules/Genshin_Paimon/res/daily_material/周二周五.jpg b/hoshino/modules/Genshin_Paimon/res/daily_material/周二周五.jpg new file mode 100644 index 0000000..555bf53 Binary files /dev/null and b/hoshino/modules/Genshin_Paimon/res/daily_material/周二周五.jpg differ diff --git a/hoshino/modules/Genshin_Paimon/util.py b/hoshino/modules/Genshin_Paimon/util.py index ad24f37..dcb761e 100644 --- a/hoshino/modules/Genshin_Paimon/util.py +++ b/hoshino/modules/Genshin_Paimon/util.py @@ -15,16 +15,17 @@ from .db_util import get_private_cookie, get_cookie_cache, get_public_cookie, li async def get_use_cookie(user_id, uid='', mys_id='', action=''): cache_cookie = await get_cookie_cache(uid, 'uid') - if cache_cookie: - if cache_cookie['type'] == 'public': - logger.info(f'---派蒙调用{uid}的缓存公共cookie执行{action}操作---') - else: - logger.info(f'---派蒙调用{uid}的缓存私人cookie执行{action}操作---') - return cache_cookie cookies = await get_private_cookie(user_id, 'user_id') if not cookies: + if cache_cookie: + if cache_cookie['type'] == 'public': + logger.info(f'---派蒙调用{uid}的缓存公共cookie执行{action}操作---') + else: + logger.info(f'---派蒙调用{uid}的缓存私人cookie执行{action}操作---') + return cache_cookie public_cookie = await get_public_cookie() if not public_cookie: + logger.info(f'---派蒙当前没有可用的公共cookie,可能是都达到了上限或没有公共cookie---') return None else: logger.info(f'---派蒙调用{public_cookie[0]}号公共cookie执行{action}操作---') @@ -34,6 +35,12 @@ async def get_use_cookie(user_id, uid='', mys_id='', action=''): if (uid and uid_ == uid) or (mys_id and mys_id_ == mys_id): logger.info(f'---派蒙调用用户{user_id_}的uid{uid_}私人cookie执行{action}操作---') return {'type':'private', 'user_id': user_id_, 'cookie': cookie, 'uid': uid_, 'mys_id': mys_id_} + if cache_cookie: + if cache_cookie['type'] == 'public': + logger.info(f'---派蒙调用{uid}的缓存公共cookie执行{action}操作---') + else: + logger.info(f'---派蒙调用{uid}的缓存私人cookie执行{action}操作---') + return cache_cookie use_cookie = random.choice(cookies) logger.info(f'---派蒙调用用户{use_cookie[0]}的uid{use_cookie[2]}私人cookie执行{action}操作---') return {'type':'private', 'user_id': use_cookie[0], 'cookie': use_cookie[1], 'uid': use_cookie[2], 'mys_id': use_cookie[3]} @@ -54,7 +61,7 @@ async def get_own_cookie(uid='', mys_id='', action=''): # 检查数据返回状态,10001为ck过期了,10101为达到每日30次上线了 async def check_retcode(data, cookie, uid): - if data['retcode'] == 10001: + if data['retcode'] == 10001 or data['retcode'] == -100: await delete_cookie(cookie['cookie'], cookie['type']) await send_cookie_delete_msg(cookie) return False