-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patholdM.py
38 lines (34 loc) · 1.13 KB
/
oldM.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
import json
import random
def randomMsg():
with open('kdn/data.json', encoding="utf8") as json_file:
data = json.load(json_file)
msg= data["messages"]
boto = False
while boto == False:
equisDe = random.randint(1, len(msg)) #Gets a random number between 1 and the lenght of the json file adn we use it to browse the json
#print(msg[equisDe])
imagen = False
noesBot=msg[equisDe]["author"]["isBot"] #Check if the msg author is a bot
mensaje = msg[equisDe]["content"]
if not mensaje: #When theres no text only img
imagen = True
mensaje = msg[equisDe]["attachments"][0]["url"]
autor = msg[equisDe]["author"]["name"]
pica = msg[equisDe]["author"]["avatarUrl"]
fecha = msg[equisDe]["timestamp"]
fecha = fecha[0:10]
if not fecha:
fecha = "NULL / IMAGEN"
myDict = {
"pfp" : pica,
"autor" : autor,
"mensaje" : mensaje,
"fecha": fecha,
"imagen": imagen
}
if noesBot == False:
boto = True
return myDict
else:
boto = False