Skip to content

Commit

Permalink
allow admin replies even if message was deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
ohld committed Sep 21, 2024
1 parent 6bec5b1 commit fbe3bda
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/tgbot/handlers/upload/moderation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from telegram import Bot, InlineKeyboardButton, InlineKeyboardMarkup, Update
from telegram.constants import ParseMode
from telegram.ext import ContextTypes
from telegram.error import BadRequest

from src.config import settings
from src.flows.storage.memes import (
Expand Down Expand Up @@ -246,18 +247,29 @@ async def handle_uploaded_meme_review_button(
external_id=str(meme["id"]),
)

await context.bot.send_message(
chat_id=meme_upload["user_id"],
reply_to_message_id=meme_upload["message_id"],
text="""
text = """
🎉🎉🎉
Your <b>meme has been approved</b> and soon bot will send it to other users!
See realtime stats of your uploaded memes: /uploads
""",
parse_mode=ParseMode.HTML,
)
"""

try:
await context.bot.send_message(
chat_id=meme_upload["user_id"],
reply_to_message_id=meme_upload["message_id"],
text=text,
parse_mode=ParseMode.HTML,
)
except BadRequest:
# messsage was deleted ??
# trying again withount reply_message_id
await context.bot.send_message(
chat_id=meme_upload["user_id"],
text=text,
parse_mode=ParseMode.HTML,
)

else:
await update_meme_by_upload_id(upload_id, status=MemeStatus.REJECTED)
Expand Down

0 comments on commit fbe3bda

Please sign in to comment.