1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-27 21:44:21 +00:00
royalnet/royalpack/commands/userinfo.py

75 lines
2.2 KiB
Python
Raw Normal View History

2019-12-03 12:53:08 +00:00
from typing import *
2020-05-10 22:46:12 +00:00
import royalnet.commands as rc
import royalnet.backpack.tables as rbt
2019-12-03 12:53:08 +00:00
2020-05-10 22:46:12 +00:00
class UserinfoCommand(rc.Command):
2019-12-03 12:53:08 +00:00
name: str = "userinfo"
aliases = ["uinfo", "ui", "useri"]
description: str = "Visualizza informazioni su un utente."
syntax = "[username]"
2020-05-10 22:46:12 +00:00
async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None:
2019-12-03 12:53:08 +00:00
username = args.optional(0)
if username is None:
2020-05-10 22:46:12 +00:00
user: rbt.User = await data.get_author(error_if_none=True)
2019-12-03 12:53:08 +00:00
else:
2020-05-10 22:46:12 +00:00
found: Optional[rbt.User] = await rbt.User.find(self.alchemy, data.session, username)
2019-12-03 12:53:08 +00:00
if not found:
2020-05-10 22:46:12 +00:00
raise rc.InvalidInputError("Utente non trovato.")
2019-12-03 12:53:08 +00:00
else:
user = found
r = [
2020-04-11 00:20:47 +00:00
f" [url=https://ryg.steffo.eu/#/user/{user.uid}]{user.username}[/url]",
2020-05-10 22:46:12 +00:00
f"{', '.join(user.roles)}",
2019-12-03 12:53:08 +00:00
]
2020-05-10 22:46:12 +00:00
if user.email:
r.append(f"{user.email}")
r.append("")
2019-12-03 12:53:08 +00:00
# Bios are a bit too long
# if user.bio:
# r.append(f"{user.bio}")
for account in user.telegram:
r.append(f"{account}")
for account in user.discord:
r.append(f"{account}")
2020-01-20 23:54:55 +00:00
for account in user.steam:
r.append(f"{account}")
2020-01-24 00:07:11 +00:00
if account.dota is not None:
r.append(f"{account.dota}")
2020-04-09 18:59:22 +00:00
if account.brawlhalla is not None:
r.append(f"{account.brawlhalla}")
2020-01-20 23:54:55 +00:00
2019-12-03 12:53:08 +00:00
for account in user.leagueoflegends:
r.append(f"{account}")
r.append("")
2020-04-11 00:20:47 +00:00
r.append(f"Ha creato [b]{len(user.diario_created)}[/b] righe di "
f"[url=https://ryg.steffo.eu/#/diario]Diario[/url], e vi compare in"
2019-12-03 12:53:08 +00:00
f" [b]{len(user.diario_quoted)}[/b] righe.")
r.append("")
if user.trivia_score:
2020-04-11 00:20:47 +00:00
r.append(f"Ha [b]{user.trivia_score.score:.0f}[/b] punti Trivia, avendo risposto correttamente a"
2020-01-20 23:54:55 +00:00
f" [b]{user.trivia_score.correct_answers}[/b] domande su"
f" [b]{user.trivia_score.total_answers}[/b].")
r.append("")
if user.fiorygi:
r.append(f"Ha [b]{user.fiorygi}[/b].")
r.append("")
2019-12-03 12:53:08 +00:00
await data.reply("\n".join(r))