✨ v0.3.4 mihoyo 国外支持查询每月统计
This commit is contained in:
parent
185acb7fe0
commit
bf1ff94f00
12
defs/db2.py
12
defs/db2.py
@ -1,6 +1,7 @@
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
import re
|
import re
|
||||||
import traceback
|
import traceback
|
||||||
|
from datetime import datetime
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
import genshinstats as gs
|
import genshinstats as gs
|
||||||
|
|
||||||
@ -132,6 +133,17 @@ async def OwnerCookies(uid):
|
|||||||
return cookies
|
return cookies
|
||||||
|
|
||||||
|
|
||||||
|
async def GetAward(Uid):
|
||||||
|
try:
|
||||||
|
gs.set_cookie(await OwnerCookies(Uid))
|
||||||
|
return gs.fetch_endpoint("https://hk4e-api-os.mihoyo.com/event/ysledgeros/month_info",
|
||||||
|
params=dict(uid=Uid, region=gs.utils.recognize_server(Uid),
|
||||||
|
month=datetime.now().month, lang='zh=cn'))
|
||||||
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
|
print("访问失败,请重试!")
|
||||||
|
|
||||||
|
|
||||||
async def MysSign(Uid):
|
async def MysSign(Uid):
|
||||||
try:
|
try:
|
||||||
gs.set_cookie(await OwnerCookies(Uid))
|
gs.set_cookie(await OwnerCookies(Uid))
|
||||||
|
@ -11,7 +11,7 @@ from wordcloud import WordCloud
|
|||||||
from PIL import Image, ImageDraw, ImageFilter
|
from PIL import Image, ImageDraw, ImageFilter
|
||||||
from pyrogram.types import Message
|
from pyrogram.types import Message
|
||||||
|
|
||||||
from defs.db2 import MysSign, GetDaily, cacheDB, GetMysInfo, errorDB, GetInfo, GetSpiralAbyssInfo
|
from defs.db2 import MysSign, GetDaily, cacheDB, GetMysInfo, errorDB, GetInfo, GetSpiralAbyssInfo, GetAward
|
||||||
from defs.event import ys_font
|
from defs.event import ys_font
|
||||||
from genshinstats.daily import DailyRewardInfo
|
from genshinstats.daily import DailyRewardInfo
|
||||||
|
|
||||||
@ -65,6 +65,15 @@ avatar_json = {
|
|||||||
"Kokomi": "珊瑚宫心海",
|
"Kokomi": "珊瑚宫心海",
|
||||||
"Shenhe": "申鹤"
|
"Shenhe": "申鹤"
|
||||||
}
|
}
|
||||||
|
award_json = {
|
||||||
|
"Mail": "邮件奖励",
|
||||||
|
"Events": "活动奖励",
|
||||||
|
"Adventure": "冒险奖励",
|
||||||
|
"Daily Activity": "每日活跃",
|
||||||
|
"Quests": "任务奖励",
|
||||||
|
"Spiral Abyss": "深境螺旋",
|
||||||
|
"Other": "其他",
|
||||||
|
}
|
||||||
daily_im = '''
|
daily_im = '''
|
||||||
*数据刷新可能存在一定延迟,请以当前游戏实际数据为准{}
|
*数据刷新可能存在一定延迟,请以当前游戏实际数据为准{}
|
||||||
==============
|
==============
|
||||||
@ -75,6 +84,52 @@ daily_im = '''
|
|||||||
探索派遣:
|
探索派遣:
|
||||||
总数/完成/上限:{}/{}/{}
|
总数/完成/上限:{}/{}/{}
|
||||||
{}'''
|
{}'''
|
||||||
|
month_im = '''
|
||||||
|
==============
|
||||||
|
{}
|
||||||
|
UID:{}
|
||||||
|
==============
|
||||||
|
本日获取原石:{}
|
||||||
|
本日获取摩拉:{}
|
||||||
|
==============
|
||||||
|
本月获取原石:{}
|
||||||
|
本月获取摩拉:{}
|
||||||
|
==============
|
||||||
|
上月获取原石:{}
|
||||||
|
上月获取摩拉:{}
|
||||||
|
==============
|
||||||
|
原石收入组成:
|
||||||
|
{}=============='''
|
||||||
|
|
||||||
|
|
||||||
|
def trans_award(string: str) -> str:
|
||||||
|
if string in award_json:
|
||||||
|
return award_json[string]
|
||||||
|
else:
|
||||||
|
return string
|
||||||
|
|
||||||
|
|
||||||
|
async def award(uid):
|
||||||
|
data = await GetAward(uid)
|
||||||
|
if data is None:
|
||||||
|
# 等级太低,或者不够活跃
|
||||||
|
return "暂无每月统计信息"
|
||||||
|
nickname = data['nickname']
|
||||||
|
day_stone = data['day_data']['current_primogems']
|
||||||
|
day_mora = data['day_data']['current_mora']
|
||||||
|
month_stone = data['month_data']['current_primogems']
|
||||||
|
month_mora = data['month_data']['current_mora']
|
||||||
|
lastmonth_stone = data['month_data']['last_primogems']
|
||||||
|
lastmonth_mora = data['month_data']['last_mora']
|
||||||
|
group_str = ''
|
||||||
|
for i in data['month_data']['group_by']:
|
||||||
|
group_str = group_str + \
|
||||||
|
trans_award(i['action']) + ":" + str(i['num']) + \
|
||||||
|
"(" + str(i['percent']) + "%)" + '\n'
|
||||||
|
|
||||||
|
im = month_im.format(nickname, uid, day_stone, day_mora, month_stone, month_mora,
|
||||||
|
lastmonth_stone, lastmonth_mora, group_str)
|
||||||
|
return im
|
||||||
|
|
||||||
|
|
||||||
# 签到函数
|
# 签到函数
|
||||||
|
@ -4,7 +4,7 @@ from defs.artifacts import get_artifacts
|
|||||||
|
|
||||||
|
|
||||||
async def artifacts_msg(client: Client, message: Message):
|
async def artifacts_msg(client: Client, message: Message):
|
||||||
name = message.text.replace('圣遗物详情', '').strip()
|
name = message.text.replace('圣遗物查询', '').strip()
|
||||||
text, url = await get_artifacts(name)
|
text, url = await get_artifacts(name)
|
||||||
if url:
|
if url:
|
||||||
await message.reply_photo(photo=url, caption=text, quote=True)
|
await message.reply_photo(photo=url, caption=text, quote=True)
|
||||||
|
@ -8,7 +8,7 @@ from pyrogram import Client
|
|||||||
from pyrogram.types import Message
|
from pyrogram.types import Message
|
||||||
|
|
||||||
from defs.db2 import deal_ck, selectDB, OpenPush, CheckDB, connectDB, deletecache
|
from defs.db2 import deal_ck, selectDB, OpenPush, CheckDB, connectDB, deletecache
|
||||||
from defs.mihoyo import sign, daily, draw_pic, draw_wordcloud
|
from defs.mihoyo import sign, daily, draw_pic, draw_wordcloud, award
|
||||||
|
|
||||||
from ci import scheduler, app, admin_id
|
from ci import scheduler, app, admin_id
|
||||||
from defs.redis_load import redis
|
from defs.redis_load import redis
|
||||||
@ -62,6 +62,15 @@ async def mihoyo_msg(client: Client, message: Message):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
await message.reply("未找到uid绑定记录。", quote=True)
|
await message.reply("未找到uid绑定记录。", quote=True)
|
||||||
|
elif "每月统计" in text:
|
||||||
|
try:
|
||||||
|
uid = await selectDB(message.from_user.id, mode="uid")
|
||||||
|
uid = uid[0]
|
||||||
|
im = await award(uid)
|
||||||
|
await message.reply(im, quote=True)
|
||||||
|
except Exception as e:
|
||||||
|
traceback.print_exc()
|
||||||
|
await message.reply('未找到绑定信息', quote=True)
|
||||||
elif "签到" in text:
|
elif "签到" in text:
|
||||||
try:
|
try:
|
||||||
uid = await selectDB(message.from_user.id, mode="uid")
|
uid = await selectDB(message.from_user.id, mode="uid")
|
||||||
@ -134,8 +143,14 @@ async def mihoyo_qun_msg(client: Client, message: Message):
|
|||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
await message.reply("未绑定uid信息!")
|
await message.reply("未绑定uid信息!")
|
||||||
elif "每月统计" in text:
|
elif "每月统计" in text:
|
||||||
# need auth_key 不支持
|
try:
|
||||||
await message.reply('暂不支持!')
|
uid = await selectDB(message.from_user.id, mode="uid")
|
||||||
|
uid = uid[0]
|
||||||
|
im = await award(uid)
|
||||||
|
await message.reply(im)
|
||||||
|
except Exception as e:
|
||||||
|
traceback.print_exc()
|
||||||
|
await message.reply('未找到绑定信息')
|
||||||
elif "签到" in text:
|
elif "签到" in text:
|
||||||
try:
|
try:
|
||||||
uid = await selectDB(message.from_user.id, mode="uid")
|
uid = await selectDB(message.from_user.id, mode="uid")
|
||||||
|
@ -94,7 +94,7 @@ async def process_private_msg(client: Client, message: Message):
|
|||||||
await fortunate_msg(client, message)
|
await fortunate_msg(client, message)
|
||||||
await log(client, message, '查询今日运势')
|
await log(client, message, '查询今日运势')
|
||||||
# 圣遗物查询
|
# 圣遗物查询
|
||||||
if '圣遗物详情' in message.text:
|
if '圣遗物查询' in message.text:
|
||||||
await artifacts_msg(client, message)
|
await artifacts_msg(client, message)
|
||||||
await log(client, message, '查询圣遗物详情')
|
await log(client, message, '查询圣遗物详情')
|
||||||
# 圣遗物评分
|
# 圣遗物评分
|
||||||
@ -173,7 +173,7 @@ async def process_group_msg(client: Client, message: Message):
|
|||||||
await set_fortunate_img(client, message)
|
await set_fortunate_img(client, message)
|
||||||
await log(client, message, '设置运势角色')
|
await log(client, message, '设置运势角色')
|
||||||
# 圣遗物查询
|
# 圣遗物查询
|
||||||
if text.startswith('圣遗物详情'):
|
if text.startswith('圣遗物查询'):
|
||||||
await artifacts_msg(client, message)
|
await artifacts_msg(client, message)
|
||||||
await log(client, message, '查询圣遗物详情')
|
await log(client, message, '查询圣遗物详情')
|
||||||
# 圣遗物评分
|
# 圣遗物评分
|
||||||
|
@ -2,7 +2,7 @@ from ci import admin_id
|
|||||||
from pyrogram import Client
|
from pyrogram import Client
|
||||||
from pyrogram.types import Message, CallbackQuery, InlineKeyboardMarkup, InlineKeyboardButton
|
from pyrogram.types import Message, CallbackQuery, InlineKeyboardMarkup, InlineKeyboardButton
|
||||||
|
|
||||||
HELP_MSG_PRE = '<a href="https://git.io/JcbTD">PaimonBot</a> 0.3.3beta By Xtao-Labs\n\n' \
|
HELP_MSG_PRE = '<a href="https://git.io/JcbTD">PaimonBot</a> 0.3.4beta By Xtao-Labs\n\n' \
|
||||||
'🔅 以下是小派蒙我学会了的功能(部分):\n'
|
'🔅 以下是小派蒙我学会了的功能(部分):\n'
|
||||||
HELP_MSG = """① [武器/今日武器] 查看今日武器材料和武器
|
HELP_MSG = """① [武器/今日武器] 查看今日武器材料和武器
|
||||||
② [天赋/今日天赋] 查看今日天赋材料和角色
|
② [天赋/今日天赋] 查看今日天赋材料和角色
|
||||||
@ -20,8 +20,8 @@ HELP_MSG = """① [武器/今日武器] 查看今日武器材料和武器
|
|||||||
💠 <code>原魔查询 丘丘人</code>
|
💠 <code>原魔查询 丘丘人</code>
|
||||||
⑨ [食物查询] 查看食物资料
|
⑨ [食物查询] 查看食物资料
|
||||||
💠 <code>食物查询 甜甜花/甜甜花酿鸡</code>
|
💠 <code>食物查询 甜甜花/甜甜花酿鸡</code>
|
||||||
⑩ [武器查询 武器名] 查看武器资料
|
⑩ [圣遗物查询 武器名] 查看武器资料
|
||||||
💠 <code>武器查询 沐浴龙血的剑</code>
|
💠 <code>圣遗物查询 逆飞的流星</code>
|
||||||
======
|
======
|
||||||
(11) [原神黄历] 查看随机生成的原神黄历
|
(11) [原神黄历] 查看随机生成的原神黄历
|
||||||
(12) [活动列表] 查看今日活动列表和祈愿列表
|
(12) [活动列表] 查看今日活动列表和祈愿列表
|
||||||
|
Loading…
Reference in New Issue
Block a user