简体   繁体   English

如何在电视节目中重新发送图片

[英]How to resend pictures in telethon

There is a code that forwards messages from one group to another.有一个代码可以将消息从一个组转发到另一个组。

history = await tg_client(GetHistoryRequest(
                peer=channel,
                offset_id=0,
                offset_date=None, add_offset=0,
                limit=1, max_id=0, min_id=0,
                hash=0))
            messages = history.messages
            if last_message_id != messages[0].id:
                last_message_id = messages[0].id
                print(str(messages[0].message))
                await tg_client.send_message('user_id', str(messages[0].message+"\n\n\n sent by bot"))

But if there are pictures in the post, it ignores them and sends only the text, if there is no text, but only a picture, then it does not send anything.但是如果帖子中有图片,它会忽略它们,只发送文本,如果没有文本,而只有一张图片,那么它不会发送任何内容。 How can I make it send an image as well?我怎样才能让它也发送图像?

I tried to search the documentation for the option I needed, but I did not find anything similar.我试图在文档中搜索我需要的选项,但没有找到类似的东西。

You must either use tg_client.send_file when there's media, or pass the message object (not message.message , which is the string text) to send_message , which will copy the values (won't work on channels with restricted content).您必须在有媒体时使用tg_client.send_file ,或者将message object (不是message.message ,它是字符串文本)传递给send_message ,这将复制值(不适用于内容受限的频道)。

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

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