generated from Nemesis/Exemple
last all
This commit is contained in:
parent
28969891ac
commit
c2e067236e
1 changed files with 21 additions and 18 deletions
13
asmodee.py
13
asmodee.py
|
@ -10,7 +10,7 @@ import pickle
|
|||
import time
|
||||
import threading
|
||||
import json
|
||||
from datetime import datetime
|
||||
from datetime import datetime,timedelta
|
||||
|
||||
from matrix_bot_api.matrix_bot_api import MatrixBotAPI
|
||||
from matrix_bot_api.mregex_handler import MRegexHandler
|
||||
|
@ -1130,6 +1130,7 @@ def statistiques(room,event): # Enregistrement des statistiques
|
|||
stats[room.room_id,user] = usrstats1
|
||||
stats[room.room_id,nick] = usrstats2
|
||||
|
||||
|
||||
@not_myself
|
||||
def last(room,event): # Regarde la dernière fois que quelqu'un a écrit un message
|
||||
global modules
|
||||
|
@ -1143,7 +1144,6 @@ def last(room,event): # Regarde la dernière fois que quelqu'un a écrit un mess
|
|||
args.pop(0)
|
||||
pers = ""
|
||||
if (len(args) >= 1 and args[0] == "all"):
|
||||
try:
|
||||
max_sign = "+"
|
||||
max_duree = 0
|
||||
if (len(args) > 1):
|
||||
|
@ -1151,15 +1151,17 @@ def last(room,event): # Regarde la dernière fois que quelqu'un a écrit un mess
|
|||
max_duree = int(args[1][1:])
|
||||
ref_duree = datetime.now() - timedelta(days=max_duree)
|
||||
salon = verifPMRoom(room,event)
|
||||
all_usr = {}
|
||||
reponse = "Les gens ayant posté à " + max_sign + " de " + str(max_duree) + " jours :\n"
|
||||
for cle,valeur in stats.items():
|
||||
if (cle[0] == room.room_id):
|
||||
usrstats = stats[room.room_id,cle[1]]
|
||||
if ((usrstats.user in all_usr and all_usr[usrstats.user].date < usrstats.date) or not usrstats.user in all_usr):
|
||||
all_usr[usrstats.user] = usrstats
|
||||
for user,usrstats in all_usr.items():
|
||||
if ((max_sign == "+" and usrstats.date < ref_duree) or ((max_sign == "-" and usrstats.date > ref_duree))):
|
||||
reponse += "- " + usrstats.nick + " le " + usrstats.date.strftime("%Y-%m-%d %H:%M:%S") + "\n"
|
||||
reponse += "- " + usrstats.nick + "(" + user + ")" + " le " + usrstats.date.strftime("%Y-%m-%d %H:%M:%S") + "\n"
|
||||
msg(salon, reponse)
|
||||
except:
|
||||
msg(room,pers + " : Erreur de commande")
|
||||
else:
|
||||
if (len(args) == 0):
|
||||
pers = getNick(room,event)
|
||||
|
@ -1174,6 +1176,7 @@ def last(room,event): # Regarde la dernière fois que quelqu'un a écrit un mess
|
|||
# if (cle[0] == room.room_id):
|
||||
# msg(room,cle[1] + "\n")
|
||||
|
||||
|
||||
@not_myself
|
||||
def actif(room,event): # Stats d'activité d'une personne
|
||||
global modules
|
||||
|
|
Loading…
Reference in a new issue