Search code examples
telethon

check if a private channel invite link is invalid/expired in telethon


When you try to access a private channel using expired link in telegram client you will get this message expired link

is there a way to check if a channel invite link is invalid or expired without joining the channel ?


Solution

  • You can use checkChatInvite:

    from telethon.sync import TelegramClient
    from telethon import functions, types
    
    with TelegramClient(name, api_id, api_hash) as client:
        result = client(functions.messages.CheckChatInviteRequest(
            hash='A4LmkR23G0IGxBE71zZfo1'
        ))
        print(result.stringify())