Python библиотека для ботов AxisMessenger (официальный API)
Project description
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
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
axisbot-0.1.0.tar.gz
(2.1 kB
view details)
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 axisbot-0.1.0.tar.gz.
File metadata
- Download URL: axisbot-0.1.0.tar.gz
- Upload date:
- Size: 2.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e949bac14505f38dc57a04bfcb7d17e0c85b7cfee0cbb0640ae17299b6dad3e
|
|
| MD5 |
3da1de7828740dbb8d8a4777272ef02e
|
|
| BLAKE2b-256 |
603d213a66a86814abbaafce46222a1ccb34f6a9bb4103822c64d49bcb51b0f2
|
File details
Details for the file axisbot-0.1.0-py3-none-any.whl.
File metadata
- Download URL: axisbot-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec8a75dccd62bfbf312f10b247a69396d5794eca8a99cbf28e959c201324cbbf
|
|
| MD5 |
2022f683d1aafc3a412d50ea6e8f1181
|
|
| BLAKE2b-256 |
6a696d9775a761de5b1f87d92126ddd0a9a96b854d503c045d42fdf36411e2e7
|