mitshel / sopds

Simple opds catalog
http://www.sopds.ru/
Other
210 stars 79 forks source link

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

Open PeterVoronov opened 3 years ago

PeterVoronov commented 3 years ago

[] 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 commented 3 years ago

Does this solve the download issue?

PeterVoronov commented 3 years ago

Does this solve the download issue?

For me - yes

issmirnov commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

Thank you!!