Metadata-Version: 2.4
Name: xc-bot
Version: 1.1.0
Summary: Python SDK for XaneoConnect Bot API
Author: Xaneo Team
Author-email: Xaneo Team <ltpddwk@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/saneome2/xc-bot
Project-URL: Documentation, https://xaneo.com/bot-api
Project-URL: Repository, https://github.com/saneome2/xc-bot
Keywords: xaneo,bot,api,sdk,async
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Framework :: AsyncIO
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: aiohttp>=3.8.0
Requires-Dist: grpcio>=1.60.0
Requires-Dist: protobuf>=4.25.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
Requires-Dist: aioresponses>=0.7.0; extra == "dev"
Requires-Dist: aiohttp<3.14.0,>=3.8.0; extra == "dev"
Requires-Dist: black>=23.0.0; extra == "dev"
Requires-Dist: mypy>=1.0.0; extra == "dev"
Dynamic: author
Dynamic: license-file
Dynamic: requires-python

# xc-bot

Python SDK for XaneoConnect Bot API

## Installation

```bash
pip install xc-bot
```

## Quick Start

```python
from xc_bot import Bot, InlineKeyboardButton, InlineKeyboardMarkup

bot = Bot("xbot_12345_abc...")

@bot.command('start')
async def start(message):
    keyboard = InlineKeyboardMarkup([[
        InlineKeyboardButton("Confirm", callback_data="confirm", color="#2E9D68"),
        InlineKeyboardButton("Website", url="https://xaneo.com", color="#335C91"),
    ]])
    await message.reply("Choose an action", reply_markup=keyboard)

@bot.callback_query(r"^confirm$")
async def confirm(query):
    await query.answer("Confirmed")

bot.run()
```

## Features

- Async-only API (Python 3.8+)
- Decorator-based handlers: `@bot.command()`, `@bot.hears()`, `@bot.message()`
- Message object with `.reply()`, `.edit()`, `.delete()` methods
- Webhook server with HMAC signature verification
- Automatic retry with exponential backoff

## API Methods

| Method                           | Description           |
| -------------------------------- | --------------------- |
| `get_me()`                       | Get bot information   |
| `send_message(chat_id, text)`    | Send a message        |
| `edit_message(message_id, text)` | Edit a message        |
| `delete_message(message_id)`     | Delete a message      |
| `get_chat(chat_id)`              | Get chat info         |
| `get_chat_members(chat_id)`      | Get chat members      |
| `leave_chat(chat_id)`            | Leave a chat          |
| `set_commands(commands)`         | Register bot commands |
| `set_webhook(url)`               | Set webhook URL       |
| `delete_webhook()`               | Remove webhook        |
| `upload_button_icon(path)`       | Upload a button icon  |
| `answer_callback_query(id)`      | Answer a callback     |

## Handlers

### Commands

```python
@bot.command(['start', 'help'])
async def start_handler(message):
    await message.reply("Welcome!")
```

### Regex

```python
@bot.hears(r"^/echo (.+)$")
async def echo_handler(message, match):
    await message.reply(match.group(1))
```

### All Messages

```python
@bot.message
async def log_message(message):
    print(f"[{message.chat_id}] {message.text}")
```

## Webhook

```python
from xc_bot import Bot, WebhookServer

bot = Bot("xbot_token")

@bot.command("start")
async def start(message):
    await message.reply("Hello!")

# Set webhook
await bot.set_webhook("https://your-server.com/webhook", secret="your-secret")

# Start webhook server
server = WebhookServer(bot, port=8443, secret="your-secret")
server.run()
```

## Getting a Token

1. Open chat with @BotConstructor in XaneoConnect
2. Send `/newbot`
3. Follow the instructions

## License

MIT
