1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-24 03:54:20 +00:00
royalnet/royalpack/commands/userinfo.py

71 lines
2 KiB
Python
Raw Normal View History

2019-12-03 12:53:08 +00:00
from typing import *
from royalnet.commands import *
from royalnet.utils import *
from royalnet.backpack.tables import User
from sqlalchemy import func
2020-01-20 23:54:55 +00:00
from ..tables.aliases import Alias
2019-12-03 12:53:08 +00:00
class UserinfoCommand(Command):
name: str = "userinfo"
aliases = ["uinfo", "ui", "useri"]
description: str = "Visualizza informazioni su un utente."
syntax = "[username]"
async def run(self, args: CommandArgs, data: CommandData) -> None:
username = args.optional(0)
if username is None:
user: User = await data.get_author(error_if_none=True)
else:
2020-01-20 23:54:55 +00:00
found: Optional[User] = await asyncify(Alias.find_by_alias, self.alchemy, data.session, username)
2019-12-03 12:53:08 +00:00
if not found:
raise InvalidInputError("Utente non trovato.")
else:
user = found
r = [
2020-01-20 23:54:55 +00:00
f" [b]{user.username}[/b]",
2019-12-03 12:53:08 +00:00
f"{user.role}",
"",
]
# 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-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("")
r.append(f"Ha creato [b]{len(user.diario_created)}[/b] righe di diario, e vi compare in"
f" [b]{len(user.diario_quoted)}[/b] righe.")
r.append("")
if user.trivia_score:
2020-01-20 23:54:55 +00:00
r.append(f"Ha [b]{user.trivia_score.score:.0f}[/b] punti trivia, avendo risposto correttamente a"
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))