AtlatestRenderedmarkdown
Readme

sigil-telegram

A Sigil library for the Telegram Bot API. Provides a complete bot framework with long-polling, command/message handlers, inline keyboards, MarkdownV2 formatting, and file uploads.

Features

  • Bot framework -- command, message, and callback handlers with long-polling loop
  • Message operations -- send, edit, delete with MarkdownV2 support
  • Media sending -- photos and documents by URL, file_id, or local file upload
  • Inline keyboards -- button rows with callback data or URLs
  • MarkdownV2 formatting -- bold, italic, code, links, spoilers with auto-escaping
  • Authorization -- restrict by allowed chats and/or allowed users
  • Error recovery -- configurable error handler, automatic retry on poll failure
  • Cooperative I/O -- blocking (tg-bot-run) or non-blocking (tg-bot-tick)

Usage

Add sigil-telegram as a dependency in your package.sgl:

(from-git url: "codeberg:sigil/sigil-telegram" package: "sigil-telegram")

Then build a bot:

(import (sigil telegram))

(define bot (make-tg-bot token: (getenv "TELEGRAM_BOT_TOKEN")))

(tg-on-command bot "/hello"
  (lambda (update)
    (tg-reply bot update "Hello!")))

(tg-on-message bot
  (lambda (update)
    (tg-reply bot update
      (tg-bold "Echo: ")
      (tg-escape-markdown (tg-message-text (tg-update-message update))))))

(tg-bot-run bot)

Modules

ModuleDescription
(sigil telegram)Top-level re-exports
(sigil telegram types)Data types: tg-user, tg-chat, tg-message, tg-update
(sigil telegram client)Low-level API calls, message/media operations
(sigil telegram bot)Bot framework, handlers, long-polling loop
(sigil telegram format)MarkdownV2 formatting and inline keyboards

Dependencies

  • sigil-stdlib
  • sigil-json
  • sigil-http

Building

sigil deps install
sigil build
sigil test

License

BSD-3-Clause