Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- # 🔹 Configuración
- TOKEN = "8520785101:AAF6eyh1viJXwkSdcj3RZMOUxFSb_NrrEp8"
- CHAT_ID = "6328222257" # ID del usuario o chat
- # 🔹 Obtener información del usuario
- def obtener_info_usuario():
- url = f"https://api.telegram.org/bot{TOKEN}/getChat?chat_id={CHAT_ID}"
- response = requests.get(url).json()
- if response.get("ok"):
- user_data = response["result"]
- print(f"✅ Información del usuario: {user_data}")
- # Extraer foto de perfil si existe
- if "photo" in user_data:
- photo_id = user_data["photo"]["big_file_id"]
- obtener_foto_perfil(photo_id)
- else:
- print(f"❌ Error al obtener datos: {response}")
- # 🔹 Obtener foto de perfil
- def obtener_foto_perfil(file_id):
- url = f"https://api.telegram.org/bot{TOKEN}/getFile?file_id={file_id}"
- response = requests.get(url).json()
- if response.get("ok"):
- file_path = response["result"]["file_path"]
- photo_url = f"https://api.telegram.org/file/bot{TOKEN}/{file_path}"
- print(f"📷 Foto de perfil: {photo_url}")
- else:
- print(f"❌ Error al obtener la foto: {response}")
- # 🔹 Ejecutar funciones
- if __name__ == "__main__":
- obtener_info_usuario()
Advertisement