generated from Nemesis/Exemple
actif
This commit is contained in:
parent
7b40d6dd65
commit
4fadda89b5
1 changed files with 62 additions and 6 deletions
68
asmodee.py
68
asmodee.py
|
@ -1531,6 +1531,56 @@ def statistiques(room,message): # Enregistrement des statistiques
|
||||||
# insertion des objets
|
# insertion des objets
|
||||||
stats[room.room_id,user] = usrstats
|
stats[room.room_id,user] = usrstats
|
||||||
|
|
||||||
|
async def actif(room,message): # Stats d'activité d'une personne
|
||||||
|
global modules
|
||||||
|
try:
|
||||||
|
rmod = modules[room.room_id, 'stats']
|
||||||
|
except:
|
||||||
|
modules[room.room_id, 'stats'] = False
|
||||||
|
if (modules[room.room_id, 'stats']):
|
||||||
|
global stats
|
||||||
|
args = getMessage(message).split()
|
||||||
|
sender = getUser(message)
|
||||||
|
args.pop(0)
|
||||||
|
if (len(args) > 0 and args[0] == "list"):
|
||||||
|
salon = await verifPMRoom(room,message)
|
||||||
|
room_act = []
|
||||||
|
for cle,valeur in stats.items():
|
||||||
|
if (cle[0] == room.room_id):
|
||||||
|
room_act.append(valeur)
|
||||||
|
room_act.sort(key=lambda us: us.mess, reverse=True)
|
||||||
|
reponse="Voici le tableau des plus gros posteurs!\n"
|
||||||
|
for us in room_act:
|
||||||
|
reponse = reponse + us.nick + " : " + str(us.mess) + "\n"
|
||||||
|
await msg(salon,reponse,sender)
|
||||||
|
else:
|
||||||
|
pers = ""
|
||||||
|
usrstats = None
|
||||||
|
if (len(args) == 0):
|
||||||
|
pers = getUser(message)
|
||||||
|
else:
|
||||||
|
pers=" ".join(args)
|
||||||
|
print(pers)
|
||||||
|
try:
|
||||||
|
usrstats = stats[room.room_id,pers]
|
||||||
|
except:
|
||||||
|
for cle,valeur in room.users.items():
|
||||||
|
if (valeur.display_name == pers):
|
||||||
|
try:
|
||||||
|
usrstats = stats[room.room_id, cle]
|
||||||
|
except:
|
||||||
|
usrstats = None
|
||||||
|
if (usrstats is not None):
|
||||||
|
break
|
||||||
|
if(usrstats):
|
||||||
|
try:
|
||||||
|
moy = "{:10.2f}".format(usrstats.char / usrstats.mess)
|
||||||
|
await msg(room,usrstats.nick + " a posté " + str(usrstats.mess) + " messages avec une moyenne de " + moy + " caractères par message",sender)
|
||||||
|
except:
|
||||||
|
print("erreur usrstats")
|
||||||
|
else:
|
||||||
|
await msg(room,pers + " : Personne non reconnue\n",sender)
|
||||||
|
|
||||||
|
|
||||||
async def help(room, message): # Aide en message privé
|
async def help(room, message): # Aide en message privé
|
||||||
await help_center(room,message,"help",True)
|
await help_center(room,message,"help",True)
|
||||||
|
@ -1626,18 +1676,18 @@ async def help_center(room,message,name,private): # Aide sur les commandes dispo
|
||||||
message += "\n- !modo : Gère les modérateurs du salon\n- !module : Gère les modules actifs sur le salon\n\n- Pour plus de details, tapez !" + name + " <commande>\n\nRetrouvez Asmodee sur https://git.ombreport.info/nemesis/asmodee_matrix"
|
message += "\n- !modo : Gère les modérateurs du salon\n- !module : Gère les modules actifs sur le salon\n\n- Pour plus de details, tapez !" + name + " <commande>\n\nRetrouvez Asmodee sur https://git.ombreport.info/nemesis/asmodee_matrix"
|
||||||
await msg(salon,message,sender, False)
|
await msg(salon,message,sender, False)
|
||||||
|
|
||||||
|
@bot.listener.on_message_event
|
||||||
|
async def callActif(room, message):
|
||||||
|
match = botlib.MessageMatch(room, message, bot, PREFIX)
|
||||||
|
if match.is_not_from_this_bot() and match.prefix() and match.command("actif"):
|
||||||
|
await actif(room, message)
|
||||||
|
|
||||||
@bot.listener.on_message_event
|
@bot.listener.on_message_event
|
||||||
async def callLast(room, message):
|
async def callLast(room, message):
|
||||||
match = botlib.MessageMatch(room, message, bot, PREFIX)
|
match = botlib.MessageMatch(room, message, bot, PREFIX)
|
||||||
if match.is_not_from_this_bot() and match.prefix() and match.command("last"):
|
if match.is_not_from_this_bot() and match.prefix() and match.command("last"):
|
||||||
await last(room, message)
|
await last(room, message)
|
||||||
|
|
||||||
@bot.listener.on_message_event
|
|
||||||
async def callStats(room, message):
|
|
||||||
match = botlib.MessageMatch(room, message, bot)
|
|
||||||
if match.is_not_from_this_bot():
|
|
||||||
statistiques(room, message)
|
|
||||||
|
|
||||||
@bot.listener.on_message_event
|
@bot.listener.on_message_event
|
||||||
async def callSave(room, message):
|
async def callSave(room, message):
|
||||||
match = botlib.MessageMatch(room, message, bot, PREFIX)
|
match = botlib.MessageMatch(room, message, bot, PREFIX)
|
||||||
|
@ -1754,6 +1804,12 @@ async def echo(room, message):
|
||||||
await bot.api.send_text_message(
|
await bot.api.send_text_message(
|
||||||
room.room_id, " ".join(arg for arg in match.args())
|
room.room_id, " ".join(arg for arg in match.args())
|
||||||
)
|
)
|
||||||
|
@bot.listener.on_message_event
|
||||||
|
async def callStats(room, message):
|
||||||
|
match = botlib.MessageMatch(room, message, bot)
|
||||||
|
if match.is_not_from_this_bot():
|
||||||
|
statistiques(room, message)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read('asmodee.ini')
|
config.read('asmodee.ini')
|
||||||
|
|
Loading…
Reference in a new issue