This repository has been archived by the owner on Sep 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
module.py
73 lines (57 loc) · 2.01 KB
/
module.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import requests
import json
import base64
import boto3
import os
file_path = "json/command_usagetime.json"
s3 = boto3.resource(
's3',
region_name='ap-northeast-1',
aws_access_key_id=os.environ["AWS_S3_ACCESS_KEY_ID"],
aws_secret_access_key=os.environ["AWS_S3_SECRET_ACCESS_KEY"]
)
# mojang_api_url class
class mojang_api_url():
def __init__(self, mciduuid):
self.mciduuid = mciduuid
def mcid_to_uuid(self):
if len(self.mciduuid) > 16:
return self.mciduuid
else:
UserUrl = f"https://api.mojang.com/users/profiles/minecraft/{self.mciduuid}"
response = requests.get(UserUrl)
UserData = response.json()
UUID = UserData['id']
return UUID
def data_profile(self):
ProfileUrl = f"https://sessionserver.mojang.com/session/minecraft/profile/{self.mciduuid}"
response = requests.get(ProfileUrl)
ProfileData = response.json()
DecodeProfileData = base64.b64decode(ProfileData['properties'][0]['value']).decode()
ReDecodeProfileData = json.loads(DecodeProfileData)
return ReDecodeProfileData
def data_history(self):
HistoryUrl = f"https://api.mojang.com/user/profiles/{self.mciduuid}/names"
response = requests.get(HistoryUrl)
HistoryData = response.json()
return HistoryData
# language class
class language():
def load_language_english():
json_open = open("json/language/en.json", "r")
json_load = json.load(json_open)
return json_load
# usagetime class
class usagetime():
def upload_usagetime():
s3.Bucket(os.environ["AWS_S3_BUCKET_NAME"]).upload_file(file_path, "command_usagetime.json")
def load_usagetime():
with open(file_path, "r") as f:
data = json.load(f)
return data
def write_usagetime(n):
with open(file_path, "r") as f:
data = json.load(f)
data[n] = data[n] + 1
with open(file_path, "w") as f:
json.dump(data, f)