gpt4 book ai didi

Python, Telethon 发送专辑

转载 作者:行者123 更新时间:2023-12-04 08:50:44 27 4
gpt4 key购买 nike

好久没写剧本了我有一个电报 channel ,我不想从这个 channel 重新发送专辑,但只需在一条消息中发送给我

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()

关于Python, Telethon 发送专辑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64111232/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com