Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Florestan Biaux
Messenger Statistics
Commits
f3c1c7ce
Commit
f3c1c7ce
authored
Jul 22, 2021
by
Adrien Simon
Browse files
Modification de counttalk pour utiliser un dictionnaire
parent
a5fcb030
Changes
2
Hide whitespace changes
Inline
Side-by-side
main.py
View file @
f3c1c7ce
...
...
@@ -27,8 +27,7 @@ if __name__ == "__main__":
if
choice
==
2
:
print
(
users
.
usertab
(
data
))
if
choice
==
3
:
print
(
"
\n
Affichage 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
:
...
...
stats.py
View file @
f3c1c7ce
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
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment