'Sending file to private telegram group via telethon

I'm trying to send a file to a private group in which my bot is already an admin member of.


    from telethon import TelegramClient
    
    api_id = '1234567' 
    api_hash = 'myhash' 
    bot_token = '123:abcde' 
    filename='path/to/file'
    client = TelegramClient('anon', api_id, api_hash).start(bot_token=bot_token)
    
    async def main():
        me = await client.get_me()
        await client.send_file("-123456789",filename)
    with client:
        client.loop.run_until_complete(main())

Error:

telethon.errors.rpcerrorlist.BotMethodInvalidError: The API access for bot users is restricted. The method you tried to invoke cannot be executed as a bot (caused by GetContactsRequest)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source