【问题标题】:With telethon is it possible to forward a message to a group topic?使用 telethon 是否可以将消息转发到组主题?
【发布时间】:2023-02-26 06:32:04
【问题描述】:

文档中没有关于将消息转发或发送到主题的内容。

我试过使用 client.forward_messages 但是,由于文档中没有关于主题的任何内容,我只能胡思乱想并猜测什么可能有效。例如。:

await client.send_message(
    destination__id,
    message,
    reply_to=destination_topic_id,
)
    if (0x10000 <= ord(x) <= 0x10FFFF) else x for x in text
TypeError: ord() expected a character, but string of length 2 found

【问题讨论】:

    标签: python telethon


    【解决方案1】:

    友好的client.forward_messages 方法尚未公开将消息转发到特定主题的方法。但是,您可以像这样直接使用ForwardMessagesRequest:

    from telethon import TelegramClient, functions
    
    client = TelegramClient(...)
    
    client(functions.messages.ForwardMessagesRequest(
        from_peer=source_chat,     # <- chat where the messages exist
        id=[123, 456],             # <- message ids to forward from source_chat
        to_peer=destination_chat,  # <- where to forward the messages
        top_msg_id=topic_id,       # <- topic id
    ))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-16
      • 1970-01-01
      • 1970-01-01
      • 2019-09-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多