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()
  • 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.4.tar.gz (33.8 kB view details)

Uploaded Source

Built Distribution

django_oscarbot-0.4-py3-none-any.whl (48.1 kB view details)

Uploaded Python 3

File details

Details for the file django-oscarbot-0.4.tar.gz.

File metadata

  • Download URL: django-oscarbot-0.4.tar.gz
  • Upload date:
  • Size: 33.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.4.tar.gz
Algorithm Hash digest
SHA256 23e7edee9638dae36beff8a06e6cc8814c977ac28208f352f4a753b0cb83e9f9
MD5 42c6a4f81e156cefce5226db8b40ff5e
BLAKE2b-256 5b197dcfcb5149a83967e4282652a4a36b5d9c915ba83d22e9f7b3c55c33afc6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_oscarbot-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 74bd1ef848907c5a72b5c5a864932a42bf1debc5ac4fdff77d3790972450a0c6
MD5 8c575220f393b22cbc88cf73adcc9509
BLAKE2b-256 1d4a8a3dd7d586a52cea265da6ef051b3fa4fffb5cdf1ee11b4c1711fa11d876

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