向下兼容Python 3.8

This commit is contained in:
MingxuanGame 2022-04-02 23:22:28 +08:00
parent 02f3595ede
commit 8fd1ad6e8f
No known key found for this signature in database
GPG Key ID: 90C7EFA11DC3C2FF
6 changed files with 232 additions and 218 deletions

View File

@ -26,16 +26,17 @@
## 丨我该如何获取Cookies[#92](https://github.com/KimigaiiWuyi/GenshinUID/issues/92)[@RemKeeper](https://github.com/RemKeeper)
```
var cookie=document.cookie;
```js
var cookie = document.cookie;
var Str_Num = cookie.indexOf('_MHYUUID=');
cookie ='添加 '+cookie.substring(Str_Num);
var ask=confirm('Cookie:'+cookie+'\n\n按确认然后粘贴发送给机器人');
if(ask==true)
{copy(cookie);
msg=cookie}
else
{msg='Cancel'}
cookie = '添加 ' + cookie.substring(Str_Num);
var ask = confirm('Cookie:' + cookie + '\n\n按确认然后粘贴发送给机器人');
if (ask == true) {
copy(cookie);
msg = cookie
} else {
msg = 'Cancel'
}
```
1. 复制上面全部代码然后打开https://bbs.mihoyo.com/ys/
@ -46,11 +47,18 @@ else
**警告Cookies属于个人隐私其效用相当于账号密码请勿随意公开**
## 丨获取米游社Stoken([AutoMihoyoBBS](https://github.com/Womsxd/AutoMihoyoBBS#%E8%8E%B7%E5%8F%96%E7%B1%B3%E6%B8%B8%E7%A4%BECookie))
**前提**已经添加过米游社Cookies并且已经绑定过uid(仅用于米游社币的获取)
```sh
var cookie=document.cookie;
var ask=confirm('Cookie:'+cookie+'\n\nDo you want to copy the cookie to the clipboard?');
if(ask==true){copy("添加 stoken" + cookie);msg=cookie}else{msg='Cancel'}
```js
var cookie = document.cookie;
var ask = confirm('Cookie:' + cookie + '\n\nDo you want to copy the cookie to the clipboard?');
if (ask == true) {
copy("添加 stoken" + cookie);
msg = cookie
} else {
msg = 'Cancel'
}
```
1. 复制上面全部代码然后打开http://user.mihoyo.com/
@ -76,7 +84,7 @@ if(ask==true){copy("添加 stoken" + cookie);msg=cookie}else{msg='Cancel'}
## 丨其他
+ 如果对本插件有功能建议&Bug报告欢迎提Issuse & Pr每一条都会详细看过
+ 如果对本插件有功能建议&Bug报告欢迎提Issue & Pr每一条都会详细看过
+ 如果本插件对你有帮助不要忘了点个Star~
+ 本项目仅供学习使用,请勿用于商业用途
+ [爱发电](https://afdian.net/@KimigaiiWuyi)

View File

@ -34,7 +34,7 @@ async def send_weapon_adv(bot: HoshinoBot, ev: CQEvent):
name = str(ev.message).strip().replace(" ", "")[:-3]
im = await weapon_adv(name)
await bot.send(ev, im)
except Exception as e:
except Exception:
logger.exception("获取建议失败。")

View File

@ -404,8 +404,8 @@ async def get_stoken_by_login_ticket(loginticket, mys_id):
url="https://api-takumi.mihoyo.com/auth/api/getMultiTokenByLoginTicket",
params={
"login_ticket": loginticket,
"token_types" : "3",
"uid" : mys_id
"token_types": "3",
"uid": mys_id
}
)
return req.json()
@ -419,15 +419,15 @@ async def get_daily_data(uid, server_id="cn_gf01"):
req = await client.get(
url="https://api-takumi.mihoyo.com/game_record/app/genshin/api/dailyNote",
headers={
'DS' : get_ds_token("role_id=" + uid + "&server=" + server_id),
'DS': get_ds_token("role_id=" + uid + "&server=" + server_id),
'x-rpc-app_version': mhyVersion,
'User-Agent' : 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 ('
'KHTML, like Gecko) miHoYoBBS/2.11.1',
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 ('
'KHTML, like Gecko) miHoYoBBS/2.11.1',
'x-rpc-client_type': '5',
'Referer' : 'https://webstatic.mihoyo.com/',
"Cookie" : await owner_cookies(uid)},
'Referer': 'https://webstatic.mihoyo.com/',
"Cookie": await owner_cookies(uid)},
params={
"server" : server_id,
"server": server_id,
"role_id": uid
}
)
@ -439,15 +439,15 @@ async def get_daily_data(uid, server_id="cn_gf01"):
req = await client.get(
url="https://api-takumi-record.mihoyo.com/game_record/app/genshin/api/dailyNote",
headers={
'DS' : get_ds_token("role_id=" + uid + "&server=" + server_id),
'DS': get_ds_token("role_id=" + uid + "&server=" + server_id),
'x-rpc-app_version': mhyVersion,
'User-Agent' : 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 '
'(KHTML, like Gecko) miHoYoBBS/2.11.1',
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 '
'(KHTML, like Gecko) miHoYoBBS/2.11.1',
'x-rpc-client_type': '5',
'Referer' : 'https://webstatic.mihoyo.com/',
"Cookie" : await owner_cookies(uid)},
'Referer': 'https://webstatic.mihoyo.com/',
"Cookie": await owner_cookies(uid)},
params={
"server" : server_id,
"server": server_id,
"role_id": uid
}
)
@ -467,10 +467,10 @@ async def get_sign_list():
url="https://api-takumi.mihoyo.com/event/bbs_sign_reward/home",
headers={
'x-rpc-app_version': mhyVersion,
'User-Agent' : 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 ('
'KHTML, like Gecko) miHoYoBBS/2.11.1',
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 ('
'KHTML, like Gecko) miHoYoBBS/2.11.1',
'x-rpc-client_type': '5',
'Referer' : 'https://webstatic.mihoyo.com/'},
'Referer': 'https://webstatic.mihoyo.com/'},
params={
"act_id": "e202009291139501"
}
@ -490,15 +490,15 @@ async def get_sign_info(uid, server_id="cn_gf01"):
url="https://api-takumi.mihoyo.com/event/bbs_sign_reward/info",
headers={
'x-rpc-app_version': mhyVersion,
"Cookie" : await owner_cookies(uid),
'User-Agent' : 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 ('
'KHTML, like Gecko) miHoYoBBS/2.11.1',
"Cookie": await owner_cookies(uid),
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 ('
'KHTML, like Gecko) miHoYoBBS/2.11.1',
'x-rpc-client_type': '5',
'Referer' : 'https://webstatic.mihoyo.com/'},
'Referer': 'https://webstatic.mihoyo.com/'},
params={
"act_id": "e202009291139501",
"region": server_id,
"uid" : uid
"uid": uid
}
)
data = json.loads(req.text)
@ -514,17 +514,17 @@ async def mihoyo_bbs_sign(uid, server_id="cn_gf01"):
req = requests.post(
url="https://api-takumi.mihoyo.com/event/bbs_sign_reward/sign",
headers={
'User_Agent' : 'Mozilla/5.0 (Linux; Android 10; MIX 2 Build/QKQ1.190825.002; wv) AppleWebKit/537.36 ('
'KHTML, like Gecko) Version/4.0 Chrome/83.0.4103.101 Mobile Safari/537.36 '
'miHoYoBBS/2.3.0',
"Cookie" : await owner_cookies(uid),
"x-rpc-device_id" : random_hex(32),
'Origin' : 'https://webstatic.mihoyo.com',
'X_Requested_With' : 'com.mihoyo.hyperion',
'DS' : old_version_get_ds_token(),
'User_Agent': 'Mozilla/5.0 (Linux; Android 10; MIX 2 Build/QKQ1.190825.002; wv) AppleWebKit/537.36 ('
'KHTML, like Gecko) Version/4.0 Chrome/83.0.4103.101 Mobile Safari/537.36 '
'miHoYoBBS/2.3.0',
"Cookie": await owner_cookies(uid),
"x-rpc-device_id": random_hex(32),
'Origin': 'https://webstatic.mihoyo.com',
'X_Requested_With': 'com.mihoyo.hyperion',
'DS': old_version_get_ds_token(),
'x-rpc-client_type': '5',
'Referer' : 'https://webstatic.mihoyo.com/bbs/event/signin-ys/index.html?bbs_auth_required=true&act_id'
'=e202009291139501&utm_source=bbs&utm_medium=mys&utm_campaign=icon',
'Referer': 'https://webstatic.mihoyo.com/bbs/event/signin-ys/index.html?bbs_auth_required=true&act_id'
'=e202009291139501&utm_source=bbs&utm_medium=mys&utm_campaign=icon',
'x-rpc-app_version': '2.3.0'
},
json={"act_id": "e202009291139501", "uid": uid, "region": server_id}
@ -544,23 +544,23 @@ async def get_award(uid, server_id="cn_gf01"):
url="https://hk4e-api.mihoyo.com/event/ys_ledger/monthInfo",
headers={
'x-rpc-app_version': mhyVersion,
"Cookie" : await owner_cookies(uid),
'DS' : old_version_get_ds_token(),
"x-rpc-device_id" : random_hex(32),
'User-Agent' : 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 ('
'KHTML, like Gecko) miHoYoBBS/2.11.1',
"Cookie": await owner_cookies(uid),
'DS': old_version_get_ds_token(),
"x-rpc-device_id": random_hex(32),
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 ('
'KHTML, like Gecko) miHoYoBBS/2.11.1',
'x-rpc-client_type': '5',
'Referer' : 'https://webstatic.mihoyo.com/'},
'Referer': 'https://webstatic.mihoyo.com/'},
params={
"act_id" : "e202009291139501",
"bind_region" : server_id,
"bind_uid" : uid,
"month" : "0",
"act_id": "e202009291139501",
"bind_region": server_id,
"bind_uid": uid,
"month": "0",
"bbs_presentation_style": "fullscreen",
"bbs_auth_required" : True,
"utm_source" : "bbs",
"utm_medium" : "mys",
"utm_campaign" : "icon"
"bbs_auth_required": True,
"utm_source": "bbs",
"utm_medium": "mys",
"utm_campaign": "icon"
}
)
data = json.loads(req.text)
@ -578,16 +578,16 @@ async def get_info(uid, ck, server_id="cn_gf01"):
req = await client.get(
url="https://api-takumi.mihoyo.com/game_record/app/genshin/api/index",
headers={
'DS' : get_ds_token("role_id=" + uid + "&server=" + server_id),
'DS': get_ds_token("role_id=" + uid + "&server=" + server_id),
'x-rpc-app_version': mhyVersion,
'User-Agent' : 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 ('
'KHTML, like Gecko) miHoYoBBS/2.11.1',
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 ('
'KHTML, like Gecko) miHoYoBBS/2.11.1',
'x-rpc-client_type': '5',
'Referer' : 'https://webstatic.mihoyo.com/',
"Cookie" : ck},
'Referer': 'https://webstatic.mihoyo.com/',
"Cookie": ck},
params={
"role_id": uid,
"server" : server_id
"server": server_id
}
)
data = json.loads(req.text)
@ -598,16 +598,16 @@ async def get_info(uid, ck, server_id="cn_gf01"):
req = await client.get(
url="https://api-takumi-record.mihoyo.com/game_record/app/genshin/api/index",
headers={
'DS' : get_ds_token("role_id=" + uid + "&server=" + server_id),
'DS': get_ds_token("role_id=" + uid + "&server=" + server_id),
'x-rpc-app_version': mhyVersion,
'User-Agent' : 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 '
'(KHTML, like Gecko) miHoYoBBS/2.11.1',
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 '
'(KHTML, like Gecko) miHoYoBBS/2.11.1',
'x-rpc-client_type': '5',
'Referer' : 'https://webstatic.mihoyo.com/',
"Cookie" : ck},
'Referer': 'https://webstatic.mihoyo.com/',
"Cookie": ck},
params={
"role_id": uid,
"server" : server_id
"server": server_id
}
)
data = json.loads(req.text)
@ -627,20 +627,20 @@ async def get_spiral_abyss_info(uid, ck, schedule_type="1", server_id="cn_gf01")
req = await client.get(
url="https://api-takumi.mihoyo.com/game_record/app/genshin/api/spiralAbyss",
headers={
'DS' : get_ds_token(
'DS': get_ds_token(
"role_id=" + uid + "&schedule_type=" + schedule_type + "&server=" + server_id),
'Origin' : 'https://webstatic.mihoyo.com',
'Cookie' : ck,
'Origin': 'https://webstatic.mihoyo.com',
'Cookie': ck,
'x-rpc-app_version': mhyVersion,
'User-Agent' : 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS '
'X) AppleWebKit/605.1.15 (KHTML, like Gecko) miHoYoBBS/2.11.1',
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS '
'X) AppleWebKit/605.1.15 (KHTML, like Gecko) miHoYoBBS/2.11.1',
'x-rpc-client_type': '5',
'Referer' : 'https://webstatic.mihoyo.com/'
'Referer': 'https://webstatic.mihoyo.com/'
},
params={
"schedule_type": schedule_type,
"role_id" : uid,
"server" : server_id
"role_id": uid,
"server": server_id
}
)
data = json.loads(req.text)
@ -651,24 +651,24 @@ async def get_spiral_abyss_info(uid, ck, schedule_type="1", server_id="cn_gf01")
req = await client.get(
url="https://api-takumi-record.mihoyo.com/game_record/app/genshin/api/spiralAbyss",
headers={
'DS' : get_ds_token(
'DS': get_ds_token(
"role_id=" + uid + "&schedule_type=" + schedule_type + "&server=" + server_id),
'Origin' : 'https://webstatic.mihoyo.com',
'Cookie' : ck,
'Origin': 'https://webstatic.mihoyo.com',
'Cookie': ck,
'x-rpc-app_version': mhyVersion,
'User-Agent' : 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 '
'(KHTML, like Gecko) miHoYoBBS/2.11.1',
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 '
'(KHTML, like Gecko) miHoYoBBS/2.11.1',
'x-rpc-client_type': '5',
'Referer' : 'https://webstatic.mihoyo.com/'
'Referer': 'https://webstatic.mihoyo.com/'
},
params={
"role_id" : uid,
"server" : server_id,
"role_id": uid,
"server": server_id,
"bbs_presentation_style": "fullscreen",
"bbs_auth_required" : "true",
"utm_source" : "bbs",
"utm_medium" : "mys",
"utm_campaign" : "icon"
"bbs_auth_required": "true",
"utm_source": "bbs",
"utm_medium": "mys",
"utm_campaign": "icon"
}
)
data = json.loads(req.text)
@ -687,15 +687,15 @@ def get_character(uid, character_ids, ck, server_id="cn_gf01"):
req = requests.post(
url="https://api-takumi.mihoyo.com/game_record/app/genshin/api/character",
headers={
'DS' : get_ds_token('', {"character_ids": character_ids, "role_id": uid,
"server" : server_id}),
'Origin' : 'https://webstatic.mihoyo.com',
'Cookie' : ck,
'DS': get_ds_token('', {"character_ids": character_ids, "role_id": uid,
"server": server_id}),
'Origin': 'https://webstatic.mihoyo.com',
'Cookie': ck,
'x-rpc-app_version': mhyVersion,
'User-Agent' : 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, '
'like Gecko) miHoYoBBS/2.11.1',
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, '
'like Gecko) miHoYoBBS/2.11.1',
'x-rpc-client_type': '5',
'Referer' : 'https://webstatic.mihoyo.com/'
'Referer': 'https://webstatic.mihoyo.com/'
},
json={"character_ids": character_ids, "role_id": uid, "server": server_id}
)
@ -706,15 +706,15 @@ def get_character(uid, character_ids, ck, server_id="cn_gf01"):
req = requests.post(
url="https://api-takumi-record.mihoyo.com/game_record/app/genshin/api/character",
headers={
'DS' : get_ds_token('', {"character_ids": character_ids, "role_id": uid,
"server" : server_id}),
'Origin' : 'https://webstatic.mihoyo.com',
'Cookie' : ck,
'DS': get_ds_token('', {"character_ids": character_ids, "role_id": uid,
"server": server_id}),
'Origin': 'https://webstatic.mihoyo.com',
'Cookie': ck,
'x-rpc-app_version': mhyVersion,
'User-Agent' : 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 ('
'KHTML, like Gecko) miHoYoBBS/2.11.1',
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 ('
'KHTML, like Gecko) miHoYoBBS/2.11.1',
'x-rpc-client_type': '5',
'Referer' : 'https://webstatic.mihoyo.com/'
'Referer': 'https://webstatic.mihoyo.com/'
},
json={"character_ids": character_ids, "role_id": uid, "server": server_id}
)
@ -758,13 +758,13 @@ async def get_mihoyo_bbs_info(mysid, ck):
req = await client.get(
url="https://api-takumi.mihoyo.com/game_record/card/wapi/getGameRecordCard",
headers={
'DS' : get_ds_token("uid=" + mysid),
'DS': get_ds_token("uid=" + mysid),
'x-rpc-app_version': mhyVersion,
'User-Agent' : 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 ('
'KHTML, like Gecko) miHoYoBBS/2.11.1',
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 ('
'KHTML, like Gecko) miHoYoBBS/2.11.1',
'x-rpc-client_type': '5',
'Referer' : 'https://webstatic.mihoyo.com/',
"Cookie" : ck},
'Referer': 'https://webstatic.mihoyo.com/',
"Cookie": ck},
params={"uid": mysid}
)
data = json.loads(req.text)
@ -775,13 +775,13 @@ async def get_mihoyo_bbs_info(mysid, ck):
req = await client.get(
url="https://api-takumi-record.mihoyo.com/game_record/card/wapi/getGameRecordCard?uid=" + mysid,
headers={
'DS' : get_ds_token("uid=" + mysid),
'DS': get_ds_token("uid=" + mysid),
'x-rpc-app_version': mhyVersion,
'User-Agent' : 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 '
'(KHTML, like Gecko) miHoYoBBS/2.11.1',
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 '
'(KHTML, like Gecko) miHoYoBBS/2.11.1',
'x-rpc-client_type': '5',
'Referer' : 'https://webstatic.mihoyo.com/',
"Cookie" : ck},
'Referer': 'https://webstatic.mihoyo.com/',
"Cookie": ck},
params={"uid": mysid}
)
data = json.loads(req.text)
@ -801,7 +801,7 @@ async def get_audio_info(name, audioid, language="cn"):
headers={
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/95.0.4638.69 Safari/537.36',
'Referer' : 'https://genshin.minigg.cn/index.html'},
'Referer': 'https://genshin.minigg.cn/index.html'},
params={"characters": name, "audioid": audioid, "language": language}
)
return req.text
@ -863,7 +863,7 @@ async def get_char_info(name, mode="char", level=None):
headers={
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/95.0.4638.69 Safari/537.36',
'Referer' : 'https://genshin.minigg.cn/index.html'})
'Referer': 'https://genshin.minigg.cn/index.html'})
data2 = json.loads(req.text)
if "errcode" in data2:
async with AsyncClient() as client_:
@ -872,7 +872,7 @@ async def get_char_info(name, mode="char", level=None):
headers={
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, '
'like Gecko) Chrome/95.0.4638.69 Safari/537.36',
'Referer' : 'https://genshin.minigg.cn/index.html'})
'Referer': 'https://genshin.minigg.cn/index.html'})
data2 = json.loads(req.text)
async with AsyncClient() as client:
@ -881,7 +881,7 @@ async def get_char_info(name, mode="char", level=None):
headers={
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/95.0.4638.69 Safari/537.36',
'Referer' : 'https://genshin.minigg.cn/index.html'})
'Referer': 'https://genshin.minigg.cn/index.html'})
try:
data = json.loads(req.text)
if "errcode" in data:
@ -891,7 +891,7 @@ async def get_char_info(name, mode="char", level=None):
headers={
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, '
'like Gecko) Chrome/95.0.4638.69 Safari/537.36',
'Referer' : 'https://genshin.minigg.cn/index.html'})
'Referer': 'https://genshin.minigg.cn/index.html'})
data = json.loads(req.text)
except:
data = None
@ -903,22 +903,22 @@ async def get_genshin_events(mode="List"):
now_time = datetime.datetime.now().strftime('%Y-%m-%d')
base_url = "https://api-takumi.mihoyo.com/event/bbs_activity_calendar/getActList"
params = {
"time" : now_time,
"time": now_time,
"game_biz": "ys_cn",
"page" : 1,
"tag_id" : 0
"page": 1,
"tag_id": 0
}
else:
base_url = "https://hk4e-api.mihoyo.com/common/hk4e_cn/announcement/api/getAnn{}".format(mode)
params = {
"game" : "hk4e",
"game_biz" : "hk4e_cn",
"lang" : "zh-cn",
"game": "hk4e",
"game_biz": "hk4e_cn",
"lang": "zh-cn",
"bundle_id": "hk4e_cn",
"platform" : "pc",
"region" : "cn_gf01",
"level" : 55,
"uid" : 100000000
"platform": "pc",
"region": "cn_gf01",
"level": 55,
"uid": 100000000
}
async with AsyncClient() as client:

View File

@ -4,7 +4,7 @@ import threading
from base64 import b64encode
from io import BytesIO
from re import Match, findall
from typing import Optional
from typing import Optional, Tuple, List
import numpy as np
from PIL import Image, ImageDraw, ImageFilter, ImageFont
@ -67,7 +67,7 @@ class CustomizeImage:
return bg_img
@staticmethod
def get_bg_color(edit_bg: Image) -> tuple[int, int, int]:
def get_bg_color(edit_bg: Image) -> Tuple[int, int, int]:
# 获取背景主色
color = 8
q = edit_bg.quantize(colors=color, method=2)
@ -85,7 +85,7 @@ class CustomizeImage:
return bg_color
@staticmethod
def get_text_color(bg_color: tuple[int, int, int]) -> tuple[int, int, int]:
def get_text_color(bg_color: Tuple[int, int, int]) -> Tuple[int, int, int]:
# 通过背景主色bg_color确定文字主色
r = 125
if max(*bg_color) > 255 - r:
@ -96,7 +96,7 @@ class CustomizeImage:
return text_color
@staticmethod
def get_char_color(bg_color: tuple[int, int, int]) -> tuple[int, int, int]:
def get_char_color(bg_color: Tuple[int, int, int]) -> Tuple[int, int, int]:
r = 140
if max(*bg_color) > 255 - r:
r *= -1
@ -106,7 +106,7 @@ class CustomizeImage:
return char_color
@staticmethod
def get_char_high_color(bg_color: tuple[int, int, int]) -> tuple[int, int, int]:
def get_char_high_color(bg_color: Tuple[int, int, int]) -> Tuple[int, int, int]:
r = 140
d = 20
if max(*bg_color) > 255 - r:
@ -117,7 +117,7 @@ class CustomizeImage:
return char_color
@staticmethod
def get_bg_detail_color(bg_color: tuple[int, int, int]) -> tuple[int, int, int]:
def get_bg_detail_color(bg_color: Tuple[int, int, int]) -> Tuple[int, int, int]:
r = 140
if max(*bg_color) > 255 - r:
r *= -1
@ -127,7 +127,7 @@ class CustomizeImage:
return bg_detail_color
@staticmethod
def get_highlight_color(color: tuple[int, int, int]) -> tuple[int, int, int]:
def get_highlight_color(color: Tuple[int, int, int]) -> Tuple[int, int, int]:
red_color = color[0]
green_color = color[1]
blue_color = color[2]
@ -980,7 +980,7 @@ async def draw_abyss_pic(uid: str, nickname: str, floor_num: int, image: Optiona
return resultmes
async def get_all_calculate_info(client: ClientSession, uid: str, char_id: list[str], ck: str, name: list):
async def get_all_calculate_info(client: ClientSession, uid: str, char_id: List[str], ck: str, name: list):
tasks = []
for id_, name_ in zip(char_id, name):
tasks.append(get_calculate_info(client, uid, id_, ck, name_))
@ -991,9 +991,9 @@ async def get_all_calculate_info(client: ClientSession, uid: str, char_id: list[
return data
async def draw_char_pic(img: Image, char_data: dict, index: int, bg_color: tuple[int, int, int],
text_color: tuple[int, int, int], bg_detail_color: tuple[int, int, int],
char_high_color: tuple[int, int, int], char_talent_data: dict):
async def draw_char_pic(img: Image, char_data: dict, index: int, bg_color: Tuple[int, int, int],
text_color: Tuple[int, int, int], bg_detail_color: Tuple[int, int, int],
char_high_color: Tuple[int, int, int], char_talent_data: dict):
char_mingzuo = 0
for k in char_data['constellations']:
if k['is_actived']:

View File

@ -1,17 +1,19 @@
import time
import random
import string
import time
from httpx import AsyncClient
from get_data import old_version_get_ds_token,random_hex
from get_data import old_version_get_ds_token, random_hex
# 米游社的API列表
bbs_Cookieurl = "https://webapi.account.mihoyo.com/Api/cookie_accountinfo_by_loginticket?login_ticket={}"
bbs_Cookieurl2 = "https://api-takumi.mihoyo.com/auth/api/getMultiTokenByLoginTicket?login_ticket={}&token_types=3&uid={}"
bbs_Cookieurl2 = "https://api-takumi.mihoyo.com/auth/api/getMultiTokenByLoginTicket" \
"?login_ticket={}&token_types=3&uid={}"
bbs_Taskslist = "https://bbs-api.mihoyo.com/apihub/sapi/getUserMissionsState" # 获取任务列表
bbs_Signurl = "https://bbs-api.mihoyo.com/apihub/sapi/signIn?gids={}" # post
bbs_Listurl = "https://bbs-api.mihoyo.com/post/api/getForumPostList?forum_id={}&is_good=false&is_hot=false&page_size=20&sort_type=1"
bbs_Listurl = "https://bbs-api.mihoyo.com/post/api/getForumPostList?" \
"forum_id={}&is_good=false&is_hot=false&page_size=20&sort_type=1"
bbs_Detailurl = "https://bbs-api.mihoyo.com/post/api/getPostFull?post_id={}"
bbs_Shareurl = "https://bbs-api.mihoyo.com/apihub/api/getShareConf?entity_id={}&entity_type=1"
bbs_Likeurl = "https://bbs-api.mihoyo.com/apihub/sapi/upvotePost" # post json
@ -48,11 +50,13 @@ mihoyobbs_List = [{
"url": "https://bbs.mihoyo.com/sr/"
}]
def random_text(num: int) -> str:
return ''.join(random.sample(string.ascii_lowercase + string.digits, num))
class mihoyobbs_coin:
def __init__(self,cookies):
class MihoyoBBSCoin:
def __init__(self, cookies):
self.headers = {
"DS": old_version_get_ds_token(True),
"cookie": cookies,
@ -81,31 +85,31 @@ class mihoyobbs_coin:
self.Have_coins = 0
async def task_run(self):
await self.Load_Mihoyobbs_List_Use()
start = await self.Get_taskslist()
await self.load_mihoyo_bbs_list_use()
start = await self.get_tasks_list()
self.postsList = await self.get_list()
sign = await self.signing()
read = await self.read_posts()
like = await self.Likeposts()
like = await self.like_posts()
share = await self.share_post()
im = start + "\n" + sign + "\n" + read + "\n" + like + "\n" + share
return im
async def Load_Mihoyobbs_List_Use(self):
for i in [2,5]:
async def load_mihoyo_bbs_list_use(self):
for i in [2, 5]:
for k in mihoyobbs_List:
if i == int(k["id"]):
self.mihoyobbs_List_Use.append(k)
# 获取任务列表,用来判断做了哪些任务
async def Get_taskslist(self):
#log.info("正在获取任务列表")
async def get_tasks_list(self):
# log.info("正在获取任务列表")
async with AsyncClient() as client:
req = await client.get(url = bbs_Taskslist, headers = self.headers)
req = await client.get(url=bbs_Taskslist, headers=self.headers)
data = req.json()
if "err" in data["message"] or data["retcode"] == -100:
return "你的Cookies已失效。"
#log.error("获取任务列表失败你的cookie可能已过期请重新设置cookie。")
# log.error("获取任务列表失败你的cookie可能已过期请重新设置cookie。")
else:
self.Today_getcoins = data["data"]["can_get_points"]
self.Today_have_getcoins = data["data"]["already_received_points"]
@ -119,10 +123,10 @@ class mihoyobbs_coin:
else:
# 如果第0个大于或等于62则直接判定任务没做
if data["data"]["states"][0]["mission_id"] >= 62:
#log.info(f"新的一天,今天可以获得{self.Today_getcoins}个米游币")
# log.info(f"新的一天,今天可以获得{self.Today_getcoins}个米游币")
pass
else:
#log.info(f"似乎还有任务没完成,今天还能获得{self.Today_getcoins}")
# log.info(f"似乎还有任务没完成,今天还能获得{self.Today_getcoins}")
for i in data["data"]["states"]:
# 58是讨论区签到
if i["mission_id"] == 58:
@ -157,7 +161,7 @@ class mihoyobbs_coin:
data = req.json()
for n in range(5):
temp_list.append([data["data"]["list"][n]["post"]["post_id"], data["data"]["list"][n]["post"]["subject"]])
#log.info("已获取{}个帖子".format(len(temp_list)))
# log.info("已获取{}个帖子".format(len(temp_list)))
return temp_list
# 进行签到操作
@ -175,7 +179,6 @@ class mihoyobbs_coin:
return "你的Cookies已失效。"
return "已完成签到任务~"
# 看帖子
async def read_posts(self):
if self.Task_do["bbs_Read_posts"]:
@ -190,8 +193,9 @@ class mihoyobbs_coin:
num_ok += 1
time.sleep(random.randint(2, 8))
return "已完成看帖任务~共计成功{}次~".format(str(num_ok))
# 点赞
async def Likeposts(self):
async def like_posts(self):
if self.Task_do["bbs_Like_posts"]:
return "点赞任务已经完成过了~"
else:
@ -214,8 +218,8 @@ class mihoyobbs_coin:
if data["message"] == "OK":
num_cancel += 1
time.sleep(random.randint(2, 8))
return "已完成点赞任务~共计点赞{}次,取消点赞{}次~".format(str(num_ok),str(num_cancel))
# 分享操作
return "已完成点赞任务~共计点赞{}次,取消点赞{}次~".format(str(num_ok), str(num_cancel))
# 分享操作
async def share_post(self):
if self.Task_do["bbs_Share"]:

View File

@ -3,13 +3,15 @@ import os
import sys
from base64 import b64encode
from io import BytesIO
from typing import List
from openpyxl import load_workbook
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from .get_data import *
from .get_image import draw_event_pic
import get_mihoyo_bbs_coin as coin
# 忽略PEP8 E402 module level import not at top of file 警告
from .get_data import * # noqa: E402
from .get_image import draw_event_pic # noqa: E402
import get_mihoyo_bbs_coin as coin # noqa: E402
FILE_PATH = os.path.dirname(__file__)
FILE2_PATH = os.path.join(FILE_PATH, 'mihoyo_bbs')
@ -17,47 +19,47 @@ INDEX_PATH = os.path.join(FILE2_PATH, 'index')
Texture_PATH = os.path.join(FILE2_PATH, 'texture2d')
avatar_json = {
"Albedo" : "阿贝多",
"Ambor" : "安柏",
"Barbara" : "芭芭拉",
"Beidou" : "北斗",
"Bennett" : "班尼特",
"Chongyun" : "重云",
"Diluc" : "迪卢克",
"Diona" : "迪奥娜",
"Eula" : "优菈",
"Fischl" : "菲谢尔",
"Ganyu" : "甘雨",
"Hutao" : "胡桃",
"Jean" : "",
"Kazuha" : "枫原万叶",
"Kaeya" : "凯亚",
"Ayaka" : "神里绫华",
"Keqing" : "刻晴",
"Klee" : "可莉",
"Lisa" : "丽莎",
"Mona" : "莫娜",
"Albedo": "阿贝多",
"Ambor": "安柏",
"Barbara": "芭芭拉",
"Beidou": "北斗",
"Bennett": "班尼特",
"Chongyun": "重云",
"Diluc": "迪卢克",
"Diona": "迪奥娜",
"Eula": "优菈",
"Fischl": "菲谢尔",
"Ganyu": "甘雨",
"Hutao": "胡桃",
"Jean": "",
"Kazuha": "枫原万叶",
"Kaeya": "凯亚",
"Ayaka": "神里绫华",
"Keqing": "刻晴",
"Klee": "可莉",
"Lisa": "丽莎",
"Mona": "莫娜",
"Ningguang": "凝光",
"Noel" : "诺艾尔",
"Qiqi" : "七七",
"Razor" : "雷泽",
"Rosaria" : "罗莎莉亚",
"Sucrose" : "砂糖",
"Noel": "诺艾尔",
"Qiqi": "七七",
"Razor": "雷泽",
"Rosaria": "罗莎莉亚",
"Sucrose": "砂糖",
"Tartaglia": "达达利亚",
"Venti" : "温迪",
"Venti": "温迪",
"Xiangling": "香菱",
"Xiao" : "",
"Xingqiu" : "行秋",
"Xinyan" : "辛焱",
"Yanfei" : "烟绯",
"Zhongli" : "钟离",
"Yoimiya" : "宵宫",
"Sayu" : "早柚",
"Shogun" : "雷电将军",
"Aloy" : "埃洛伊",
"Sara" : "九条裟罗",
"Kokomi" : "珊瑚宫心海",
"Shenhe" : "申鹤"
"Xiao": "",
"Xingqiu": "行秋",
"Xinyan": "辛焱",
"Yanfei": "烟绯",
"Zhongli": "钟离",
"Yoimiya": "宵宫",
"Sayu": "早柚",
"Shogun": "雷电将军",
"Aloy": "埃洛伊",
"Sara": "九条裟罗",
"Kokomi": "珊瑚宫心海",
"Shenhe": "申鹤"
}
daily_im = '''
@ -159,7 +161,7 @@ char_adv_im = '''【{}】
async def weapon_adv(name):
char_adv_path = os.path.join(FILE_PATH, "Genshin All Char.xlsx")
#char_adv_path = FILE_PATH
# char_adv_path = FILE_PATH
wb = load_workbook(char_adv_path)
ws = wb.active
@ -184,7 +186,7 @@ async def weapon_adv(name):
async def char_adv(name):
char_name = None
char_adv_path = os.path.join(FILE_PATH, "Genshin All Char.xlsx")
#char_adv_path = FILE_PATH
# char_adv_path = FILE_PATH
wb = load_workbook(char_adv_path)
ws = wb.active
char_list = ws["A"]
@ -444,7 +446,7 @@ async def daily(mode="push", uid=None):
current_expedition_num = dailydata['current_expedition_num']
max_expedition_num = dailydata['max_expedition_num']
finished_expedition_num = 0
expedition_info: list[str] = []
expedition_info: List[str] = []
for expedition in dailydata['expeditions']:
avatar: str = expedition['avatar_side_icon'][89:-4]
try:
@ -465,8 +467,8 @@ async def daily(mode="push", uid=None):
transformer_status = "可用"
else:
transformer_time = dailydata['transformer']['recovery_time']
transformer_status = "还剩{}{}小时{}分钟可用".format(transformer_time['Day'], transformer_time['Hour'],
transformer_time['Minute'])
transformer_status = "还剩{}{}小时{}分钟可用".format(transformer_time['Day'], transformer_time['Hour'],
transformer_time['Minute'])
# 推送条件检查,在指令查询时 row[6] 为 0 ,而自动推送时 row[6] 为 140这样保证用指令查询时必回复
# 说实话我仔细看了一会才理解…
@ -512,8 +514,8 @@ async def daily(mode="push", uid=None):
expedition_data = "\n".join(expedition_info)
send_mes = daily_im.format(tip, current_resin, max_resin, rec_time, finished_task_num, total_task_num,
is_extra_got, used_resin_discount_num,
resin_discount_num_limit, home_coin, transformer_status,
current_expedition_num, finished_expedition_num,
resin_discount_num_limit, home_coin, transformer_status,
current_expedition_num, finished_expedition_num,
max_expedition_num, expedition_data)
temp_list.append(
@ -528,7 +530,7 @@ async def mihoyo_coin(qid, s_cookies=None):
s_cookies = await get_stoken(uid)
if s_cookies:
get_coin = coin.mihoyobbs_coin(s_cookies)
get_coin = coin.MihoyoBBSCoin(s_cookies)
im = await get_coin.task_run()
else:
im = "你还没有绑定Stoken~"
@ -726,8 +728,8 @@ async def char_wiki(name, mode="char", level=None):
mes_list.append({
"type": "node",
"data": {
"name" : "小仙",
"uin" : "3399214199",
"name": "小仙",
"uin": "3399214199",
"content": "" + skill_name + "" + "\n" + skill_info
}
})
@ -737,8 +739,8 @@ async def char_wiki(name, mode="char", level=None):
node_data = {
"type": "node",
"data": {
"name" : "小仙",
"uin" : "3399214199",
"name": "小仙",
"uin": "3399214199",
"content": "lv." + str(index + 1) + "\n" + mes
}
}