mirror of
https://github.com/baiqwerdvd/StarRailUID.git
synced 2025-05-05 19:23:45 +08:00
✨支持sr每月统计
This commit is contained in:
parent
4e9ecf0e50
commit
fbd8f74605
@ -8,6 +8,9 @@ STAR_RAIL_SIGN_EXTRA_INFO_URL = f'{OLD_URL}/event/luna/extra_info'
|
||||
STAR_RAIL_SIGN_EXTRA_REWARD_URL = f'{OLD_URL}/event/luna/extra_reward'
|
||||
STAR_RAIL_SIGN_URL = f'{OLD_URL}/event/luna/sign'
|
||||
STAR_RAIL_MONTH_INFO_URL = f'{OLD_URL}/event/srledger/month_info' # 开拓阅历接口
|
||||
STAR_RAIL_MONTH_DETAIL_URL = (
|
||||
f'{OLD_URL}/event/srledger/month_detail' # 开拓阅历详情接口
|
||||
)
|
||||
|
||||
STAR_RAIL_NOTE_URL = f'{NEW_URL}/game_record/app/hkrpg/api/note' # 实时便签接口
|
||||
STAR_RAIL_INDEX_URL = f'{NEW_URL}/game_record/app/hkrpg/api/index' # 角色橱窗接口
|
||||
|
@ -1,5 +1,53 @@
|
||||
from typing import Any, List, TypedDict
|
||||
|
||||
################
|
||||
# 每月札记相关 #
|
||||
################
|
||||
|
||||
|
||||
class DataText(TypedDict):
|
||||
type: str
|
||||
key: str
|
||||
mi18n_key: str
|
||||
|
||||
|
||||
class DayData(TypedDict):
|
||||
current_hcoin: int
|
||||
current_rails_pass: int
|
||||
last_hcoin: int
|
||||
last_rails_pass: int
|
||||
|
||||
|
||||
class GroupBy(TypedDict):
|
||||
action: str
|
||||
num: int
|
||||
percent: int
|
||||
action_name: str
|
||||
|
||||
|
||||
class MonthData(TypedDict):
|
||||
current_hcoin: int
|
||||
current_rails_pass: int
|
||||
last_hcoin: int
|
||||
last_rails_pass: int
|
||||
hcoin_rate: int
|
||||
rails_rate: int
|
||||
group_by: List[GroupBy]
|
||||
|
||||
|
||||
class MonthlyAward(TypedDict):
|
||||
uid: str
|
||||
region: str
|
||||
login_flag: bool
|
||||
optional_month: List[int]
|
||||
month: str
|
||||
data_month: str
|
||||
month_data: MonthData
|
||||
day_data: DayData
|
||||
version: str
|
||||
start_month: str
|
||||
data_text: DataText
|
||||
|
||||
|
||||
################
|
||||
# 实时便签 #
|
||||
|
33
StarRailUID/starrailuid_note/__init__.py
Normal file
33
StarRailUID/starrailuid_note/__init__.py
Normal file
@ -0,0 +1,33 @@
|
||||
from gsuid_core.sv import SV
|
||||
from gsuid_core.bot import Bot
|
||||
from gsuid_core.models import Event
|
||||
|
||||
from .note_text import award
|
||||
|
||||
# from ..utils.convert import get_uid
|
||||
from ..utils.api import get_sqla
|
||||
from ..utils.error_reply import UID_HINT
|
||||
|
||||
# from .draw_note_card import draw_note_img
|
||||
|
||||
sv_get_monthly_data = SV('sr查询月历')
|
||||
|
||||
|
||||
# 群聊内 每月统计 功能
|
||||
@sv_get_monthly_data.on_fullmatch(('sr每月统计'))
|
||||
async def send_monthly_data(bot: Bot, ev: Event):
|
||||
sqla = get_sqla(ev.bot_id)
|
||||
sr_uid = await sqla.get_bind_sruid(ev.user_id)
|
||||
if sr_uid is None:
|
||||
return UID_HINT
|
||||
await bot.send(await award(sr_uid))
|
||||
|
||||
|
||||
# @sv_get_monthly_data.on_fullmatch(('sr当前信息', 'srzj', 'sr月历'))
|
||||
# async def send_monthly_pic(bot: Bot, ev: Event):
|
||||
# await bot.logger.info('开始执行[sr每日信息]')
|
||||
# uid = await get_uid(bot, ev)
|
||||
# if uid is None:
|
||||
# return UID_HINT
|
||||
# im = await draw_note_img(str(uid))
|
||||
# await bot.send(im)
|
@ -14,7 +14,7 @@ from gsuid_core.utils.api.mys.tools import (
|
||||
|
||||
from ..utils.api import get_sqla
|
||||
from ..sruid_utils.api.mys.api import _API
|
||||
from ..sruid_utils.api.mys.models import DailyNoteData
|
||||
from ..sruid_utils.api.mys.models import MonthlyAward, DailyNoteData
|
||||
from ....GenshinUID.GenshinUID.genshinuid_config.gs_config import gsconfig
|
||||
|
||||
RECOGNIZE_SERVER = {
|
||||
@ -193,6 +193,38 @@ class _MysApi(BaseMysApi):
|
||||
data = cast(MysSign, data['data'])
|
||||
return data
|
||||
|
||||
async def get_award(self, sr_uid) -> Union[MonthlyAward, int]:
|
||||
server_id = RECOGNIZE_SERVER.get(str(sr_uid)[0])
|
||||
ck = await self.get_ck(sr_uid, 'OWNER')
|
||||
if ck is None:
|
||||
return -51
|
||||
if int(str(sr_uid)[0]) < 6:
|
||||
HEADER = copy.deepcopy(self._HEADER)
|
||||
HEADER['Cookie'] = ck
|
||||
HEADER['DS'] = get_web_ds_token(True)
|
||||
HEADER['x-rpc-device_id'] = random_hex(32)
|
||||
data = await self._mys_request(
|
||||
url=_API['STAR_RAIL_MONTH_INFO_URL'],
|
||||
method='GET',
|
||||
header=HEADER,
|
||||
params={'uid': sr_uid, 'region': server_id, 'month': ''},
|
||||
)
|
||||
else:
|
||||
HEADER = copy.deepcopy(self._HEADER_OS)
|
||||
HEADER['Cookie'] = ck
|
||||
HEADER['x-rpc-device_id'] = random_hex(32)
|
||||
HEADER['DS'] = generate_os_ds()
|
||||
data = await self._mys_request(
|
||||
url=_API['STAR_RAIL_MONTH_INFO_URL'],
|
||||
method='GET',
|
||||
header=HEADER,
|
||||
params={'uid': sr_uid, 'region': server_id, 'month': ''},
|
||||
use_proxy=True,
|
||||
)
|
||||
if isinstance(data, Dict):
|
||||
data = cast(MonthlyAward, data['data'])
|
||||
return data
|
||||
|
||||
async def _mys_req_get(
|
||||
self,
|
||||
url: str,
|
||||
|
Loading…
x
Reference in New Issue
Block a user