Exception messages implemented

This commit is contained in:
Profitroll 2022-12-13 14:33:22 +01:00
parent a54d78ccb6
commit 04093d0a20
2 changed files with 57 additions and 50 deletions

View File

@ -1,3 +1,4 @@
from traceback import print_exc
from app import app, isAnAdmin
from typing import Any, List, Union
from pyrogram.types import User, ChatMember, ChatPrivileges, Chat, Message, Photo, Video, Document, Animation, Voice
@ -72,8 +73,8 @@ class HoloUser():
logWrite(f"Set attribute {key} of user {self.id} to {value}")
async def message(self,
context: Message,
origin: Union[Message, None] = None,
context: Union[Message, None] = None,
text: Union[str, None] = None,
caption: Union[str, None] = None,
photo: Union[str, Photo, None] = None,
@ -108,6 +109,8 @@ class HoloUser():
else:
caption = locale("message_reply_notice", "message")
try:
if origin is not None:
if photo is not None:
@ -158,11 +161,13 @@ class HoloUser():
else:
new_message = await app.send_message(self.id, text)
# new_message = await app.send_message(self.id, text+locale("message_reply_notice", "message"))
await context.reply_text(locale("message_sent", "message"), quote=should_quote(context))
col_messages.insert_one({"origin": {"chat": context.chat.id, "id": context.id}, "destination": {"chat": new_message.chat.id, "id": new_message.id}})
except Exception as exp:
await context.reply_text(locale("message_traceback", "message").format(context.from_user.id, self.id, exp, print_exc()))
await context.reply_text(locale("message_error", "message"), quote=should_quote(context))
async def set_label(self, chat: Chat, label: str):
"""Set label in destination group

View File

@ -60,6 +60,8 @@
"message_invalid_syntax": "Неправильний синтаксис!\nТреба: `/message ID ПОВІДОМЛЕННЯ`",
"message_from": "Повідомлення від **{0}** (`{1}`):\n\n",
"message_reply_notice": "\n\n**Щоб надіслати відповідь на це повідомлення, тегніть його.**",
"message_error": "⚠️ **Сталась помилка**\nНе вдалось надіслати ваше повідомлення. Розробника повідомлено про цю помилку.",
"message_traceback": "⚠️ **Сталась помилка**\nПомилка повідомлень: `{0}` -> `{1}`\nПомилка: `{2}`\n\nTraceback:\n```\n{3}\n```",
"question_titles": {
"question1": "Ім'я/звертання:",
"question2": "День народження:",