/warnings can now show all warnings
This commit is contained in:
@@ -15,7 +15,32 @@ from modules import custom_filters
|
||||
& custom_filters.admin
|
||||
)
|
||||
async def cmd_warnings(app: Client, msg: Message):
|
||||
if len(msg.command) <= 1:
|
||||
if len(msg.command) == 1:
|
||||
warnings = {}
|
||||
warnings_output = []
|
||||
for warning in col_warnings.find({"active": True}):
|
||||
if str(warning["user"]) not in warnings:
|
||||
warnings[str(warning["user"])] = {
|
||||
"name": (col_users.find_one({"user": warning["user"]}))["tg_name"],
|
||||
"warns": 1,
|
||||
}
|
||||
else:
|
||||
warnings[str(warning["user"])]["warns"] += 1
|
||||
for warning in warnings:
|
||||
warnings_output.append(
|
||||
locale("warnings_entry", "message", locale=msg.from_user).format(
|
||||
warnings[warning]["name"], warning, warnings[warning]["warns"]
|
||||
),
|
||||
)
|
||||
await msg.reply_text(
|
||||
locale("warnings_all", "message", locale=msg.from_user).format(
|
||||
"\n".join(warnings_output)
|
||||
),
|
||||
quote=should_quote(msg),
|
||||
)
|
||||
return
|
||||
|
||||
if len(msg.command) > 2:
|
||||
await msg.reply_text(
|
||||
locale("syntax_warnings", "message", locale=msg.from_user),
|
||||
quote=should_quote(msg),
|
||||
|
Reference in New Issue
Block a user