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

Telebot: Fix deprecated RegexHandler and change order of handlers. #61

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

PeterVoronov
Copy link

[] Fix the "RegexHandler is deprecated. See https://git.io/fxJuV
for more info" in Telebot.
[
] Change order of handlers to cats the regexp (download command)
before the common text (book search) in Telebot.
modified: management/commands/sopds_telebot.py

[*] Fix the "RegexHandler is deprecated. See https://git.io/fxJuV
    for more info" in Telebot.
[*] Change order of handlers to cats the regexp (download command)
    before the common text (book search) in Telebot.
	modified:   management/commands/sopds_telebot.py
@issmirnov
Copy link

Does this solve the download issue?

issmirnov added a commit to issmirnov-forks/docker-sopds that referenced this pull request Jan 9, 2021
The telegram bot isn't starting, and we have mitshel/sopds#61 with the fix.
@PeterVoronov
Copy link
Author

Does this solve the download issue?

For me - yes

@issmirnov
Copy link

Interesting. I set up a fork where I pulled in both of your PR's, and I'm getting an error.

Quit the sopds_telebot with CONTROL-C.
2021-01-09 06:42:20,101 INFO     Scheduler started
2021-01-09 06:42:25,231 ERROR    No error handlers are registered, logging exception.
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/telegram/ext/dispatcher.py", line 432, in process_update
    handler.handle_update(update, self, check, context)
  File "/usr/local/lib/python3.9/site-packages/telegram/ext/handler.py", line 156, in handle_update
    return self.callback(update, context)
  File "/sopds/opds_catalog/management/commands/sopds_telebot.py", line 30, in wrapper
    result =  func(self, bot, update)
  File "/sopds/opds_catalog/management/commands/sopds_telebot.py", line 45, in wrapper
    query = update.message if update.message else update.callback_query.message
AttributeError: 'CallbackContext' object has no attribute 'message'
2021-01-09 06:42:30,403 ERROR    No error handlers are registered, logging exception.
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/telegram/ext/dispatcher.py", line 432, in process_update
    handler.handle_update(update, self, check, context)
  File "/usr/local/lib/python3.9/site-packages/telegram/ext/handler.py", line 156, in handle_update
    return self.callback(update, context)
  File "/sopds/opds_catalog/management/commands/sopds_telebot.py", line 30, in wrapper
    result =  func(self, bot, update)
  File "/sopds/opds_catalog/management/commands/sopds_telebot.py", line 45, in wrapper
    query = update.message if update.message else update.callback_query.message
AttributeError: 'CallbackContext' object has no attribute 'message'

Do you have any thoughts off the top of your head? Any guidance is appreciated.

Thanks!

@PeterVoronov
Copy link
Author

PeterVoronov commented Jan 11, 2021

Interesting. I set up a fork where I pulled in both of your PR's, and I'm getting an error.

Quit the sopds_telebot with CONTROL-C.
2021-01-09 06:42:20,101 INFO     Scheduler started
2021-01-09 06:42:25,231 ERROR    No error handlers are registered, logging exception.
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/telegram/ext/dispatcher.py", line 432, in process_update
    handler.handle_update(update, self, check, context)
  File "/usr/local/lib/python3.9/site-packages/telegram/ext/handler.py", line 156, in handle_update
    return self.callback(update, context)
  File "/sopds/opds_catalog/management/commands/sopds_telebot.py", line 30, in wrapper
    result =  func(self, bot, update)
  File "/sopds/opds_catalog/management/commands/sopds_telebot.py", line 45, in wrapper
    query = update.message if update.message else update.callback_query.message
AttributeError: 'CallbackContext' object has no attribute 'message'
2021-01-09 06:42:30,403 ERROR    No error handlers are registered, logging exception.
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/telegram/ext/dispatcher.py", line 432, in process_update
    handler.handle_update(update, self, check, context)
  File "/usr/local/lib/python3.9/site-packages/telegram/ext/handler.py", line 156, in handle_update
    return self.callback(update, context)
  File "/sopds/opds_catalog/management/commands/sopds_telebot.py", line 30, in wrapper
    result =  func(self, bot, update)
  File "/sopds/opds_catalog/management/commands/sopds_telebot.py", line 45, in wrapper
    query = update.message if update.message else update.callback_query.message
AttributeError: 'CallbackContext' object has no attribute 'message'

Do you have any thoughts off the top of your head? Any guidance is appreciated.

Thanks!

Strange. But it is depend on version of python telegram package.

what do you have an output of
docker exec -t sopds_contaner_name pip list | grep telegram ?

@PeterVoronov
Copy link
Author

Interesting. I set up a fork where I pulled in both of your PR's, and I'm getting an error.

Quit the sopds_telebot with CONTROL-C.
2021-01-09 06:42:20,101 INFO     Scheduler started
2021-01-09 06:42:25,231 ERROR    No error handlers are registered, logging exception.
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/telegram/ext/dispatcher.py", line 432, in process_update
    handler.handle_update(update, self, check, context)
  File "/usr/local/lib/python3.9/site-packages/telegram/ext/handler.py", line 156, in handle_update
    return self.callback(update, context)
  File "/sopds/opds_catalog/management/commands/sopds_telebot.py", line 30, in wrapper
    result =  func(self, bot, update)
  File "/sopds/opds_catalog/management/commands/sopds_telebot.py", line 45, in wrapper
    query = update.message if update.message else update.callback_query.message
AttributeError: 'CallbackContext' object has no attribute 'message'
2021-01-09 06:42:30,403 ERROR    No error handlers are registered, logging exception.
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/telegram/ext/dispatcher.py", line 432, in process_update
    handler.handle_update(update, self, check, context)
  File "/usr/local/lib/python3.9/site-packages/telegram/ext/handler.py", line 156, in handle_update
    return self.callback(update, context)
  File "/sopds/opds_catalog/management/commands/sopds_telebot.py", line 30, in wrapper
    result =  func(self, bot, update)
  File "/sopds/opds_catalog/management/commands/sopds_telebot.py", line 45, in wrapper
    query = update.message if update.message else update.callback_query.message
AttributeError: 'CallbackContext' object has no attribute 'message'

Do you have any thoughts off the top of your head? Any guidance is appreciated.

Thanks!

I have a solution for you ...
There is two commits to align with version 13.5 of telegrambot
Align telebot with python-telegram-bot v. 13.5 and fix rare empty
Align telebot with python-telegram-bot v. 13.5 - one more fix

@issmirnov
Copy link

Thank you!!

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

Successfully merging this pull request may close these issues.

2 participants