Skip to main content

Telegram auto-binder for ClawTell: capture chat id from first inbound update and persist channel directory

Project description

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

pip install clawtell-telegram

Single-active-chat setup

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:

{
  "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.

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

clawtell_telegram-2026.6.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

clawtell_telegram-2026.6.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file clawtell_telegram-2026.6.0.tar.gz.

File metadata

  • Download URL: clawtell_telegram-2026.6.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for clawtell_telegram-2026.6.0.tar.gz
Algorithm Hash digest
SHA256 00ba219af70b18175c59c14b78e7b32b4a29d0008d85427f700b82f388f981fd
MD5 b0221a30aad731e4df05dbc17f198774
BLAKE2b-256 d53e69576dd05b1d78036fc76aac0b5d8fbd1f08e4aa9ed882f5a429f73ba88c

See more details on using hashes here.

File details

Details for the file clawtell_telegram-2026.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for clawtell_telegram-2026.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e85ee0fddaab20a4af07557f1f590d021692f8cee76bf66751eceee42ad4cb31
MD5 326de160d668578bc44c72668cc8d267
BLAKE2b-256 6f87572eb104e5fa31a70112433aff5c3c0cbd1e5b353a184ba0bb54f6b455d8

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