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

Uploaded Source

Built Distribution

django_oscarbot-0.58-py3-none-any.whl (71.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_oscarbot-0.58.tar.gz
  • Upload date:
  • Size: 48.3 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.58.tar.gz
Algorithm Hash digest
SHA256 29c44559ea40b941cee2969e583d368b8ef872d70312bc32cb6a27615a5a5c3c
MD5 68c4dbb36635880528a16f813ef46c2a
BLAKE2b-256 055af298f99fea404ef36daf8110a8096e0db2c3cf0dd194c3f6fb4515046527

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_oscarbot-0.58-py3-none-any.whl
Algorithm Hash digest
SHA256 8ea50bfaf7db47bb306b923999f45dfc827835cd1e16c42f3a8c4b0adcd058f4
MD5 4bee9c9c31f93c94a770ce471b7fefd1
BLAKE2b-256 dc61f72f1ef8d09f3ad53e131f63db7e87d7c8c2e435a79aa88b6c9030ee422f

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