Skip to main content

Django app for create Telegram bot

Project description

TG Core from Oscar

Telegram bot core only for webhooks way working

Telegram bot core, created in django style with routing and views(handlers) where you can use included builders for menu or messages

Installing / Getting started

This is package only for using with Django project.

pip install django-oscarbot

Initial Configuration

In settings.py file you need to specify application for tg use:

OSCARBOT_APPS = ['main']

# set Telegram api url in your env variables TELEGRAM_URL
# set Telegram message parse mode:
TELEGRAM_PARSE_MODE = 'HTML'
# or
TELEGRAM_PARSE_MODE = 'MARKDOWN'

Run django server and open localhost:8000/admin/ and create new bot, at least fill bot token for testing ability

Features

  • User model
from oscarbot.models import User

some_user = User.objects.filter(username='@maslov_oa').first()
  • Menu and Buttons builder
from oscarbot.menu import Menu, Button


button_list = [
    Button(text='Text for callback', callback='/some_callback/'),
    Button(text='Text for external url', url='https://oscarbot.site/'),
    Button(text='Web app view', web_app='https://oscarbot.site/'),
]

menu = Menu(button_list)
  • Message builder
from oscarbot.shortcut import QuickBot

quick_bot = QuickBot(
    chat=111111111,
    message='Hello from command line',
    token='token can be saved in DB and not required'
)
quick_bot.send()
  • Application with routing and views(handlers):

    example application

  • Long polling server for testing

python manage.py runbot
  • Update messages available
# TODO: work in progress
  • Messages log
# TODO: work in progress

Links

Licensing

The code in this project is licensed under MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_oscarbot-0.54.tar.gz (47.5 kB view details)

Uploaded Source

Built Distribution

django_oscarbot-0.54-py3-none-any.whl (70.0 kB view details)

Uploaded Python 3

File details

Details for the file django_oscarbot-0.54.tar.gz.

File metadata

  • Download URL: django_oscarbot-0.54.tar.gz
  • Upload date:
  • Size: 47.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for django_oscarbot-0.54.tar.gz
Algorithm Hash digest
SHA256 3810aa0d8b9903d050042f8ba99be13cd48a6de5b811e369a4539ca999e034e6
MD5 4c5ea3d4ba3fd29b0c5681b3e4504ab8
BLAKE2b-256 a8ee5eaecfe58cd89a95000b7d6753f028269a8e10899550f6a8b75113917e37

See more details on using hashes here.

File details

Details for the file django_oscarbot-0.54-py3-none-any.whl.

File metadata

File hashes

Hashes for django_oscarbot-0.54-py3-none-any.whl
Algorithm Hash digest
SHA256 7845a0846963a3463741e2f291e13a25113a4eac38b7ef436e0e050337abe1a3
MD5 f92b05f784296a78dc39e79234616294
BLAKE2b-256 44fcdbe713a5104615d58151955210a2168a1de27cdb2bc3117a1e277f640df9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page