Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 30, 2026

概述 / Overview

Implements Telegram voice message receiving. Adapter now captures voice messages via filters.VOICE, downloads OGG/Opus audio from Telegram API, and converts to platform_message.Voice components with base64 encoding for LLM processing.

实现电报语音消息接收。适配器现在通过 filters.VOICE 捕获语音消息,从 Telegram API 下载 OGG/Opus 音频,并转换为带有 base64 编码的 platform_message.Voice 组件供 LLM 处理。

Changes / 更改

File: src/langbot/pkg/platform/sources/telegram.py (+21 lines)

  1. Message handler filter - Added filters.VOICE to capture voice messages

    MessageHandler(filters.TEXT | filters.COMMAND | filters.PHOTO | filters.VOICE, callback)
  2. Voice processing in target2yiri() - Downloads voice file, extracts MIME type, encodes to base64:

    if message.voice:
        file = await message.voice.get_file()
        file_format = message.voice.mime_type or 'audio/ogg'
        async with aiohttp.ClientSession(trust_env=True) as session:
            async with session.get(file.file_path) as response:
                file_bytes = await response.read()
        message_components.append(
            platform_message.Voice(
                base64=f'data:{file_format};base64,{base64.b64encode(file_bytes).decode("utf-8")}',
                length=message.voice.duration,
            )
        )

Technical Notes / 技术说明

  • Follows existing photo handling pattern for consistency
  • Pipeline preprocessing already handles Voice components as file content
  • Zero new dependencies; uses existing python-telegram-bot and aiohttp
  • Works automatically without configuration changes

更改前后对比截图 / Screenshots

N/A - Backend adapter change, no UI modifications

不适用 - 后端适配器更改,无用户界面修改

检查清单 / Checklist

PR 作者完成 / For PR author

  • 阅读仓库贡献指引了吗? / Have you read the contribution guide?
  • 与项目所有者沟通过了吗? / Have you communicated with the project maintainer?
  • 我确定已自行测试所作的更改,确保功能符合预期。 / I have tested the changes and ensured they work as expected.

项目维护者完成 / For project maintainer

  • 相关 issues 链接了吗? / Have you linked the related issues?
  • 配置项写好了吗?迁移写好了吗?生效了吗? / Have you written the configuration items? Have you written the migration? Has it taken effect?
  • 依赖加到 pyproject.toml 和 core/bootutils/deps.py 了吗 / Have you added the dependencies to pyproject.toml and core/bootutils/deps.py?
  • 文档编写了吗? / Have you written the documentation?
Original prompt

This section details on the original issue you should resolve

<issue_title>[Feature]: Telegramm Voice Messages Recieving</issue_title>
<issue_description>### This is a?

New feature

Detailed description

Please add it asap . It’s very crucial part of build a really great telegram based chat bot . All other services like dify etc are supporting voice . I hope you could do it asap 🙏🏽</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

- Add filters.VOICE to Telegram message handler to capture voice messages
- Implement voice message processing in target2yiri converter
- Download voice files from Telegram API and convert to base64
- Create platform_message.Voice component with proper mime type and duration
- Maintain compatibility with existing text, photo, and command messages

Co-authored-by: RockChinQ <45992437+RockChinQ@users.noreply.github.com>
Copilot AI changed the title [WIP] Add voice message receiving for Telegram bot feat: Add Telegram voice message receiving support Jan 30, 2026
Copilot AI requested a review from RockChinQ January 30, 2026 15:54
@RockChinQ RockChinQ marked this pull request as ready for review January 30, 2026 16:22
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. eh: Feature enhance: 新功能添加 / add new features m: Platform 机器人管理相关 / Bots management pd: Need testing pending: 待测试的PR / PR waiting to be tested labels Jan 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

eh: Feature enhance: 新功能添加 / add new features m: Platform 机器人管理相关 / Bots management pd: Need testing pending: 待测试的PR / PR waiting to be tested size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Telegramm Voice Messages Recieving

2 participants