Search code examples
pythonbotstelegramtelepot

Run handle(msg) in telepot (telegram bot python package)


I made a python script, I use telepot package for telegram bot. I use handle(msg) this is my script:

import telepot
bot = telepot.Bot('my_token')

def handle(msg):
    bot.sendMessage(my_chat_id , 'ok')

How can I run this script? when I call handle() I got this error:

Traceback (most recent call last):
  File "address_my_script", line 7, in <module>
    handle()
TypeError: handle() missing 1 required positional argument: 'msg'

Solution

  • handle() requires a single arg. You are calling it without any. Either change handle() (and based on your code, the better option, since 'msg' is never used) or change your caller.