Django Telegram bot base config
Project description
django-tbot-base
Django Telegram bot base config
Installation:
pip install django-tbot-base
Setting up
YourProject/settings.py
# Application definition
INSTALLED_APPS = [
'tbot_base',
...
]
# Add your bot handlers in order of priority
BOT_HANDLERS = [
'tbot.handlers',
]
YourProject/urls.py
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('tbot_base.urls')), # include webhook url
]
python manage.py makemigrations tbot_base
python manage.py migrate
Usage
Handlers
YourProject/tbot/handlers.py
from telebot import types
from telebot.apihelper import ApiTelegramException
from tbot_base.bot import tbot
@tbot.message_handler(func=lambda message: True)
def text_messages(message: types.Message):
tbot.send_message(message.from_user.id, 'Hello!')
@tbot.callback_query_handler(func=lambda call: True)
def callback_inline(call: types.CallbackQuery):
tbot.send_message(call.from_user.id, 'Hello!')
# remove the "clock" on the inline button
try:
tbot.answer_callback_query(callback_query_id=call.id, text='')
except ApiTelegramException:
pass
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-tbot-base-1.0.1.tar.gz
.
File metadata
- Download URL: django-tbot-base-1.0.1.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9edd4244d9f34e28452f4c51ef105c57d5037d61d57ee446feeb94c3c6e64d6a |
|
MD5 | 0f94ac88cebdfe937644702b2cb032f6 |
|
BLAKE2b-256 | cb18fd7dbcb8e9f2f5c7936d0823592931d340578db4d7175f81e0a49f9de38c |
File details
Details for the file django_tbot_base-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: django_tbot_base-1.0.1-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6abfdf796623cfbcb137f1b7c21c6b10259a9577c410748b6c237d046e21ebf |
|
MD5 | cef5d5f888514c685d237e661267242c |
|
BLAKE2b-256 | 5b99985bc9923c083a779cfe59ae8dc4c20c26faaf4c790bc3eae543a5325e90 |