Проста бібліотека для створення Telegram ботів для навчання
Project description
BendBandBot
Проста бібліотека для створення Telegram ботів, спеціально розроблена для навчання школярів програмуванню.
Особливості
- ✅ Просто - без декораторів, async/await, складних конструкцій
- ✅ Зрозуміло - коментарі українською, зрозумілі назви методів
- ✅ Для початківців - підходить для учнів 6-9 класів
- ✅ Два режими - прості команди з текстом або функції для складнішої логіки
Встановлення
pip install bendbandbot
Швидкий старт
from bendbandbot import SimpleBot
# Створюємо бота
bot = SimpleBot("ВАШ_ТОКЕН_ВІД_BOTFATHER")
# Додаємо команди (простий спосіб)
bot.on_command("start", "Привіт! 👋")
bot.on_command("help", "Я простий бот!")
# Запускаємо
bot.start()
Приклад з функціями
from bendbandbot 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 для навчання школярів програмуванню
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bendbandbot-1.0.2.tar.gz.
File metadata
- Download URL: bendbandbot-1.0.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19f1d521e38e10817f5818a38f89915a2f25e87889e1ff5a534278cbbb6eefc5
|
|
| MD5 |
01855e929a2cb70044605c4f14fc354f
|
|
| BLAKE2b-256 |
dfaddd5dd1b0cdfa84610d409d8bf041e0addac74b3589c39f5bb458d2f77d8f
|
File details
Details for the file bendbandbot-1.0.2-py3-none-any.whl.
File metadata
- Download URL: bendbandbot-1.0.2-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c52af7ebd5e54a13a444c98499f68a175ade0d0aaed7606b2beec9f9ff981c79
|
|
| MD5 |
873d5edd1999b16e7fdb885de67f670c
|
|
| BLAKE2b-256 |
f6d98b47df753273f47c432d7822b4e178e39f74a7b79ba6e6405ba469cfa080
|