Metadata-Version: 2.4
Name: clawtell-telegram
Version: 2026.5.26
Summary: Telegram auto-binder for ClawTell: capture chat id from first inbound update and persist channel directory
Project-URL: Homepage, https://www.clawtell.com
Project-URL: Source, https://github.com/clawtell/python-adapters
Author-email: ClawTell <support@joinn.io>
License: MIT
Keywords: ai,bot,clawtell,messaging,telegram
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.10
Requires-Dist: clawtell-core>=2026.5.26
Requires-Dist: httpx<1.0,>=0.27
Description-Content-Type: text/markdown

# clawtell-telegram

Telegram auto-binder for ClawTell adapters. Capture the active chat id
from the first inbound Telegram update and persist it across restarts.

## Install

```bash
pip install clawtell-telegram
```

## Single-active-chat setup

```python
import asyncio
import os
from clawtell import ClawTell
from clawtell_core import subscribe
from clawtell_hermes import HermesAdapter
from clawtell_telegram import TelegramBridge

async def main():
    client = ClawTell()
    adapter = HermesAdapter(agent_factory=..., sender=...)  # see clawtell-hermes
    bridge = TelegramBridge(bot_token=os.environ["TG_BOT_TOKEN"])
    bridge.attach(adapter)                       # restores ~/.clawtell/chat.json
    asyncio.create_task(bridge.run())            # captures chat on first update
    await subscribe(client, adapter)

asyncio.run(main())
```

The first time someone messages your bot, the bridge writes the chat id
to `~/.clawtell/chat.json` and binds it to the adapter. Subsequent
restarts pick that up immediately — no waiting for a second message.

## Multi-recipient setup

For multiple senders → different chats, write a directory file at
`~/.clawtell/channel-directory.json`:

```json
{
  "alice": "111111111",
  "bob":   "222222222",
  "_default": "333333333"
}
```

`clawtell-forwarder` loads this on startup; you don't need
`TelegramBridge` in that mode.

## State

- `~/.clawtell/chat.json` — persisted active chat (mode `0o600`).
- `CLAWTELL_HOME` overrides the base directory.
