Files
qqbot/Player_Query.py

2128 lines
92 KiB
Python

import requests
from PIL import Image
from PIL import ImageFilter
from PIL import ImageEnhance
from PIL import ImageDraw, ImageFont
import time
from datetime import datetime, timedelta
import pytz
import os
import random
import json
from io import BytesIO
import hashlib
import re
import csv
from pathlib import Path
class Character_Query():
async def Character_date(self, name):
#def Character_date(self, name):
url = "https://api.sunderer.games/census/character/search"
querystring = {"name": ""}
querystring["name"] = name
response = requests.request("GET", url, params=querystring)
response = response.json()
#print(response)
return response
async def txt_reader(self):
#def txt_reader(self):
with open("GGou7.txt", "r") as file:
lines = file.read().strip("'").strip('"')
lines = lines.replace("/n", "")
lines = lines.replace("/t", "")
lines = lines.strip("'")
lines = json.loads(lines)
# lines = lines.strip()C:\Cq-http\NoneBot\Git_Plugins\QQbot\MICROYX.json
return lines
async def get_public_ip(self):
#def get_public_ip(self):
try:
response = requests.get('https://myip.ipip.net/ip')
if response.status_code == 200:
return json.loads(response.text)['ip']
else:
return "Failed to get public IP address"
except requests.RequestException as e:
return f"Error: {e}"
async def generate_md5(self,ip, key):
#def generate_md5(self,ip, key):
# 将IP地址和key拼接
combined_string = ip + key
# 创建md5对象
md5 = hashlib.md5()
# 对拼接后的字符串进行MD5加密
md5.update(combined_string.encode('utf-8'))
# 返回MD5加密后的16进制字符串
return md5.hexdigest()
async def Sundy_authentication(self,msg):
#def Sundy_authentication(self,msg):
new_payload = msg['ID']
local_ip = await Character_Query().get_public_ip()
# 指定的key
key = "123123"
# 生成MD5
md5_result = await Character_Query().generate_md5(key,local_ip)
url = "https://u.sunderer.games/index.php/botapi/UserApi/isUserAuth"
querystring = {"gamename":"gamone1","key":"6097d1cb7d8f09bf5f60b40124d99069"}
querystring['gamename'] = new_payload
querystring['key'] = md5_result
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"page_no\"\r\n\r\n1\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"page_size\"\r\n\r\n15\r\n-----011000010111000001101001--\r\n\r\n"
headers = {
"Accept": "*/*",
"Accept-Encoding": "gzip, #deflate, br",
"User-Agent": "PostmanRuntime-ApipostRuntime/1.1.0",
"Connection": "keep-alive",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
}
response = requests.request("POST", url, data=payload, headers=headers, params=querystring)
return(response.text)
#校验
async def Date_OverView(slef,msg,date):
#def Date_OverView(slef,msg,date):
#整理数据
Player_BasicDate = date['basicInfo']
Player_LatestSessionInfo = date['latestSessionInfo']
#Player_BattleData_VehicleData = date['battleData']['vehicleData']
#Player_BattleData_BuildingData = date['battleData']['buildingData']
#首图-玩家基础信息
Online_flag = Player_BasicDate['online']
try:
if Online_flag == True :
logintimeline = (Player_LatestSessionInfo['latestLoginDate'])/1000
logintime = datetime.fromtimestamp(logintimeline)
formatted_time = logintime.strftime("%Y-%m-%d %H:%M:%S")
elif Online_flag == False :
Logouttimeline = (Player_LatestSessionInfo['latestLogoutDate'])/1000
Logouttime = datetime.fromtimestamp(Logouttimeline)
formatted_time = Logouttime.strftime("%Y-%m-%d %H:%M:%S")
except:
formatted_time = '数据库无记录'
Resus_file_path = os.path.join(os.path.dirname(__file__),'Charter_Sundy_Query')
#加载字体
judou_heavy = "ttf/judou-ui-cn-heavy.ttf"
judou_heavyit = "ttf/judou-ui-cn-heavyitalic.ttf"
gac = "ttf/gts.TTF"
judou_media = "ttf/judou-medium.ttc"
Output_dir = "/home/bot/QQbot/Charter_Sundy_Query/Output"
#Output_dir = os.path.join(Resus_file_path, "Output")
#加载图片资源
file_path = os.path.join(os.path.dirname(__file__),'Charter_Sundy_Query/头图素材')
Overview_MotherBoard_path = os.path.join(file_path,'普通.png')
Avatar_shadow_path = os.path.join(file_path,'阴影头像.png')
Thin_Block_path = os.path.join(file_path,'阴影400.png')
Ralex_Block_path = os.path.join(file_path,'阴影800.png')
Authen_player_path = os.path.join(file_path,'认证信息/认证玩家.png')
Authen_Sign_path = os.path.join(file_path,'认证信息/签到时间.png')
Authen_Sponsor_path = os.path.join(file_path,'认证信息/赞助者.png')
Authen_daddy_path = os.path.join(file_path,'认证信息/先行者.png')
Authen_Repr_path = os.path.join(file_path,'认证信息/军团代表.png')
Authen_Shadow_path = os.path.join(file_path,'认证信息/认证信息背景阴影.png')
Outfit_Shadow_path = os.path.join(file_path,'军团素材/黑色渐变遮罩.png')#C:\Cq-http\NoneBot\Git_Plugins\QQbot\Charter_Sundy_Query\头图素材\军团素材\黑色渐变遮罩.png
Clock_time_Shadow_Path = os.path.join(file_path, "锁图BLOCK用.png")
Clock_time_shadow = Image.open(Clock_time_Shadow_Path).convert("RGBA")
#加载复用资源
Overview_MotherBoard = Image.open(Overview_MotherBoard_path).convert("RGBA")
Thin_Block = Image.open(Thin_Block_path).convert("RGBA")
Ralex_Block = Image.open(Ralex_Block_path).convert("RGBA")
#请求并加载资源-等级-阵营
Exhibition_AspRank = Player_BasicDate['aspRank']
if Player_BasicDate['factionId'] == '1' :
faction = '瓦努主权国'
if Exhibition_AspRank == 0 :
path = os.path.join(file_path,'战斗军衔/瓦努主权国-非ASP.png')
Rank_banner = Image.open(path).convert("RGBA")
elif Exhibition_AspRank == 1 :
path = os.path.join(file_path,'战斗军衔/瓦努主权国-ASP.png')
Rank_banner = Image.open(path).convert("RGBA")
elif Exhibition_AspRank == 2 :
path = os.path.join(file_path,'战斗军衔/瓦努主权国-ASP2.png')
Rank_banner = Image.open(path).convert("RGBA")
elif Exhibition_AspRank == 3 :
path = os.path.join(file_path,'战斗军衔/瓦努主权国-ASP3.png')
Rank_banner = Image.open(path).convert("RGBA")
#引入阵营图
BGP_dir = os.path.join(file_path,'阵营/背景/瓦努主权国')
read_files = os.listdir(BGP_dir)
flag = random.randint(0, len(read_files)-1)
Im_Address_body = read_files[flag]
Im_Address = os.path.join(BGP_dir,Im_Address_body)
Faction_img = Image.open(Im_Address).convert("RGBA")
Mask_dir = os.path.join(file_path,'阵营/遮盖/瓦努遮盖.png')
Faction_Mask = Image.open(Mask_dir).convert("RGBA")
elif Player_BasicDate['factionId'] == '2' :
faction = '新联邦'
if Exhibition_AspRank == 0 :
path = os.path.join(file_path,'战斗军衔/新联邦-非ASP.png')
Rank_banner = Image.open(path).convert("RGBA")
elif Exhibition_AspRank == 1 :
path = os.path.join(file_path,'战斗军衔/新联邦-ASP.png')
Rank_banner = Image.open(path).convert("RGBA")
elif Exhibition_AspRank == 2 :
path = os.path.join(file_path,'战斗军衔/新联邦-ASP2.png')
Rank_banner = Image.open(path).convert("RGBA")
elif Exhibition_AspRank == 3 :
path = os.path.join(file_path,'战斗军衔/新联邦-ASP3.png')
Rank_banner = Image.open(path).convert("RGBA")
#引入阵营图
BGP_dir = os.path.join(file_path,'阵营/背景/新联邦')
read_files = os.listdir(BGP_dir)
flag = random.randint(0, len(read_files)-1)
Im_Address_body = read_files[flag]
Im_Address = os.path.join(BGP_dir,Im_Address_body)
Faction_img = Image.open(Im_Address).convert("RGBA")
Mask_dir = os.path.join(file_path,'阵营/遮盖/新联邦遮盖.png')
Faction_Mask = Image.open(Mask_dir).convert("RGBA")
elif Player_BasicDate['factionId'] == '3' :
faction = '地球共和国'
if Exhibition_AspRank == 0 :
path = os.path.join(file_path,'战斗军衔/地球共和国-非ASP.png')
Rank_banner = Image.open(path).convert("RGBA")
elif Exhibition_AspRank == 1 :
path = os.path.join(file_path,'战斗军衔/地球共和国-ASP.png')
Rank_banner = Image.open(path).convert("RGBA")
elif Exhibition_AspRank == 2 :
path = os.path.join(file_path,'战斗军衔/地球共和国-ASP2.png')
Rank_banner = Image.open(path).convert("RGBA")
elif Exhibition_AspRank == 3 :
path = os.path.join(file_path,'战斗军衔/地球共和国-ASP3.png')
Rank_banner = Image.open(path).convert("RGBA")
#引入阵营图
BGP_dir = os.path.join(file_path,'阵营/背景/地球共和国')
read_files = os.listdir(BGP_dir)
flag = random.randint(0, len(read_files)-1)
Im_Address_body = read_files[flag]
Im_Address = os.path.join(BGP_dir,Im_Address_body)
Faction_img = Image.open(Im_Address).convert("RGBA")
Mask_dir = os.path.join(file_path,'阵营/遮盖/地球共和国遮盖.png')
Faction_Mask = Image.open(Mask_dir).convert("RGBA")
elif Player_BasicDate['factionId'] == '4' :
faction = '纳能特工'
if Exhibition_AspRank == 0 :
path = os.path.join(file_path,'战斗军衔/纳能特工-非ASP.png')
Rank_banner = Image.open(path).convert("RGBA")
elif Exhibition_AspRank == 1 :
path = os.path.join(file_path,'战斗军衔/纳能特工-ASP.png')
Rank_banner = Image.open(path).convert("RGBA")
elif Exhibition_AspRank == 2 :
path = os.path.join(file_path,'战斗军衔/纳能特工-ASP2.png')
Rank_banner = Image.open(path).convert("RGBA")
elif Exhibition_AspRank == 3 :
path = os.path.join(file_path,'战斗军衔/纳能特工-ASP3.png')
Rank_banner = Image.open(path).convert("RGBA")
#引入阵营图
BGP_dir = os.path.join(file_path,'阵营/背景/纳能特工')
read_files = os.listdir(BGP_dir)
flag = random.randint(0, len(read_files)-1)
Im_Address_body = read_files[flag]
Im_Address = os.path.join(BGP_dir,Im_Address_body)
Faction_img = Image.open(Im_Address).convert("RGBA")
Mask_dir = os.path.join(file_path,'阵营/遮盖/纳能特工遮盖.png')
Faction_Mask = Image.open(Mask_dir).convert("RGBA")
Exhibition_BattleRank = 'LV.' + str(Player_BasicDate['battleRank'])
#查询角色是否认证,获取相关信息
# 调用函数发送请求
Sundy_auth = False
Sundy_auth_LX = True
Avatar_down = True
user_message = None
Money_status = None
Daddy_status = False
nickname = None
avatar_url_csv = None
outfit_flag_csv = None
Money_status = None
Daddy_status = None
result = None
try:
user_message = await Character_Query().request_api(msg['ID'])
except:
Sundy_auth_LX = False
if user_message == None:
Sundy_auth_LX = False
try:
url1 = json.loads(user_message)
except:
Sundy_auth_LX = False
if Sundy_auth_LX == True:
if url1['code'] == 1:
Sundy_auth_LX = True
else:
Sundy_auth_LX = False
#验证请求成功后下载头像储存于内存
if Sundy_auth_LX == False:
file_path_csv = os.path.join(os.path.dirname(__file__), r"csv/character.csv")
auth_dict = await Character_Query().csv_Verified_User(file_path_csv)
if msg['ID'] in auth_dict.values():
Sundy_auth = True
else:
Sundy_auth = False
if msg['ID'] in auth_dict.values():
matching_keys = [key for key, value in auth_dict.items() if value == msg['ID']]
chart_id = int(matching_keys[0])
print(chart_id)
if Sundy_auth == False and Sundy_auth_LX ==False:
#验证api请求失败时使用默认头像
avatar_file_name = '玩家提交图/玩家提交图-' + faction + '.png'
avatar_path = os.path.join(file_path,avatar_file_name)
avatar = Image.open(avatar_path).convert("RGBA")
Avatar_down = True
#json化得到头像网址,bit化以pil打开
elif Sundy_auth == False and Sundy_auth_LX == True:
Avatar_down = True
if url1['msg'] == "已认证":
avatar_url = url1['data'][0]['avatar']
if avatar_url == None:
avatar_file_name = '玩家提交图/玩家提交图-' + faction + '.png'
avatar_path = os.path.join(file_path,avatar_file_name)
avatar = Image.open(avatar_path).convert("RGBA")
else:
clean_url = re.sub(r'<[^>]+>', '', avatar_url)
Avatar_url = 'https://u.sunderer.games/' + clean_url
try:
Avatar_bit_a = requests.get(Avatar_url)
except:
Avatar_down = False
#头像下载成功后Bit化通过PIL打开
if Avatar_down != False:
Avatar_bit_b = Avatar_bit_a.content
Avatar_bit = BytesIO(Avatar_bit_b)
avatar_exf = Image.open(Avatar_bit).convert("RGBA")
avatar = Image.new(avatar_exf.mode, avatar_exf.size)
avatar.putdata(list(avatar_exf.getdata()))
xaa,yaa = avatar.size
print(xaa,yaa)
if (xaa>1600 and yaa<1400 ) or (xaa<1600 and yaa>1400):
#avatar1 = avatar.resize((1600,1400),Image.ANTIALIAS)
if xaa>1600 and yaa<1400 :
rate = 1400/yaa
rx = round(rate*xaa)
avatar1 = avatar.resize((rx,1400),Image.ANTIALIAS)
avatar = await Character_Query().add_rounded_corners(avatar1, 160, (0, 0, 0, 0))
else:
rate = 1600/xaa
ry = round(rate*yaa)
avatar1 = avatar.resize((1600,ry),Image.ANTIALIAS)
avatar = await Character_Query().add_rounded_corners(avatar1, 160, (0, 0, 0, 0))
elif yaa<1400 and xaa<1600:
rate_resize_x = 1600/xaa
resize_x = round(xaa*rate_resize_x)
resize_y = round(yaa*rate_resize_x)
avatar1 = avatar.resize((resize_x,resize_y),Image.ANTIALIAS)
avatar = await Character_Query().add_rounded_corners(avatar1, 160, (0, 0, 0, 0))
else:
avatar = await Character_Query().add_rounded_corners(avatar, 160, (0, 0, 0, 0))
else:
#下载失败后使用默认头像
avatar_file_name = '玩家提交图/玩家提交图-' + faction + '.png'
avatar_path = os.path.join(file_path,avatar_file_name)
avatar = Image.open(avatar_path).convert("RGBA")
elif Sundy_auth == True and Sundy_auth_LX == False:
csv_file_nickname = os.path.join(os.path.dirname(__file__), r"csv/nickname.csv")
nickname_csv = await Character_Query().read_csv_to_list(csv_file_nickname)
print(nickname_csv)
chart_list = await Character_Query().find_id(chart_id,nickname_csv)
print(chart_list)
#需要增加错误catch
nickname = chart_list[1]
avatar_url_csv = chart_list[2]
outfit_flag_csv = chart_list[3]
Money_status = chart_list[4]
Daddy_status = chart_list[5]
print(chart_list)
head_url = r"https://bot.file.sunderer.games/user_pic"
avatar_url = head_url + r'/' + avatar_url_csv
if avatar_url_csv == None:
avatar_file_name = '玩家提交图/玩家提交图-' + faction + '.png'
avatar_path = os.path.join(file_path,avatar_file_name)
avatar = Image.open(avatar_path).convert("RGBA")
else:
clean_url = re.sub(r'<[^>]+>', '', avatar_url)
try:
Avatar_bit_a = requests.get(clean_url)
except:
Avatar_down = False
if Avatar_bit_a.status_code == 200:
Avatar_down = True
else:
Avatar_down = False
#头像下载成功后Bit化通过PIL打开
if Avatar_down != False:
Avatar_bit_b = Avatar_bit_a.content
Avatar_bit = BytesIO(Avatar_bit_b)
avatar_exf = Image.open(Avatar_bit).convert("RGBA")
avatar = Image.new(avatar_exf.mode, avatar_exf.size)
avatar.putdata(list(avatar_exf.getdata()))
xaa,yaa = avatar.size
print(xaa,yaa)
if (xaa>1600 and yaa<1400 ) or (xaa<1600 and yaa>1400):
#avatar1 = avatar.resize((1600,1400),Image.ANTIALIAS)
if xaa>1600 and yaa<1400 :
rate = 1400/yaa
rx = round(rate*xaa)
avatar1 = avatar.resize((rx,1400),Image.ANTIALIAS)
avatar = await Character_Query().add_rounded_corners(avatar1, 160, (0, 0, 0, 0))
else:
rate = 1600/xaa
ry = round(rate*yaa)
avatar1 = avatar.resize((1600,ry),Image.ANTIALIAS)
avatar = await Character_Query().add_rounded_corners(avatar1, 160, (0, 0, 0, 0))
elif yaa<1400 and xaa<1600:
if yaa < xaa:
rate_base = yaa
else:
rate_base = xaa
rate_resize = 1600/rate_base
resize_x = round(xaa*rate_resize)
resize_y = round(yaa*rate_resize)
avatar1 = avatar.resize((resize_x,resize_y),Image.ANTIALIAS)
avatar = await Character_Query().add_rounded_corners(avatar1, 160, (0, 0, 0, 0))
else:
avatar = await Character_Query().add_rounded_corners(avatar, 160, (0, 0, 0, 0))
else:
#验证api请求失败时使用默认头像
avatar_file_name = '玩家提交图/玩家提交图-' + faction + '.png'
avatar_path = os.path.join(file_path,avatar_file_name)
avatar = Image.open(avatar_path).convert("RGBA")
#请求并加载资源-在线
if Online_flag == True:
Status_light = os.path.join(Resus_file_path,'步兵武器列表/状态/在线圆点.png')
status_text = 'ONLINE NOW ' + formatted_time
BackGround_path = os.path.join(Resus_file_path,'步兵武器列表/状态/在线文字背景.png')
color = (0,252,155)
else:
Status_light = os.path.join(Resus_file_path,'步兵武器列表/状态/离线圆点.png')
status_text = 'OFFLINE At ' + formatted_time
BackGround_path = os.path.join(Resus_file_path,'步兵武器列表/状态/离线文字背景.png')
color = (255,255,255)
light = Image.open(Status_light).convert("RGBA")
light_shadow = Image.open(BackGround_path).convert("RGBA")
#请求并加载资源-头像
#Avatar = Image.open(Avatar_bit).convert("RGBA")
Avatar_shadow = Image.open(Avatar_shadow_path).convert("RGBA")
#请求并加载资源-认证
Authen_Shadow = Image.open(Authen_Shadow_path).convert("RGBA")
#请求并加载资源-军团叠加阴影
Outfit_Shadow = Image.open(Outfit_Shadow_path).convert("RGBA")
icon_num = 0
try:
auth_status = url1['msg']
except:
if Sundy_auth_LX == False:
auth_status = False
else:
auth_status = True
#测试用
#auth_status = True
status = False
Authen_List = []
text_list = []
if Sundy_auth == True or Sundy_auth_LX == True:
auth_status = '已认证'
if auth_status == '已认证':
Authen_player = Image.open(Authen_player_path).convert("RGBA")
Authen_List.append(Authen_player)
icon_num = icon_num + 1
text = '认证玩家'
text_list.append(text)
#请求并加载资源-签到
if status == True:
Authen_Sign = Image.open(Authen_Sign_path).convert("RGBA")
Authen_List.append(Authen_Sign)
icon_num = icon_num + 1
#请求后端后拼接数据
text = '已签到999天'
text_list.append(text)
if Money_status == None:
try:
csv_file_nickname = os.path.join(os.path.dirname(__file__), r"csv/nickname.csv")
nickname_csv = await Character_Query().read_csv_to_list(csv_file_nickname)
chart_list = await Character_Query().find_id(chart_id,nickname_csv)
Money_status = chart_list[4]
except:
Money_status = False
if Money_status == None:
try:
csv_file_nickname = os.path.join(os.path.dirname(__file__), r"csv/nickname.csv")
nickname_csv = await Character_Query().read_csv_to_list(csv_file_nickname)
chart_list = await Character_Query().find_id(chart_id,nickname_csv)
Money_status = chart_list[5]
except:
Money_status = False
#请求并加载资源-爱发电
if Money_status == 'True':
Authen_Sponsor = Image.open(Authen_Sponsor_path).convert("RGBA")
Authen_List.append(Authen_Sponsor)
icon_num = icon_num + 1
#请求后端后拼接数据
text = '赞助者'
text_list.append(text)
#请求并加载资源-代表
if status == True:
Authen_Repr = Image.open(Authen_Repr_path).convert("RGBA")
Authen_List.append(Authen_Repr)
icon_num = icon_num + 1
text = '军团代表'
text_list.append(text)
#请求并加载资源-信息
#引入判断判断当前是否发送有趣数据
exca_path = os.path.join(file_path,'有趣的数据/暂不提供.png')
exciting = Image.open(exca_path).convert("RGBA")
msg_path = os.path.join(file_path,'角色信息/背景.png')
Character_msg = Image.open(msg_path).convert("RGBA")
#请求并加载资源-军团
#引入底图
outfit_background_down = True
try:
outfit_background = url1['data'][0]['outfit_background']
except:
print("outfit_background Filed")
outfit_background = None
if outfit_background == None:
if outfit_flag_csv == None:
outfit_flag_csv = Player_BasicDate['outfitAlias']
head_url = r"https://bot.file.sunderer.games/outfit_pic"
csv_file_outfit = os.path.join(os.path.dirname(__file__), r"csv/outfit.csv")
outfit_csv = await Character_Query().read_csv_to_list(csv_file_outfit)
outfit_pic_list = await Character_Query().find_id(outfit_flag_csv,outfit_csv)
try:
outfit_pic_url = outfit_pic_list[1]
except:
outfit_pic_url = '无匹配军团信息-new.png'
outfit_background = head_url + r'/' + outfit_pic_url
print(outfit_background)
if outfit_background != None:
if Sundy_auth_LX != False:
of_clean_url = re.sub(r'<[^>]+>', '', outfit_background)
of_clean_url = 'https://u.sunderer.games/' + of_clean_url
else:
of_clean_url = outfit_background
try:
outfit_background_bit_a = requests.get(of_clean_url)
if outfit_background_bit_a.status_code != 200:
outfit_background_down = False
except:
outfit_background_down = False
if outfit_background_down != False:
outfit_background_bit_b = outfit_background_bit_a.content
outfit_background_bit = BytesIO(outfit_background_bit_b)
outfit_background_exf = Image.open(outfit_background_bit).convert("RGBA")
outfit_background = Image.new(outfit_background_exf.mode, outfit_background_exf.size)
outfit_background.putdata(list(outfit_background_exf.getdata()))
x_ofg,y_ofg = outfit_background.size
print(x_ofg,y_ofg)
if (x_ofg>1600 and y_ofg<800 ) or (x_ofg<1600 and y_ofg>800):
if x_ofg>1600 and y_ofg<800 :
rate = 1400/y_ofg
rx = round(rate*x_ofg)
outfit_background1 = outfit_background.resize((rx,800),Image.ANTIALIAS)
outfit_background = await Character_Query().outfit_rounded_corners(outfit_background1, 160, (0, 0, 0, 0))
Outfit_img = outfit_background.convert("RGBA")
#print("if (x_ofg>1600 and y_ofg<800 ) or (x_ofg<1600 and y_ofg>800):")
else:
rate = 1600/x_ofg
ry = round(rate*y_ofg)
outfit_background1 = outfit_background.resize((1600,ry),Image.ANTIALIAS)
outfit_background = await Character_Query().outfit_rounded_corners(outfit_background1, 160, (0, 0, 0, 0))
Outfit_img = outfit_background.convert("RGBA")
#print("elserate = 1600/x_ofg")
elif y_ofg<800 and x_ofg<1600:
outfit_background1 = outfit_background.resize((1600,800),Image.ANTIALIAS)
outfit_background = await Character_Query().outfit_rounded_corners(outfit_background1, 160, (0, 0, 0, 0))
Outfit_img = outfit_background.convert("RGBA")
#print("y_ofg<800 and x_ofg<1600:")
else:
outfit_background = await Character_Query().outfit_rounded_corners(outfit_background, 160, (0, 0, 0, 0))
Outfit_img = outfit_background.convert("RGBA")
#print("await Character_Query().outfit")
else:
try:
#/home/bot/QQbot/Charter_Sundy_Query/Output/outfit_pic/MOMH.jpg
YuYun_outfit_background_path = r'/home/bot/QQbot/Charter_Sundy_Query/Output/outfit_pic/'
YuYun_oft_Source = YuYun_outfit_background_path + outfit_pic_url
Outfit_img = Image.open(str(YuYun_oft_Source)).convert("RGBA")
print(YuYun_oft_Source)
except:
YuYun_outfit_background_path = r'/home/bot/QQbot/Charter_Sundy_Query/Output/outfit_pic/'
YuYun_oft_Source = YuYun_outfit_background_path + outfit_pic_url
print('YuYun_oft_Source')
print(YuYun_oft_Source)
OF_BGP_dir = os.path.join(file_path,'军团素材')
read_files = os.listdir(OF_BGP_dir)
flag = random.randint(0, len(read_files)-1)
Im_Address_body = read_files[flag]
Im_Address = os.path.join(OF_BGP_dir,Im_Address_body)
Outfit_img = Image.open(Im_Address).convert("RGBA")
#print("OF_BGP_dir = os.path.join(file_path,'军团素材')")
print(Im_Address)
else:
"""outfit_id = Player_BasicDate['outfitAlias']
try:
head_url = r"https://bot.file.sunderer.games/outfit_pic"
csv_file_outfit = os.path.join(os.path.dirname(__file__), r"csv/outfit.csv")
outfit_csv = await Character_Query().read_csv_to_list(csv_file_outfit)
outfit_pic_list = await Character_Query().find_id(outfit_id,outfit_csv)
outfit_pic_url = outfit_pic_list[1]
outfit_background = head_url + r'/' + outfit_pic_url
print(outfit_background)
except:"""
OF_BGP_dir = os.path.join(file_path,'军团素材')
"""read_files = os.listdir(OF_BGP_dir)
flag = random.randint(0, len(read_files)-1)"""
Im_Address_body = '无匹配军团信息.png'
Im_Address = os.path.join(OF_BGP_dir,Im_Address_body)
Outfit_img = Image.open(Im_Address).convert("RGBA")
#print("read_files = os.listdir(OF_BGP_dir)")
print(Im_Address)
x_ofg,y_ofg = Outfit_img.size
print(x_ofg,y_ofg)
if (x_ofg>1600 and y_ofg<800 ) or (x_ofg<1600 and y_ofg>800):
if x_ofg>1600 and y_ofg<800 :
rate = 1400/y_ofg
rx = round(rate*x_ofg)
outfit_background1 = Outfit_img.resize((rx,800),Image.ANTIALIAS)
outfit_background = await Character_Query().outfit_rounded_corners(outfit_background1, 160, (0, 0, 0, 0))
Outfit_img = outfit_background.convert("RGBA")
#print("if (x_ofg>1600 and y_ofg<800 ) or (x_ofg<1600 and y_ofg>800):")
else:
rate = 1600/x_ofg
ry = round(rate*y_ofg)
outfit_background1 = outfit_background.resize((1600,ry),Image.ANTIALIAS)
outfit_background = await Character_Query().outfit_rounded_corners(outfit_background1, 160, (0, 0, 0, 0))
Outfit_img = outfit_background.convert("RGBA")
#print("elserate = 1600/x_ofg")
elif y_ofg<800 and x_ofg<1600:
outfit_background1 = outfit_background.resize((1600,800),Image.ANTIALIAS)
outfit_background = await Character_Query().outfit_rounded_corners(outfit_background1, 160, (0, 0, 0, 0))
Outfit_img = outfit_background.convert("RGBA")
#print("y_ofg<800 and x_ofg<1600:")
else:
outfit_background1 = Outfit_img
outfit_background = await Character_Query().outfit_rounded_corners(outfit_background1, 160, (0, 0, 0, 0))
Outfit_img = outfit_background.convert("RGBA")
#print("await Character_Query().outfit")
#组合底图
width,height = Overview_MotherBoard.size
MotherBoard = Image.new("RGBA", (width, height), (255, 0, 0, 0))
r,g,b,a=Overview_MotherBoard.split()
MotherBoard.paste(Overview_MotherBoard,(0,0),mask=a)
r,g,b,rlxa=Ralex_Block.split()
r,g,b,thna=Thin_Block.split()
r,g,b,atha=Avatar_shadow.split()
MotherBoard.paste(Avatar_shadow,(0,-1320),mask=atha)
MotherBoard.paste(Thin_Block,(2200-95,700-55),mask=thna)
MotherBoard.paste(Thin_Block,(2200-95,1200-55),mask=thna)
MotherBoard.paste(Ralex_Block,(2200-95,1700-58),mask=rlxa)
MotherBoard.paste(Ralex_Block,(2200-95,2600-60),mask=rlxa)
MotherBoard.paste(Ralex_Block,(200-95,2560-20),mask=rlxa)
#引入贴图层
#等级
r,g,b,a=Rank_banner.split()
MotherBoard.paste(Rank_banner,(2200,740),mask=a)
#阵营
r,g,b,a=Faction_img.split()
MotherBoard.paste(Faction_img,(2200,1240),mask=a)
r,g,b,a=Faction_Mask.split()
MotherBoard.paste(Faction_Mask,(2200,1240),mask=a)
#信息
r,g,b,a=exciting.split()
MotherBoard.paste(exciting,(2200,1740),mask=a)
r,g,b,a=Character_msg.split()
MotherBoard.paste(Character_msg,(200,2640),mask=a)
#军团
r,g,b,a=Outfit_img.split()
MotherBoard.paste(Outfit_img,(2200,2640),mask=a)
r,g,b,a=Outfit_Shadow.split()
MotherBoard.paste(Outfit_Shadow,(2200,2640),mask=a)
#头像
r,g,b,a=avatar.split()
MotherBoard.paste(avatar,(200,740),mask=a)
#先行者
if Daddy_status == 'True':
Authen_Daddy = Image.open(Authen_daddy_path).convert("RGBA")
r,g,b,a = Authen_Daddy.split()
MotherBoard.paste(Authen_Daddy,(1520,1860),mask=a)
#认证信息
r,g,b,a=Authen_Shadow.split()
MotherBoard.paste(Authen_Shadow,(0,1900),mask=a)
Authen_Coo = [(250,2240),(680,2240),(1110,2240),(1540,2240),]
text_coo = [(140,2475),(570,2475),(1000,2475),(1430,2475),]
for i in range(0,icon_num):
img = Authen_List[i]
r,g,b,a=img.split()
MotherBoard.paste(img,(Authen_Coo[i]),mask=a)
#文字
MB_text = ImageDraw.Draw(MotherBoard)
Exhibition_ID = msg['ID'][:3] + '***' + msg['ID'][-2:]
lvpth = (os.path.join(Resus_file_path, gac))
LV_format = ImageFont.truetype(
lvpth,
160,
)
heavy_40 = ImageFont.truetype(
((os.path.join(Resus_file_path,judou_heavy))),
176,
)
heavy_10 = ImageFont.truetype(
((os.path.join(Resus_file_path,judou_heavy))),
66,
)
status_time = ImageFont.truetype(
((os.path.join(Resus_file_path,judou_heavy))),
88,
)
gamename = ImageFont.truetype(
((os.path.join(Resus_file_path,judou_media))),
88,
)
heavy_1 = ImageFont.truetype(
((os.path.join(Resus_file_path,judou_heavy))),
44,
)
if auth_status == '已认证':
Name_format = ImageFont.truetype(
((os.path.join(Resus_file_path, judou_heavy))),
264,
)
Character_format = ImageFont.truetype(
((os.path.join(Resus_file_path, judou_media))),
88,
)
try:
Exhibition_ID = url1['data'][0]['nikename']
except:
Exhibition_ID = nickname
try:
Character_ID = url1['data'][0]['gamename']
except:
Character_ID = msg['ID']
w,h = Name_format.getsize(Exhibition_ID)
MB_text.text(((3800-w),100),str(Exhibition_ID),fill=(255,255,255),font=Name_format)
w,h = Character_format.getsize(Character_ID)
MB_text.text(((3800-w),400),str(Character_ID),fill=(255,255,255),font=Character_format)
w,h = status_time.getsize(status_text)
MB_text.text(((3800-w),550),str(status_text),fill=(255,255,255),font=status_time)
r,g,b,a = light.split()
MotherBoard.paste(light,(3800-w-100,580),mask=a)
else:
Name_format = ImageFont.truetype(
((os.path.join(Resus_file_path, judou_heavy))),
440,
)
w,h = Name_format.getsize(Exhibition_ID)
MB_text.text(((3800-w),80),str(Exhibition_ID),fill=(255,255,255),font=Name_format)
w,h = status_time.getsize(status_text)
MB_text.text(((3800-w),550),str(status_text),fill=(255,255,255),font=status_time)
r,g,b,a = light.split()
MotherBoard.paste(light,(3800-w-100,580),mask=a)
# 获取 UTC+8 时间
current_time = (datetime.now()).replace(tzinfo=None)
# 格式化时间字符串
loc_time = current_time.strftime("%Y年%m月%d日 %H点%M分%S秒")
w_t,h_t = heavy_40.getsize(loc_time)
s,ss = Clock_time_shadow.size
Clock_time_shadow = Clock_time_shadow.resize((w_t+200,h_t+200),Image.ANTIALIAS)
r,g,b,a = Clock_time_shadow.split()
s,ss = Clock_time_shadow.size
s_x = int(3800 - w_t/2 - s/2)
MotherBoard.paste(Clock_time_shadow,(s_x,3600),mask=a)
MB_text.text((3800 - w_t,3700),loc_time,(255,255,255),font=heavy_40)
#认证信息
i = 0
for i in range(0,icon_num):
text = text_list[i]
w,h = heavy_1.getsize(text)
Coox,Cooy = text_coo[i]
MB_text.text(((Coox+((430-w)/2)),Cooy),str(text),fill=(255,255,255),font=heavy_1)
#角色信息
Exhibition_CertCount = Player_BasicDate['availableCertCount']
ServerName = Player_BasicDate['worldName']
if ServerName == 'Soltech':
Exhibition_reg = '亚洲东部'
Exhibition_ser = '索泰克'
elif ServerName == 'Emerald':
Exhibition_reg = '美国东部'
Exhibition_ser = '艾莫若德'
elif ServerName == 'Miller':
Exhibition_reg = '欧洲'
Exhibition_ser = '米勒'
elif ServerName == 'Cobalt':
Exhibition_reg = '欧洲'
Exhibition_ser = '柯伯特'
elif ServerName == 'Connery':
Exhibition_reg = '美国西部'
Exhibition_ser = '康纳利'
Exhibition_kill = Player_BasicDate['kill']
Exhibition_death = Player_BasicDate['death']
Exhibition_kdr = Player_BasicDate['kdr']
playTime= Player_BasicDate['playTime']
minutes, seconds = divmod(playTime, 60)
hours, minutes = divmod(playTime, 60)
days, hours = divmod(hours, 24)
Exhibition_time = f"{days}{hours}{minutes}分"
MB_text.text(((570),3040),str(Exhibition_kill),fill=(255,255,255),font=heavy_10)
MB_text.text(((570),3100),str(Exhibition_death),fill=(255,255,255),font=heavy_10)
MB_text.text(((570),3160),str(Exhibition_kdr),fill=(255,255,255),font=heavy_10)
MB_text.text(((680),3225),str(Exhibition_CertCount),fill=(255,255,255),font=heavy_10)
MB_text.text(((810),3290),str(Exhibition_time),fill=(255,255,255),font=heavy_10)
MB_text.text(((570),2970),str(Exhibition_reg),fill=(233,149,12),font=heavy_10)
w,h = heavy_10.getsize(Exhibition_reg)
MB_text.text(((570+20+w),2970),str(Exhibition_ser),fill=(255,255,255),font=heavy_10)
#等级
MB_text.text((3372,840),str(Exhibition_BattleRank),fill=(0,0,0),font=LV_format)
#军团信息
of_title = ImageFont.truetype(
((os.path.join(Resus_file_path, 'ttf/庞门正道标题体2.0增强版.ttf'))),
140,
)
of_name = ImageFont.truetype(
((os.path.join(Resus_file_path, 'ttf/DreamHanSans-W20.ttc'))),
88,
)
Exhibition_OutfitName = Player_BasicDate['outfitName']
Exhibition_Outfit = Player_BasicDate["outfitAlias"]
try:
w,h = of_name.getsize(Exhibition_OutfitName)
except:
Exhibition_OutfitName = '暂无军团信息'
w,h = of_name.getsize(Exhibition_OutfitName)
if Exhibition_OutfitName != '暂无军团信息' and Exhibition_Outfit == None:
Exhibition_Outfit1 = ' '
print('Exhibition_Outfit1')
print(Exhibition_Outfit1)
MB_text.text((2300,3120),str(Exhibition_Outfit1),fill=(255,255,255),font=of_title)
elif Exhibition_OutfitName == '暂无军团信息' and Exhibition_Outfit == None:
Exhibition_Outfit1 = '未加入军团'
print('Exhibition_Outfit1')
print(Exhibition_Outfit1)
MB_text.text((2300,3120),str(Exhibition_Outfit1),fill=(255,255,255),font=of_title)
else:
print(Exhibition_Outfit)
MB_text.text((2300,3120),str(Exhibition_Outfit),fill=(255,255,255),font=of_title)
if w > 1400 :
of_name = ImageFont.truetype(
((os.path.join(Resus_file_path, 'ttf/DreamHanSans-W20.ttc'))),
66,
)
w,h = of_name.getsize(Exhibition_OutfitName)
if w > 1400 :
of_name = ImageFont.truetype(
((os.path.join(Resus_file_path, 'ttf/DreamHanSans-W20.ttc'))),
44,
)
w,h = of_name.getsize(Exhibition_OutfitName)
MB_text.text((2300,3190),str(Exhibition_OutfitName),fill=(255,255,255),font=of_name)
else:
MB_text.text((2300,3240),str(Exhibition_OutfitName),fill=(255,255,255),font=of_name)
else:
MB_text.text((2300,3260),str(Exhibition_OutfitName),fill=(255,255,255),font=of_name)
MotherBoard = MotherBoard.convert('RGB')
#output = str(msg['ID']) + '_OverView.jpg'
output = f"{msg['ID']}_OverView.jpg"
out_path = Path(Output_dir) / output # 安全构建路径
Out=r'C:\Cq-http\NoneBot\Git_Plugins\QQbot\Charter_Sundy_Query\Output\LeisurelyMotherHunter_OverView.jpg'
# 使用字符串表示保存
MotherBoard.save(str(out_path), "JPEG", quality=70, subsampling=0)
#Out = (os.path.join(Output_dir, output))
#Out=r'C:\Cq-http\NoneBot\Git_Plugins\QQbot\Charter_Sundy_Query\Output\LeisurelyMotherHunter_OverView.jpg'
#MotherBoard.save(Out, "JPEG", quality=70, subsampling=0)
#MotherBoard.show()
return output
None
async def Date_list(slef,msg,date):
#def Date_list(slef,msg,date):
#资源路径
file_path = os.path.join(os.path.dirname(__file__),'Charter_Sundy_Query')
judou_heavy = r"/ttf/judou-ui-cn-heavy.ttf"
judou_heavyit = r"/ttf/judou-ui-cn-heavyitalic.ttf"
judou_blod = r"/ttf/judou-bold.ttc"
judou_media = r"/ttf/judou-medium.ttc"
Output_dir = r"/home/bot/QQbot/Charter_Sundy_Query/Output"
#Output_dir = os.path.join(file_path,'Output')
Content = ImageFont.truetype(
(file_path + judou_media),
88,
)
special_select = ImageFont.truetype(
(file_path + judou_heavyit),
88,
)
Plater_name = ImageFont.truetype(
(file_path + judou_heavy),
308,
)
text_lable = ImageFont.truetype(
(file_path + judou_heavy),
96,
)
Soort = ImageFont.truetype(
(file_path + judou_heavy),
220,
)
Title_weapon = ImageFont.truetype(
(file_path + judou_heavy),
88,
)
No_ver_Name_ttf = ImageFont.truetype(
(file_path + judou_heavy),
308,
)
Player_ID = msg['ID']
Player_Status = msg['Status']
Player_Timeline = msg['TimeLine']
flag_Select = msg['Mode']
num = msg['Num']
Player_BattleData_Infantry = date['battleData']['infantryData']
Player_Infantry_Weaponlist = Player_BattleData_Infantry['normalInfantryData']['weaponStatList']
if flag_Select == 'kill':
#Sorted_Weaponlist = sorted(Player_Infantry_Weaponlist, key=lambda x: x["kill"], reverse=True)
Sorted_Weaponlist = Player_Infantry_Weaponlist
Select_vic = os.path.join(file_path,'步兵武器列表/对比状态/从高到低.png')
Display_banner = '击杀数'
elif flag_Select == 'death':
Sorted_Weaponlist = sorted(Player_Infantry_Weaponlist, key=lambda x: x["death"], reverse=True)
Select_vic = os.path.join(file_path,'步兵武器列表/对比状态/从高到低.png')
Display_banner = '倒地次数'
elif flag_Select == 'kdr':
Sorted_Weaponlist = sorted(Player_Infantry_Weaponlist, key=lambda x: x["kdr"], reverse=True)
Select_vic = os.path.join(file_path,'步兵武器列表/对比状态/从高到低.png')
Display_banner = 'KDR'
elif flag_Select == 'kpm':
Sorted_Weaponlist = sorted(Player_Infantry_Weaponlist, key=lambda x: x["kpm"], reverse=True)
Select_vic = os.path.join(file_path,'步兵武器列表/对比状态/从高到低.png')
Display_banner = 'KPM'
elif flag_Select == 'hpk':
Sorted_Weaponlist = sorted(Player_Infantry_Weaponlist, key=lambda x: x["hpk"], reverse=False)
Select_vic = os.path.join(file_path,'步兵武器列表/对比状态/从低到高.png')
Display_banner = 'HPK'
elif flag_Select == 'ivi':
Sorted_Weaponlist = sorted(Player_Infantry_Weaponlist, key=lambda x: x["ivi"], reverse=False)
Select_vic = os.path.join(file_path,'步兵武器列表/对比状态/从低到高.png')
Display_banner = 'IVI'
elif flag_Select == 'hsr':
Sorted_Weaponlist = sorted(Player_Infantry_Weaponlist, key=lambda x: x["hsr"], reverse=True)
Select_vic = os.path.join(file_path,'步兵武器列表/对比状态/从高到低.png')
Display_banner = 'HSR'
elif flag_Select == 'acc':
Sorted_Weaponlist = sorted(Player_Infantry_Weaponlist, key=lambda x: x["acc"], reverse=True)
Select_vic = os.path.join(file_path,'步兵武器列表/对比状态/从高到低.png')
Display_banner = 'ACC'
elif flag_Select == 'time':
Sorted_Weaponlist = sorted(Player_Infantry_Weaponlist, key=lambda x: x["playTime"], reverse=True)
Select_vic = os.path.join(file_path,'步兵武器列表/对比状态/从高到低.png')
Display_banner = '使用时长'
None
Weaponlist = Sorted_Weaponlist[:num]
Source_list = [Weaponlist[i:i+20] for i in range(0, len(Weaponlist), 20)]
None
#加载复用资源
vic = '/'+ msg['Mode'] + '.png'
if num <= 20 :
h_scr = num
Cycle = 1
else:
h_scr = 20
Cycle = len(Source_list)
head_pic_path = os.path.join(file_path,'步兵武器列表/列表/背景/上部.png')
sin_block_path = os.path.join(file_path,('步兵武器列表/列表/单数/步兵'+vic))
even_block_path = os.path.join(file_path,('步兵武器列表/列表/双数/步兵'+vic))
aurx_block_path = os.path.join(file_path,('步兵武器列表/列表/奥星/步兵'+vic))
logo_path = os.path.join(file_path,('步兵武器列表/列表/标识/决裂者软件.png'))
icon_path = os.path.join(file_path,('download'))
burh = os.path.join(icon_path,'bruh.png')
screen1 = Image.open(sin_block_path).convert("RGBA")
screen2 = Image.open(even_block_path).convert("RGBA")
screen3 = Image.open(aurx_block_path).convert("RGBA")
logo = Image.open(logo_path).convert("RGBA")
Bronze_path = os.path.join(file_path,('步兵武器列表/列表/奥星等级标识/步兵/铜牌.png'))
Silver_path = os.path.join(file_path,('步兵武器列表/列表/奥星等级标识/步兵/银牌.png'))
Gold_path = os.path.join(file_path,('步兵武器列表/列表/奥星等级标识/步兵/金牌.png'))
Aurx_path = os.path.join(file_path,('步兵武器列表/列表/奥星等级标识/步兵/奥星.png'))
Bronze = Image.open(Bronze_path).convert("RGBA")
Silver = Image.open(Silver_path).convert("RGBA")
Gold = Image.open(Gold_path).convert("RGBA")
Aurx = Image.open(Aurx_path).convert("RGBA")
head_pic = Image.open(head_pic_path).convert('RGBA')
for i in range(0,Cycle):
if (num > 20) and (i == Cycle-1) and num%20!=0:
last = len(Source_list[-1])
Datelist_MotherBoard = Image.new("RGBA", (2000, 1740+last*900+400), ( 0 , 124, 212,100))
Datelist_MotherBoard.paste(head_pic, (0, 0))
h_scr = len(Sorted_Weaponlist)%20
else:
Datelist_MotherBoard = Image.new("RGBA", (2000, 1740+h_scr*900+400), ( 0 , 124, 212,100))
Datelist_MotherBoard.paste(head_pic, (0, 0))
for j in range(0,h_scr):
weapon_date = Source_list[i][j]
if (j%2) == 0:
block = screen1
else:
block = screen2
if weapon_date['kill'] >=1160 :
block = screen3
medal = Aurx
elif weapon_date['kill'] >= 160 and weapon_date['kill'] <1160:
medal = Gold
elif weapon_date['kill'] >= 60 and weapon_date['kill'] <160:
medal = Silver
elif weapon_date['kill'] >= 10 and weapon_date['kill'] <60:
medal = Bronze
else:
medal = False
r,g,b,a = block.split()
Datelist_MotherBoard.paste(block,(0,(1740 + 900 +900*(j-1))),a)
imageID = weapon_date['imageId']
kill = weapon_date['kill']
death = weapon_date['death']
hsr = weapon_date['hsr']
hsr = "{:.2f}%".format(hsr * 100)
accuracy = weapon_date['accuracy']
accuracy = "{:.2f}%".format(accuracy * 100)
kdr = "%.2f" % weapon_date['kdr']
kpm = "%.2f" % weapon_date['kpm']
hpk = "%.2f" % weapon_date['hpk']
ivi = "%.2f" % weapon_date['ivi']
name = weapon_date['name']
playTime = int(weapon_date["playTime"])
minutes, seconds = divmod(playTime, 60)
hours, minutes = divmod(minutes, 60)
days, hours = divmod(hours, 24)
dtime = f"{days}{hours}{minutes}{seconds}秒"
if "RAMS .50M" in name :
string_A = ['RAMS .50M']
try:
string_B = ''.join(str(x) for x in splitted[2:])
except:
string_B = ''
elif "脉冲星 C" in name :
string_A = '脉冲星 C'
try:
string_B = ''.join(str(x) for x in splitted[2:])
except:
string_B = ''
elif "轨道打击信号基站" in name :
string_A = ['轨道打击']
string_B = ['信号基站']
else:
try:
splitted = name.split(" ")
string_A = splitted[0] # 获取第一个部分
string_B = ''.join(str(x) for x in splitted[1:]) # 获取第二个部分
except:
string_A = name
string_B = ''
try:
icon = str("/" + imageID + ".png")
except:
if i == 3:
icon = str('/none.png')
else :
icon = str('/wrel.png')
weapon_icondir = str(icon_path + icon)
try:
weapon = Image.open(weapon_icondir).convert("RGBA")
except:
weapon = Image.open(burh).convert("RGBA")
(x, y) = weapon.size
x_s = 400 # 定义缩小后的标准宽度
y_s = int(y * x_s / x) # 基于标准宽度计算缩小后的高度
weapon1 = weapon.resize((x_s, y_s), Image.ANTIALIAS)
weapon_r, weapon_g, weapon_b, weapon_a = weapon.split()
w_kill, h_kill = Content.getsize(str(kill))
w_death, h_death = Content.getsize(str(death))
w_hsr, h_hsr = Content.getsize(str(hsr))
w_accuracy, h_accuracy = Content.getsize(str(accuracy))
w_kdr, h_kdr = Content.getsize(str(kdr))
w_kpm, h_kpm = Content.getsize(str(kpm))
w_hpk, h_hpk = Content.getsize(str(hpk))
w_ivi, h_ivi = Content.getsize(str(ivi))
w_playTime, h_playTime = Content.getsize(str(dtime))
w_string_A, h_string_A = Title_weapon.getsize(str(string_A))
w_string_B, h_string_B = Title_weapon.getsize(str(string_B))
r, g, b, a = weapon1.split()
Datelist_MotherBoard.paste(weapon1, (110, (1535 + 460 + 900 * j)), a)
if medal != False:
r,g,b,a = medal.split()
Datelist_MotherBoard.paste(medal, (0, 900 * j+ 1740),a)
Datelist_MotherBoard_text = ImageDraw.Draw(Datelist_MotherBoard)
if flag_Select == 'kill':
w_kill, h_kill = special_select.getsize(str(kill))
Datelist_MotherBoard_text.text(
((850 + (370 - w_kill) / 2), 333 + 900 * j + 1535),
str(kill),
fill=(255, 87, 23),#255, 87, 23
font=special_select,#heavyit
)
Datelist_MotherBoard_text.text(
((850 + (370 - w_death) / 2), 475 + 900 * j+ 1535),
str(death),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((850 + (370 - w_hsr) / 2), 617 + 900 * j+ 1535),
str(hsr),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((850 + (370 - w_accuracy) / 2), 753 + 900 * j+ 1535),
str(accuracy),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_kdr) / 2), 333 + 900 * j+ 1535),
str(kdr),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_kpm) / 2), 475 + 900 * j+ 1535),
str(kpm),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_hpk) / 2), 617 + 900 * j+ 1535),
str(hpk),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_ivi) / 2), 753 + 900 * j+ 1535),
str(ivi),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1030 + (870 - w_playTime) / 2), 912 + 900 * j + 1535),
str(dtime),
fill=(0, 0, 0),
font=Content,
)
elif flag_Select == 'death':
w_death, h_death = special_select.getsize(str(death))
Datelist_MotherBoard_text.text(
((850 + (370 - w_kill) / 2), 333 + 900 * j + 1535),
str(kill),
fill=(0,0,0),#255, 87, 23
font=Content,#heavyit
)
Datelist_MotherBoard_text.text(
((850 + (370 - w_death) / 2), 475 + 900 * j+ 1535),
str(death),
fill=(255, 87, 23),
font=special_select,
)
Datelist_MotherBoard_text.text(
((850 + (370 - w_hsr) / 2), 617 + 900 * j+ 1535),
str("{:.2f}%".format(hsr * 100)),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((850 + (370 - w_accuracy) / 2), 753 + 900 * j+ 1535),
str("{:.2f}%".format(accuracy * 100)),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_kdr) / 2), 333 + 900 * j+ 1535),
str(kdr),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_kpm) / 2), 475 + 900 * j+ 1535),
str(kpm),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_hpk) / 2), 617 + 900 * j+ 1535),
str(hpk),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_ivi) / 2), 753 + 900 * j+ 1535),
str(ivi),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1030 + (870 - w_playTime) / 2), 912 + 900 * j + 1535),
str(dtime),
fill=(0, 0, 0),
font=Content,
)
elif flag_Select == 'acc':
w_accuracy,h_accuracy = special_select.getsize(str(accuracy))
Datelist_MotherBoard_text.text(
((850 + (370 - w_kill) / 2), 333 + 900 * j + 1535),
str(kill),
fill=(0,0,0),#255, 87, 23
font=Content,#heavyit
)
Datelist_MotherBoard_text.text(
((850 + (370 - w_death) / 2), 475 + 900 * j+ 1535),
str(death),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((850 + (370 - w_hsr) / 2), 617 + 900 * j+ 1535),
str("{:.2f}%".format(hsr * 100)),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((850 + (370 - w_accuracy) / 2), 753 + 900 * j+ 1535),
str("{:.2f}%".format(accuracy * 100)),
fill=(255, 87, 23),
font=special_select,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_kdr) / 2), 333 + 900 * j+ 1535),
str(kdr),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_kpm) / 2), 475 + 900 * j+ 1535),
str(kpm),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_hpk) / 2), 617 + 900 * j+ 1535),
str(hpk),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_ivi) / 2), 753 + 900 * j+ 1535),
str(ivi),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1030 + (870 - w_playTime) / 2), 912 + 900 * j + 1535),
str(dtime),
fill=(0, 0, 0),
font=Content,
)
elif flag_Select == 'hpk':
w_hpk, h_kill = special_select.getsize(str(hpk))
Datelist_MotherBoard_text.text(
((850 + (370 - w_kill) / 2), 333 + 900 * j + 1535),
str(kill),
fill=(0,0,0),#255, 87, 23
font=Content,#heavyit
)
Datelist_MotherBoard_text.text(
((850 + (370 - w_death) / 2), 475 + 900 * j+ 1535),
str(death),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((850 + (370 - w_hsr) / 2), 617 + 900 * j+ 1535),
str("{:.2f}%".format(hsr * 100)),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((850 + (370 - w_accuracy) / 2), 753 + 900 * j+ 1535),
str("{:.2f}%".format(accuracy * 100)),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_kdr) / 2), 333 + 900 * j+ 1535),
str(kdr),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_kpm) / 2), 475 + 900 * j+ 1535),
str(kpm),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_hpk) / 2), 617 + 900 * j+ 1535),
str(hpk),
fill=(255, 87, 23),
font=special_select,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_ivi) / 2), 753 + 900 * j+ 1535),
str(ivi),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1030 + (870 - w_playTime) / 2), 912 + 900 * j + 1535),
str(dtime),
fill=(0, 0, 0),
font=Content,
)
elif flag_Select == 'hsr':
w_hsr, h_hsr = special_select.getsize(str(hsr))
Datelist_MotherBoard_text.text(
((850 + (370 - w_kill) / 2), 333 + 900 * j + 1535),
str(kill),
fill=(0,0,0),#255, 87, 23
font=Content,#heavyit
)
Datelist_MotherBoard_text.text(
((850 + (370 - w_death) / 2), 475 + 900 * j+ 1535),
str(death),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((850 + (370 - w_hsr) / 2), 617 + 900 * j+ 1535),
str("{:.2f}%".format(hsr * 100)),
fill=(255, 87, 23),
font=special_select,
)
Datelist_MotherBoard_text.text(
((850 + (370 - w_accuracy) / 2), 753 + 900 * j+ 1535),
str("{:.2f}%".format(accuracy * 100)),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_kdr) / 2), 333 + 900 * j+ 1535),
str(kdr),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_kpm) / 2), 475 + 900 * j+ 1535),
str(kpm),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_hpk) / 2), 617 + 900 * j+ 1535),
str(hpk),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_ivi) / 2), 753 + 900 * j+ 1535),
str(ivi),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1030 + (870 - w_playTime) / 2), 912 + 900 * j + 1535),
str(dtime),
fill=(0, 0, 0),
font=Content,
)
elif flag_Select == 'ivi':
w_ivi, h_ivi = special_select.getsize(str(ivi))
Datelist_MotherBoard_text.text(
((850 + (370 - w_kill) / 2), 333 + 900 * j + 1535),
str(kill),
fill=(0,0,0),#255, 87, 23
font=Content,#heavyit
)
Datelist_MotherBoard_text.text(
((850 + (370 - w_death) / 2), 475 + 900 * j+ 1535),
str(death),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((850 + (370 - w_hsr) / 2), 617 + 900 * j+ 1535),
str("{:.2f}%".format(hsr * 100)),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((850 + (370 - w_accuracy) / 2), 753 + 900 * j+ 1535),
str("{:.2f}%".format(accuracy * 100)),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_kdr) / 2), 333 + 900 * j+ 1535),
str(kdr),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_kpm) / 2), 475 + 900 * j+ 1535),
str(kpm),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_hpk) / 2), 617 + 900 * j+ 1535),
str(hpk),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_ivi) / 2), 753 + 900 * j+ 1535),
str(ivi),
fill=(255, 87, 23),
font=special_select,
)
Datelist_MotherBoard_text.text(
((1030 + (870 - w_playTime) / 2), 912 + 900 * j + 1535),
str(dtime),
fill=(0, 0, 0),
font=Content,
)
elif flag_Select == 'kdr':
w_kdr, h_kdr = special_select.getsize(str(kdr))
Datelist_MotherBoard_text.text(
((850 + (370 - w_kill) / 2), 333 + 900 * j + 1535),
str(kill),
fill=(0,0,0),#255, 87, 23
font=Content,#heavyit
)
Datelist_MotherBoard_text.text(
((850 + (370 - w_death) / 2), 475 + 900 * j+ 1535),
str(death),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((850 + (370 - w_hsr) / 2), 617 + 900 * j+ 1535),
str("{:.2f}%".format(hsr * 100)),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((850 + (370 - w_accuracy) / 2), 753 + 900 * j+ 1535),
str("{:.2f}%".format(accuracy * 100)),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_kdr) / 2), 333 + 900 * j+ 1535),
str(kdr),
fill=(255, 87, 23),
font=special_select,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_kpm) / 2), 475 + 900 * j+ 1535),
str(kpm),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_hpk) / 2), 617 + 900 * j+ 1535),
str(hpk),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_ivi) / 2), 753 + 900 * j+ 1535),
str(ivi),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1030 + (870 - w_playTime) / 2), 912 + 900 * j + 1535),
str(dtime),
fill=(0, 0, 0),
font=Content,
)
elif flag_Select == 'kpm':
w_kpm, h_kpm = special_select.getsize(str(kpm))
Datelist_MotherBoard_text.text(
((850 + (370 - w_kill) / 2), 333 + 900 * j + 1535),
str(kill),
fill=(0,0,0),#255, 87, 23
font=Content,#heavyit
)
Datelist_MotherBoard_text.text(
((850 + (370 - w_death) / 2), 475 + 900 * j+ 1535),
str(death),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((850 + (370 - w_hsr) / 2), 617 + 900 * j+ 1535),
str("{:.2f}%".format(hsr * 100)),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((850 + (370 - w_accuracy) / 2), 753 + 900 * j+ 1535),
str("{:.2f}%".format(accuracy * 100)),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_kdr) / 2), 333 + 900 * j+ 1535),
str(kdr),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_kpm) / 2), 475 + 900 * j+ 1535),
str(kpm),
fill=(255, 87, 23),
font=special_select,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_hpk) / 2), 617 + 900 * j+ 1535),
str(hpk),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_ivi) / 2), 753 + 900 * j+ 1535),
str(ivi),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1030 + (870 - w_playTime) / 2), 912 + 900 * j + 1535),
str(dtime),
fill=(0, 0, 0),
font=Content,
)
elif flag_Select == 'time':
w_playTime, h_kill = special_select.getsize(str(dtime))
Datelist_MotherBoard_text.text(
((850 + (370 - w_kill) / 2), 333 + 900 * j + 1535),
str(kill),
fill=(0,0,0),#255, 87, 23
font=Content,#heavyit
)
Datelist_MotherBoard_text.text(
((850 + (370 - w_death) / 2), 475 + 900 * j+ 1535),
str(death),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((850 + (370 - w_hsr) / 2), 617 + 900 * j+ 1535),
str("{:.2f}%".format(hsr * 100)),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((850 + (370 - w_accuracy) / 2), 753 + 900 * j+ 1535),
str("{:.2f}%".format(accuracy * 100)),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_kdr) / 2), 333 + 900 * j+ 1535),
str(kdr),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_kpm) / 2), 475 + 900 * j+ 1535),
str(kpm),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_hpk) / 2), 617 + 900 * j+ 1535),
str(hpk),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1540 + (370 - w_ivi) / 2), 753 + 900 * j+ 1535),
str(ivi),
fill=(0, 0, 0),
font=Content,
)
Datelist_MotherBoard_text.text(
((1030 + (870 - w_playTime) / 2), 912 + 900 * j + 1535),
str(dtime),
fill=(255, 87, 23),
font=special_select,
)
if string_B == '':
Datelist_MotherBoard_text.text(
((65 + (465 - w_string_A) / 2), 830 + 900 * j+ 1535+44),
str(string_A),
fill=(255,255,255),
font=Title_weapon,
)
else:
Datelist_MotherBoard_text.text(
((65 + (465 - w_string_A) / 2), 830 + 900 * j+ 1535),
str(string_A),
fill=(255,255,255),
font=Title_weapon,
)
# 字行距调整
if w_string_B >=465:
Title_weapon_med = ImageFont.truetype(
(file_path + judou_heavy),
66,
)
w_string_B, h_string_B = Title_weapon_med.getsize(str(string_B))
if w_string_B >=465:
Title_weapon_sma = ImageFont.truetype(
(file_path + judou_heavy),
44,
)
w_string_B, h_string_B = Title_weapon_sma.getsize(str(string_B))
Datelist_MotherBoard_text.text(
((65 + (465 - w_string_B) / 2), 920 + 900 * j+ 1535),
str(string_B),
fill=(255,255,255),
font=Title_weapon_sma,
)
else:
Datelist_MotherBoard_text.text(
((65 + (465 - w_string_B) / 2), 920 + 900 * j+ 1535),
str(string_B),
fill=(255,255,255),
font=Title_weapon_med,
)
else:
Datelist_MotherBoard_text.text(
((65 + (465 - w_string_B) / 2), 920 + 900 * j+ 1535),
str(string_B),
fill=(255,255,255),
font=Title_weapon,
)
Sort_num = j + 1 + ( i * 20)
Datelist_MotherBoard_text.text(
(20, 900 * j+ 1535 + 135),
str(Sort_num),
fill=(255,255,255),
font=Soort,
)
Select_v = Image.open(Select_vic).convert('RGBA')
r,g,b,a = Select_v.split()
Datelist_MotherBoard.paste(Select_v, (50, 720),a)
w_sel, h_sel = Content.getsize(str(Display_banner))
Datelist_MotherBoard_text.text(
(((2000-w_sel)/2),725),
str(Display_banner),
fill=(255,255,255),
font=Content,
)
#在线状态
if Player_Status == True:
Status_light = os.path.join(file_path,'步兵武器列表/状态/在线圆点.png')
status_text = 'ONLINE NOW ' + Player_Timeline
BackGround_path = os.path.join(file_path,'步兵武器列表/状态/在线文字背景.png')
color = (0,252,155)
else:
Status_light = os.path.join(file_path,'步兵武器列表/状态/离线圆点.png')
status_text = 'OFFLINE ON ' + Player_Timeline
BackGround_path = os.path.join(file_path,'步兵武器列表/状态/离线文字背景.png')
color = (255,255,255)
light = Image.open(Status_light).convert("RGBA")
BackGround = Image.open(BackGround_path).convert("RGBA")
w_status,h_status = text_lable.getsize(str(status_text))
r,g,b,a = light.split()
Datelist_MotherBoard.paste(light, ((2000-180-w_status), 620),a)
r,g,b,a = BackGround.split()
w_bg,h_bg = text_lable.getsize(str(status_text))
Datelist_MotherBoard.paste(BackGround, ((1300-w_bg-70), 570),a)
Datelist_MotherBoard_text.text(
((2000-w_status-100),590),
str(status_text),
fill=(color),
font=text_lable,
)
file_path_csv = os.path.join(os.path.dirname(__file__), r"csv/character.csv")
auth_dict = await Character_Query().csv_Verified_User(file_path_csv)#异步
if Player_ID in auth_dict.values():
Sundy_auth = True
matching_keys = [key for key, value in auth_dict.items() if value == Player_ID]
print(matching_keys)
ver_chart_id = int(matching_keys[0])
csv_file_nickname = os.path.join(os.path.dirname(__file__), r"csv/nickname.csv")
nickname_csv = await Character_Query().read_csv_to_list(csv_file_nickname)
print(nickname_csv)
chart_list = await Character_Query().find_id(ver_chart_id,nickname_csv)
ver_charactername = chart_list[1]
else:
Sundy_auth = False
ver_file_path = os.path.dirname(os.path.abspath(__file__))
ver_Source_dir = str(ver_file_path + "/Vechile_query/Source")
if Sundy_auth == False :
Player_ID_1 = Player_ID[0:3] + "**" +Player_ID[-2:]
w_tit,h_tit = No_ver_Name_ttf.getsize(Player_ID)
if w_tit + 200 > 2000:
No_ver_Name_ttf = ImageFont.truetype(
(file_path + judou_heavy),
280,
)
w_tit,h_tit = No_ver_Name_ttf.getsize(Player_ID_1)
if w_tit + 200 > 2000:
No_ver_Name_ttf = ImageFont.truetype(
(file_path + judou_heavy),
240,
)
w_tit,h_tit = No_ver_Name_ttf.getsize(Player_ID_1)
if w_tit + 200 > 2000:
No_ver_Name_ttf = ImageFont.truetype(
(file_path + judou_heavy),
240,
)
w_tit,h_tit = No_ver_Name_ttf.getsize(Player_ID_1)
x_No_ver_Name = 2000 - w_tit -100
Datelist_MotherBoard_text.text(
(x_No_ver_Name, 250),
Player_ID_1,
fill=(255,255,255),
font=No_ver_Name_ttf
)
else:
Ver_NickName_ttf = ImageFont.truetype(
(file_path + judou_heavy),
264,
)
Ver_ChartName_ttf = ImageFont.truetype(
(file_path + judou_heavy),
88,
)
w_tit,h_tit = Ver_NickName_ttf.getsize(ver_charactername)
x_ver_nickName = 2000 - w_tit -100
Datelist_MotherBoard_text.text(
(x_ver_nickName, 120),
ver_charactername,
fill=(255,255,255),
font=Ver_NickName_ttf
)
w_tit,h_tit = Ver_ChartName_ttf.getsize(Player_ID)
x_ver_nickName = 2000 - w_tit -100
Datelist_MotherBoard_text.text(
(x_ver_nickName, 410),
Player_ID,
fill=(255,255,255),
font=Ver_ChartName_ttf
)
r,g,b,a = logo.split()
w,h = Datelist_MotherBoard.size
w1,h2 = logo.size
Datelist_MotherBoard.paste(logo,(((2000-w1)//2),(h-350)),a)
#图片生成时间
time_now = datetime.now().strftime("%Y年%m月%d日 %H时%M分%S秒")
w_time,h_time = text_lable.getsize(time_now)
Datelist_MotherBoard_text.text(
(((2000-w_time)/2),(h-150)),
str(time_now),
fill=(255,255,255),
font=text_lable,
)
output = str(Output_dir + '/' + str(Player_ID) +'(' + str(i) + ').jpg')
Datelist_MotherBoard = Datelist_MotherBoard.convert("RGB")
Datelist_MotherBoard.save(output, "JPEG", quality=45, subsampling=2)
cycle = len(Source_list)
return cycle
# 获取请求时的IP
async def get_request_ip(self):
#def get_request_ip(self):
# 使用httpbin的IP接口来获取请求时的IP
response = requests.get("http://httpbin.org/ip")
if response.status_code == 200:
ip_data = response.json()
return ip_data['origin']
else:
return None
# 生成MD5加密的key
async def generate_key(self,ip):
#def generate_key(self,ip):
# 固定字符串123123与请求时的IP拼接
raw_string = f"123123{ip}"
# 对拼接的字符串进行MD5加密
return hashlib.md5(raw_string.encode('utf-8')).hexdigest()
# 请求API
async def request_api(self,name):
#def request_api(self,name):
# 获取请求时的IP
ip = await Character_Query().get_request_ip()
if ip is None:
print("无法获取请求时的IP地址")
return
print(f"请求时的IP地址: {ip}")
# 生成key
key = await Character_Query().generate_key(ip)
print(f"生成的key: {key}")
# API的url
url = "https://u.sunderer.games/index.php/botapi/UserApi/isUserAuth"
# 请求的body
data = {
'gamename':'test',
'key': key
}
data["gamename"] = name
# 发送POST请求
response = requests.post(url, data=data)
# 打印返回结果
print(response.text)
return(response.text)
async def add_rounded_corners(self,image, radius, color):
#def add_rounded_corners(self,image, radius, color):
# 创建一个与原始图像大小相同的掩膜图像
mask = Image.new("L", (1600,1400), 0)
draw = ImageDraw.Draw(mask)
image = image
# 获取原始图像的宽度和高度
width, height = image.size
# 计算裁剪框的左上角和右下角坐标
left = (width - 1600) / 2
top = (height - 1400) / 2
right = (width + 1600) / 2
bottom = (height + 1400) / 2
# 使用crop()方法裁剪图像
cropped_image = image.crop((left, top, right, bottom))
# 在掩膜图像上绘制一个带有圆角的矩形
draw.pieslice([0, 0, radius * 2, radius * 2], 180, 270, fill=255)
draw.pieslice([cropped_image.width - 2 * radius, 0, cropped_image.width, 2 * radius], 270, 360, fill=255)
draw.pieslice([0, cropped_image.height - 2 * radius, 2 * radius, cropped_image.height], 90, 180, fill=255)
draw.pieslice([cropped_image.width - 2 * radius, cropped_image.height - 2 * radius, cropped_image.width, cropped_image.height], 0, 90, fill=255)
draw.rectangle([radius, 0, cropped_image.width - radius, cropped_image.height], fill=255)
draw.rectangle([0, radius, cropped_image.width, cropped_image.height - radius], fill=255)
# 创建一个新图像,并将原始图像放置在上面
result = Image.new("RGBA", cropped_image.size, (0, 0, 0, 0))
result.paste(cropped_image, (0, 0), mask)
return result
async def outfit_rounded_corners(self,image, radius, color):
#def outfit_rounded_corners(self,image, radius, color):
# 创建一个与原始图像大小相同的掩膜图像
mask = Image.new("L", (1600,800), 0)
draw = ImageDraw.Draw(mask)
image = image
# 获取原始图像的宽度和高度
width, height = image.size
# 计算裁剪框的左上角和右下角坐标
left = (width - 1600) / 2
top = (height - 800) / 2
right = (width + 1600) / 2
bottom = (height + 800) / 2
# 使用crop()方法裁剪图像
cropped_image = image.crop((left, top, right, bottom))
# 在掩膜图像上绘制一个带有圆角的矩形
draw.pieslice([0, 0, radius * 2, radius * 2], 180, 270, fill=255)
draw.pieslice([cropped_image.width - 2 * radius, 0, cropped_image.width, 2 * radius], 270, 360, fill=255)
draw.pieslice([0, cropped_image.height - 2 * radius, 2 * radius, cropped_image.height], 90, 180, fill=255)
draw.pieslice([cropped_image.width - 2 * radius, cropped_image.height - 2 * radius, cropped_image.width, cropped_image.height], 0, 90, fill=255)
draw.rectangle([radius, 0, cropped_image.width - radius, cropped_image.height], fill=255)
draw.rectangle([0, radius, cropped_image.width, cropped_image.height - radius], fill=255)
# 创建一个新图像,并将原始图像放置在上面
result = Image.new("RGBA", cropped_image.size, (0, 0, 0, 0))
result.paste(cropped_image, (0, 0), mask)
return result
async def csv_Verified_User(self,file_path):
#def csv_Verified_User(self,file_path):
csv_dict = {}
try:
with open(file_path, 'r', newline='', encoding='utf-8') as csvfile:
# 创建CSV阅读器对象
csv_reader = csv.reader(csvfile)
# 跳过标题行(如果不需要标题可删除此部分)
headers = next(csv_reader)
# 逐行处理数据
for row_num, row in enumerate(csv_reader, 1):
csv_dict[row[0]] = row[1]
return csv_dict
except FileNotFoundError:
print(f"错误:文件 {file_path} 不存在")
except Exception as e:
print(f"读取文件时出错: {str(e)}")
async def read_csv_to_list(self,csv_file):
#def read_csv_to_list(self,csv_file):
"""
将CSV文件读取为列表
参数:
csv_file (str): CSV文件路径
返回:
list: 包含所有行数据的列表,每行是一个子列表
"""
data_list = []
try:
with open(csv_file, 'r', encoding='utf-8') as file:
# 创建CSV阅读器
csv_reader = csv.reader(file)
# 跳过标题行(可选)
next(csv_reader) # 去掉这行如果不需要跳过标题
# 逐行读取
for row in csv_reader:
data_list.append(row)
return data_list
except FileNotFoundError:
print(f"错误: 文件 {csv_file} 不存在")
return []
except Exception as e:
print(f"读取CSV时出错111: {str(e)}")
return []
async def find_id(self,id,data_list):
#def find_id(self,id,data_list):
#print(data_list)
id = str(id)
#print(id)
result = None
for row in data_list:
#print(row)
if row[0] == id:
result = row
else:
continue
return result
"""msg = { 'ID': 'PS2CPCxMicroYF',
'Num':40,
'Mode':'kill',
"Status":True,
"TimeLine":'2024-04-24 20:41',
}
date = await Character_Query().Character_date('PS2CPCxMicroYF')
#strat = await Character_Query().Date_list(msg,date)
strat = await Character_Query().Date_OverView(msg,date)"""