You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Telethon能否将消息转发至Telegram群组话题?

解决Telethon向群组话题发消息/转发消息的报错问题

问题分析

你尝试用reply_to参数指定群组话题ID发送消息时触发了TypeError: ord() expected a character, but string of length 2 found错误,核心原因是用错了参数:reply_to是用来指定回复某条具体消息的ID,而非话题ID。

正确实现方式

Telethon中指定群组话题的正确参数是message_thread_id,发送消息和转发消息场景都适用:

发送消息到话题

await client.send_message(
    destination_id,
    message,
    message_thread_id=destination_topic_id
)

转发消息到话题

await client.forward_messages(
    destination_id,
    messages_to_forward,
    message_thread_id=destination_topic_id
)

错误原因说明

你之前的代码把话题ID传给了reply_to,这个参数预期接收单条消息的整数ID,当传入不符合要求的内容时,内部文本处理逻辑出现类型不匹配,从而抛出ord()相关错误。

内容的提问来源于stack exchange,提问作者jackwalton

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.30 04:08:20