Nettoyage de la branche product : suppression des fichiers de develop
This commit is contained in:
36
Chat-Id.py
36
Chat-Id.py
@@ -1,36 +0,0 @@
|
||||
import requests
|
||||
import json
|
||||
|
||||
# Remplace par ton token de bot Telegram
|
||||
token = "8128378340:AAF2sO3gaH1XpMNya_pEslzerqokoCiFRGs"
|
||||
|
||||
url = f"https://api.telegram.org/bot{token}/getUpdates"
|
||||
|
||||
try:
|
||||
response = requests.get(url)
|
||||
data = response.json()
|
||||
|
||||
print("🔍 Récupération des chats Telegram récents...\n")
|
||||
|
||||
if "result" in data:
|
||||
chats = set()
|
||||
|
||||
for update in data["result"]:
|
||||
message = update.get("message") or update.get("edited_message")
|
||||
if not message:
|
||||
continue
|
||||
|
||||
chat = message["chat"]
|
||||
chat_id = chat["id"]
|
||||
chat_title = chat.get("title") or chat.get("username") or chat.get("first_name") or "Inconnu"
|
||||
|
||||
if chat_id not in chats:
|
||||
chats.add(chat_id)
|
||||
print(f"➡️ Chat : {chat_title} | ID : {chat_id}")
|
||||
|
||||
if not chats:
|
||||
print("⚠️ Aucun chat trouvé. Envoie un message depuis un groupe ou une discussion avec le bot.")
|
||||
else:
|
||||
print("❌ Erreur : aucune donnée 'result' trouvée dans la réponse.")
|
||||
except Exception as e:
|
||||
print(f"Erreur lors de la récupération des chats : {e}")
|
||||
Reference in New Issue
Block a user