Skip to main content

Python client for the Ashur bot API

Project description

AshurBot Python Client Library

A Python client for the Ashur bot API. This library allows you to interact with your Ashur bot using Python.

Installation

pip install requests flask

Copy the ashurbot directory into your project or install as a package (if published).

Usage

from ashurbot.client import AshurBotClient

client = AshurBotClient(
    bot_token="YOUR_BOT_TOKEN",
    bot_secret="YOUR_BOT_SECRET"
    # api_base_url is optional and defaults to https://ashurbots.vercel.app
)

# Send a message
client.send_message(target="user_or_group_id", message="Hello!")

# Read messages
messages = client.read_messages(target="user_or_group_id")

# Webhook example
# You must set your bot's webhook URL to your server's public address + /webhook

def handle_event(event):
    print("Received webhook event:", event)
    # Do stuff with the event dict

client.on_webhook(handle_event)  # Starts a Flask server on http://0.0.0.0:8080/webhook

Supported Methods

  • send_message(target, message)
  • read_messages(target, limit=20)
  • edit_message(target, message_id, new_text)
  • delete_message(target, message_id)
  • reply_to(target, message, reply_to_id)
  • get_bot_info()
  • update_bot_profile(name=None, pic=None, bio=None, webhook_url=None)
  • list_chats()
  • get_chat_info(chat_id, is_group=False)
  • list_group_members(group_id)
  • add_group_member(group_id, user_id)
  • remove_group_member(group_id, user_id)
  • pin_message(target, message_id, is_group=False)
  • unpin_message(target, message_id, is_group=False)
  • set_chat_title(group_id, name)
  • set_group_photo(group_id, pic)
  • leave_chat(target, is_group=False)
  • get_message_by_id(target, message_id, is_group=False)
  • forward_message(from_target, message_id, to_target, from_is_group=False, to_is_group=False)
  • get_bot_stats()
  • on_webhook(handler, host="0.0.0.0", port=8080, path="/webhook") — Start a Flask server to receive webhook events

Requirements

  • Python 3.7+
  • requests library
  • flask library (for webhook server)

License

AGPL-3.0

Publishing to PyPI

  1. Update your metadata in pyproject.toml (name, version, description, authors, license, etc.).
  2. Build the package:
    cd ashurbot
    python3 -m pip install --upgrade build
    python3 -m build
    
    This will create a dist/ directory with .tar.gz and .whl files.
  3. Register an account on PyPI if you haven't already.
  4. Install Twine:
    python3 -m pip install --upgrade twine
    
  5. Upload your package:
    python3 -m twine upload dist/*
    
    Enter your PyPI username and password when prompted.
  6. Install your package:
    pip install ashur
    

See the PyPI packaging guide for more details.

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

ashur-0.1.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

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

ashur-0.1.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ashur-0.1.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for ashur-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bbda2c86ba81ca66737b362f70e8e22479242ef761b115683fb226c88e31caee
MD5 a73030e1bc903535552992d565405075
BLAKE2b-256 1e8b992e025453f15844bb93522f5d991cef134008d172f5d01478b7d702fd32

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ashur-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for ashur-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bc661046d645f1a4bd9c9e06bdfc7302ce61718a452fd5f6488fc9d61bd6dec4
MD5 9a5de109b4df60e00781120a88ca8e67
BLAKE2b-256 d2db5f8ad63cba424602698adcee958479befa82dc1b70a115a14bbc56675159

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