mirror of
https://github.com/Alishahryar1/free-claude-code.git
synced 2026-04-28 11:30:03 +00:00
- Introduced message_thread_id to the IncomingMessage model for handling forum topic IDs in Telegram. - Updated messaging platforms (Discord and Telegram) to accept and process message_thread_id in send_message methods. - Modified message handlers to utilize message_thread_id when sending messages. - Enhanced test cases to validate the integration of message_thread_id in message handling. This change improves support for forum supergroups in Telegram and enhances message management across platforms.
36 lines
1 KiB
Python
36 lines
1 KiB
Python
"""Platform-agnostic message models."""
|
|
|
|
from dataclasses import dataclass, field
|
|
from datetime import UTC, datetime
|
|
from typing import Any
|
|
|
|
|
|
@dataclass
|
|
class IncomingMessage:
|
|
"""
|
|
Platform-agnostic incoming message.
|
|
|
|
Adapters convert platform-specific events to this format.
|
|
"""
|
|
|
|
text: str
|
|
chat_id: str
|
|
user_id: str
|
|
message_id: str
|
|
platform: str # "telegram", "discord", "slack", etc.
|
|
|
|
# Optional fields
|
|
reply_to_message_id: str | None = None
|
|
# Forum topic ID (Telegram); required when replying in forum supergroups
|
|
message_thread_id: str | None = None
|
|
username: str | None = None
|
|
# Pre-sent status message ID (e.g. "Transcribing voice note..."); handler edits in place
|
|
status_message_id: str | None = None
|
|
timestamp: datetime = field(default_factory=lambda: datetime.now(UTC))
|
|
|
|
# Platform-specific raw event for edge cases
|
|
raw_event: Any = None
|
|
|
|
def is_reply(self) -> bool:
|
|
"""Check if this message is a reply to another message."""
|
|
return self.reply_to_message_id is not None
|