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.57.tar.gz (47.8 kB view details)

Uploaded Source

Built Distribution

django_oscarbot-0.57-py3-none-any.whl (70.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_oscarbot-0.57.tar.gz
  • Upload date:
  • Size: 47.8 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.57.tar.gz
Algorithm Hash digest
SHA256 044da336fcec1d0ab381528e389f4c7e43eb482c859b2e18599d5ecb77db94c2
MD5 e1f6f925b69c50bd6f04b09510d888d9
BLAKE2b-256 10574a3ef9ac61d0f6c7e6b8325d171f5c7f76c17f021a7a14dc540c0e6d29b5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_oscarbot-0.57-py3-none-any.whl
Algorithm Hash digest
SHA256 2f4d316f7efb6167dda7a9585fa2fc6d9d7d0017afdba87b7a50d139a55c75d1
MD5 50cf277161364e2b718dfb0900ad51ab
BLAKE2b-256 b1f5f6ab1c4d457b1095cc6fef92dbe6d2150eeb50fa95842b425581e906176e

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