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.25.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.25-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: clawtell_telegram-2026.5.25.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.25.tar.gz
Algorithm Hash digest
SHA256 8c64d560cbdaa9f6642905a98fc317d2d334e83d8f21d0ffb73972b9d7fc9953
MD5 6abbe0e8965b8a287fa042762e30f296
BLAKE2b-256 66619840f26818ab558c2774433d4d8b677ee5b4534e57e6ad2566244597d521

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for clawtell_telegram-2026.5.25-py3-none-any.whl
Algorithm Hash digest
SHA256 e24081c7643b8af01d7f8b681d94ae9e9fe5e45fca6b472dabb77e9e7a8283bf
MD5 811bb9f405f5b4368ead403fa7367bb9
BLAKE2b-256 f2f7a04efbf5acb7a1499f1928c1b4f2c37206e5f2404b0f30a55878d7d25d06

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