Search code examples
pythonapichattelegram

How to get a message from Telegram groups by API?


I was looking for some way to listen and catch new messages provided by telegram groups.

I have not found libraries or API in order to do this in Python.

Someone having any suggestion?


Solution

  • There are two ways to achieve your goal:

    Method 1:

    My suggested library for python: python-telegram-bot

    1. Create a bot.
    2. Add the bot to the desired group as administrator.
    3. Listen to messages as you normally listen in bots.

    Method 2:

    My suggested library for python: Telethon

    1. Join the desired group as a user (not a bot).
    2. Create a simple client that listens to new messages.