Browse Source

last all

master
Nemesis 5 years ago
parent
commit
c2e067236e
  1. 39
      asmodee.py

39
asmodee.py

@ -10,7 +10,7 @@ import pickle
import time import time
import threading import threading
import json import json
from datetime import datetime from datetime import datetime,timedelta
from matrix_bot_api.matrix_bot_api import MatrixBotAPI from matrix_bot_api.matrix_bot_api import MatrixBotAPI
from matrix_bot_api.mregex_handler import MRegexHandler 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,user] = usrstats1
stats[room.room_id,nick] = usrstats2 stats[room.room_id,nick] = usrstats2
@not_myself @not_myself
def last(room,event): # Regarde la dernière fois que quelqu'un a écrit un message def last(room,event): # Regarde la dernière fois que quelqu'un a écrit un message
global modules global modules
@ -1143,23 +1144,24 @@ def last(room,event): # Regarde la dernière fois que quelqu'un a écrit un mess
args.pop(0) args.pop(0)
pers = "" pers = ""
if (len(args) >= 1 and args[0] == "all"): if (len(args) >= 1 and args[0] == "all"):
try: max_sign = "+"
max_sign = "+" max_duree = 0
max_duree = 0 if (len(args) > 1):
if (len(args) > 1): max_sign = args[1][0]
max_sign = args[1][0] max_duree = int(args[1][1:])
max_duree = int(args[1][1:]) ref_duree = datetime.now() - timedelta(days=max_duree)
ref_duree = datetime.now() - timedelta(days=max_duree) salon = verifPMRoom(room,event)
salon = verifPMRoom(room,event) all_usr = {}
reponse = "Les gens ayant posté à " + max_sign + " de " + str(max_duree) + " jours :\n" reponse = "Les gens ayant posté à " + max_sign + " de " + str(max_duree) + " jours :\n"
for cle,valeur in stats.items(): for cle,valeur in stats.items():
if (cle[0] == room.room_id): if (cle[0] == room.room_id):
usrstats = stats[room.room_id,cle[1]] usrstats = stats[room.room_id,cle[1]]
if ((max_sign == "+" and usrstats.date < ref_duree) or ((max_sign == "-" and usrstats.date > ref_duree))): if ((usrstats.user in all_usr and all_usr[usrstats.user].date < usrstats.date) or not usrstats.user in all_usr):
reponse += "- " + usrstats.nick + " le " + usrstats.date.strftime("%Y-%m-%d %H:%M:%S") + "\n" all_usr[usrstats.user] = usrstats
msg(salon, reponse) for user,usrstats in all_usr.items():
except: if ((max_sign == "+" and usrstats.date < ref_duree) or ((max_sign == "-" and usrstats.date > ref_duree))):
msg(room,pers + " : Erreur de commande") reponse += "- " + usrstats.nick + "(" + user + ")" + " le " + usrstats.date.strftime("%Y-%m-%d %H:%M:%S") + "\n"
msg(salon, reponse)
else: else:
if (len(args) == 0): if (len(args) == 0):
pers = getNick(room,event) 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): # if (cle[0] == room.room_id):
# msg(room,cle[1] + "\n") # msg(room,cle[1] + "\n")
@not_myself @not_myself
def actif(room,event): # Stats d'activité d'une personne def actif(room,event): # Stats d'activité d'une personne
global modules global modules

Loading…
Cancel
Save