-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassist_Functions.py
173 lines (148 loc) · 4.88 KB
/
assist_Functions.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
import enka
import asyncio
import string
# ---------------------------------------------------- #
# Afif UID: 607566990
# Pheu UID: 701473745
# Andrew UID: 602115277
# Edison UID: 602114999
# Ichigo UID: 601179564
# Okami UID: 600383198
# Sora UID: 606380789
# ---------------------------------------------------- #
"""
This function returns a string of basic information
of the requested user
Parameters:
uid (int) The players UID
Returns:
String
"""
async def userInfo(uid) -> str:
await connection_Test(uid)
async with enka.EnkaAPI() as api:
response = await api.fetch_showcase(uid)
characters = [character.name for character in response.characters]
if len(characters) == 0:
return "ERROR"
info = f"""
=== Player Info ===
Nickname: {response.player.nickname}
Level: {response.player.level}
Signature: {response.player.signature}
Achievements: {response.player.achievements}
Abyss Floor: {response.player.abyss_floor}
Characters: {characters}
===================
"""
return info
"""
This function returns the players
in-game name
Parameters:
uid (int) The players UID
Returns:
string
"""
async def userName(uid) -> None:
await connection_Test(uid)
async with enka.EnkaAPI() as api:
response = await api.fetch_showcase(uid)
return response.player.nickname
"""
This function returns character
information is a general basis
Parameters:
uid (int) The players UID
name (string) The character to be viewed
Returns:
None
"""
async def characterInfo(uid, name):
await connection_Test(uid)
async with enka.EnkaAPI() as api:
response = await api.fetch_showcase(uid)
for character in response.characters:
if character.name.lower() == name.lower():
return character
return None
"""
This function returns information
of each artifact from the specified
character that's requested
Parameters:
uid (int) The players UID
name (string) The character to be viewed
Returns:
combined_info (dict) A dictionary of all the artifact information
"""
async def artifact_Extractor(uid, name):
await connection_Test(uid)
async with enka.EnkaAPI() as api:
response = await api.fetch_showcase(uid)
for characters in response.characters:
if(characters.name.lower() == name.lower()):
artifactName = {characters.name: {artifact.name.replace("'", "") for artifact in characters.artifacts}}
artifactMainStat = {f"{artifact.name}": [artifact.main_stat.name, artifact.main_stat.formatted_value] for artifact in characters.artifacts} #Main Stats
artifactSubStat = {f"{artifact.name} ss": [(substat.name, substat.formatted_value) for substat in artifact.sub_stats] for artifact in characters.artifacts} #Sub Stats
combined_info = {**artifactName, **artifactMainStat, **artifactSubStat}
return combined_info
"""
This function returns the main
stats of a artifact in a tuple
Parameters:
uid (int) The players UID
name (string) The character to be viewed
Returns:
List object
"""
async def artifact_MainStat(uid, name):
await connection_Test(uid)
async with enka.EnkaAPI() as api:
response = await api.fetch_showcase(uid)
for characters in response.characters:
if(characters.name.lower() == name.lower()):
aMS = [(artifact.main_stat.name, artifact.main_stat.formatted_value) for artifact in characters.artifacts] #Main Stats
return aMS
"""
This function returns information
of the weapon from the specified
character that's requested
Parameters:
uid (int) The players UID
name (string) The character to be viewed
Returns:
combined_info (DoL) A dictionary of List that stores information on the weapon
"""
async def weapon_Extractor(uid, name):
await connection_Test(uid)
weaponInfo = {}
async with enka.EnkaAPI() as api:
response = await api.fetch_showcase(uid)
for character in response.characters:
if(character.name.lower() == name.lower()):
weapon = character.weapon
weaponInfo = {weapon.name: [weapon.level, weapon.rarity, weapon.refinement]}
return weaponInfo
"""
This function makes sure that
EnkaNetwork is up and running
in-order to retrieve data
Parameters:
uid (int) The players UID
Returns:
combined_info (DoL) A dictionary of List that stores information on the weapon
"""
async def connection_Test(uid) -> None:
async with enka.EnkaAPI() as api:
try:
response = await api.fetch_showcase(uid)
except enka.exceptions.PlayerDoesNotExistError:
return print("Player does not exist.")
except enka.exceptions.GameMaintenanceError:
return print("Game is in maintenance.")
# ==========================
# How to test code Below
# test = asyncio.run(weapon_Extractor(602115277, 'Furina'))
# print(test)
# ==========================