MCPcopy Create free account
hub / github.com/CScorza/IntelOSINT / _parse_tg_entity

Method _parse_tg_entity

IntelOSINT.py:13704–13746  ·  view source on GitHub ↗
(self, client, entity, base_icon, query, exact=False)

Source from the content-addressed store, hash-verified

13702
13703 # --- RICERCA TELEGRAM GLOBALE CON API ---
13704 async def _parse_tg_entity(self, client, entity, base_icon, query, exact=False):
13705 img_path = base_icon
13706 try:
13707 photo_bytes = await client.download_profile_photo(entity, file=bytes)
13708 if photo_bytes:
13709 img_path = f"data:image/jpeg;base64,{base64.b64encode(photo_bytes).decode()}"
13710 except: pass
13711
13712 if hasattr(entity, 'first_name'): # Gestione Utenti/Bot
13713 info = {
13714 "Status": " Trovato (Match Esatto)" if exact else " Trovato (Ricerca API)",
13715 "ID Numerico": str(entity.id),
13716 "Tipologia": "Bot" if getattr(entity, 'bot', False) else "Utente",
13717 }
13718 if getattr(entity, 'first_name', None): info["Nome"] = entity.first_name
13719 if getattr(entity, 'last_name', None): info["Cognome"] = entity.last_name
13720 if getattr(entity, 'username', None): info["Username"] = f"@{entity.username}"
13721 if getattr(entity, 'phone', None): info["Telefono Visibile"] = f"+{entity.phone}"
13722
13723 url = f"https://t.me/{entity.username}" if getattr(entity, 'username', None) else ""
13724 username_label = getattr(entity, 'username', None) or f"{getattr(entity, 'first_name', '')} {getattr(entity, 'last_name', '')}".strip()
13725
13726 else: # Gestione Canali/Gruppi
13727 info = {
13728 "Status": " Trovato (Match Esatto)" if exact else " Trovato (Ricerca API)",
13729 "ID Numerico": str(entity.id),
13730 "Tipologia": "Canale/Gruppo",
13731 "Titolo": getattr(entity, 'title', 'Sconosciuto')
13732 }
13733 if getattr(entity, 'username', None): info["Username"] = f"@{entity.username}"
13734 if getattr(entity, 'participants_count', None): info["Partecipanti (Stima)"] = str(entity.participants_count)
13735
13736 url = f"https://t.me/{entity.username}" if getattr(entity, 'username', None) else ""
13737 username_label = getattr(entity, 'title', 'Sconosciuto')
13738
13739 return {
13740 "username": username_label,
13741 "type": "Telegram",
13742 "info": info,
13743 "main_img": img_path,
13744 "status_code": 200,
13745 "url": url
13746 }
13747
13748 async def analyze_telegram(self, query):
13749 results = []

Callers 1

analyze_telegramMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected