Skip to content

Commit

Permalink
fix reply message_id not found
Browse files Browse the repository at this point in the history
  • Loading branch information
ohld committed Sep 30, 2024
1 parent fbe3bda commit 7c69882
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
19 changes: 14 additions & 5 deletions src/tgbot/handlers/chat/feedback.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import random

from telegram import Update
from telegram.error import BadRequest
from telegram.ext import ContextTypes

from src.tgbot.constants import TELEGRAM_FEEDBACK_CHAT_ID
Expand Down Expand Up @@ -41,8 +42,16 @@ async def handle_feedback_reply(update: Update, context: ContextTypes.DEFAULT_TY
header, _ = update.message.reply_to_message.text.split("\n", 1)
user_id, message_id = header.split(":")

await context.bot.send_message(
chat_id=user_id,
text=reply_text,
reply_to_message_id=int(message_id),
)
try:
await context.bot.send_message(
chat_id=user_id,
text=reply_text,
reply_to_message_id=int(message_id),
)
except BadRequest:
# message was deleted ??
# trying again without reply_message_id
await context.bot.send_message(
chat_id=user_id,
text=reply_text,
)
2 changes: 1 addition & 1 deletion src/tgbot/handlers/upload/moderation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

from telegram import Bot, InlineKeyboardButton, InlineKeyboardMarkup, Update
from telegram.constants import ParseMode
from telegram.ext import ContextTypes
from telegram.error import BadRequest
from telegram.ext import ContextTypes

from src.config import settings
from src.flows.storage.memes import (
Expand Down

0 comments on commit 7c69882

Please sign in to comment.