Commit f3c1c7ce authored by Adrien Simon's avatar Adrien Simon
Browse files

Modification de counttalk pour utiliser un dictionnaire

parent a5fcb030
......@@ -27,8 +27,7 @@ if __name__ == "__main__":
if choice == 2:
print(users.usertab(data))
if choice == 3:
print("\nAffichage du nombre de messages envoyés \n")
stats.printtab(stats.counttalk(users.usertab(data), data))
stats.counttalk(data)
if choice == 4:
stats.countreacts(data)
if choice == 5:
......
import decode
import users
def counttalk(usertab, data):
tmp = ""
for i in range(len(usertab)):
tmp = tmp + "0 "
tmp = tmp.split()
counttalk = [usertab, tmp]
def counttalk(data):
messages = data["messages"]
cpt = 0
participants = users.userdico(data)
for participant in participants:
participants[participant] = 0
for msg in messages:
for i in range(len(counttalk[0])):
if decode.string_decode(msg["sender_name"]) == counttalk[0][i]:
counttalk[1][i] = int(counttalk[1][i])+1
cpt += 1
print("Messages envoyés : " + str(cpt) + " messages\n")
return counttalk
if not msg["is_unsent"]:
participants[decode.string_decode(msg["sender_name"])] += 1
def printtab(tab):
for i in range(len(tab[0])):
print(str(tab[0][i]) + " : " + str(tab[1][i]) + " messages")
for nb_talk in participants:
print(nb_talk + " : " + str(participants[nb_talk]))
def countreacts(data):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment