feat: enhance message context handling by adding message_id parameter

This commit is contained in:
Darye
2026-02-18 20:18:27 +01:00
parent 8de36d398f
commit c865b293a9
2 changed files with 15 additions and 7 deletions

View File

@@ -13,16 +13,19 @@ class MessageTool(Tool):
self,
send_callback: Callable[[OutboundMessage], Awaitable[None]] | None = None,
default_channel: str = "",
default_chat_id: str = ""
default_chat_id: str = "",
default_message_id: str | None = None
):
self._send_callback = send_callback
self._default_channel = default_channel
self._default_chat_id = default_chat_id
self._default_message_id = default_message_id
def set_context(self, channel: str, chat_id: str) -> None:
def set_context(self, channel: str, chat_id: str, message_id: str | None = None) -> None:
"""Set the current message context."""
self._default_channel = channel
self._default_chat_id = chat_id
self._default_message_id = message_id
def set_send_callback(self, callback: Callable[[OutboundMessage], Awaitable[None]]) -> None:
"""Set the callback for sending messages."""
@@ -67,11 +70,13 @@ class MessageTool(Tool):
content: str,
channel: str | None = None,
chat_id: str | None = None,
message_id: str | None = None,
media: list[str] | None = None,
**kwargs: Any
) -> str:
channel = channel or self._default_channel
chat_id = chat_id or self._default_chat_id
message_id = message_id or self._default_message_id
if not channel or not chat_id:
return "Error: No target channel/chat specified"
@@ -83,7 +88,10 @@ class MessageTool(Tool):
channel=channel,
chat_id=chat_id,
content=content,
media=media or []
media=media or [],
metadata={
"message_id": message_id,
}
)
try: