forked from DNNDHH/F-D-L
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebhook.py
268 lines (228 loc) · 8.59 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
import main
import requests
import user
import json
def topLogin(data: list) -> None:
endpoint = main.webhook_discord_url
rewards: user.Rewards = data[0]
login: user.Login = data[1]
bonus: user.Bonus or 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 is not None:
messageBonus += f"{nl}__{bonus.bonus_name}__{nl}{bonus.bonus_detail}{nl}```{nl.join(bonus.bonus_camp_items)}```"
messageBonus += "\n"
jsonData = {
"content": None,
"embeds": [
{
"title": "FGO登录系统 - " + main.fate_region,
"description": f"登录成功。列出角色信息.\n\n{messageBonus}",
"color": 563455,
"fields": [
{"name": "御主名", "value": f"{name1}", "inline": True},
{"name": "朋友ID", "value": f"{fpids1}", "inline": True},
{"name": "等级", "value": f"{rewards.level}", "inline": True},
{"name": "呼符", "value": f"{rewards.ticket}", "inline": True},
{"name": "圣晶石", "value": f"{rewards.stone}", "inline": True},
{"name": "圣晶片", "value": f"{rewards.sqf01}", "inline": True},
{
"name": "金苹果",
"value": f"{rewards.goldenfruit}",
"inline": True,
},
{
"name": "银苹果",
"value": f"{rewards.silverfruit}",
"inline": True,
},
{
"name": "铜苹果",
"value": f"{rewards.bronzefruit}",
"inline": True,
},
{
"name": "蓝苹果",
"value": f"{rewards.bluebronzefruit}",
"inline": True,
},
{
"name": "蓝苹果树苗",
"value": f"{rewards.bluebronzesapling}",
"inline": True,
},
{
"name": "连续登录天数",
"value": f"{login.login_days}",
"inline": True,
},
{
"name": "累计登录天数",
"value": f"{login.total_days}",
"inline": True,
},
{
"name": "白方块",
"value": f"{rewards.pureprism}",
"inline": True,
},
{"name": "友情点", "value": f"{login.total_fp}", "inline": True},
{
"name": "今天 获得的友情点",
"value": f"+{login.add_fp}",
"inline": True,
},
{
"name": "当前AP",
"value": f"{login.remaining_ap}",
"inline": True,
},
{"name": "圣杯", "value": f"{rewards.holygrail}", "inline": True},
],
"thumbnail": {
"url": "https://www.fate-go.jp/manga_fgo/images/commnet_chara01.png"
},
}
],
"attachments": [],
}
headers = {"Content-Type": "application/json"}
requests.post(endpoint, json=jsonData, headers=headers)
def shop(item: str, quantity: str) -> None:
endpoint = main.webhook_discord_url
jsonData = {
"content": None,
"embeds": [
{
"title": "FGO自动购物系统 - " + main.fate_region,
"description": "购买成功.",
"color": 5814783,
"fields": [
{
"name": "商店",
"value": f"消费 {40 * quantity}Ap 购买 {quantity}x {item}",
"inline": False,
}
],
"thumbnail": {
"url": "https://www.fate-go.jp/manga_fgo2/images/commnet_chara10.png"
},
}
],
"attachments": [],
}
headers = {"Content-Type": "application/json"}
requests.post(endpoint, json=jsonData, headers=headers)
def drawFP(servants, missions) -> None:
endpoint = main.webhook_discord_url
message_mission = ""
message_servant = ""
if len(servants) > 0:
servants_atlas = requests.get(
"https://api.atlasacademy.io/export/JP/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']}` "
else:
continue
if len(missions) > 0:
for mission in missions:
message_mission += (
f"__{mission.message}__\n{mission.progressTo}/{mission.condition}\n"
)
jsonData = {
"content": None,
"embeds": [
{
"title": "FGO自动抽卡系统 - " + main.fate_region,
"description": f"完成当日免费友情抽卡。列出抽卡结果.\n\n{message_mission}",
"color": 5750876,
"fields": [
{
"name": "友情卡池",
"value": f"{message_servant}",
"inline": False,
}
],
"thumbnail": {
"url": "https://www.fate-go.jp/manga_fgo/images/commnet_chara02_rv.png"
},
}
],
"attachments": [],
}
headers = {"Content-Type": "application/json"}
requests.post(endpoint, json=jsonData, headers=headers)
def LTO_Gacha(servants) -> None:
endpoint = main.webhook_discord_url
message_servant = ""
if len(servants) > 0:
servants_atlas = requests.get(
"https://api.atlasacademy.io/export/JP/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']}` "
else:
continue
jsonData = {
"content": None,
"embeds": [
{
"title": "FGO限定抽卡 - " + main.fate_region,
"description": "完成限定友情抽卡。列出抽卡结果.",
"color": 16711680,
"fields": [
{
"name": "限定卡池",
"value": f"{message_servant}",
"inline": False,
}
],
"thumbnail": {
"url": "https://www.fate-go.jp/manga_fgo/images/commnet_chara02_rv.png"
},
}
],
"attachments": [],
}
headers = {"Content-Type": "application/json"}
requests.post(endpoint, json=jsonData, headers=headers)
def Present(name, namegift, object_id_count) -> None:
endpoint = main.webhook_discord_url
jsonData = {
"content": None,
"embeds": [
{
"title": "FGO兑换系统 - JP",
"description": "兑换成功",
"color": 8388736,
"fields": [
{
"name": f"{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"}
requests.post(endpoint, json=jsonData, headers=headers)