简体   繁体   English

转发消息(专辑)电视节目

[英]Forward message (album) telethon

I'm trying to forward a message with a group of photos.我正在尝试转发包含一组照片的消息。 But they are redirected by separate messages in destination channel.但是它们被目标通道中的单独消息重定向。 How can I redirect with one message?如何使用一条消息重定向?

@client.on(events.NewMessage(incoming=True, chats=FROM))
async def handler_frw(event):
    await client.forward_messages(CHANNEL_TO, event.message)

If I use "send_message" it send as one message.如果我使用“send_message”,它会作为一条消息发送。 But TO_NAME - doesn't work with id Channel, only name:( And i need "Forward from" in destination channel.但是 TO_NAME - 不适用于 id Channel,只有 name:( 而且我需要在目标频道中“转发自”。

@client.on(events.Album(chats=FROM))
async def handler_snd(event):
    print("Have album.")
    caps = []
    for item in event.messages:
        caps.append(item.message)
    await client.send_message(TO_NAME, file=event.messages, message=caps)

If you want to forward the whole album, utilize the corresponding Album event instead of the New Message event.如果要转发整个相册,请使用相应的相册事件而不是新消息事件。 Telethon supposedly does the necessary hacks to collect the single messages together.据推测,Telethon 进行了必要的黑客攻击以将单个消息收集在一起。

See the docu 看文档

from telethon import events

@events.register(events.Album)
async def albumHandler(self, event):
    # Forwarding the album as a whole to some chat
    event.forward_to(chat)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM