Skip to main content

axisbot — Python библиотека для ботов AxisMessenger

Установка

pip install axisbot  # (после публикации на PyPI)

Быстрый старт (polling)

from axisbot import AxisBot

bot = AxisBot("AxisBotABCDE:12345", base_url="https://your-messenger.com/api")

@bot.on_message
def handle_message(update):
    if "ping" in update.text:
        bot.send_message(update.chat_id, "pong!")
    else:
        bot.send_message(update.chat_id, f"Вы написали: {update.text}")

bot.polling()

Webhook-режим

from axisbot import AxisBot
from flask import Flask, request

bot = AxisBot("AxisBotABCDE:12345", base_url="https://your-messenger.com/api")
app = Flask(__name__)

@bot.on_message
def handle(update):
    bot.send_message(update.chat_id, "Webhook OK!")

@app.route("/webhook", methods=["POST"])
def webhook():
    bot.webhook_handler(request.json)
    return "ok"

if __name__ == "__main__":
    bot.set_webhook("https://your-server.com/webhook")
    app.run(port=8080)

Кнопки и вложения

from axisbot import AxisBot, MessageButton

bot = AxisBot("AxisBotABCDE:12345", base_url="https://your-messenger.com/api")

@bot.on_message
def handle(update):
    if update.text == "/buttons":
        buttons = [[MessageButton("Кнопка 1", "btn1"), MessageButton("Кнопка 2", "btn2")]]
        bot.send_message(update.chat_id, "Выберите:", buttons=buttons)
    elif update.button_data:
        bot.send_message(update.chat_id, f"Вы нажали: {update.button_data}")
    elif update.attachments:
        for att in update.attachments:
            bot.send_message(update.chat_id, f"Получен файл: {att.filename}")

bot.polling()

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

Лицензия

MIT

Metadata

Release files for axisbot 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for axisbot 0.1.0
File Size Uploaded
axisbot-0.1.0.tar.gz 2.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for axisbot 0.1.0
File Interpreter ABI Platform
axisbot-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 4.1 kB

Release files / axisbot-0.1.0.tar.gz

Download URL axisbot-0.1.0.tar.gz
Size 2.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2e949bac14505f38dc57a04bfcb7d17e0c85b7cfee0cbb0640ae17299b6dad3e
BLAKE2b-256 checksum
How to use checksums
603d213a66a86814abbaafce46222a1ccb34f6a9bb4103822c64d49bcb51b0f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.0

Release files / axisbot-0.1.0-py3-none-any.whl

Download URL axisbot-0.1.0-py3-none-any.whl
Size 2.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ec8a75dccd62bfbf312f10b247a69396d5794eca8a99cbf28e959c201324cbbf
BLAKE2b-256 checksum
How to use checksums
6a696d9775a761de5b1f87d92126ddd0a9a96b854d503c045d42fdf36411e2e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page