Search code examples
pythontelegramtelegram-botpython-telegram-bottelegram-webhook

Bulk creation of telegram channels via script/automation


I’ve been researching for a few days but can’t find guidance on a way to create multiple telegram channels at once or via automation(Shell script, python, Java etc etc)

The intent is to create multiple channels by specifying name, description & users to be added to it.

Could someone please help


Solution

  • TELEGRAM_USER = <Your telegram username - @my_name>
    TELEGRAM_APP_API_ID = <Get the API ID from https://my.telegram.org/apps - App api_id:>
    TELEGRAM_APP_API_HASH = <Get the API HASH from https://my.telegram.org/apps - App api_hash:>
    
    
    def create_channel_with_users(chname, descrip):
        with TelegramClient(TELEGRAM_USER, TELEGRAMA_APP_API_ID, TELEGRAMA_APP_API_HASH) as client:
            result = client(functions.channels.CreateChannelRequest(
                title=chname,
                about=descrip,
                megagroup=True
            ))
            return result