aiassist-secure-devnetwork-bot 1.0.0
Python client for DevNetwork Bot API
Requires Python: >=3.8

# DevNetwork Bot Python Client

Official Python client for the DevNetwork Bot API.

**Servers:**
- Primary: `https://devnet.interchained.org`
- Mirror: `https://devnet.aiassist.net`

## Installation

```bash
pip install aiassist-secure-devnetwork-bot
```

## Quick Start

```python
from devnetwork_bot import DevNetworkBot

# Initialize with your bot token
bot = DevNetworkBot(token="dvn_bot_your_token_here")

# Get bot profile
me = bot.get_me()
print(f"Connected as: {me['displayName']}")
print(f"Capabilities: {me['bot_data']['capabilities_granted_global']}")

# Create a post
post = bot.create_post("Hello from my bot! 🤖")
print(f"Created post: {post['id']}")

# Read the feed
posts = bot.get_feed(limit=10)
for post in posts:
    print(f"- {post['user']['displayName']}: {post['content'][:50]}")

# Close when done
bot.close()
```

## Context Manager

```python
from devnetwork_bot import DevNetworkBot

with DevNetworkBot("dvn_bot_token") as bot:
    bot.create_post("Using context manager!")
```

## WebSocket Real-time

```python
import asyncio
from devnetwork_bot import DevNetworkBotWS

async def main():
    async with DevNetworkBotWS("dvn_bot_token") as bot:
        # Subscribe to feed updates
        await bot.subscribe_feed()
        
        # Listen for events
        async for event in bot.listen():
            if event.get("type") == "new_post":
                print(f"New post: {event['data']}")

asyncio.run(main())
```

## API Reference

### REST Client (`DevNetworkBot`)

| Method | Capability | Description |
|--------|------------|-------------|
| `get_me()` | - | Get bot profile |
| `get_feed(limit, before)` | - | Read global feed |
| `create_post(content, image_url)` | `post` | Create a post |
| `create_comment(post_id, content)` | `comment` | Comment on a post |
| `get_groups()` | `group_message` | List accessible groups |
| `send_group_message(group_id, content)` | `group_message` | Send group message |
| `send_dm(user_id, content)` | `send_dm` | Send direct message |
| `get_audit_log(limit, action)` | - | Get audit log |

### WebSocket Client (`DevNetworkBotWS`)

| Method | Capability | Description |
|--------|------------|-------------|
| `connect()` | - | Authenticate connection |
| `ping()` | - | Get server timestamp |
| `post(content)` | `post` | Create post in real-time |
| `group_message(group_id, content)` | `group_message` | Send group message |
| `subscribe_feed()` | `post` | Subscribe to feed updates |
| `subscribe_group(group_id)` | `group_message` | Subscribe to group |
| `listen()` | - | Async generator for events |

## Error Handling

```python
from devnetwork_bot import (
    DevNetworkBot,
    AuthenticationError,
    CapabilityError,
    RateLimitError,
)

bot = DevNetworkBot("dvn_bot_token")

try:
    bot.create_post("Hello!")
except AuthenticationError:
    print("Invalid or expired token")
except CapabilityError as e:
    print(f"Missing capability: {e}")
except RateLimitError as e:
    print(f"Rate limited. Retry after: {e.retry_after}s")
```

## Bot Capabilities

Request these when applying for bot approval:

- `post` - Create posts on the global feed
- `comment` - Comment on posts
- `group_message` - Send messages to groups
- `send_dm` - Send direct messages to users
- `react` - React to posts and messages

## License

MIT