Tuesday, 23 August 2022

Telethon, can not get comments from messages telegram

I am trying to get all the messages/posts from channel and also the comments on them. I successfully got messages from the channel but I could not get the comments. I always get an error. I dont know what it means or even if the method is correct or not. The code is

from telethon.sync import TelegramClient
from asyncio import run

api_id = 1245242 #Random id
api_hash = "afdsf24242sfdfa524f42sdaedfaAFEfaf" #random hash
chat = 'https://t.me/CryptoAlerts'
# use full phone number including + and country code
phone = "+9256445664" # Random number
name = "username"
async def messages_func(name, api_id, api_hash):
  async with TelegramClient(name, api_id, api_hash) as client:
    print("Extracting messages")
    async for message in client.iter_messages(chat):
        async for message in client.iter_messages(chat, reply_to=int(message.sender_id)):# This line produces error.
          print(message.text)
       
        #print(message.sender_id, ':', message.text)
              
run(messages_func(name, api_id, api_hash))

The error is.

error: 'i' format requires -2147483648 <= number <= 2147483647

The full image showing Error is

Thanks in advance.



from Telethon, can not get comments from messages telegram

No comments:

Post a Comment