Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
See telegram group Ids
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import telegram
from telegram.error import NetworkError, Unauthorized
from time import sleep
from sys import argv
token = ''
if len(argv) == 2:
token = argv[1]
bot = telegram.Bot(token)
update_id = 0
print('Obteniendo el id de grupo... cuando salga dale a Ctrl-C')
printed = []
while True:
for update in bot.getUpdates(offset=update_id, timeout=10):
chat_id = update.message.chat_id
chat_title = update.message
if chat_id not in printed:
print("Title: " + str(chat_title['chat']['title']))
print("ID: " + str(chat_id))
except NetworkError:
except Unauthorized:
update_id += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.