Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get respond properly #6

Open
ghost opened this issue Dec 27, 2021 · 2 comments
Open

Can't get respond properly #6

ghost opened this issue Dec 27, 2021 · 2 comments

Comments

@ghost
Copy link

ghost commented Dec 27, 2021

Greeting, thank you for your wonderful work! Currently, I'm writing a telegram bot using flask and webhook for my company.
I found your bot and it's easy to understand. However, when I try to run and test the POST method (with Postman), I received:

 * Serving Flask app 'app' (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
[2021-12-27 23:07:30,019] ERROR in app: Exception on /<bot-token-not-shown> [POST]
Traceback (most recent call last):
  File "D:\Anaconda3\envs\XXXXX\lib\site-packages\flask\app.py", line 2073, in wsgi_app
    response = self.full_dispatch_request()
  File "D:\Anaconda3\envs\XXXXX\lib\site-packages\flask\app.py", line 1518, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "D:\Anaconda3\envs\XXXXX\lib\site-packages\flask\app.py", line 1516, in full_dispatch_request
    rv = self.dispatch_request()
  File "D:\Anaconda3\envs\XXXXX\lib\site-packages\flask\app.py", line 1502, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "G:\XXXXX\flask-telegram-bot\app.py", line 17, in respond
    update = telegram.Update.de_json(request.get_json(force=True), bot)
  File "D:\Anaconda3\envs\XXXXX\lib\site-packages\telegram\update.py", line 416, in de_json
    return cls(**data)
TypeError: __init__() missing 1 required positional argument: 'update_id'

I'm using Python 3.8 and python-telegram-bot 13.9

@ghost
Copy link
Author

ghost commented Dec 28, 2021

I've even tried to create a new Anaconda environment with Python 3.6 and done pip install -r requirements.txt but it seems that the problem still happens:

  File "/home/ubuntu/anaconda3/envs/XXXXX/lib/python3.6/site-packages/telegram/update.py", line 219, in de_json
    return cls(**data)
TypeError: __init__() missing 1 required positional argument: 'update_id'

p/s: I tried to run on both OSes: Windows 11 (my PC at home) and Linux (the company PC)

@ghost
Copy link
Author

ghost commented Dec 29, 2021

Not sure how to fix this bug. However, I've found that: when I tried to call /getUpdates from the api.telegram.org, it said:

{"ok":false,"error_code":409,"description":"Conflict: can't use getUpdates method while webhook is active; use deleteWebhook to delete the webhook first"}

Therefore, I understood my problem - missing the 'update_id' (since the telegram bot couldn't retrieve the getUpdates info successfully). I think the webhook shouldn't be actived before the getUpdates method is called. How can I fix this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants