添加每日云原神签到

This commit is contained in:
clover420 2022-08-27 21:51:38 +08:00
parent 62bf1e0d59
commit fc262e2a91
6 changed files with 75 additions and 1 deletions

44
cloud_genshin.py Normal file
View File

@ -0,0 +1,44 @@
import setting
from request import http
import tools
import config
from loghelper import log
class cloud_ys():
def __init__(self,token) -> None:
self.headers = {
'x-rpc-combo_token': token,
'x-rpc-client_type': setting.mihoyobbs_Client_type,
'x-rpc-app_version': setting.cloudgenshin_Version,
'x-rpc-sys_version': '12', # Previous version need to convert the type of this var
'x-rpc-channel': 'mihoyo',
'x-rpc-device_id': tools.get_cloud_device_id(),
'x-rpc-device_name': 'Xiaomi M2012K11AC',
'x-rpc-device_model': 'M2012K11AC',
'x-rpc-app_id': '1953439974',
'Referer': 'https://app.mihoyo.com',
'Host': 'api-cloudgame.mihoyo.com',
'Connection': 'Keep-Alive',
'Accept-Encoding': 'gzip',
'User-Agent': 'okhttp/4.9.0'
}
def Sgin(self):
req = http.get(url=setting.Cloud_Ys_Sgin,headers=self.headers).json()
try:
jg = req['data']['list'][0]['msg']
if "每日登录奖励" in jg:
log.info("云原神签到成功")
data = "云原神签到成功"
except IndexError:
log.warning("云原神签到失败或重复签到")
data = "云原神签到失败或重复签到"
except Exception as er:
log.warning(f"云原神签到失败,出现了错误:{er}")
data = f"云原神签到失败,出现了错误:{er}"
reqs = http.get(url=setting.Cloud_ys_Inquire,headers=self.headers).json()
nr = (f"\n你当前拥有免费时长 {reqs['data']['free_time']['free_time']} 分钟,畅玩卡状态为 {reqs['data']['play_card']['short_msg']},拥有米云币 {reqs['data']['coin']['coin_num']}")
data = data + nr
return data

View File

@ -34,6 +34,10 @@ config = {
'enable': False, 'cookie': '', 'enable': False, 'cookie': '',
'genshin': {'auto_checkin': False, 'black_list': []} 'genshin': {'auto_checkin': False, 'black_list': []}
} }
},
'cloud_genshin': {
'token': '',
'enable': False
} }
} }
@ -78,6 +82,9 @@ def update_config():
continue continue
config['games']['cn'][i] = config_json['games']['cn'][i] config['games']['cn'][i] = config_json['games']['cn'][i]
config['games']['os'] = config_json['games']['os'] config['games']['os'] = config_json['games']['os']
config['cloud_genshin']['token'] = config_json['cloud_genshin']['token']
config['cloud_genshin']['enable'] = config_json['cloud_genshin']['enable']
print(config)
save_config() save_config()
log.info('config更新完毕') log.info('config更新完毕')
if not serverless: if not serverless:

View File

@ -39,3 +39,6 @@ games:
genshin: genshin:
auto_checkin: false auto_checkin: false
black_list: [] black_list: []
cloud_genshin:
token: ''
enable: true

View File

@ -10,6 +10,7 @@ import setting
import mihoyobbs import mihoyobbs
import honkai3rd import honkai3rd
import tearsofthemis import tearsofthemis
import cloud_genshin
from error import * from error import *
from loghelper import log from loghelper import log
@ -95,6 +96,14 @@ def main():
ret_code = 3 ret_code = 3
return_data += "\n\n" + genshin_message return_data += "\n\n" + genshin_message
time.sleep(random.randint(2, 8)) time.sleep(random.randint(2, 8))
if config.config['cloud_genshin']['enable']:
log.info("正在进行云原神签到")
if config.config['cloud_genshin']['token'] == "":
log.info("token为空,跳过任务")
else:
cloud_ys = cloud_genshin.cloud_ys(config.config['cloud_genshin']['token'])
data = cloud_ys.Sgin()
return_data += "\n\n云原神:\n"+data
return ret_code, return_data return ret_code, return_data
elif config.config["account"]["cookie"] == "CookieError": elif config.config["account"]["cookie"] == "CookieError":
raise CookieError('Cookie expires') raise CookieError('Cookie expires')

View File

@ -7,6 +7,9 @@ mihoyobbs_Version = "2.35.2" # Slat和Version相互对应
# 米游社的客户端类型 # 米游社的客户端类型
mihoyobbs_Client_type = "2" # 1为ios 2为安卓 mihoyobbs_Client_type = "2" # 1为ios 2为安卓
mihoyobbs_Client_type_web = "5" # 4为pc web 5为mobile web mihoyobbs_Client_type_web = "5" # 4为pc web 5为mobile web
#云原神版本
cloudgenshin_Version = "3.0.0"
# 米游社的分区列表 # 米游社的分区列表
mihoyobbs_List = [{ mihoyobbs_List = [{
"id": "1", "id": "1",
@ -75,6 +78,7 @@ headers = {
# 通用设置 # 通用设置
bbs_Api = "https://bbs-api.mihoyo.com" bbs_Api = "https://bbs-api.mihoyo.com"
web_Api = "https://api-takumi.mihoyo.com" web_Api = "https://api-takumi.mihoyo.com"
Cloud_Ys_Api = "https://api-cloudgame.mihoyo.com"
account_Info_url = web_Api + "/binding/api/getUserGameRolesByCookie?game_biz=" account_Info_url = web_Api + "/binding/api/getUserGameRolesByCookie?game_biz="
# 米游社的API列表 # 米游社的API列表
@ -110,3 +114,7 @@ genshin_Act_id = "e202009291139501"
genshin_checkin_rewards = f'{web_Api}/event/bbs_sign_reward/home?act_id={genshin_Act_id}' genshin_checkin_rewards = f'{web_Api}/event/bbs_sign_reward/home?act_id={genshin_Act_id}'
genshin_Is_signurl = web_Api + "/event/bbs_sign_reward/info?act_id={}&region={}&uid={}" genshin_Is_signurl = web_Api + "/event/bbs_sign_reward/info?act_id={}&region={}&uid={}"
genshin_Signurl = web_Api + "/event/bbs_sign_reward/sign" genshin_Signurl = web_Api + "/event/bbs_sign_reward/sign"
# 云原神相关api
Cloud_Ys_Sgin = Cloud_Ys_Api + "/hk4e_cg_cn/gamer/api/listNotifications?status=NotificationStatusUnread&type=NotificationTypePopup&is_sort=true"
Cloud_ys_Inquire = Cloud_Ys_Api + "/hk4e_cg_cn/wallet/wallet/get"

View File

@ -50,6 +50,9 @@ def get_ds2(q: str, b: str) -> str:
def get_device_id() -> str: def get_device_id() -> str:
return str(uuid.uuid3(uuid.NAMESPACE_URL, config.config["account"]["cookie"])) return str(uuid.uuid3(uuid.NAMESPACE_URL, config.config["account"]["cookie"]))
# 生成一个device id
def get_cloud_device_id() -> str:
return str(uuid.uuid3(uuid.NAMESPACE_URL, "ai=4;ci=1;oi=74192553;ct=78851ef4251e14fb45659a5276370b819ab9f47b;si=f8bc714db618c290b05c1949c654e6e4fb38edb49831e3a2b75455dfa8812320;bi=hk4e_cn"))
# 获取签到的奖励名称 # 获取签到的奖励名称
def get_item(raw_data: dict) -> str: def get_item(raw_data: dict) -> str: