-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
55 lines (49 loc) · 1.68 KB
/
main.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
import time
import datetime
from discordwebhook import Discord
import json
directory = 'chats'
discord = Discord(
url="")
def restore(file):
f = open(file, encoding='utf-8')
data = json.load(f)
counter = 0
wait = 1
for i in data['messages']:
time.sleep(1.5)
if bool(i["mentions"]):
msg = str(i["content"])
x = (len(i["mentions"]))
for y in range(x):
nname = i["mentions"][y]["nickname"]
uid = i["mentions"][y]["id"]
msg = msg.replace("@" + nname, "<@" + uid + ">")
discord.post(
content=msg,
username=i["author"]["nickname"],
avatar_url=i["author"]["avatarUrl"],
)
if bool(i["attachments"]):
x = (len(i["attachments"]))
for y in range(x):
discord.post(
content=i["attachments"][y]["url"],
username=i["author"]["nickname"],
avatar_url=i["author"]["avatarUrl"]
)
else:
discord.post(
content=i["content"],
username=i["author"]["nickname"],
avatar_url=i["author"]["avatarUrl"],
)
counter += 1
wait += 1
if (wait % 100) == 0:
time.sleep(5)
print(str(round(counter / len(data['messages']), 5) * 100) + " % done sending (" + str(
counter) + ") messages sent " + "time left ~: " + str(datetime.timedelta(
seconds=(len(data['messages']) - counter) * 1.5 + ((len(data['messages']) - counter) // 100) * 5)))
if __name__ == '__main__':
restore("chats/")