Bot become a Community Guard & Post send manager

added: dictionary support for censore
message/user management with dict triggers
This commit is contained in:
2025-08-22 21:44:14 +09:00
parent efdafb0efa
commit c16ec54891
27 changed files with 1746 additions and 184 deletions

View File

@@ -0,0 +1,16 @@
import traceback
from telegram.ext import ContextTypes
from app.db.session import get_session
from app.db.models import ModerationLog
async def on_error(update: object, context: ContextTypes.DEFAULT_TYPE) -> None:
try:
chat_id = getattr(getattr(update, "effective_chat", None), "id", 0)
user_id = getattr(getattr(update, "effective_user", None), "id", 0)
err = "".join(traceback.format_exception(context.error))[-4000:]
with get_session() as s:
s.add(ModerationLog(chat_id=chat_id or 0, tg_user_id=user_id or 0,
message_id=None, reason=err, action="error"))
s.commit()
except Exception:
pass