Skip to content

Commit

Permalink
Not throwing deletion error exception
Browse files Browse the repository at this point in the history
  • Loading branch information
f213 committed Jun 20, 2024
1 parent 1859f46 commit d34abec
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions bot.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
from telegram import Message, Update
from telegram.error import TelegramError
from telegram.ext import Application, CommandHandler, ContextTypes, MessageHandler
from telegram.ext.filters import TEXT, BaseFilter

Expand Down Expand Up @@ -33,8 +34,12 @@ async def delete(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
message = update.message or update.edited_message

if message is not None:
await log_message(message, action='delete')
await message.delete()
try:
await message.delete()
except TelegramError:
await log_message(message, action='deletion_error')
else:
await log_message(message, action='delete')


async def introduce_myself(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
Expand Down

0 comments on commit d34abec

Please sign in to comment.