格式化提交(事件响应部分)
@ -1,19 +1,24 @@
|
|||||||
from httpx import AsyncClient
|
import datetime
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import random
|
||||||
|
import re
|
||||||
|
import sqlite3
|
||||||
|
import string
|
||||||
|
import time
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
|
|
||||||
import sqlite3
|
import requests
|
||||||
import requests,random,os,json,re
|
from httpx import AsyncClient
|
||||||
import time,datetime,urllib
|
|
||||||
import string
|
|
||||||
import hashlib
|
|
||||||
|
|
||||||
mhyVersion = "2.11.1"
|
mhyVersion = "2.11.1"
|
||||||
|
|
||||||
FILE_PATH = os.path.abspath(os.path.join(os.getcwd(), "hoshino"))
|
|
||||||
BASE_PATH = os.path.dirname(__file__)
|
BASE_PATH = os.path.dirname(__file__)
|
||||||
BASE2_PATH = os.path.join(BASE_PATH,'mys')
|
BASE2_PATH = os.path.join(BASE_PATH, 'mihoyo_bbs')
|
||||||
INDEX_PATH = os.path.join(BASE2_PATH, 'index')
|
INDEX_PATH = os.path.join(BASE2_PATH, 'index')
|
||||||
|
|
||||||
|
|
||||||
async def config_check(func, mode="CHECK"):
|
async def config_check(func, mode="CHECK"):
|
||||||
conn = sqlite3.connect('ID_DATA.db')
|
conn = sqlite3.connect('ID_DATA.db')
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
@ -43,7 +48,8 @@ async def config_check(func,mode = "CHECK"):
|
|||||||
conn.close()
|
conn.close()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
async def get_alots(qid):
|
|
||||||
|
async def get_a_lots(qid):
|
||||||
conn = sqlite3.connect('ID_DATA.db')
|
conn = sqlite3.connect('ID_DATA.db')
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
c.execute('''CREATE TABLE IF NOT EXISTS UseridDict
|
c.execute('''CREATE TABLE IF NOT EXISTS UseridDict
|
||||||
@ -66,7 +72,7 @@ async def get_alots(qid):
|
|||||||
c.execute("INSERT OR IGNORE INTO UseridDict (QID,lots) \
|
c.execute("INSERT OR IGNORE INTO UseridDict (QID,lots) \
|
||||||
VALUES (?, ?)", (qid, str(num)))
|
VALUES (?, ?)", (qid, str(num)))
|
||||||
else:
|
else:
|
||||||
if c_data[0][1] == None:
|
if c_data[0][1] is None:
|
||||||
num = random.randint(0, len(raw_data) - 1)
|
num = random.randint(0, len(raw_data) - 1)
|
||||||
data = raw_data[num]
|
data = raw_data[num]
|
||||||
c.execute("UPDATE UseridDict SET lots = ? WHERE QID=?", (str(num), qid))
|
c.execute("UPDATE UseridDict SET lots = ? WHERE QID=?", (str(num), qid))
|
||||||
@ -77,7 +83,8 @@ async def get_alots(qid):
|
|||||||
conn.close()
|
conn.close()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
async def OpenPush(uid,qid,status,mode):
|
|
||||||
|
async def open_push(uid, qid, status, mode):
|
||||||
conn = sqlite3.connect('ID_DATA.db')
|
conn = sqlite3.connect('ID_DATA.db')
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
cursor = c.execute("SELECT * from NewCookiesTable WHERE UID = ?", (uid,))
|
cursor = c.execute("SELECT * from NewCookiesTable WHERE UID = ?", (uid,))
|
||||||
@ -93,9 +100,10 @@ async def OpenPush(uid,qid,status,mode):
|
|||||||
else:
|
else:
|
||||||
return "未找到Ck绑定记录。"
|
return "未找到Ck绑定记录。"
|
||||||
|
|
||||||
async def CheckDB():
|
|
||||||
str = ''
|
async def check_db():
|
||||||
invalidlist = []
|
return_str = str()
|
||||||
|
invalid_list = []
|
||||||
conn = sqlite3.connect('ID_DATA.db')
|
conn = sqlite3.connect('ID_DATA.db')
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
cursor = c.execute("SELECT UID,Cookies,QID from NewCookiesTable")
|
cursor = c.execute("SELECT UID,Cookies,QID from NewCookiesTable")
|
||||||
@ -103,17 +111,16 @@ async def CheckDB():
|
|||||||
for row in c_data:
|
for row in c_data:
|
||||||
try:
|
try:
|
||||||
aid = re.search(r"account_id=(\d*)", row[1])
|
aid = re.search(r"account_id=(\d*)", row[1])
|
||||||
mysid_data = aid.group(0).split('=')
|
mihoyo_id_data = aid.group(0).split('=')
|
||||||
mysid = mysid_data[1]
|
mihoyo_id = mihoyo_id_data[1]
|
||||||
mys_data = await GetMysInfo(mysid,row[1])
|
mys_data = await get_mihoyo_bbs_info(mihoyo_id, row[1])
|
||||||
for i in mys_data['data']['list']:
|
for i in mys_data['data']['list']:
|
||||||
if i['game_id'] != 2:
|
if i['game_id'] != 2:
|
||||||
mys_data['data']['list'].remove(i)
|
mys_data['data']['list'].remove(i)
|
||||||
uid = mys_data['data']['list'][0]['game_role_id']
|
return_str = return_str + f"uid{row[0]}/mys{mihoyo_id}的Cookies是正常的!\n"
|
||||||
str = str + f"uid{row[0]}/mysid{mysid}的Cookies是正常的!\n"
|
|
||||||
except:
|
except:
|
||||||
str = str + f"uid{row[0]}的Cookies是异常的!已删除该条Cookies!\n"
|
return_str = return_str + f"uid{row[0]}的Cookies是异常的!已删除该条Cookies!\n"
|
||||||
invalidlist.append([row[2],row[0]])
|
invalid_list.append([row[2], row[0]])
|
||||||
c.execute("DELETE from NewCookiesTable where UID=?", (row[0],))
|
c.execute("DELETE from NewCookiesTable where UID=?", (row[0],))
|
||||||
try:
|
try:
|
||||||
c.execute("DELETE from CookiesCache where Cookies=?", (row[1],))
|
c.execute("DELETE from CookiesCache where Cookies=?", (row[1],))
|
||||||
@ -121,9 +128,10 @@ async def CheckDB():
|
|||||||
pass
|
pass
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
return [str,invalidlist]
|
return [return_str, invalid_list]
|
||||||
|
|
||||||
async def connectDB(userid,uid = None,mys = None):
|
|
||||||
|
async def connect_db(userid, uid=None, mys=None):
|
||||||
conn = sqlite3.connect('ID_DATA.db')
|
conn = sqlite3.connect('ID_DATA.db')
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
c.execute('''CREATE TABLE IF NOT EXISTS UIDDATA
|
c.execute('''CREATE TABLE IF NOT EXISTS UIDDATA
|
||||||
@ -142,7 +150,8 @@ async def connectDB(userid,uid = None,mys = None):
|
|||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
async def selectDB(userid,mode = "auto"):
|
|
||||||
|
async def select_db(userid, mode="auto"):
|
||||||
conn = sqlite3.connect('ID_DATA.db')
|
conn = sqlite3.connect('ID_DATA.db')
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
cursor = c.execute("SELECT * FROM UIDDATA WHERE USERID = ?", (userid,))
|
cursor = c.execute("SELECT * FROM UIDDATA WHERE USERID = ?", (userid,))
|
||||||
@ -162,7 +171,8 @@ async def selectDB(userid,mode = "auto"):
|
|||||||
elif mode == "mys":
|
elif mode == "mys":
|
||||||
return [row[2], 3]
|
return [row[2], 3]
|
||||||
|
|
||||||
async def deletecache():
|
|
||||||
|
async def delete_cache():
|
||||||
try:
|
try:
|
||||||
copyfile("ID_DATA.db", "ID_DATA_bak.db")
|
copyfile("ID_DATA.db", "ID_DATA_bak.db")
|
||||||
print("————数据库成功备份————")
|
print("————数据库成功备份————")
|
||||||
@ -194,7 +204,8 @@ async def deletecache():
|
|||||||
except:
|
except:
|
||||||
print("\nerror\n")
|
print("\nerror\n")
|
||||||
|
|
||||||
def errorDB(ck,err):
|
|
||||||
|
def error_db(ck, err):
|
||||||
conn = sqlite3.connect('ID_DATA.db')
|
conn = sqlite3.connect('ID_DATA.db')
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
if err == "error":
|
if err == "error":
|
||||||
@ -202,8 +213,8 @@ def errorDB(ck,err):
|
|||||||
elif err == "limit30":
|
elif err == "limit30":
|
||||||
c.execute("UPDATE NewCookiesTable SET Extra = ? WHERE Cookies=?", ("limit30", ck))
|
c.execute("UPDATE NewCookiesTable SET Extra = ? WHERE Cookies=?", ("limit30", ck))
|
||||||
|
|
||||||
def cacheDB(uid,mode = 1,mys = None):
|
|
||||||
use = ''
|
def cache_db(uid, mode=1, mys=None):
|
||||||
conn = sqlite3.connect('ID_DATA.db')
|
conn = sqlite3.connect('ID_DATA.db')
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
c.execute('''CREATE TABLE IF NOT EXISTS CookiesCache
|
c.execute('''CREATE TABLE IF NOT EXISTS CookiesCache
|
||||||
@ -214,21 +225,19 @@ def cacheDB(uid,mode = 1,mys = None):
|
|||||||
if mode == 1:
|
if mode == 1:
|
||||||
if mys:
|
if mys:
|
||||||
cursor = c.execute("SELECT * FROM CookiesCache WHERE MYSID = ?", (mys,))
|
cursor = c.execute("SELECT * FROM CookiesCache WHERE MYSID = ?", (mys,))
|
||||||
c_data = cursor.fetchall()
|
|
||||||
else:
|
else:
|
||||||
cursor = c.execute("SELECT * FROM CookiesCache WHERE UID = ?", (uid,))
|
cursor = c.execute("SELECT * FROM CookiesCache WHERE UID = ?", (uid,))
|
||||||
c_data = cursor.fetchall()
|
else:
|
||||||
elif mode == 2:
|
|
||||||
cursor = c.execute("SELECT * FROM CookiesCache WHERE MYSID = ?", (uid,))
|
cursor = c.execute("SELECT * FROM CookiesCache WHERE MYSID = ?", (uid,))
|
||||||
c_data = cursor.fetchall()
|
c_data = cursor.fetchall()
|
||||||
|
|
||||||
if len(c_data) == 0:
|
if len(c_data) == 0:
|
||||||
if mode == 2:
|
if mode == 2:
|
||||||
conn.create_function("REGEXP", 2, functionRegex)
|
conn.create_function("REGEXP", 2, regex_func)
|
||||||
cursor = c.execute("SELECT * FROM NewCookiesTable WHERE REGEXP(Cookies, ?)", (uid,))
|
cursor = c.execute("SELECT * FROM NewCookiesTable WHERE REGEXP(Cookies, ?)", (uid,))
|
||||||
d_data = cursor.fetchall()
|
d_data = cursor.fetchall()
|
||||||
|
|
||||||
elif mode == 1:
|
else:
|
||||||
cursor = c.execute("SELECT * FROM NewCookiesTable WHERE UID = ?", (uid,))
|
cursor = c.execute("SELECT * FROM NewCookiesTable WHERE UID = ?", (uid,))
|
||||||
d_data = cursor.fetchall()
|
d_data = cursor.fetchall()
|
||||||
|
|
||||||
@ -242,8 +251,8 @@ def cacheDB(uid,mode = 1,mys = None):
|
|||||||
c.execute("INSERT OR IGNORE INTO CookiesCache (Cookies,MYSID) \
|
c.execute("INSERT OR IGNORE INTO CookiesCache (Cookies,MYSID) \
|
||||||
VALUES (?, ?)", (use, uid))
|
VALUES (?, ?)", (use, uid))
|
||||||
else:
|
else:
|
||||||
cookiesrow = c.execute("SELECT * FROM NewCookiesTable WHERE Extra IS NULL ORDER BY RANDOM() LIMIT 1")
|
cookies_row = c.execute("SELECT * FROM NewCookiesTable WHERE Extra IS NULL ORDER BY RANDOM() LIMIT 1")
|
||||||
e_data = cookiesrow.fetchall()
|
e_data = cookies_row.fetchall()
|
||||||
if len(e_data) != 0:
|
if len(e_data) != 0:
|
||||||
if mode == 1:
|
if mode == 1:
|
||||||
c.execute("INSERT OR IGNORE INTO CookiesCache (Cookies,UID) \
|
c.execute("INSERT OR IGNORE INTO CookiesCache (Cookies,UID) \
|
||||||
@ -255,8 +264,8 @@ def cacheDB(uid,mode = 1,mys = None):
|
|||||||
else:
|
else:
|
||||||
return "没有可以使用的Cookies!"
|
return "没有可以使用的Cookies!"
|
||||||
else:
|
else:
|
||||||
cookiesrow = c.execute("SELECT * FROM NewCookiesTable WHERE Extra IS NULL ORDER BY RANDOM() LIMIT 1")
|
cookies_row = c.execute("SELECT * FROM NewCookiesTable WHERE Extra IS NULL ORDER BY RANDOM() LIMIT 1")
|
||||||
e_data = cookiesrow.fetchall()
|
e_data = cookies_row.fetchall()
|
||||||
if len(e_data) != 0:
|
if len(e_data) != 0:
|
||||||
if mode == 1:
|
if mode == 1:
|
||||||
c.execute("INSERT OR IGNORE INTO CookiesCache (Cookies,UID) \
|
c.execute("INSERT OR IGNORE INTO CookiesCache (Cookies,UID) \
|
||||||
@ -279,11 +288,13 @@ def cacheDB(uid,mode = 1,mys = None):
|
|||||||
conn.close()
|
conn.close()
|
||||||
return use
|
return use
|
||||||
|
|
||||||
def functionRegex(value,patter):
|
|
||||||
|
def regex_func(value, patter):
|
||||||
c_pattern = re.compile(r"account_id={}".format(patter))
|
c_pattern = re.compile(r"account_id={}".format(patter))
|
||||||
return c_pattern.search(value) is not None
|
return c_pattern.search(value) is not None
|
||||||
|
|
||||||
async def cookiesDB(uid,Cookies,qid):
|
|
||||||
|
async def cookies_db(uid, cookies, qid):
|
||||||
conn = sqlite3.connect('ID_DATA.db')
|
conn = sqlite3.connect('ID_DATA.db')
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
|
|
||||||
@ -301,14 +312,15 @@ async def cookiesDB(uid,Cookies,qid):
|
|||||||
c_data = cursor.fetchall()
|
c_data = cursor.fetchall()
|
||||||
if len(c_data) == 0:
|
if len(c_data) == 0:
|
||||||
c.execute("INSERT OR IGNORE INTO NewCookiesTable (Cookies,UID,StatusA,StatusB,StatusC,NUM,QID) \
|
c.execute("INSERT OR IGNORE INTO NewCookiesTable (Cookies,UID,StatusA,StatusB,StatusC,NUM,QID) \
|
||||||
VALUES (?, ?,?,?,?,?,?)",(Cookies,uid,"off","off","off",140,qid))
|
VALUES (?, ?,?,?,?,?,?)", (cookies, uid, "off", "off", "off", 140, qid))
|
||||||
else:
|
else:
|
||||||
c.execute("UPDATE NewCookiesTable SET Cookies = ? WHERE UID=?",(Cookies,uid))
|
c.execute("UPDATE NewCookiesTable SET Cookies = ? WHERE UID=?", (cookies, uid))
|
||||||
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
async def OwnerCookies(uid):
|
|
||||||
|
async def owner_cookies(uid):
|
||||||
conn = sqlite3.connect('ID_DATA.db')
|
conn = sqlite3.connect('ID_DATA.db')
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
try:
|
try:
|
||||||
@ -321,33 +333,28 @@ async def OwnerCookies(uid):
|
|||||||
return cookies
|
return cookies
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def random_hex(length):
|
def random_hex(length):
|
||||||
result = hex(random.randint(0, 16 ** length)).replace('0x', '').upper()
|
result = hex(random.randint(0, 16 ** length)).replace('0x', '').upper()
|
||||||
if len(result) < length:
|
if len(result) < length:
|
||||||
result = "0" * (length - len(result)) + result
|
result = "0" * (length - len(result)) + result
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def md5(text):
|
|
||||||
md5 = hashlib.md5()
|
|
||||||
md5.update(text.encode())
|
|
||||||
return md5.hexdigest()
|
|
||||||
|
|
||||||
def oldDSGet():
|
def md5(text):
|
||||||
|
md5_func = hashlib.md5()
|
||||||
|
md5_func.update(text.encode())
|
||||||
|
return md5_func.hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def old_version_get_ds_token():
|
||||||
n = "h8w582wxwgqvahcdkpvdhbh2w9casgfl"
|
n = "h8w582wxwgqvahcdkpvdhbh2w9casgfl"
|
||||||
i = str(int(time.time()))
|
i = str(int(time.time()))
|
||||||
r = ''.join(random.sample(string.ascii_lowercase + string.digits, 6))
|
r = ''.join(random.sample(string.ascii_lowercase + string.digits, 6))
|
||||||
c = md5("salt=" + n + "&t=" + i + "&r=" + r)
|
c = md5("salt=" + n + "&t=" + i + "&r=" + r)
|
||||||
return (i + "," + r + "," + c)
|
return i + "," + r + "," + c
|
||||||
|
|
||||||
def DSGet(q = "",b = None):
|
|
||||||
|
def get_ds_token(q="", b=None):
|
||||||
if b:
|
if b:
|
||||||
br = json.dumps(b)
|
br = json.dumps(b)
|
||||||
else:
|
else:
|
||||||
@ -358,20 +365,27 @@ def DSGet(q = "",b = None):
|
|||||||
c = md5("salt=" + s + "&t=" + t + "&r=" + r + "&b=" + br + "&q=" + q)
|
c = md5("salt=" + s + "&t=" + t + "&r=" + r + "&b=" + br + "&q=" + q)
|
||||||
return t + "," + r + "," + c
|
return t + "," + r + "," + c
|
||||||
|
|
||||||
async def GetDaily(Uid,ServerID="cn_gf01"):
|
|
||||||
if Uid[0] == '5':
|
async def get_daily_data(uid, server_id="cn_gf01"):
|
||||||
ServerID = "cn_qd01"
|
if uid[0] == '5':
|
||||||
|
server_id = "cn_qd01"
|
||||||
try:
|
try:
|
||||||
async with AsyncClient() as client:
|
async with AsyncClient() as client:
|
||||||
req = await client.get(
|
req = await client.get(
|
||||||
url="https://api-takumi.mihoyo.com/game_record/app/genshin/api/dailyNote?server=" + ServerID + "&role_id=" + Uid,
|
url="https://api-takumi.mihoyo.com/game_record/app/genshin/api/dailyNote",
|
||||||
headers={
|
headers={
|
||||||
'DS': DSGet("role_id=" + Uid + "&server=" + ServerID),
|
'DS': get_ds_token("role_id=" + uid + "&server=" + server_id),
|
||||||
'x-rpc-app_version': mhyVersion,
|
'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',
|
'x-rpc-client_type': '5',
|
||||||
'Referer': 'https://webstatic.mihoyo.com/',
|
'Referer': 'https://webstatic.mihoyo.com/',
|
||||||
"Cookie": await OwnerCookies(Uid)})
|
"Cookie": await owner_cookies(uid)},
|
||||||
|
params={
|
||||||
|
"server": server_id,
|
||||||
|
"role_id": uid
|
||||||
|
}
|
||||||
|
)
|
||||||
data = json.loads(req.text)
|
data = json.loads(req.text)
|
||||||
# print(data)
|
# print(data)
|
||||||
return data
|
return data
|
||||||
@ -379,14 +393,20 @@ async def GetDaily(Uid,ServerID="cn_gf01"):
|
|||||||
try:
|
try:
|
||||||
async with AsyncClient() as client:
|
async with AsyncClient() as client:
|
||||||
req = await client.get(
|
req = await client.get(
|
||||||
url="https://api-takumi-record.mihoyo.com/game_record/app/genshin/api/dailyNote?server=" + ServerID + "&role_id=" + Uid,
|
url="https://api-takumi-record.mihoyo.com/game_record/app/genshin/api/dailyNote",
|
||||||
headers={
|
headers={
|
||||||
'DS': DSGet("role_id=" + Uid + "&server=" + ServerID),
|
'DS': get_ds_token("role_id=" + uid + "&server=" + server_id),
|
||||||
'x-rpc-app_version': mhyVersion,
|
'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',
|
'x-rpc-client_type': '5',
|
||||||
'Referer': 'https://webstatic.mihoyo.com/',
|
'Referer': 'https://webstatic.mihoyo.com/',
|
||||||
"Cookie": await OwnerCookies(Uid)})
|
"Cookie": await owner_cookies(uid)},
|
||||||
|
params={
|
||||||
|
"server": server_id,
|
||||||
|
"role_id": uid
|
||||||
|
}
|
||||||
|
)
|
||||||
data = json.loads(req.text)
|
data = json.loads(req.text)
|
||||||
return data
|
return data
|
||||||
except json.decoder.JSONDecodeError:
|
except json.decoder.JSONDecodeError:
|
||||||
@ -395,136 +415,135 @@ async def GetDaily(Uid,ServerID="cn_gf01"):
|
|||||||
print("访问每日信息失败,请重试!")
|
print("访问每日信息失败,请重试!")
|
||||||
print(e.with_traceback)
|
print(e.with_traceback)
|
||||||
|
|
||||||
async def GetSignList():
|
|
||||||
|
async def get_sign_list():
|
||||||
try:
|
try:
|
||||||
async with AsyncClient() as client:
|
async with AsyncClient() as client:
|
||||||
req = await client.get(
|
req = await client.get(
|
||||||
url="https://api-takumi.mihoyo.com/event/bbs_sign_reward/home?act_id=e202009291139501",
|
url="https://api-takumi.mihoyo.com/event/bbs_sign_reward/home",
|
||||||
headers={
|
headers={
|
||||||
'x-rpc-app_version': mhyVersion,
|
'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',
|
'x-rpc-client_type': '5',
|
||||||
'Referer': 'https://webstatic.mihoyo.com/'})
|
'Referer': 'https://webstatic.mihoyo.com/'},
|
||||||
|
params={
|
||||||
|
"act_id": "e202009291139501"
|
||||||
|
}
|
||||||
|
)
|
||||||
data = json.loads(req.text)
|
data = json.loads(req.text)
|
||||||
return data
|
return data
|
||||||
except:
|
except:
|
||||||
print("获取签到奖励列表失败,请重试")
|
print("获取签到奖励列表失败,请重试")
|
||||||
|
|
||||||
async def GetSignInfo(Uid,ServerID="cn_gf01"):
|
|
||||||
if Uid[0] == '5':
|
async def get_sign_info(uid, server_id="cn_gf01"):
|
||||||
ServerID = "cn_qd01"
|
if uid[0] == '5':
|
||||||
|
server_id = "cn_qd01"
|
||||||
try:
|
try:
|
||||||
async with AsyncClient() as client:
|
async with AsyncClient() as client:
|
||||||
req = await client.get(
|
req = await client.get(
|
||||||
url="https://api-takumi.mihoyo.com/event/bbs_sign_reward/info?act_id=e202009291139501®ion=" + ServerID + "&uid=" + Uid,
|
url="https://api-takumi.mihoyo.com/event/bbs_sign_reward/info",
|
||||||
headers={
|
headers={
|
||||||
'x-rpc-app_version': mhyVersion,
|
'x-rpc-app_version': mhyVersion,
|
||||||
"Cookie": await OwnerCookies(Uid),
|
"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',
|
'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',
|
'x-rpc-client_type': '5',
|
||||||
'Referer': 'https://webstatic.mihoyo.com/'})
|
'Referer': 'https://webstatic.mihoyo.com/'},
|
||||||
|
params={
|
||||||
|
"act_id": "e202009291139501",
|
||||||
|
"region": server_id,
|
||||||
|
"uid": uid
|
||||||
|
}
|
||||||
|
)
|
||||||
data = json.loads(req.text)
|
data = json.loads(req.text)
|
||||||
return data
|
return data
|
||||||
except:
|
except:
|
||||||
print("获取签到信息失败,请重试")
|
print("获取签到信息失败,请重试")
|
||||||
|
|
||||||
async def MysSign(Uid,ServerID="cn_gf01"):
|
|
||||||
if Uid[0] == '5':
|
async def mihoyo_bbs_sign(uid, server_id="cn_gf01"):
|
||||||
ServerID = "cn_qd01"
|
if uid[0] == '5':
|
||||||
|
server_id = "cn_qd01"
|
||||||
try:
|
try:
|
||||||
req = requests.post(
|
req = requests.post(
|
||||||
url="https://api-takumi.mihoyo.com/event/bbs_sign_reward/sign",
|
url="https://api-takumi.mihoyo.com/event/bbs_sign_reward/sign",
|
||||||
headers={
|
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',
|
'User_Agent': 'Mozilla/5.0 (Linux; Android 10; MIX 2 Build/QKQ1.190825.002; wv) AppleWebKit/537.36 ('
|
||||||
"Cookie": await OwnerCookies(Uid),
|
'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),
|
"x-rpc-device_id": random_hex(32),
|
||||||
'Origin': 'https://webstatic.mihoyo.com',
|
'Origin': 'https://webstatic.mihoyo.com',
|
||||||
'X_Requested_With': 'com.mihoyo.hyperion',
|
'X_Requested_With': 'com.mihoyo.hyperion',
|
||||||
'DS': oldDSGet(),
|
'DS': old_version_get_ds_token(),
|
||||||
'x-rpc-client_type': '5',
|
'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'
|
'x-rpc-app_version': '2.3.0'
|
||||||
},
|
},
|
||||||
json = {"act_id": "e202009291139501" ,"uid": Uid ,"region": ServerID}
|
json={"act_id": "e202009291139501", "uid": uid, "region": server_id}
|
||||||
)
|
)
|
||||||
data2 = json.loads(req.text)
|
data2 = json.loads(req.text)
|
||||||
return data2
|
return data2
|
||||||
except:
|
except:
|
||||||
print("签到失败,请重试")
|
print("签到失败,请重试")
|
||||||
|
|
||||||
async def GetAward(Uid,ServerID="cn_gf01"):
|
|
||||||
if Uid[0] == '5':
|
async def get_award(uid, server_id="cn_gf01"):
|
||||||
ServerID = "cn_qd01"
|
if uid[0] == '5':
|
||||||
|
server_id = "cn_qd01"
|
||||||
try:
|
try:
|
||||||
async with AsyncClient() as client:
|
async with AsyncClient() as client:
|
||||||
req = await client.get(
|
req = await client.get(
|
||||||
url="https://hk4e-api.mihoyo.com/event/ys_ledger/monthInfo?month={}&bind_uid={}&bind_region={}&bbs_presentation_style=fullscreen&bbs_auth_required=true&utm_source=bbs&utm_medium=mys&utm_campaign=icon".format("0",Uid,ServerID),
|
url="https://hk4e-api.mihoyo.com/event/ys_ledger/monthInfo",
|
||||||
headers={
|
headers={
|
||||||
'x-rpc-app_version': mhyVersion,
|
'x-rpc-app_version': mhyVersion,
|
||||||
"Cookie": await OwnerCookies(Uid),
|
"Cookie": await owner_cookies(uid),
|
||||||
'DS': oldDSGet(),
|
'DS': old_version_get_ds_token(),
|
||||||
"x-rpc-device_id": random_hex(32),
|
"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',
|
'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',
|
'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",
|
||||||
|
"bbs_presentation_style": "fullscreen",
|
||||||
|
"bbs_auth_required": True,
|
||||||
|
"utm_source": "bbs",
|
||||||
|
"utm_medium": "mys",
|
||||||
|
"utm_campaign": "icon"
|
||||||
|
}
|
||||||
|
)
|
||||||
data = json.loads(req.text)
|
data = json.loads(req.text)
|
||||||
return data
|
return data
|
||||||
except:
|
except:
|
||||||
print("访问失败,请重试!")
|
print("访问失败,请重试!")
|
||||||
# sys.exit(1)
|
# sys.exit(1)
|
||||||
|
|
||||||
async def GetInfo(Uid,ck,ServerID="cn_gf01"):
|
|
||||||
if Uid[0] == '5':
|
|
||||||
ServerID = "cn_qd01"
|
|
||||||
try:
|
|
||||||
async with AsyncClient() as client:
|
|
||||||
req = await client.get(
|
|
||||||
url="https://api-takumi.mihoyo.com/game_record/app/genshin/api/index?role_id=" + Uid + "&server=" + ServerID,
|
|
||||||
headers={
|
|
||||||
'DS': DSGet("role_id=" + Uid + "&server=" + ServerID),
|
|
||||||
'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',
|
|
||||||
'x-rpc-client_type': '5',
|
|
||||||
'Referer': 'https://webstatic.mihoyo.com/',
|
|
||||||
"Cookie": ck})
|
|
||||||
data = json.loads(req.text)
|
|
||||||
#print(data)
|
|
||||||
return data
|
|
||||||
except requests.exceptions.SSLError:
|
|
||||||
try:
|
|
||||||
async with AsyncClient() as client:
|
|
||||||
req = await client.get(
|
|
||||||
url="https://api-takumi-record.mihoyo.com/game_record/app/genshin/api/index?role_id=" + Uid + "&server=" + ServerID,
|
|
||||||
headers={
|
|
||||||
'DS': DSGet("role_id=" + Uid + "&server=" + ServerID),
|
|
||||||
'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',
|
|
||||||
'x-rpc-client_type': '5',
|
|
||||||
'Referer': 'https://webstatic.mihoyo.com/',
|
|
||||||
"Cookie": ck})
|
|
||||||
data = json.loads(req.text)
|
|
||||||
return data
|
|
||||||
except json.decoder.JSONDecodeError:
|
|
||||||
print("米游社基础信息读取新Api失败!")
|
|
||||||
except Exception as e:
|
|
||||||
print("米游社基础信息读取老Api失败!")
|
|
||||||
print(e.with_traceback)
|
|
||||||
|
|
||||||
async def GetSpiralAbyssInfo(Uid, ck,Schedule_type="1",ServerID="cn_gf01"):
|
async def get_info(uid, ck, server_id="cn_gf01"):
|
||||||
if Uid[0] == '5':
|
if uid[0] == '5':
|
||||||
ServerID = "cn_qd01"
|
server_id = "cn_qd01"
|
||||||
try:
|
try:
|
||||||
async with AsyncClient() as client:
|
async with AsyncClient() as client:
|
||||||
req = await client.get(
|
req = await client.get(
|
||||||
url="https://api-takumi.mihoyo.com/game_record/app/genshin/api/spiralAbyss?schedule_type=" + Schedule_type + "&server="+ ServerID +"&role_id=" + Uid,
|
url="https://api-takumi.mihoyo.com/game_record/app/genshin/api/index",
|
||||||
headers={
|
headers={
|
||||||
'DS': DSGet("role_id=" + Uid + "&schedule_type=" + Schedule_type + "&server="+ ServerID),
|
'DS': get_ds_token("role_id=" + uid + "&server=" + server_id),
|
||||||
'Origin': 'https://webstatic.mihoyo.com',
|
|
||||||
'Cookie': ck,
|
|
||||||
'x-rpc-app_version': mhyVersion,
|
'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',
|
'x-rpc-client_type': '5',
|
||||||
'Referer': 'https://webstatic.mihoyo.com/'
|
'Referer': 'https://webstatic.mihoyo.com/',
|
||||||
|
"Cookie": ck},
|
||||||
|
params={
|
||||||
|
"role_id": uid,
|
||||||
|
"server": server_id
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
data = json.loads(req.text)
|
data = json.loads(req.text)
|
||||||
@ -533,15 +552,78 @@ async def GetSpiralAbyssInfo(Uid, ck,Schedule_type="1",ServerID="cn_gf01"):
|
|||||||
try:
|
try:
|
||||||
async with AsyncClient() as client:
|
async with AsyncClient() as client:
|
||||||
req = await client.get(
|
req = await client.get(
|
||||||
url="https://api-takumi-record.mihoyo.com/game_record/app/genshin/api/spiralAbyss?schedule_type=" + Schedule_type + "&server="+ ServerID +"&role_id=" + Uid,
|
url="https://api-takumi-record.mihoyo.com/game_record/app/genshin/api/index",
|
||||||
headers={
|
headers={
|
||||||
'DS': DSGet("role_id=" + Uid + "&schedule_type=" + Schedule_type + "&server="+ ServerID),
|
'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',
|
||||||
|
'x-rpc-client_type': '5',
|
||||||
|
'Referer': 'https://webstatic.mihoyo.com/',
|
||||||
|
"Cookie": ck},
|
||||||
|
params={
|
||||||
|
"role_id": uid,
|
||||||
|
"server": server_id
|
||||||
|
}
|
||||||
|
)
|
||||||
|
data = json.loads(req.text)
|
||||||
|
return data
|
||||||
|
except json.decoder.JSONDecodeError:
|
||||||
|
print("米游社基础信息读取新Api失败!")
|
||||||
|
except Exception as e:
|
||||||
|
print("米游社基础信息读取旧Api失败!")
|
||||||
|
print(e.with_traceback)
|
||||||
|
|
||||||
|
|
||||||
|
async def get_spiral_abyss_info(uid, ck, schedule_type="1", server_id="cn_gf01"):
|
||||||
|
if uid[0] == '5':
|
||||||
|
server_id = "cn_qd01"
|
||||||
|
try:
|
||||||
|
async with AsyncClient() as client:
|
||||||
|
req = await client.get(
|
||||||
|
url="https://api-takumi.mihoyo.com/game_record/app/genshin/api/spiralAbyss",
|
||||||
|
headers={
|
||||||
|
'DS': get_ds_token("role_id=" + uid + "&schedule_type=" + schedule_type + "&server=" + server_id),
|
||||||
'Origin': 'https://webstatic.mihoyo.com',
|
'Origin': 'https://webstatic.mihoyo.com',
|
||||||
'Cookie': ck,
|
'Cookie': ck,
|
||||||
'x-rpc-app_version': mhyVersion,
|
'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',
|
'x-rpc-client_type': '5',
|
||||||
'Referer': 'https://webstatic.mihoyo.com/'
|
'Referer': 'https://webstatic.mihoyo.com/'
|
||||||
|
},
|
||||||
|
parmas={
|
||||||
|
"schedule_type": schedule_type,
|
||||||
|
"role_id": uid,
|
||||||
|
"server": server_id
|
||||||
|
}
|
||||||
|
)
|
||||||
|
data = json.loads(req.text)
|
||||||
|
return data
|
||||||
|
except requests.exceptions.SSLError:
|
||||||
|
try:
|
||||||
|
async with AsyncClient() as client:
|
||||||
|
req = await client.get(
|
||||||
|
url="https://api-takumi-record.mihoyo.com/game_record/app/genshin/api/spiralAbyss",
|
||||||
|
headers={
|
||||||
|
'DS': get_ds_token(
|
||||||
|
"role_id=" + uid + "&schedule_type=" + schedule_type + "&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',
|
||||||
|
'x-rpc-client_type': '5',
|
||||||
|
'Referer': 'https://webstatic.mihoyo.com/'
|
||||||
|
},
|
||||||
|
params={
|
||||||
|
"role_id": uid,
|
||||||
|
"server": server_id,
|
||||||
|
"bbs_presentation_style": "fullscreen",
|
||||||
|
"bbs_auth_required": "true",
|
||||||
|
"utm_source": "bbs",
|
||||||
|
"utm_medium": "mys",
|
||||||
|
"utm_campaign": "icon"
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
data = json.loads(req.text)
|
data = json.loads(req.text)
|
||||||
@ -553,22 +635,23 @@ async def GetSpiralAbyssInfo(Uid, ck,Schedule_type="1",ServerID="cn_gf01"):
|
|||||||
print(e.with_traceback)
|
print(e.with_traceback)
|
||||||
|
|
||||||
|
|
||||||
def GetCharacter(Uid,Character_ids, ck,ServerID="cn_gf01"):
|
def get_character(uid, character_ids, ck, server_id="cn_gf01"):
|
||||||
if Uid[0] == '5':
|
if uid[0] == '5':
|
||||||
ServerID = "cn_qd01"
|
server_id = "cn_qd01"
|
||||||
try:
|
try:
|
||||||
req = requests.post(
|
req = requests.post(
|
||||||
url="https://api-takumi.mihoyo.com/game_record/app/genshin/api/character",
|
url="https://api-takumi.mihoyo.com/game_record/app/genshin/api/character",
|
||||||
headers={
|
headers={
|
||||||
'DS': DSGet('',{"character_ids": Character_ids ,"role_id": Uid ,"server": ServerID}),
|
'DS': get_ds_token('', {"character_ids": character_ids, "role_id": uid, "server": server_id}),
|
||||||
'Origin': 'https://webstatic.mihoyo.com',
|
'Origin': 'https://webstatic.mihoyo.com',
|
||||||
'Cookie': ck,
|
'Cookie': ck,
|
||||||
'x-rpc-app_version': mhyVersion,
|
'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',
|
'x-rpc-client_type': '5',
|
||||||
'Referer': 'https://webstatic.mihoyo.com/'
|
'Referer': 'https://webstatic.mihoyo.com/'
|
||||||
},
|
},
|
||||||
json = {"character_ids": Character_ids ,"role_id": Uid ,"server": ServerID}
|
json={"character_ids": character_ids, "role_id": uid, "server": server_id}
|
||||||
)
|
)
|
||||||
data2 = json.loads(req.text)
|
data2 = json.loads(req.text)
|
||||||
return data2
|
return data2
|
||||||
@ -577,15 +660,16 @@ def GetCharacter(Uid,Character_ids, ck,ServerID="cn_gf01"):
|
|||||||
req = requests.post(
|
req = requests.post(
|
||||||
url="https://api-takumi-record.mihoyo.com/game_record/app/genshin/api/character",
|
url="https://api-takumi-record.mihoyo.com/game_record/app/genshin/api/character",
|
||||||
headers={
|
headers={
|
||||||
'DS': DSGet('',{"character_ids": Character_ids ,"role_id": Uid ,"server": ServerID}),
|
'DS': get_ds_token('', {"character_ids": character_ids, "role_id": uid, "server": server_id}),
|
||||||
'Origin': 'https://webstatic.mihoyo.com',
|
'Origin': 'https://webstatic.mihoyo.com',
|
||||||
'Cookie': ck,
|
'Cookie': ck,
|
||||||
'x-rpc-app_version': mhyVersion,
|
'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',
|
'x-rpc-client_type': '5',
|
||||||
'Referer': 'https://webstatic.mihoyo.com/'
|
'Referer': 'https://webstatic.mihoyo.com/'
|
||||||
},
|
},
|
||||||
json = {"character_ids": Character_ids ,"role_id": Uid ,"server": ServerID}
|
json={"character_ids": character_ids, "role_id": uid, "server": server_id}
|
||||||
)
|
)
|
||||||
data = json.loads(req.text)
|
data = json.loads(req.text)
|
||||||
return data
|
return data
|
||||||
@ -595,18 +679,22 @@ def GetCharacter(Uid,Character_ids, ck,ServerID="cn_gf01"):
|
|||||||
print("深渊信息读取老Api失败!")
|
print("深渊信息读取老Api失败!")
|
||||||
print(e.with_traceback)
|
print(e.with_traceback)
|
||||||
|
|
||||||
async def GetMysInfo(mysid,ck):
|
|
||||||
|
async def get_mihoyo_bbs_info(mysid, ck):
|
||||||
try:
|
try:
|
||||||
async with AsyncClient() as client:
|
async with AsyncClient() as client:
|
||||||
req = await client.get(
|
req = await client.get(
|
||||||
url="https://api-takumi.mihoyo.com/game_record/card/wapi/getGameRecordCard?uid=" + mysid,
|
url="https://api-takumi.mihoyo.com/game_record/card/wapi/getGameRecordCard",
|
||||||
headers={
|
headers={
|
||||||
'DS': DSGet("uid="+mysid),
|
'DS': get_ds_token("uid=" + mysid),
|
||||||
'x-rpc-app_version': mhyVersion,
|
'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',
|
'x-rpc-client_type': '5',
|
||||||
'Referer': 'https://webstatic.mihoyo.com/',
|
'Referer': 'https://webstatic.mihoyo.com/',
|
||||||
"Cookie": ck})
|
"Cookie": ck},
|
||||||
|
params={"uid": mysid}
|
||||||
|
)
|
||||||
data = json.loads(req.text)
|
data = json.loads(req.text)
|
||||||
return data
|
return data
|
||||||
except requests.exceptions.SSLError:
|
except requests.exceptions.SSLError:
|
||||||
@ -615,12 +703,15 @@ async def GetMysInfo(mysid,ck):
|
|||||||
req = await client.get(
|
req = await client.get(
|
||||||
url="https://api-takumi-record.mihoyo.com/game_record/card/wapi/getGameRecordCard?uid=" + mysid,
|
url="https://api-takumi-record.mihoyo.com/game_record/card/wapi/getGameRecordCard?uid=" + mysid,
|
||||||
headers={
|
headers={
|
||||||
'DS': DSGet("uid="+mysid),
|
'DS': get_ds_token("uid=" + mysid),
|
||||||
'x-rpc-app_version': mhyVersion,
|
'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',
|
'x-rpc-client_type': '5',
|
||||||
'Referer': 'https://webstatic.mihoyo.com/',
|
'Referer': 'https://webstatic.mihoyo.com/',
|
||||||
"Cookie": ck})
|
"Cookie": ck},
|
||||||
|
params={"uid": mysid}
|
||||||
|
)
|
||||||
data = json.loads(req.text)
|
data = json.loads(req.text)
|
||||||
return data
|
return data
|
||||||
except json.decoder.JSONDecodeError:
|
except json.decoder.JSONDecodeError:
|
||||||
@ -629,36 +720,53 @@ async def GetMysInfo(mysid,ck):
|
|||||||
print("米游社信息读取老Api失败!")
|
print("米游社信息读取老Api失败!")
|
||||||
print(e.with_traceback)
|
print(e.with_traceback)
|
||||||
|
|
||||||
async def GetAudioInfo(name,audioid,language = "cn"):
|
|
||||||
|
async def get_audio_info(name, audioid, language="cn"):
|
||||||
url = "https://genshin.minigg.cn/?characters=" + name + "&audioid=" + audioid + "&language=" + language
|
url = "https://genshin.minigg.cn/?characters=" + name + "&audioid=" + audioid + "&language=" + language
|
||||||
async with AsyncClient() as client:
|
async with AsyncClient() as client:
|
||||||
req = await client.get(
|
req = await client.get(
|
||||||
url=url,
|
url=url,
|
||||||
headers={
|
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',
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
|
||||||
'Referer': 'https://genshin.minigg.cn/index.html'})
|
'Chrome/95.0.4638.69 Safari/537.36',
|
||||||
|
'Referer': 'https://genshin.minigg.cn/index.html'},
|
||||||
|
params={"characters": name, "audioid": audioid, "language": language}
|
||||||
|
)
|
||||||
return req.text
|
return req.text
|
||||||
|
|
||||||
async def GetWeaponInfo(name,level = None):
|
|
||||||
|
async def get_weapon_info(name, level=None):
|
||||||
|
if level:
|
||||||
|
params = {"query": name, "stats": level}
|
||||||
|
else:
|
||||||
|
params = {"query": name}
|
||||||
async with AsyncClient() as client:
|
async with AsyncClient() as client:
|
||||||
req = await client.get(
|
req = await client.get(
|
||||||
url="https://info.minigg.cn/weapons?query=" + name + "&stats=" + level if level else "https://info.minigg.cn/weapons?query=" + name,
|
url="https://info.minigg.cn/weapons",
|
||||||
headers={
|
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'})
|
'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'},
|
||||||
|
params=params
|
||||||
|
)
|
||||||
data = json.loads(req.text)
|
data = json.loads(req.text)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
async def GetMiscInfo(mode,name):
|
|
||||||
url = "https://info.minigg.cn/{}?query={}".format(mode,urllib.parse.quote(name, safe=''))
|
async def get_misc_info(mode, name):
|
||||||
|
url = "https://info.minigg.cn/{}".format(mode)
|
||||||
async with AsyncClient() as client:
|
async with AsyncClient() as client:
|
||||||
req = await client.get(
|
req = await client.get(
|
||||||
url=url,
|
url=url,
|
||||||
headers={
|
headers={
|
||||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36'})
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
|
||||||
|
'Chrome/97.0.4692.71 Safari/537.36'},
|
||||||
|
params={"query": name}
|
||||||
|
)
|
||||||
data = json.loads(req.text)
|
data = json.loads(req.text)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
async def GetCharInfo(name,mode = "char",level = None):
|
|
||||||
|
async def get_char_info(name, mode="char", level=None):
|
||||||
url2 = None
|
url2 = None
|
||||||
data2 = None
|
data2 = None
|
||||||
baseurl = "https://info.minigg.cn/characters?query="
|
baseurl = "https://info.minigg.cn/characters?query="
|
||||||
@ -680,17 +788,17 @@ async def GetCharInfo(name,mode = "char",level = None):
|
|||||||
req = await client.get(
|
req = await client.get(
|
||||||
url=url2,
|
url=url2,
|
||||||
headers={
|
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',
|
'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)
|
data2 = json.loads(req.text)
|
||||||
if "errcode" not in data2:
|
if "errcode" in data2:
|
||||||
pass
|
async with AsyncClient() as client_:
|
||||||
else:
|
req = await client_.get(
|
||||||
async with AsyncClient() as client:
|
|
||||||
req = await client.get(
|
|
||||||
url=url3,
|
url=url3,
|
||||||
headers={
|
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',
|
'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)
|
data2 = json.loads(req.text)
|
||||||
|
|
||||||
@ -698,43 +806,55 @@ async def GetCharInfo(name,mode = "char",level = None):
|
|||||||
req = await client.get(
|
req = await client.get(
|
||||||
url=url,
|
url=url,
|
||||||
headers={
|
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',
|
'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:
|
try:
|
||||||
data = json.loads(req.text)
|
data = json.loads(req.text)
|
||||||
if "errcode" not in data:
|
if "errcode" in data:
|
||||||
pass
|
async with AsyncClient() as client_:
|
||||||
else:
|
req = await client_.get(
|
||||||
async with AsyncClient() as client:
|
|
||||||
req = await client.get(
|
|
||||||
url=url + "&matchCategories=true",
|
url=url + "&matchCategories=true",
|
||||||
headers={
|
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',
|
'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)
|
data = json.loads(req.text)
|
||||||
except:
|
except:
|
||||||
data = None
|
data = None
|
||||||
return data if data2 == None else [data,data2]
|
return data if data2 is None else [data, data2]
|
||||||
|
|
||||||
async def GetGenshinEvent(mode = "List"):
|
|
||||||
|
async def get_genshin_events(mode="List"):
|
||||||
if mode == "Calendar":
|
if mode == "Calendar":
|
||||||
now_time = datetime.datetime.now().strftime('%Y-%m-%d')
|
now_time = datetime.datetime.now().strftime('%Y-%m-%d')
|
||||||
base_url = "https://api-takumi.mihoyo.com/event/bbs_activity_calendar/getActList?time={}&game_biz=ys_cn&page=1&tag_id=0".format(now_time)
|
base_url = "https://api-takumi.mihoyo.com/event/bbs_activity_calendar/getActList"
|
||||||
|
params = {
|
||||||
|
"time": now_time,
|
||||||
|
"game_biz": "ys_cn",
|
||||||
|
"page": 1,
|
||||||
|
"tag_id": 0
|
||||||
|
}
|
||||||
else:
|
else:
|
||||||
base_url = "https://hk4e-api.mihoyo.com/common/hk4e_cn/announcement/api/getAnn" + mode + "?game=hk4e&game_biz=hk4e_cn&lang=zh-cn&bundle_id=hk4e_cn&platform=pc®ion=cn_gf01&level=55&uid=100000000"
|
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",
|
||||||
|
"bundle_id": "hk4e_cn",
|
||||||
|
"platform": "pc",
|
||||||
|
"region": "cn_gf01",
|
||||||
|
"level": 55,
|
||||||
|
"uid": 100000000
|
||||||
|
}
|
||||||
|
|
||||||
async with AsyncClient() as client:
|
async with AsyncClient() as client:
|
||||||
req = await client.get(
|
req = await client.get(
|
||||||
url=base_url,
|
url=base_url,
|
||||||
headers={
|
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'})
|
'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'},
|
||||||
|
params=params
|
||||||
|
)
|
||||||
data = json.loads(req.text)
|
data = json.loads(req.text)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
'''
|
|
||||||
def jsonfy(s:str)->object:
|
|
||||||
s = s.replace("stats: [Function (anonymous)]","").replace("(","(").replace(")",")")
|
|
||||||
#此函数将不带双引号的json的key标准化
|
|
||||||
obj = eval(s, type('js', (dict,), dict(__getitem__=lambda s, n: n))())
|
|
||||||
return obj
|
|
||||||
'''
|
|
1380
get_image.py
Normal file
@ -1,13 +1,20 @@
|
|||||||
import math,sqlite3,re,os,random,requests,json
|
import json
|
||||||
|
import math
|
||||||
|
import os
|
||||||
|
import random
|
||||||
|
import re
|
||||||
|
import sqlite3
|
||||||
from base64 import b64encode
|
from base64 import b64encode
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
from .getDB import ( GetAward, GetCharInfo, GetDaily, GetMysInfo, GetAudioInfo,
|
import requests
|
||||||
GetSignInfo, GetSignList, GetWeaponInfo, MysSign,
|
|
||||||
cookiesDB, GetMiscInfo)
|
from .get_data import (get_award, get_char_info, get_daily_data, get_mihoyo_bbs_info, get_audio_info,
|
||||||
|
get_sign_info, get_sign_list, get_weapon_info, mihoyo_bbs_sign,
|
||||||
|
cookies_db, get_misc_info)
|
||||||
|
|
||||||
FILE_PATH = os.path.dirname(__file__)
|
FILE_PATH = os.path.dirname(__file__)
|
||||||
FILE2_PATH = os.path.join(FILE_PATH, 'mys')
|
FILE2_PATH = os.path.join(FILE_PATH, 'mihoyo_bbs')
|
||||||
INDEX_PATH = os.path.join(FILE2_PATH, 'index')
|
INDEX_PATH = os.path.join(FILE2_PATH, 'index')
|
||||||
Texture_PATH = os.path.join(FILE2_PATH, 'texture2d')
|
Texture_PATH = os.path.join(FILE2_PATH, 'texture2d')
|
||||||
|
|
||||||
@ -143,13 +150,14 @@ audio_json = '''{
|
|||||||
"1020000":["1020000_01"]
|
"1020000":["1020000_01"]
|
||||||
}'''
|
}'''
|
||||||
|
|
||||||
|
|
||||||
async def deal_ck(mes, qid):
|
async def deal_ck(mes, qid):
|
||||||
aid = re.search(r"account_id=(\d*)", mes)
|
aid = re.search(r"account_id=(\d*)", mes)
|
||||||
mysid_data = aid.group(0).split('=')
|
mysid_data = aid.group(0).split('=')
|
||||||
mysid = mysid_data[1]
|
mysid = mysid_data[1]
|
||||||
cookie = ';'.join(filter(lambda x: x.split('=')[0] in [
|
cookie = ';'.join(filter(lambda x: x.split('=')[0] in [
|
||||||
"cookie_token", "account_id"], [i.strip() for i in mes.split(';')]))
|
"cookie_token", "account_id"], [i.strip() for i in mes.split(';')]))
|
||||||
mys_data = await GetMysInfo(mysid, cookie)
|
mys_data = await get_mihoyo_bbs_info(mysid, cookie)
|
||||||
for i in mys_data['data']['list']:
|
for i in mys_data['data']['list']:
|
||||||
if i['game_id'] != 2:
|
if i['game_id'] != 2:
|
||||||
mys_data['data']['list'].remove(i)
|
mys_data['data']['list'].remove(i)
|
||||||
@ -166,10 +174,11 @@ async def deal_ck(mes,qid):
|
|||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
await cookiesDB(uid, cookie, qid)
|
await cookies_db(uid, cookie, qid)
|
||||||
|
|
||||||
|
|
||||||
async def award(uid):
|
async def award(uid):
|
||||||
data = await GetAward(uid)
|
data = await get_award(uid)
|
||||||
nickname = data['data']['nickname']
|
nickname = data['data']['nickname']
|
||||||
day_stone = data['data']['day_data']['current_primogems']
|
day_stone = data['data']['day_data']['current_primogems']
|
||||||
day_mora = data['data']['day_data']['current_mora']
|
day_mora = data['data']['day_data']['current_mora']
|
||||||
@ -189,23 +198,25 @@ async def award(uid):
|
|||||||
month_stone, month_mora, lastmonth_stone, lastmonth_mora, group_str)
|
month_stone, month_mora, lastmonth_stone, lastmonth_mora, group_str)
|
||||||
return im
|
return im
|
||||||
|
|
||||||
|
|
||||||
async def audio_wiki(name, message):
|
async def audio_wiki(name, message):
|
||||||
async def get(audioid):
|
async def get(_audioid):
|
||||||
tmp_json = json.loads(audio_json)
|
tmp_json = json.loads(audio_json)
|
||||||
for _ in range(3): # 重试3次
|
for _ in range(3): # 重试3次
|
||||||
if audioid in tmp_json:
|
if _audioid in tmp_json:
|
||||||
if not tmp_json[audioid]:
|
if not tmp_json[_audioid]:
|
||||||
return
|
return
|
||||||
audioid1 = random.choice(tmp_json[audioid])
|
audioid1 = random.choice(tmp_json[_audioid])
|
||||||
else:
|
else:
|
||||||
audioid1=audioid
|
audioid1 = _audioid
|
||||||
url = await GetAudioInfo(name,audioid1)
|
url = await get_audio_info(name, audioid1)
|
||||||
req = requests.get(url)
|
req = requests.get(url)
|
||||||
if req.headers["Content-Type"].startswith("audio"):
|
if req.headers["Content-Type"].startswith("audio"):
|
||||||
return BytesIO(req.content)
|
return BytesIO(req.content)
|
||||||
else:
|
else:
|
||||||
if audioid in tmp_json:
|
if _audioid in tmp_json:
|
||||||
tmp_json[audioid].remove(audioid1)
|
tmp_json[_audioid].remove(audioid1)
|
||||||
|
|
||||||
if name == "列表":
|
if name == "列表":
|
||||||
im = f'[CQ:image,file=file://{os.path.join(INDEX_PATH, "语音.png")}]'
|
im = f'[CQ:image,file=file://{os.path.join(INDEX_PATH, "语音.png")}]'
|
||||||
return im
|
return im
|
||||||
@ -219,10 +230,11 @@ async def audio_wiki(name,message):
|
|||||||
return "语音获取失败"
|
return "语音获取失败"
|
||||||
if audio:
|
if audio:
|
||||||
audios = 'base64://' + b64encode(audio.getvalue()).decode()
|
audios = 'base64://' + b64encode(audio.getvalue()).decode()
|
||||||
return (f"[CQ:record,file={audios}]")
|
return f"[CQ:record,file={audios}]"
|
||||||
|
|
||||||
|
|
||||||
async def artifacts_wiki(name):
|
async def artifacts_wiki(name):
|
||||||
data = await GetMiscInfo("artifacts",name)
|
data = await get_misc_info("artifacts", name)
|
||||||
if "errcode" in data:
|
if "errcode" in data:
|
||||||
im = "该圣遗物不存在。"
|
im = "该圣遗物不存在。"
|
||||||
else:
|
else:
|
||||||
@ -230,13 +242,17 @@ async def artifacts_wiki(name):
|
|||||||
for i in data["rarity"]:
|
for i in data["rarity"]:
|
||||||
star = star + i + "星、"
|
star = star + i + "星、"
|
||||||
star = star[:-1]
|
star = star[:-1]
|
||||||
im = artifacts_im.format(data["name"],star,data["2pc"],data["4pc"],data["flower"]["name"],data["flower"]["description"],
|
im = artifacts_im.format(data["name"], star, data["2pc"], data["4pc"], data["flower"]["name"],
|
||||||
data["plume"]["name"],data["plume"]["description"],data["sands"]["name"],data["sands"]["description"],
|
data["flower"]["description"],
|
||||||
data["goblet"]["name"],data["goblet"]["description"],data["circlet"]["name"],data["circlet"]["description"])
|
data["plume"]["name"], data["plume"]["description"], data["sands"]["name"],
|
||||||
|
data["sands"]["description"],
|
||||||
|
data["goblet"]["name"], data["goblet"]["description"], data["circlet"]["name"],
|
||||||
|
data["circlet"]["description"])
|
||||||
return im
|
return im
|
||||||
|
|
||||||
|
|
||||||
async def foods_wiki(name):
|
async def foods_wiki(name):
|
||||||
data = await GetMiscInfo("foods",name)
|
data = await get_misc_info("foods", name)
|
||||||
if "errcode" in data:
|
if "errcode" in data:
|
||||||
im = "该食物不存在。"
|
im = "该食物不存在。"
|
||||||
else:
|
else:
|
||||||
@ -250,11 +266,13 @@ async def foods_wiki(name):
|
|||||||
for i in food_temp:
|
for i in food_temp:
|
||||||
ingredients += i + ":" + str(food_temp[i]) + "\n"
|
ingredients += i + ":" + str(food_temp[i]) + "\n"
|
||||||
ingredients = ingredients[:-1]
|
ingredients = ingredients[:-1]
|
||||||
im = food_im.format(data["name"],data["rarity"],data["foodtype"],data["foodfilter"],data["effect"],data["description"],ingredients)
|
im = food_im.format(data["name"], data["rarity"], data["foodtype"], data["foodfilter"], data["effect"],
|
||||||
|
data["description"], ingredients)
|
||||||
return im
|
return im
|
||||||
|
|
||||||
|
|
||||||
async def enemies_wiki(name):
|
async def enemies_wiki(name):
|
||||||
raw_data = await GetMiscInfo("enemies",name)
|
raw_data = await get_misc_info("enemies", name)
|
||||||
if "errcode" in raw_data:
|
if "errcode" in raw_data:
|
||||||
im = "该原魔不存在。"
|
im = "该原魔不存在。"
|
||||||
else:
|
else:
|
||||||
@ -266,13 +284,14 @@ async def enemies_wiki(name):
|
|||||||
raw_data["category"], raw_data["description"], reward)
|
raw_data["category"], raw_data["description"], reward)
|
||||||
return im
|
return im
|
||||||
|
|
||||||
|
|
||||||
# 签到函数
|
# 签到函数
|
||||||
async def sign(uid):
|
async def sign(uid):
|
||||||
try:
|
try:
|
||||||
sign_data = await MysSign(uid)
|
sign_data = await mihoyo_bbs_sign(uid)
|
||||||
sign_info = await GetSignInfo(uid)
|
sign_info = await get_sign_info(uid)
|
||||||
sign_info = sign_info['data']
|
sign_info = sign_info['data']
|
||||||
sign_list = await GetSignList()
|
sign_list = await get_sign_list()
|
||||||
status = sign_data['message']
|
status = sign_data['message']
|
||||||
getitem = sign_list['data']['awards'][int(
|
getitem = sign_list['data']['awards'][int(
|
||||||
sign_info['total_sign_day']) - 1]['name']
|
sign_info['total_sign_day']) - 1]['name']
|
||||||
@ -289,9 +308,9 @@ async def sign(uid):
|
|||||||
im = "签到失败,请检查Cookies是否失效。"
|
im = "签到失败,请检查Cookies是否失效。"
|
||||||
return im
|
return im
|
||||||
|
|
||||||
|
|
||||||
# 统计状态函数
|
# 统计状态函数
|
||||||
async def daily(mode="push", uid=None):
|
async def daily(mode="push", uid=None):
|
||||||
|
|
||||||
def seconds2hours(seconds: int) -> str:
|
def seconds2hours(seconds: int) -> str:
|
||||||
m, s = divmod(int(seconds), 60)
|
m, s = divmod(int(seconds), 60)
|
||||||
h, m = divmod(m, 60)
|
h, m = divmod(m, 60)
|
||||||
@ -308,7 +327,7 @@ async def daily(mode="push", uid=None):
|
|||||||
c_data = ([uid, 0, 0, 0, 0, 0, 0],)
|
c_data = ([uid, 0, 0, 0, 0, 0, 0],)
|
||||||
|
|
||||||
for row in c_data:
|
for row in c_data:
|
||||||
raw_data = await GetDaily(str(row[0]))
|
raw_data = await get_daily_data(str(row[0]))
|
||||||
if raw_data["retcode"] != 0:
|
if raw_data["retcode"] != 0:
|
||||||
temp_list.append(
|
temp_list.append(
|
||||||
{"qid": row[2], "gid": row[3], "message": "你的推送状态有误;可能是uid绑定错误或没有在米游社打开“实时便筏”功能。"})
|
{"qid": row[2], "gid": row[3], "message": "你的推送状态有误;可能是uid绑定错误或没有在米游社打开“实时便筏”功能。"})
|
||||||
@ -339,7 +358,7 @@ async def daily(mode="push", uid=None):
|
|||||||
if current_resin >= row[6] or dailydata["max_home_coin"] - dailydata["current_home_coin"] <= 100:
|
if current_resin >= row[6] or dailydata["max_home_coin"] - dailydata["current_home_coin"] <= 100:
|
||||||
tip = ''
|
tip = ''
|
||||||
|
|
||||||
if current_resin >= row[6] and row[6] != 0:
|
if current_resin >= row[6] != 0:
|
||||||
tip += "\n==============\n你的树脂快满了!"
|
tip += "\n==============\n你的树脂快满了!"
|
||||||
if dailydata["max_home_coin"] - dailydata["current_home_coin"] <= 100:
|
if dailydata["max_home_coin"] - dailydata["current_home_coin"] <= 100:
|
||||||
tip += "\n==============\n你的洞天宝钱快满了!"
|
tip += "\n==============\n你的洞天宝钱快满了!"
|
||||||
@ -352,7 +371,8 @@ async def daily(mode="push", uid=None):
|
|||||||
resin_recovery_time = seconds2hours(
|
resin_recovery_time = seconds2hours(
|
||||||
dailydata['resin_recovery_time'])
|
dailydata['resin_recovery_time'])
|
||||||
next_resin_rec_time = seconds2hours(
|
next_resin_rec_time = seconds2hours(
|
||||||
8 * 60 - ((dailydata['max_resin'] - dailydata['current_resin']) * 8 * 60 - int(dailydata['resin_recovery_time'])))
|
8 * 60 - ((dailydata['max_resin'] - dailydata['current_resin']) * 8 * 60 - int(
|
||||||
|
dailydata['resin_recovery_time'])))
|
||||||
rec_time = f' ({next_resin_rec_time}/{resin_recovery_time})'
|
rec_time = f' ({next_resin_rec_time}/{resin_recovery_time})'
|
||||||
|
|
||||||
finished_task_num = dailydata['finished_task_num']
|
finished_task_num = dailydata['finished_task_num']
|
||||||
@ -366,12 +386,15 @@ async def daily(mode="push", uid=None):
|
|||||||
coin = f'{dailydata["current_home_coin"]}/{dailydata["max_home_coin"]}'
|
coin = f'{dailydata["current_home_coin"]}/{dailydata["max_home_coin"]}'
|
||||||
if dailydata["current_home_coin"] < dailydata["max_home_coin"]:
|
if dailydata["current_home_coin"] < dailydata["max_home_coin"]:
|
||||||
coin_rec_time = seconds2hours(int(dailydata["home_coin_recovery_time"]))
|
coin_rec_time = seconds2hours(int(dailydata["home_coin_recovery_time"]))
|
||||||
coin_add_speed=math.ceil((dailydata["max_home_coin"]-dailydata["current_home_coin"])/(int(dailydata["home_coin_recovery_time"])/60/60))
|
coin_add_speed = math.ceil((dailydata["max_home_coin"] - dailydata["current_home_coin"]) / (
|
||||||
|
int(dailydata["home_coin_recovery_time"]) / 60 / 60))
|
||||||
coin += f'({coin_rec_time} 约{coin_add_speed}/h)'
|
coin += f'({coin_rec_time} 约{coin_add_speed}/h)'
|
||||||
|
|
||||||
expedition_data = "\n".join(expedition_info)
|
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,
|
send_mes = daily_im.format(tip, current_resin, max_resin, rec_time, finished_task_num, total_task_num,
|
||||||
resin_discount_num_limit, coin,current_expedition_num, finished_expedition_num, max_expedition_num, expedition_data)
|
is_extra_got, used_resin_discount_num,
|
||||||
|
resin_discount_num_limit, coin, current_expedition_num,
|
||||||
|
finished_expedition_num, max_expedition_num, expedition_data)
|
||||||
|
|
||||||
temp_list.append(
|
temp_list.append(
|
||||||
{"qid": row[2], "gid": row[3], "message": send_mes})
|
{"qid": row[2], "gid": row[3], "message": send_mes})
|
||||||
@ -379,20 +402,21 @@ async def daily(mode="push", uid=None):
|
|||||||
|
|
||||||
|
|
||||||
async def weapon_wiki(name, level=None):
|
async def weapon_wiki(name, level=None):
|
||||||
data = await GetWeaponInfo(name)
|
data = await get_weapon_info(name)
|
||||||
if "errcode" in data:
|
if "errcode" in data:
|
||||||
im = "武器不存在。"
|
im = "武器不存在。"
|
||||||
elif level:
|
elif level:
|
||||||
data2 = await GetWeaponInfo(name,level)
|
data2 = await get_weapon_info(name, level)
|
||||||
if data["substat"] != "":
|
if data["substat"] != "":
|
||||||
sp = data["substat"] + ":" + '%.1f%%' % (data2["specialized"] * 100) if data["substat"] != "元素精通" else data["substat"] + ":" + str(math.floor(data2["specialized"]))
|
sp = data["substat"] + ":" + '%.1f%%' % (data2["specialized"] * 100) \
|
||||||
|
if data["substat"] != "元素精通" else data["substat"] + ":" + str(math.floor(data2["specialized"]))
|
||||||
else:
|
else:
|
||||||
sp = ""
|
sp = ""
|
||||||
im = (data["name"] + "\n等级:" + str(data2["level"]) + "(突破" + str(data2["ascension"]) + ")" +
|
im = (data["name"] + "\n等级:" + str(data2["level"]) + "(突破" + str(data2["ascension"]) + ")" +
|
||||||
"\n攻击力:" + str(round(data2["attack"])) + "\n" + sp)
|
"\n攻击力:" + str(round(data2["attack"])) + "\n" + sp)
|
||||||
else:
|
else:
|
||||||
name = data['name']
|
name = data['name']
|
||||||
type = data['weapontype']
|
_type = data['weapontype']
|
||||||
star = data['rarity'] + "星"
|
star = data['rarity'] + "星"
|
||||||
info = data['description']
|
info = data['description']
|
||||||
atk = str(data['baseatk'])
|
atk = str(data['baseatk'])
|
||||||
@ -417,27 +441,29 @@ async def weapon_wiki(name,level = None):
|
|||||||
effect = "\n" + "【" + data['effectname'] + "】" + ":" + raw_effect
|
effect = "\n" + "【" + data['effectname'] + "】" + ":" + raw_effect
|
||||||
else:
|
else:
|
||||||
effect = ""
|
effect = ""
|
||||||
im = weapon_im.format(name, type, star, info, atk,
|
im = weapon_im.format(name, _type, star, info, atk,
|
||||||
sub, effect)
|
sub, effect)
|
||||||
return im
|
return im
|
||||||
|
|
||||||
|
|
||||||
async def char_wiki(name, mode="char", level=None):
|
async def char_wiki(name, mode="char", level=None):
|
||||||
data = await GetCharInfo(name, mode, level if mode == "char" else None)
|
data = await get_char_info(name, mode, level if mode == "char" else None)
|
||||||
if mode == "char":
|
if mode == "char":
|
||||||
if isinstance(data, list):
|
if isinstance(data, list):
|
||||||
im = ','.join(data)
|
im = ','.join(data)
|
||||||
elif "errcode" in data:
|
elif "errcode" in data:
|
||||||
im = "不存在该角色或类型。"
|
im = "不存在该角色或类型。"
|
||||||
elif level:
|
elif level:
|
||||||
data2 = await GetCharInfo(name, mode)
|
data2 = await get_char_info(name, mode)
|
||||||
sp = data2["substat"] + ":" + '%.1f%%' % (data["specialized"] * 100) if data2["substat"] != "元素精通" else data2["substat"] + ":" + str(math.floor(data["specialized"]))
|
sp = data2["substat"] + ":" + '%.1f%%' % (data["specialized"] * 100) if data2["substat"] != "元素精通" else \
|
||||||
|
data2["substat"] + ":" + str(math.floor(data["specialized"]))
|
||||||
im = (data2["name"] + "\n等级:" + str(data["level"]) + "\n血量:" + str(math.floor(data["hp"])) +
|
im = (data2["name"] + "\n等级:" + str(data["level"]) + "\n血量:" + str(math.floor(data["hp"])) +
|
||||||
"\n攻击力:" + str(math.floor(data["attack"])) + "\n防御力:" + str(math.floor(data["defense"])) +
|
"\n攻击力:" + str(math.floor(data["attack"])) + "\n防御力:" + str(math.floor(data["defense"])) +
|
||||||
"\n" + sp)
|
"\n" + sp)
|
||||||
else:
|
else:
|
||||||
name = data['title'] + ' — ' + data['name']
|
name = data['title'] + ' — ' + data['name']
|
||||||
star = data['rarity']
|
star = data['rarity']
|
||||||
type = data["weapontype"]
|
_type = data["weapontype"]
|
||||||
element = data['element']
|
element = data['element']
|
||||||
up_val = data['substat']
|
up_val = data['substat']
|
||||||
bdday = data['birthday']
|
bdday = data['birthday']
|
||||||
@ -445,7 +471,7 @@ async def char_wiki(name, mode="char", level=None):
|
|||||||
cv = data['cv']['chinese']
|
cv = data['cv']['chinese']
|
||||||
info = data['description']
|
info = data['description']
|
||||||
im = char_info_im.format(
|
im = char_info_im.format(
|
||||||
name, star, type, element, up_val, bdday, polar, cv, info)
|
name, star, _type, element, up_val, bdday, polar, cv, info)
|
||||||
elif mode == "costs":
|
elif mode == "costs":
|
||||||
if isinstance(data[1], list):
|
if isinstance(data[1], list):
|
||||||
im = ','.join(data[1])
|
im = ','.join(data[1])
|
||||||
@ -490,7 +516,7 @@ async def char_wiki(name, mode="char", level=None):
|
|||||||
if "errcode" in data:
|
if "errcode" in data:
|
||||||
im = "不存在该角色。"
|
im = "不存在该角色。"
|
||||||
else:
|
else:
|
||||||
if int(level) <=6 and int(level) > 0:
|
if 6 >= int(level) > 0:
|
||||||
if int(level) <= 3:
|
if int(level) <= 3:
|
||||||
if level == "1":
|
if level == "1":
|
||||||
data = data["combat1"]
|
data = data["combat1"]
|
Before Width: | Height: | Size: 129 KiB After Width: | Height: | Size: 129 KiB |
Before Width: | Height: | Size: 793 KiB After Width: | Height: | Size: 793 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 614 KiB After Width: | Height: | Size: 614 KiB |
Before Width: | Height: | Size: 508 KiB After Width: | Height: | Size: 508 KiB |
Before Width: | Height: | Size: 689 KiB After Width: | Height: | Size: 689 KiB |
Before Width: | Height: | Size: 530 KiB After Width: | Height: | Size: 530 KiB |
Before Width: | Height: | Size: 637 KiB After Width: | Height: | Size: 637 KiB |
Before Width: | Height: | Size: 590 KiB After Width: | Height: | Size: 590 KiB |
Before Width: | Height: | Size: 602 KiB After Width: | Height: | Size: 602 KiB |
Before Width: | Height: | Size: 418 KiB After Width: | Height: | Size: 418 KiB |
Before Width: | Height: | Size: 611 KiB After Width: | Height: | Size: 611 KiB |
Before Width: | Height: | Size: 595 KiB After Width: | Height: | Size: 595 KiB |
Before Width: | Height: | Size: 507 KiB After Width: | Height: | Size: 507 KiB |
Before Width: | Height: | Size: 516 KiB After Width: | Height: | Size: 516 KiB |
Before Width: | Height: | Size: 540 KiB After Width: | Height: | Size: 540 KiB |
Before Width: | Height: | Size: 712 KiB After Width: | Height: | Size: 712 KiB |
Before Width: | Height: | Size: 795 KiB After Width: | Height: | Size: 795 KiB |
Before Width: | Height: | Size: 549 KiB After Width: | Height: | Size: 549 KiB |
Before Width: | Height: | Size: 423 KiB After Width: | Height: | Size: 423 KiB |
Before Width: | Height: | Size: 489 KiB After Width: | Height: | Size: 489 KiB |
Before Width: | Height: | Size: 530 KiB After Width: | Height: | Size: 530 KiB |
Before Width: | Height: | Size: 581 KiB After Width: | Height: | Size: 581 KiB |
Before Width: | Height: | Size: 518 KiB After Width: | Height: | Size: 518 KiB |
Before Width: | Height: | Size: 561 KiB After Width: | Height: | Size: 561 KiB |
Before Width: | Height: | Size: 545 KiB After Width: | Height: | Size: 545 KiB |
Before Width: | Height: | Size: 461 KiB After Width: | Height: | Size: 461 KiB |
Before Width: | Height: | Size: 475 KiB After Width: | Height: | Size: 475 KiB |
Before Width: | Height: | Size: 589 KiB After Width: | Height: | Size: 589 KiB |
Before Width: | Height: | Size: 916 KiB After Width: | Height: | Size: 916 KiB |
Before Width: | Height: | Size: 788 KiB After Width: | Height: | Size: 788 KiB |
Before Width: | Height: | Size: 540 KiB After Width: | Height: | Size: 540 KiB |
Before Width: | Height: | Size: 465 KiB After Width: | Height: | Size: 465 KiB |
Before Width: | Height: | Size: 788 KiB After Width: | Height: | Size: 788 KiB |
Before Width: | Height: | Size: 454 KiB After Width: | Height: | Size: 454 KiB |
Before Width: | Height: | Size: 656 KiB After Width: | Height: | Size: 656 KiB |
Before Width: | Height: | Size: 651 KiB After Width: | Height: | Size: 651 KiB |
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 80 KiB |
Before Width: | Height: | Size: 104 KiB After Width: | Height: | Size: 104 KiB |
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 81 KiB |
Before Width: | Height: | Size: 95 KiB After Width: | Height: | Size: 95 KiB |
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 84 KiB |
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 91 KiB |
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 80 KiB |
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 73 KiB |
Before Width: | Height: | Size: 95 KiB After Width: | Height: | Size: 95 KiB |
Before Width: | Height: | Size: 69 KiB After Width: | Height: | Size: 69 KiB |
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 87 KiB |
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 92 KiB |
Before Width: | Height: | Size: 96 KiB After Width: | Height: | Size: 96 KiB |
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 81 KiB |