我很长一段时间都不能写剧本。我有一个电报频道,我不想从这个频道重新发送相册,但只需在一条消息中发送给我
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发布于 2020-09-29 15:22:42
这里有一个方法可以做到这一点:
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()发布于 2021-05-06 11:41:57
有一个send_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))
)https://stackoverflow.com/questions/64111232
复制相似问题