|
9 | 9 | from pydantic import BaseModel, Field, model_validator |
10 | 10 | from rich.console import Console |
11 | 11 | from telegram import Bot |
12 | | -from telegram.error import RetryAfter, TelegramError, NetworkError |
| 12 | +from telegram.error import RetryAfter, TelegramError, NetworkError, BadRequest |
13 | 13 | import telegram |
14 | 14 |
|
15 | 15 | from dumpyarabot.config import settings |
@@ -505,13 +505,22 @@ async def _process_message(self, message: QueuedMessage) -> bool: |
505 | 505 | console.print(f"[green]Successfully processed {message.type.value} message[/green]") |
506 | 506 | return True |
507 | 507 |
|
508 | | - except RetryAfter as e: |
509 | | - console.print(f"[yellow]Rate limited by Telegram API. Retry after {e.retry_after} seconds[/yellow]") |
510 | | - # Re-queue the message with a delay |
511 | | - message.scheduled_for = datetime.now(timezone.utc) + timedelta(seconds=e.retry_after) |
512 | | - await self._requeue_message(message) |
513 | | - return True # Don't increment retry count for rate limits |
514 | | - |
| 508 | + except RetryAfter as e: |
| 509 | + console.print(f"[yellow]Rate limited by Telegram API. Retry after {e.retry_after} seconds[/yellow]") |
| 510 | + # Re-queue the message with a delay |
| 511 | + message.scheduled_for = datetime.now(timezone.utc) + timedelta(seconds=e.retry_after) |
| 512 | + await self._requeue_message(message) |
| 513 | + return True # Don't increment retry count for rate limits |
| 514 | + |
| 515 | + except BadRequest as e: |
| 516 | + error_text = str(e) |
| 517 | + if "message is not modified" in error_text.lower(): |
| 518 | + console.print("[yellow]Skipping no-op edit: message content is unchanged[/yellow]") |
| 519 | + return True |
| 520 | + |
| 521 | + console.print(f"[red]Telegram bad request processing message: {e}[/red]") |
| 522 | + return False |
| 523 | + |
515 | 524 | except NetworkError as e: |
516 | 525 | console.print(f"[yellow]Network error processing message: {e}[/yellow]") |
517 | 526 | message.retry_count += 1 |
|
0 commit comments