mirror of
https://github.com/Alishahryar1/free-claude-code.git
synced 2026-07-03 14:05:26 +02:00
Add voice note processing feedback for Telegram and Discord platforms
- Implemented a queue message to indicate "Processing voice note..." for both Telegram and Discord platforms. - Updated the Telegram platform to send a status message when handling voice notes. - Enhanced the test for Telegram voice handling to verify the queue message is sent correctly.
This commit is contained in:
@@ -137,6 +137,13 @@ class DiscordPlatform(MessagingPlatform):
|
||||
if not self._message_handler:
|
||||
return False
|
||||
|
||||
await self.queue_send_message(
|
||||
channel_id,
|
||||
format_status_discord("Processing voice note..."),
|
||||
reply_to=str(message.id),
|
||||
fire_and_forget=False,
|
||||
)
|
||||
|
||||
user_id = str(message.author.id)
|
||||
message_id = str(message.id)
|
||||
reply_to = (
|
||||
|
||||
@@ -23,7 +23,7 @@ if TYPE_CHECKING:
|
||||
|
||||
from .base import MessagingPlatform
|
||||
from ..models import IncomingMessage
|
||||
from ..rendering.telegram_markdown import escape_md_v2
|
||||
from ..rendering.telegram_markdown import escape_md_v2, format_status
|
||||
|
||||
|
||||
# Optional import - python-telegram-bot may not be installed
|
||||
@@ -525,6 +525,14 @@ class TelegramPlatform(MessagingPlatform):
|
||||
if not self._message_handler:
|
||||
return
|
||||
|
||||
await self.queue_send_message(
|
||||
chat_id,
|
||||
format_status("⏳", "Processing voice note..."),
|
||||
reply_to=str(update.message.message_id),
|
||||
parse_mode="MarkdownV2",
|
||||
fire_and_forget=False,
|
||||
)
|
||||
|
||||
message_id = str(update.message.message_id)
|
||||
reply_to = (
|
||||
str(update.message.reply_to_message.message_id)
|
||||
|
||||
@@ -87,6 +87,7 @@ async def test_telegram_voice_success_invokes_handler(telegram_platform):
|
||||
whisper_model="base",
|
||||
)
|
||||
|
||||
mock_queue_send = AsyncMock()
|
||||
with (
|
||||
patch(
|
||||
"config.settings.get_settings",
|
||||
@@ -96,9 +97,20 @@ async def test_telegram_voice_success_invokes_handler(telegram_platform):
|
||||
"messaging.transcription.transcribe_audio",
|
||||
return_value="Hello from voice",
|
||||
),
|
||||
patch.object(
|
||||
telegram_platform,
|
||||
"queue_send_message",
|
||||
mock_queue_send,
|
||||
),
|
||||
):
|
||||
await telegram_platform._on_telegram_voice(mock_update, mock_context)
|
||||
|
||||
mock_queue_send.assert_called_once()
|
||||
call_args, call_kw = mock_queue_send.call_args
|
||||
assert "Processing voice note" in call_args[1]
|
||||
assert call_kw["reply_to"] == "42"
|
||||
assert call_kw["fire_and_forget"] is False
|
||||
|
||||
handler.assert_called_once()
|
||||
incoming = handler.call_args[0][0]
|
||||
assert incoming.text == "Hello from voice"
|
||||
|
||||
Reference in New Issue
Block a user