如何使用TELETHON
我正在使用以下代码
date_of_post = datetime.datetime(2019, 12, 24)
with TelegramClient(name, api_id, api_hash) as client:
for message in client.iter_messages(chat , offset_date = date_of_post):
print(message.sender_id, ':', message.text)
答案 0 :(得分:0)
offset_date
用于获取该日期之前 的消息。所以您应该使用第二天:
async def get_messages_at_date(chat, date):
result = []
tomorrow = date + datetime.timedelta(days=1)
async for msg in client.iter_messages(chat, offset_date=date):
if msg.date < date:
return result
result.append(msg)