{"id":13764671,"url":"https://github.com/jlmadurga/django-telegram-bot","last_synced_at":"2025-04-06T20:12:41.925Z","repository":{"id":53670494,"uuid":"50352758","full_name":"jlmadurga/django-telegram-bot","owner":"jlmadurga","description":"Django app to write Telegram bots. Just define commands and how to handle them.","archived":false,"fork":false,"pushed_at":"2022-12-26T20:23:19.000Z","size":92,"stargazers_count":143,"open_issues_count":22,"forks_count":45,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-30T19:08:45.153Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jlmadurga.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.rst","contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-25T13:38:05.000Z","updated_at":"2025-03-23T06:58:44.000Z","dependencies_parsed_at":"2023-01-31T01:15:16.168Z","dependency_job_id":null,"html_url":"https://github.com/jlmadurga/django-telegram-bot","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jlmadurga%2Fdjango-telegram-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jlmadurga%2Fdjango-telegram-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jlmadurga%2Fdjango-telegram-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jlmadurga%2Fdjango-telegram-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jlmadurga","download_url":"https://codeload.github.com/jlmadurga/django-telegram-bot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247543593,"owners_count":20955865,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T16:00:25.230Z","updated_at":"2025-04-06T20:12:41.896Z","avatar_url":"https://github.com/jlmadurga.png","language":"Python","funding_links":[],"categories":["Bots","一般机器人（bots）"],"sub_categories":["Bot Libs","机器人类库"],"readme":"=============================\ndjango-telegram-bot\n=============================\nCI:\n\n.. image:: https://travis-ci.org/jlmadurga/django-telegram-bot.svg?branch=master\n    :target: https://travis-ci.org/jlmadurga/django-telegram-bot\n\n.. image:: https://coveralls.io/repos/github/jlmadurga/django-telegram-bot/badge.svg?branch=master \n\t:target: https://coveralls.io/github/jlmadurga/django-telegram-bot?branch=master\n  \n.. image:: https://requires.io/github/jlmadurga/django-telegram-bot/requirements.svg?branch=master\n     :target: https://requires.io/github/jlmadurga/django-telegram-bot/requirements/?branch=master\n     :alt: Requirements Status\n     \nPyPI:\n\n\n.. image:: https://img.shields.io/pypi/v/django-telegram-bot.svg\n        :target: https://pypi.python.org/pypi/django-telegram-bot\n\nDocs:\n\n.. image:: https://readthedocs.org/projects/django-telegram-bot/badge/?version=latest\n        :target: https://readthedocs.org/projects/django-telegram-bot/?badge=latest\n        :alt: Documentation Status\n\nDjango app to write Telegram bots. Just define commands and how to handle them.\n\n**Try Permabots**: more stable django app for bots https://github.com/jlmadurga/permabots\n\nNOTE: Just for text messages at this moment.\n\nDocumentation\n-------------\n\nThe full documentation is at https://django-telegram-bot.readthedocs.org.\n\nTelegram API documentation at https://core.telegram.org/bots/api\n\nQuickstart\n----------\n\nInstall django-telegram-bot::\n\n    pip install django-telegram-bot\n    \nAdd ``telegrambot`` and ``rest_framework`` to your ``INSTALLED_APPS``, and run::\n\n\t$ python manage.py migrate\n\t\n\nAfter creating a bot in Telegram Platform, create at least one bot with django admin. Token is the only\nrequired field. You may need to provided public key certificate for your server. https://core.telegram.org/bots/self-signed\nHeroku has https and ssl by default so it is a good option if you dont want to deal with that.\n\nAdd webhook url to your urlpatterns::\n\n\turl(r'^telegrambot/', include('telegrambot.urls', namespace=\"telegrambot\")),\t\n\nDefine the file where commands will be defined in ``urlpatterns`` variable, analogue to django ``urls``\nand ``ROOT_URLCONF``::\n\n\tTELEGRAM_BOT_HANDLERS_CONF = \"app.handlers\"\n\t\nSet bot commands handlers is very easy just as defining `urls` in django. Module with ``urlpatterns`` that list \ndifferent handlers. You can `regex` directly or use shortcuts like `command` or `unknown_command` ::\n\n\turlpatterns = [command('start', StartView.as_command_view()),\n               \t   command('author', AuthorCommandView.as_command_view()),\n               \t   command('author_inverse', AuthorInverseListView.as_command_view()),\n                   command('author_query', login_required(AuthorCommandQueryView.as_command_view())),\n                   unknown_command(UnknownView.as_command_view()),\n                   regex(r'author_(?P\u003cname\u003e\\w+)', AuthorName.as_command_view()),\n                  ]\n\nTo set the webhook for telegram you need ``django.contrib.sites`` installed, ``SITE_ID`` configured \nin settings and with it correct value in the DB. The webhook for each bot is set when a Bot is saved and \n``enabled`` field is set to true.\n\t\nBot views responses with Telegram messages to the user who send the command with a text message and keyboard.\nCompound with a context and a template. The way it is handled is analogue to Django views.  Visits docs for more \ndetails https://django-telegram-bot.readthedocs.io/en/latest/usage.html\n\n\nFeatures\n--------\n\n* Multiple bots\n* Message handling definition.\n* Authentication\n* Text responses and keyboards. \n* Media messages not supported.\n* Only Markup parse mode.\n\n.. image:: https://raw.github.com/jlmadurga/django-oscar-telegram-bot/master/docs/imgs/list_commands.png\n\n.. image:: https://raw.github.com/jlmadurga/django-oscar-telegram-bot/master/docs/imgs/categories.png\n\nRunning Tests\n--------------\n\nDoes the code actually work?\n\n::\n\n    source \u003cYOURVIRTUALENV\u003e/bin/activate\n    (myenv) $ pip install -r requirements/test.txt\n    (myenv) $ make test\n    (myenv) $ make test-all\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjlmadurga%2Fdjango-telegram-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjlmadurga%2Fdjango-telegram-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjlmadurga%2Fdjango-telegram-bot/lists"}