Skip to main content

Проста бібліотека для створення Telegram ботів для навчання

Project description

BendBandBot

Проста бібліотека для створення Telegram ботів, спеціально розроблена для навчання школярів програмуванню.

Особливості

  • Просто - без декораторів, async/await, складних конструкцій
  • Зрозуміло - коментарі українською, зрозумілі назви методів
  • Для початківців - підходить для учнів 6-9 класів
  • Два режими - прості команди з текстом або функції для складнішої логіки

Встановлення

pip install bendbandbot

Швидкий старт

from simple_bot import SimpleBot

# Створюємо бота
bot = SimpleBot("ВАШ_ТОКЕН_ВІД_BOTFATHER")

# Додаємо команди (простий спосіб)
bot.on_command("start", "Привіт! 👋")
bot.on_command("help", "Я простий бот!")

# Запускаємо
bot.start()

Приклад з функціями

from simple_bot import SimpleBot

bot = SimpleBot("ВАШ_ТОКЕН")

def greeting(message):
    name = bot.get_name(message)
    bot.send(message, f"Привіт, {name}! 😊")

bot.on_command("start", greeting)
bot.start()

Документація

Повний курс з 14 уроків: bendband.net/bot-course

API

Створення бота

bot = SimpleBot(token: str)

Команди

# Простий спосіб - тільки текст
bot.on_command("start", "Привіт!")

# Складніший - з функцією
def hello(message):
    bot.send(message, "Привіт!")
bot.on_command("start", hello)

Отримання даних

text = bot.get_text(message)  # Текст повідомлення
name = bot.get_name(message)  # Ім'я користувача

Надсилання

bot.send(message, "Текст")
bot.send_photo(message, "photo.jpg", "Підпис")

Обробка повідомлень

def echo(message):
    text = bot.get_text(message)
    bot.send(message, text)

bot.on_message(echo)

Приклади

Калькулятор

def calculate(message):
    text = bot.get_text(message)
    parts = text.split()
    
    if len(parts) == 3:
        num1 = float(parts[0])
        op = parts[1]
        num2 = float(parts[2])
        
        if op == "+":
            result = num1 + num2
        elif op == "-":
            result = num1 - num2
        elif op == "*":
            result = num1 * num2
        elif op == "/":
            result = num1 / num2 if num2 != 0 else "Помилка"
        
        bot.send(message, f"= {result}")

bot.on_message(calculate)

Випадковий вибір

import random

jokes = ["Жарт 1", "Жарт 2", "Жарт 3"]

def joke(message):
    bot.send(message, random.choice(jokes))

bot.on_command("joke", joke)

Ліцензія

MIT License - вільно для навчальних цілей

Автор

Створено bendband для навчання школярів програмуванню

🌐 https://bendband.net

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

bendbandbot-1.0.0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bendbandbot-1.0.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file bendbandbot-1.0.0.tar.gz.

File metadata

  • Download URL: bendbandbot-1.0.0.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for bendbandbot-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ed8662cd23169728dd5237a6e841c34cd7f906c863c1bb397017bad7d6177211
MD5 79eedd1292475ce06b630ebe5763aad6
BLAKE2b-256 1c727ae6c3a0e10080b354918e857d0b184b2a0a5aa02ca561f500113cf2e501

See more details on using hashes here.

File details

Details for the file bendbandbot-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: bendbandbot-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for bendbandbot-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fe24498a69d923a5d7b902b3a4e570a3efd6426e170f22dee6c7691cda62531f
MD5 d96d139aae4ef0cd72ca2f4905451bec
BLAKE2b-256 47a42612a753f297b9141129bc66b491423f6010f25e783b0038b54176e8a277

See more details on using hashes here.

Supported by

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