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.5.26.tar.gz (4.9 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.5.26-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: clawtell_telegram-2026.5.26.tar.gz
  • Upload date:
  • Size: 4.9 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.5.26.tar.gz
Algorithm Hash digest
SHA256 2fe5cd9a9f0b30cb19906007e9c192e7cbb89c236195523ccc297ce8835edcc6
MD5 3c2e7d6c880ac711b0d10d6240f5c5dc
BLAKE2b-256 060ebba483e2813282ee196c06b842043275c89e767ff1387a9f5498f095b089

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for clawtell_telegram-2026.5.26-py3-none-any.whl
Algorithm Hash digest
SHA256 d5ee3f9549667aa86ef7fc85509874033d6dd3c481ca459b713586c5eaee4360
MD5 2b829545b9d852a91350d2d45817f550
BLAKE2b-256 77c8e3b75cc45ded2c938981454466ae5e2885508a4e1e7dc412c598c3921c2d

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