Git Product home page Git Product logo

django-telegrambot's Introduction

django-telegrambot

https://badge.fury.io/py/django-telegrambot.png https://travis-ci.org/JungDev/django-telegrambot.png?branch=master http://pepy.tech/badge/django-telegrambot

A simple app to develop Telegram bots with Django

Documentation

The full documentation is at https://django-telegrambot.readthedocs.org.

If this project help you reduce time to develop, you can give me a cup of coffee :)

https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif

Changelog

  • IMPORTANT ver 1.0.0 : If you upgrade from a previous version, you MUST change how to include django_telegrambot.urls and modify your settings.py.

Quickstart

Install django-telegrambot:

pip install django-telegrambot

Configure your installation

Add django_telegrambot in INSTALLED_APPS

#settings.py
INSTALLED_APPS = (
    ...
    'django_telegrambot',
    ...
)

And set your bots:

#settings.py
#Django Telegram Bot settings

DJANGO_TELEGRAMBOT = {

    'MODE' : 'WEBHOOK', #(Optional [str]) # The default value is WEBHOOK,
                        # otherwise you may use 'POLLING'
                        # NB: if use polling you must provide to run
                        # a management command that starts a worker

    'WEBHOOK_SITE' : 'https://mywebsite.com',
    'WEBHOOK_PREFIX' : '/prefix', # (Optional[str]) # If this value is specified,
                                  # a prefix is added to webhook url

    #'WEBHOOK_CERTIFICATE' : 'cert.pem', # If your site use self-signed
                         #certificate, must be set with location of your public key
                         #certificate.(More info at https://core.telegram.org/bots/self-signed )

    'STRICT_INIT': True, # If set to True, the server will fail to start if some of the
                         # apps contain telegrambot.py files that cannot be successfully
                         # imported.

    'BOTS' : [
        {
           'TOKEN': '123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11', #Your bot token.

           #'ALLOWED_UPDATES':(Optional[list[str]]), # List the types of
                                                   #updates you want your bot to receive. For example, specify
                                                   #``["message", "edited_channel_post", "callback_query"]`` to
                                                   #only receive updates of these types. See ``telegram.Update``
                                                   #for a complete list of available update types.
                                                   #Specify an empty list to receive all updates regardless of type
                                                   #(default). If not specified, the previous setting will be used.
                                                   #Please note that this parameter doesn't affect updates created
                                                   #before the call to the setWebhook, so unwanted updates may be
                                                   #received for a short period of time.

           #'TIMEOUT':(Optional[int|float]), # If this value is specified,
                                   #use it as the read timeout from the server

           #'WEBHOOK_MAX_CONNECTIONS':(Optional[int]), # Maximum allowed number of
                                   #simultaneous HTTPS connections to the webhook for update
                                   #delivery, 1-100. Defaults to 40. Use lower values to limit the
                                   #load on your bot's server, and higher values to increase your
                                   #bot's throughput.

           # 'MESSAGEQUEUE_ENABLED':(Optinal[bool]), # Make this True if you want to use messagequeue

           # 'MESSAGEQUEUE_ALL_BURST_LIMIT':(Optional[int]), # If not provided 29 is the default value

           # 'MESSAGEQUEUE_ALL_TIME_LIMIT_MS':(Optional[int]), # If not provided 1024 is the default value

           # 'MESSAGEQUEUE_REQUEST_CON_POOL_SIZE':(Optional[int]), # If not provided 8 is the default value

           #'POLL_INTERVAL' : (Optional[float]), # Time to wait between polling updates from Telegram in
                           #seconds. Default is 0.0

           #'POLL_CLEAN':(Optional[bool]), # Whether to clean any pending updates on Telegram servers before
                                   #actually starting to poll. Default is False.

           #'POLL_BOOTSTRAP_RETRIES':(Optional[int]), # Whether the bootstrapping phase of the `Updater`
                                   #will retry on failures on the Telegram server.
                                   #|   < 0 - retry indefinitely
                                   #|     0 - no retries (default)
                                   #|   > 0 - retry up to X times

           #'POLL_READ_LATENCY':(Optional[float|int]), # Grace time in seconds for receiving the reply from
                                   #server. Will be added to the `timeout` value and used as the read timeout from
                           #server (Default: 2).
        },
        #Other bots here with same structure.
    ],

}

Include in your urls.py the django_telegrambot.urls (NB: If you upgrade from a previous version, you MUST change how to include django_telegrambot.urls. Never set prefix here!):

#urls.py
urlpatterns = [
    ...
    url(r'^', include('django_telegrambot.urls')),
    ...
]

Then use it in a project creating a module telegrambot.py in your app

#myapp/telegrambot.py
# Example code for telegrambot.py module
from telegram.ext import CommandHandler, MessageHandler, Filters
from django_telegrambot.apps import DjangoTelegramBot

import logging
logger = logging.getLogger(__name__)


# Define a few command handlers. These usually take the two arguments bot and
# update. Error handlers also receive the raised TelegramError object in error.
def start(bot, update):
    bot.sendMessage(update.message.chat_id, text='Hi!')


def help(bot, update):
    bot.sendMessage(update.message.chat_id, text='Help!')


def echo(bot, update):
    bot.sendMessage(update.message.chat_id, text=update.message.text)


def error(bot, update, error):
    logger.warn('Update "%s" caused error "%s"' % (update, error))


def main():
    logger.info("Loading handlers for telegram bot")

    # Default dispatcher (this is related to the first bot in settings.DJANGO_TELEGRAMBOT['BOTS'])
    dp = DjangoTelegramBot.dispatcher
    # To get Dispatcher related to a specific bot
    # dp = DjangoTelegramBot.getDispatcher('BOT_n_token')     #get by bot token
    # dp = DjangoTelegramBot.getDispatcher('BOT_n_username')  #get by bot username

    # on different commands - answer in Telegram
    dp.add_handler(CommandHandler("start", start))
    dp.add_handler(CommandHandler("help", help))

    # on noncommand i.e message - echo the message on Telegram
    dp.add_handler(MessageHandler([Filters.text], echo))

    # log all errors
    dp.add_error_handler(error)

Features

  • Multiple bots

  • Admin dashboard available at /admin/django-telegrambot

  • Polling mode by management command (an easy to way to run bot in local machine, not recommended in production!)

    (myenv) $ python manage.py botpolling --username=<username_bot>

  • Supporting messagequeues

Contributing

Patches and bug reports are welcome, just please keep the style consistent with the original source.

Running Tests

Does the code actually work?

source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install -r requirements-test.txt
(myenv) $ python runtests.py

Sample Application

There a sample application in sampleproject directory. Here is installation instructions:

  1. Install requirements with command

    pip install -r requirements.txt

  2. Copy file local_settings.sample.py as local_settings.py and edit your bot token

    cp sampleproject/local_settings.sample.py sampleproject/local_settings.py

    nano sampleproject/local_settings.py

  3. Run Django migrations

    python manage.py migrate

  4. Run server

    python manage.py runserver

  5. If WEBHOOK Mode setted go to 8

  6. If POLLING Mode setted, open in your browser http://localhost/

  7. Open Django-Telegram Dashboard http://localhost/admin/django-telegrambot and follow instruction to run worker by management command botpolling. Then go to 10

  8. To test webhook locally install ngrok application and run command

    ./ngrok http 8000

  9. Change WEBHOOK_SITE and ALLOWED_HOSTS in local_settings.py file

  10. Start a chat with your bot using telegram.me link avaible in Django-Telegram Dashboard at http://localhost/admin/django-telegrambot

Credits

Required package:

Tools used in rendering this package:

django-telegrambot's People

Contributors

alistvt avatar jungdev avatar peleccom avatar rafis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-telegrambot's Issues

Request for not found token : `bot_token`

First, I should thank you for your great app. In polling mode on my local machine the module works like charm. However when I use the web hook mode, sometimes I get the

Request for not found token : bot_token

error and no response is given by the bot. I didn't setup the cert file in my settings.py . I am using nginx with combination of gunicorn to serve my web app. The server os is ubuntu 16.04. Below is the settings I've used:

DJANGO_TELEGRAMBOT = {
    'MODE' : 'WEBHOOK', #(Optional [str]) # The default value is WEBHOOK,
                        # otherwise you may use 'POLLING'
                        # NB: if use polling you must provide to run
                        # a management command that starts a worker
    'WEBHOOK_SITE' : 'https://www.shipup.ir',
    'WEBHOOK_PREFIX' : '/telegram-bot/', # (Optional[str]) # If this value is specified,
                                  # a prefix is added to webhook url
   # 'WEBHOOK_CERTIFICATE' : '', # If your site use self-signed
                         #certificate, must be set with location of your public key
                         #certificate.(More info at https://core.telegram.org/bots/self-signed )
    'BOTS' : [
        {
           'TOKEN': 'bot_token', #Your bot token.
        },
    ],
}

The thing that intrigues is the point that sometimes my bot works. Any advice to solve the issue is appreciated.

ImportError: cannot import name patterns on django_telegrambot\urls.py

I ran this after following the instructions:

(my project)\>py -2 manage.py check

and

(my project)\>py -3 manage.py check

And both got this error:

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "D:\Python27\lib\site-packages\django\core\management\__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "D:\Python27\lib\site-packages\django\core\management\__init__.py", line 359, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "D:\Python27\lib\site-packages\django\core\management\base.py", line 294, in run_from_argv
    self.execute(*args, **cmd_options)
  File "D:\Python27\lib\site-packages\django\core\management\base.py", line 345, in execute
    output = self.handle(*args, **options)
  File "D:\Python27\lib\site-packages\django\core\management\commands\check.py", line 68, in handle
    fail_level=getattr(checks, options['fail_level']),
  File "D:\Python27\lib\site-packages\django\core\management\base.py", line 374, in check
    include_deployment_checks=include_deployment_checks,
  File "D:\Python27\lib\site-packages\django\core\management\base.py", line 361, in _run_checks
    return checks.run_checks(**kwargs)
  File "D:\Python27\lib\site-packages\django\core\checks\registry.py", line 81, in run_checks
    new_errors = check(app_configs=app_configs)
  File "D:\Python27\lib\site-packages\django\core\checks\urls.py", line 14, in check_url_config
    return check_resolver(resolver)
  File "D:\Python27\lib\site-packages\django\core\checks\urls.py", line 24, in check_resolver
    for pattern in resolver.url_patterns:
  File "D:\Python27\lib\site-packages\django\utils\functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "D:\Python27\lib\site-packages\django\urls\resolvers.py", line 313, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "D:\Python27\lib\site-packages\django\utils\functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "D:\Python27\lib\site-packages\django\urls\resolvers.py", line 306, in urlconf_module
    return import_module(self.urlconf_name)
  File "D:\Python27\lib\importlib\__init__.py", line 37, in import_module
    __import__(name)
  File "(my project)\urls.py", line 23, in <module>
    url(r'^t/', include('django_telegrambot.urls')),
  File "D:\Python27\lib\site-packages\django\conf\urls\__init__.py", line 50, in include
    urlconf_module = import_module(urlconf_module)
  File "D:\Python27\lib\importlib\__init__.py", line 37, in import_module
    __import__(name)
  File "D:\Python27\lib\site-packages\django_telegrambot\urls.py", line 2, in <module>
    from django.conf.urls import url, include, patterns
ImportError: cannot import name patterns

on Windows 10 Pro x64
Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:38:48) [MSC v.1900 32 bit (Intel)]
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:40:30) [MSC v.1500 64 bit (AMD64)]

Sending message with bot

How to send message with bot without handler in this package?!

something just like this: bot.sendmessage().... bot out of any def!

telegram bot doesn't catch all forwarded messages

I use django-telegrambot package to make anti-spam telegram bot. The mode for the bot is WEBHOOK

I have some functionality to remove all forwarded messages from chat.

My code looks like:

if update.message.forward_from or update.message.forward_from_chat: bot.delete_message(chat_id=update.message.chat_id, message_id=update.message.message_id)

the code above doesn't work very well, for example when I select a few messages and send them to channel, it deletes only one(sometimes two) messages from forwarded set, sometimes it even doesn't delete if I forward one message, I checked if we always have forward_from and forward_from_chat when forwarding, yes -- we always have it, also I thought I just have some amount of pending_update_count, but it's 0

I know your django-telegrambot based on python-telegram-bot package when I have the same code using only python-telegram-bot and run it locally like python main.py it works perfect(catch and delete all forwarded messages)

Sorry if my question is not correct or is not related to your package, but maybe someone faced with such error here, or have any thinks/suggestions?

Thanks!

""

Hello I am using python telegram bot 10 and they added the argument in the updater to updater = Updater("TOKEN", use_context=True). This will be the default going forward. How do I add the argument in the module exist function

    def module_exists(module_name, method_name, execute):
        try:
            m = importlib.import_module(module_name)
            if execute and hasattr(m, method_name):
                logger.debug('Run {}.{}()'.format(module_name,method_name))
                getattr(m, method_name)()
            else:
                logger.debug('Run {}'.format(module_name))

        except ImportError as er:
            logger.debug('{} : {}'.format(module_name, repr(er)))
            return False

        return True

    # import telegram bot handlers for all INSTALLED_APPS
    for app_config in apps.get_app_configs():
        if module_has_submodule(app_config.module, TELEGRAM_BOT_MODULE_NAME):
            module_name = '%s.%s' % (app_config.name, TELEGRAM_BOT_MODULE_NAME)
            if module_exists(module_name, 'main', True):
                logger.info('Loaded {}'.format(module_name))

apps Error : RetryAfter()

I'm trying to use django-telegram bot but during the running phase I have this error frequently:

ERROR 2018-05-29 16:28:47,375 apps Error : RetryAfter()
after this message the system doesn't work, this is the message during the chat:

WARNING 2018-05-29 16:28:55,619 views Request for not found token : XXXXXXXXXXXXXX
[29/May/2018 16:28:55]"POST /prefix/XXXXXXXXXXXXXXXX/ HTTP/1.1" 200 2

The result is that I don't receive any message in telegram.

I think the problem is in the rapidly sequence of instruction in apps.py file during the setWebhook phase .
A possible solution that I finded is this:

setted = bot.setWebhook(hookurl, certificate=certificate, timeout=timeout, max_connections=max_connections, allowed_updates=allowed_updates)
time.sleep(5)
webhook_info = bot.getWebhookInfo()

I added to time.sleep function and now the system seems to work.

proxy

is there a way that I add a proxy to bot settings? it will be good if there is an option in settings that determines proxy settings.

Login detail to localhost/admin/django-telegrambot

I cannot find any information how to createsuperuser for django-telegrambot and enter the dashboard.

I'm trying to django-admin createsupeuser but it don't success

No Django settings specified.
Unknown command: 'createsuperuser'
Type 'django-admin help' for usage.

How can I specify login details and enter the django-telegrambot dashboard?

No module named 'telegram.ext'

Hi,

Whenever I try to run any project I get this error message:

  File "/home/laptop/.pyenv/versions/django-telegrambot/lib/python3.6/site-packages/django_telegrambot/apps.py", line 9, in <module>
    from telegram.ext import Dispatcher
ModuleNotFoundError: No module named 'telegram.ext'

Does django-telegrambot is outdated Or my settings are incorrect?

My Settings:

$ python --version
Python 3.6.9

$ pip list
Package             Version
------------------- ---------
asgiref             3.2.10
certifi             2020.6.20
cffi                1.14.0
cryptography        2.9.2
decorator           4.4.2
Django              3.0.7
django-telegrambot  1.0.1
djangorestframework 3.3.2
future              0.18.2
pip                 20.1.1
pkg-resources       0.0.0
pycparser           2.20
python-telegram-bot 3.2.0
pytz                2020.1
setuptools          39.0.1
six                 1.15.0
sqlparse            0.3.1
tornado             6.0.4

$ python manage.py runserver
Watching for file changes with StatReloader
INFO 2020-06-22 07:06:08,863 autoreload Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/home/laptop/.pyenv/versions/django-telegrambot/lib/python3.6/site-packages/django/utils/autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "/home/laptop/.pyenv/versions/django-telegrambot/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "/home/laptop/.pyenv/versions/django-telegrambot/lib/python3.6/site-packages/django/utils/autoreload.py", line 76, in raise_last_exception
    raise _exception[1]
  File "/home/laptop/.pyenv/versions/django-telegrambot/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
    autoreload.check_errors(django.setup)()
  File "/home/laptop/.pyenv/versions/django-telegrambot/lib/python3.6/site-packages/django/utils/autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "/home/laptop/.pyenv/versions/django-telegrambot/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/laptop/.pyenv/versions/django-telegrambot/lib/python3.6/site-packages/django/apps/registry.py", line 91, in populate
    app_config = AppConfig.create(entry)
  File "/home/laptop/.pyenv/versions/django-telegrambot/lib/python3.6/site-packages/django/apps/config.py", line 116, in create
    mod = import_module(mod_path)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/laptop/.pyenv/versions/django-telegrambot/lib/python3.6/site-packages/django_telegrambot/apps.py", line 9, in <module>
    from telegram.ext import Dispatcher
ModuleNotFoundError: No module named 'telegram.ext'

sampleproject not working

Every time I try to run sampleproject from the repository, the bot does not work.
The application starts, but the bot does not work.
If I change the code without shutting down, django will reread the files and the bot will start working.

I tried to call main() in wsgi.py, but only got an error: list index out of range
here: https://github.com/JungDev/django-telegrambot/blob/master/django_telegrambot/apps.py#L47

How to make the bot work at the start (after manage.py runserver)?

How to make bot conversations persistent

I want to my bot save its conversation handler states to Pickle and then deserialize on start.
Without Django-Telegrambot extension I solve this problem that way:

def main():
    dp = Dispatcher(bot, update_queue)
    
    load_data(dp, main_conv_handler)
    threading.Thread(target=save_data, args=(dp, main_conv_handler)).start()
    delete_webhook()
    start_webhook()
    add_handlers(dp)
    ....

But using Django-Telegrambot this way doesnt work. After every python manage.py ... operation console locks, I think because of Thread...

So what is the way to make bot persistent using this library?

Flood Error

Hi. Thanks for writing this module.
Everything seems to work fine for me from the cold start, so configured properly.
But even on first restart of the django debug server I'm expecting "telegram.error.RetryAfter: Flood control exceeded. Retry in 1 seconds".
I thought it was a problem when telegram routes webhook continuously untill 200 code is received. But even when I received all the messages and only then started again, I am expecting same error. The proper reference from the telegram API seems to be this . It takes about an hour till I can run bot again.
I am wondering how can I flood the telegram servers this way.

Also, UserWarning: telegram.dispatcher.addErrorHandler is being deprecated, please use telegram.dispatcher.add_error_handler from now.

start bot using proxy

how can I start the bot using a proxy, because I know that in the original python-telegram-bot package, the init method of the bot updaters can accept some request_kwargs where we can put proxies there.
I need this to run the bot locally.

Error: Old Handler API is deprecated

Hello!

Installed last version with config from example. On server reload got a message from python-telegram-bot:
TelegramDeprecationWarning: Old Handler API is deprecated - see https://git.io/fxJuV for details

Can you tell me, are you planning to fix this issue, or is there any other way to bypass this issue?

Thanks a lot for your answer and package!

Cannot find default bot with username username_of_my_bot

hello and thank you for your great job

I can work with this app with webhook method and it's working very well but i need to work with
polling method on my local app. then i went to my settings.py and changed MODE to POLLING
then i went to the root path and opened a terminal then i runed this command:
python manage.py botpolling --username konar19bot
but i get this error:
Cannot find default bot with username konar19bot Bot not found
but I an sure that there is a robot with this name I created it myself
and something wired is this message :
Required TELEGRAM_WEBHOOK_SITE missing in settings
why I have to difine TELEGRAM_WEBHOOK_SITE ? I don't want to set webhook. i just want to work with update method .

so can you tell where am I going wrong?
Do I have to do something more?

thank you

Should fail if app cannot be initalized

The app initializer catches all exceptions that happen during loading telegrambot modules in user apps, and only logs a debug message in case if import fails - until I looked at the source code, I had to spend more than an hour to understand what was happening.

I think this at least merits an error log message (ideally, the Django app shouldn't even start if there is an error during initialization, but that change may be backwards-incompatible).

Happy to submit a pull request if you agree.

AttributeError: 'list' object has no attribute 'data_filter'

 python manage.py runserver
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/Users/baltschun/opt/anaconda3/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/Users/baltschun/opt/anaconda3/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/baltschun/project/ananas/venv_attendance/lib/python3.8/site-packages/django/utils/autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "/Users/baltschun/project/ananas/venv_attendance/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "/Users/baltschun/project/ananas/venv_attendance/lib/python3.8/site-packages/django/utils/autoreload.py", line 76, in raise_last_exception
    raise _exception[1]
  File "/Users/baltschun/project/ananas/venv_attendance/lib/python3.8/site-packages/django/core/management/__init__.py", line 357, in execute
    autoreload.check_errors(django.setup)()
  File "/Users/baltschun/project/ananas/venv_attendance/lib/python3.8/site-packages/django/utils/autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "/Users/baltschun/project/ananas/venv_attendance/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Users/baltschun/project/ananas/venv_attendance/lib/python3.8/site-packages/django/apps/registry.py", line 122, in populate
    app_config.ready()
  File "/Users/baltschun/project/ananas/venv_attendance/lib/python3.8/site-packages/django_telegrambot/apps.py", line 230, in ready
    if module_exists(module_name, 'main', True):
  File "/Users/baltschun/project/ananas/venv_attendance/lib/python3.8/site-packages/django_telegrambot/apps.py", line 216, in module_exists
    getattr(m, method_name)()
  File "/Users/baltschun/project/ananas/private_web/app/app_attendance/telegrambot.py", line 45, in main
    dp.add_handler(MessageHandler([Filters.text], echo))
  File "/Users/baltschun/project/ananas/venv_attendance/lib/python3.8/site-packages/telegram/ext/messagehandler.py", line 150, in __init__
    self.filters = Filters.update & filters
  File "/Users/baltschun/project/ananas/venv_attendance/lib/python3.8/site-packages/telegram/ext/filters.py", line 121, in __and__
    return MergedFilter(self, and_filter=other)
  File "/Users/baltschun/project/ananas/venv_attendance/lib/python3.8/site-packages/telegram/ext/filters.py", line 255, in __init__
    and self.and_filter.data_filter
AttributeError: 'list' object has no attribute 'data_filter'

update url patterns

Django provided some new functionality for url patterns. Even if it's backward compatible, it would be nice to update it some when.
This is what djangos system check told me.

WARNINGS:
?: (urls.W002) Your URL pattern '/(?P<bot_token>.+?)/$' [name='webhook'] has a route beginning with a '/'. Remove this slash as it is unnecessary. If this pattern is targeted in an include(), ensure the include() pattern has a trailing '/'.

also update the include in the installation process.

job_queue is none when using webhook mode

Set pass_job_queue to true, my task can run normally in polling mode, but the job_queue passed in webhook mode is none.

django-telegrambot==1.0.1
python-telegram-bot==10.1.0

ALLOWED_UPDATES not working in WEBHOOK mode.

OS: Windows 10
using django-sslserver to run https server.(Not really related i think.)

i have 'ALLOWED_UPDATES': ['message'] but when i run the django app,and do webHookInfo , ALLOWED_UPDATES is not updated(its using the previous value).but it changes if i have a empty list,meaning it changes to "ALL" updates.
if i use POLLING mode,the allowed_updates get changed every time i run the app.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.