-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebhook.py
287 lines (250 loc) · 9.38 KB
/
webhook.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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
import main
import requests
import user
import json
# Define Dracula color palette
dracula_colors = {
"purple": 0xBD93F9,
"pink": 0xFF79C6,
"cyan": 0x8BE9FD,
"green": 0x50FA7B,
"yellow": 0xF1FA8C,
"orange": 0xFFB86C,
}
def topLogin(data: list) -> None:
endpoint = main.webhook_discord_url
rewards: user.Rewards = data[0]
login: user.Login = data[1]
bonus: user.Bonus | str = data[2]
with open("login.json", "r", encoding="utf-8") as f:
data22 = json.load(f)
name1 = data22["cache"]["replaced"]["userGame"][0]["name"]
fpids1 = data22["cache"]["replaced"]["userGame"][0]["friendCode"]
messageBonus = ""
nl = "\n"
if bonus != "No Bonus":
messageBonus += f"__{bonus.message}__{nl}```{nl.join(bonus.items)}```"
if bonus.bonus_name:
messageBonus += f"{nl}__{bonus.bonus_name}__{nl}{bonus.bonus_detail}{nl}```{nl.join(bonus.bonus_camp_items)}```"
messageBonus += "\n"
jsonData = {
"content": None,
"embeds": [
{
"title": f"Fate/Grand Order Daily Login Manager - {main.fate_region}",
"description": f"Login success.\n\n{messageBonus}",
"color": dracula_colors["pink"],
"fields": [
{"name": "Master", "value": f"{name1}", "inline": True},
{"name": "ID", "value": f"{fpids1}", "inline": True},
{"name": "Level", "value": f"{rewards.level}", "inline": True},
{
"name": "Summon Ticket",
"value": f"{rewards.ticket}",
"inline": True,
},
{
"name": "Saint Quartz",
"value": f"{rewards.stone}",
"inline": True,
},
{
"name": "Saint Quartz Fragment",
"value": f"{rewards.sqf01}",
"inline": True,
},
{
"name": "Fruit",
"value": f"Golden: {rewards.goldenfruit}\nSilver: {rewards.silverfruit}\nBronze: {rewards.bronzefruit}\nBronzed Cobalt: {rewards.bluebronzefruit}",
"inline": True,
},
{
"name": "Bronze Sapling",
"value": f"{rewards.bluebronzesapling}",
"inline": True,
},
{
"name": "Consecutive / Total Logins",
"value": f"{login.login_days} days / {login.total_days} days",
"inline": True,
},
{
"name": "Pure Prism",
"value": f"{rewards.pureprism}",
"inline": True,
},
{"name": "FP", "value": f"{login.total_fp}", "inline": True},
{"name": "Gained FP", "value": f"+{login.add_fp}", "inline": True},
{
"name": "Current AP",
"value": f"{login.remaining_ap}",
"inline": True,
},
{
"name": "Holy Grail",
"value": f"{rewards.holygrail}",
"inline": True,
},
],
"thumbnail": {
"url": "https://static.atlasacademy.io/JP/External/FGOPoker/314.png"
},
}
],
"attachments": [],
}
headers = {"Content-Type": "application/json"}
try:
response = requests.post(endpoint, json=jsonData, headers=headers)
response.raise_for_status()
print("topLogin response:", response.status_code, response.text)
except requests.exceptions.RequestException as e:
print("Request failed:", e)
def shop(item: str, quantity: int) -> None:
endpoint = main.webhook_discord_url
jsonData = {
"content": None,
"embeds": [
{
"title": f"Fate/Grand Order Shop Manager - {main.fate_region}",
"description": "",
"color": dracula_colors["cyan"],
"fields": [
{
"name": "Da Vinci's Workshop",
"value": f"Used {40 * quantity} AP on x{quantity} {item}",
"inline": False,
}
],
"thumbnail": {
"url": "https://www.fate-go.jp/manga_fgo3/images/commnet_chara10.png"
},
}
],
"attachments": [],
}
headers = {"Content-Type": "application/json"}
try:
response = requests.post(endpoint, json=jsonData, headers=headers)
response.raise_for_status()
print("shop response:", response.status_code, response.text)
except requests.exceptions.RequestException as e:
print("Request failed:", e)
def drawFP(servants, missions) -> None:
endpoint = main.webhook_discord_url
message_mission = ""
message_servant = ""
if servants:
servants_atlas = requests.get(
"https://api.atlasacademy.io/export/NA/basic_svt.json"
).json()
svt_dict = {svt["id"]: svt for svt in servants_atlas}
for servant in servants:
objectId = servant.objectId
if objectId in svt_dict:
svt = svt_dict[objectId]
message_servant += f"`{svt['name']}` "
if missions:
for mission in missions:
message_mission += (
f"__{mission.message}__\n{mission.progressTo}/{mission.condition}\n"
)
jsonData = {
"content": None,
"embeds": [
{
"title": f"Fate/Grand Order FP Summon Manager - {main.fate_region}",
"description": message_mission,
"color": dracula_colors["green"],
"fields": [
{
"name": "FP Gacha results",
"value": message_servant,
"inline": False,
}
],
"thumbnail": {
"url": "https://www.fate-go.jp/manga_fgo3/images/commnet_chara04.png"
},
}
],
"attachments": [],
}
headers = {"Content-Type": "application/json"}
try:
response = requests.post(endpoint, json=jsonData, headers=headers)
response.raise_for_status()
print("drawFP response:", response.status_code, response.text)
except requests.exceptions.RequestException as e:
print("Request failed:", e)
def LTO_Gacha(servants) -> None:
endpoint = main.webhook_discord_url
message_servant = ""
if servants:
servants_atlas = requests.get(
"https://api.atlasacademy.io/export/NA/basic_svt_lang_en.json"
).json()
svt_dict = {svt["id"]: svt for svt in servants_atlas}
for servant in servants:
objectId = servant.objectId
if objectId in svt_dict:
svt = svt_dict[objectId]
message_servant += f"`{svt['name']}` "
jsonData = {
"content": None,
"embeds": [
{
"title": "FP Summoning - " + main.fate_region,
"description": "FP Summoning Gacha",
"color": dracula_colors["yellow"],
"fields": [
{
"name": "Limited Cards",
"value": message_servant,
"inline": False,
}
],
"thumbnail": {
"url": "https://www.fate-go.jp/manga_fgo/images/commnet_chara02_rv.png"
},
}
],
"attachments": [],
}
headers = {"Content-Type": "application/json"}
try:
response = requests.post(endpoint, json=jsonData, headers=headers)
response.raise_for_status()
print("LTO_Gacha response:", response.status_code, response.text)
except requests.exceptions.RequestException as e:
print("Request failed:", e)
def Present(name: str, namegift: str, object_id_count: int) -> None:
endpoint = main.webhook_discord_url
jsonData = {
"content": None,
"embeds": [
{
"title": "Present Box",
"description": "",
"color": dracula_colors["purple"],
"fields": [
{
"name": name,
"value": f"{namegift} x{object_id_count}",
"inline": False,
}
],
"thumbnail": {
"url": "https://www.fate-go.jp/manga_fgo2/images/commnet_chara06.png"
},
}
],
"attachments": [],
}
headers = {"Content-Type": "application/json"}
try:
response = requests.post(endpoint, json=jsonData, headers=headers)
response.raise_for_status()
print("Present response:", response.status_code, response.text)
except requests.exceptions.RequestException as e:
print("Request failed:", e)