如何解决Python,Telethon发送相册
我很长一段时间都无法制作脚本。我有一个电报频道,我不想从该频道重新发送相册,而只是通过一条消息发送给我
from telethon import TelegramClient,events
from telethon import events
api_id =
api_hash = ""
chat = ''
client = TelegramClient('',api_id,api_hash)
print('started')
@client.on(events.Album)
async def handler(event):
#what farther
解决方法
这是一种实现方法:
from telethon import TelegramClient,events
api_id = ...
api_hash = ' ... '
chat = -1001277xxxxxx
client = TelegramClient('session',api_id,api_hash)
@client.on(events.Album)
async def handler(event):
# craft a new message and send
await client.send_message(
chat,file=event.messages,# event.messages is a List - meaning we're sending an album
message=event.original_update.message.message,# get the caption message from the album
)
## or forward it directly
# await event.forward_to(chat)
client.start()
client.run_until_disconnected()
,
有 send_file
表示
file (...): 要发送专辑,您应该在此参数中提供一个列表。 如果提供了列表或类似内容,则其中的文件将按照它们出现的顺序作为专辑发送,如果提供的文件超过 10 个,则将其切成 10 个块。
caption (str,optional):
已发送媒体消息的可选标题。发送专辑时,标题可能是一个字符串列表,将成对分配给文件。
所以扩展@Tibebes 答案
await client.send_file( # Note this is send_file not send_message
chat,file=event.messages
caption=list(map(lambda a: str(a.message),event.messages))
)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。