JungDev / django-telegrambot

Simple app for Telegram bot in Django
BSD 3-Clause "New" or "Revised" License
237 stars 88 forks source link

add context based handlers for ptb12 #37

Closed lukruh closed 2 years ago

lukruh commented 4 years ago

I just added the use_context parameter to the creation of the Updater, to be able to use the new handlerfunc(update, context) style. The bool variable is read from the bots config in settings.py

DJANGO_TELEGRAMBOT = {
    ...
    'BOTS' : [
        {
           'TOKEN': xxx',
           'CONTEXT': True, # pass context to handler fucntions func(update, context)
          ...

If not set it stays False, which is also the default if no use_context is given. So this should be downwards compatible, at least for older bot code. The kwarg probably raise an error for older ptb versions. Howerver, should be easy to except that case and adjust the example project. Let me know when you want me to do that.

codecov-io commented 4 years ago

Codecov Report

Merging #37 into master will increase coverage by 0.17%. The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #37      +/-   ##
==========================================
+ Coverage   41.84%   42.02%   +0.17%     
==========================================
  Files           9        9              
  Lines         325      326       +1     
==========================================
+ Hits          136      137       +1     
  Misses        189      189
Impacted Files Coverage Δ
django_telegrambot/apps.py 52.26% <66.66%> (+0.24%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 55aa268...332a828. Read the comment docs.

lukruh commented 2 years ago

closing due to inactivity