Python 如何使用telethon阅读已回复的电报信息
我需要脚本来阅读电报频道的最后一条消息。如果此频道的最后一条消息是回复我想阅读的内容,那么最后一条消息的回复内容是什么。例如,此图片上突出显示的消息 我有这段代码来阅读最后一条消息,但我不知道如何阅读这条消息,我知道我可以使用参数is\u reply来知道最后一条消息是否是回复,但我不知道下一步该怎么做,有什么想法吗Python 如何使用telethon阅读已回复的电报信息,python,python-3.x,telegram-bot,python-telegram-bot,telethon,Python,Python 3.x,Telegram Bot,Python Telegram Bot,Telethon,我需要脚本来阅读电报频道的最后一条消息。如果此频道的最后一条消息是回复我想阅读的内容,那么最后一条消息的回复内容是什么。例如,此图片上突出显示的消息 我有这段代码来阅读最后一条消息,但我不知道如何阅读这条消息,我知道我可以使用参数is\u reply来知道最后一条消息是否是回复,但我不知道下一步该怎么做,有什么想法吗 async def get_mess(): limit = 1 global new async for message in client.iter_m
async def get_mess():
limit = 1
global new
async for message in client.iter_messages('Passive Lifestyle Forex Signals', limit):
new = message.text
whlie True:
get_mess()
我知道这不是最有效的,但那并不重要。你知道怎么编码吗?如果您需要更具体的信息,我可以回答您。我建议您使用以获取最后一条消息,这样您也可以忽略限制。然后,您需要检查该消息是否正在回复另一条消息,如果是,则获取该消息
async def get_mess():
limit = 1
global new
async for message in client.iter_messages('Passive Lifestyle Forex Signals', limit):
new = message
if new.reply_to_msg_id:
yourtext = await new.get_reply_message()
whlie True:
get_mess()
async def get_mess():
global new
message = await client.get_messages('YOUR CHAT') # you can omit the limit
if message.is_reply:
new = await message.get_reply_message()
whlie True:
get_mess()
这可以通过使用
get_messages
来简化,以消除循环<如果没有回复,code>get\u reply\u message也将返回None
,因此无需检查reply\u to\u msg\u id
。