Files
Hermes-Skills/devops/telegram-message-forwarder/references/diagnose-group-migration.py
T
Hermes Skills Manager 6770bc9b9d Initial commit: Hermes Agent skills collection
- Trading skills (OKX, dividend, lottery, quantitative)
- Creative skills (ASCII art, diagrams, video)
- Development skills (GitHub, debugging, TDD)
- Research skills (arXiv, blog monitoring)
- Productivity skills (email, documents, notes)
- MCP integration skills
- Custom user skills
2026-07-05 02:31:15 -04:00

37 lines
1.4 KiB
Python

# Diagnostic: check if a Telegram group has been migrated to a supergroup
# Usage: docker exec telegram-forwarder python3 <this-script>
#
# When a group migrates to a supergroup, the old ID becomes deactivated.
# The new ID is the channel_id from migrated_to, prefixed with -100.
from telethon import TelegramClient
import asyncio, socks
async def check_migration(chat_id: int):
proxy = (socks.SOCKS5, '127.0.0.1', 7890)
# Use bot client for checking
bot = TelegramClient('./sessions/bot', API_ID, API_HASH, proxy=proxy)
await bot.start()
try:
entity = await bot.get_entity(chat_id)
print(f'Entity type: {type(entity).__name__}')
print(f'ID: {entity.id}')
print(f'Title: {getattr(entity, "title", "N/A")}')
if hasattr(entity, 'deactivated') and entity.deactivated:
print(f'⚠️ DEACTIVATED - group was migrated!')
if hasattr(entity, 'migrated_to') and entity.migrated_to:
new_id = entity.migrated_to.channel_id
print(f'New channel_id: {new_id}')
print(f'New Telethon ID: -100{new_id}')
print(f'Hermes free_response_channels should be: "-100{new_id}"')
else:
print('✅ Active - no migration detected')
except Exception as e:
print(f'Error: {e}')
await bot.disconnect()
# Example: check old group ID
# asyncio.run(check_migration(5586190970))