Skip to main content

Library for Collaps Chat bots (Telegram-style), pure stdlib

Project description

collaps-bot

Библиотека для ботов Collaps Chat — в стиле python-telegram-bot, без зависимостей (только стандартная библиотека Python 3).

Установка

pip install collaps-bot

Быстрый старт

Токен берётся в BotFather (botfather.html), формат <botId>:<secret>.

from collaps_bot import CollapsBot

bot = CollapsBot("ВСТАВЬ_ТОКЕН")

@bot.command("start")
def start(u):
    u.reply("Привет! Я бот на Python 🐍")

@bot.command("help")
def help_cmd(u):
    u.reply("Команды: /start /help /echo")

@bot.command("echo")
def echo_cmd(u):
    u.reply(" ".join(u.args) or "Напишите текст после /echo")

@bot.message
def fallback(u):
    u.reply("Вы написали: " + u.text)

bot.run()

API

  • CollapsBot(token, db_url=..., poll_interval=2.0)
  • @bot.command("name") — обработчик команды /name
  • @bot.message — обработчик остальных сообщений
  • bot.send_message(chat_id, text)
  • bot.run() — запуск polling-цикла
  • в обработчике доступны: u.text, u.args, u.command, u.sender_id, u.sender_name, u.chat_id, u.reply(...)

Лицензия

MIT

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

collaps_bot-0.1.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

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

collaps_bot-0.1.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file collaps_bot-0.1.0.tar.gz.

File metadata

  • Download URL: collaps_bot-0.1.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for collaps_bot-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9289622f93de71350af179ebf267e6e5796e2af852ccf09ae6c6b4144aeece83
MD5 1933e23135a3b531f83a3c0ba910e5e1
BLAKE2b-256 9a9e29c23df108dc0d2406255008764b6bc46025c2d121c1fa145c7cc26e8f9d

See more details on using hashes here.

File details

Details for the file collaps_bot-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: collaps_bot-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for collaps_bot-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 56e18fc53fb50f641370e98db17bc355d781969a768a4aa0d54754071c61f59b
MD5 9f8f886c53c95050aa324bcec9f4d25c
BLAKE2b-256 1550c21daadfd5bfde96e6f8223e7ee8c4e97ef53921033691d6f74fa15ca01f

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