AtlatestRepositorysigil-telegram
sigil-telegram / treeREADME.md
1
# sigil-telegram3
A [Sigil](https://codeberg.org/sigil/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.5
## Features7
- **Bot framework** -- command, message, and callback handlers with long-polling loop8
- **Message operations** -- send, edit, delete with MarkdownV2 support9
- **Media sending** -- photos and documents by URL, file_id, or local file upload10
- **Inline keyboards** -- button rows with callback data or URLs11
- **MarkdownV2 formatting** -- bold, italic, code, links, spoilers with auto-escaping12
- **Authorization** -- restrict by allowed chats and/or allowed users13
- **Error recovery** -- configurable error handler, automatic retry on poll failure14
- **Cooperative I/O** -- blocking (`tg-bot-run`) or non-blocking (`tg-bot-tick`)16
## Usage18
Add `sigil-telegram` as a dependency in your `package.sgl`:20
```scheme21
(from-git url: "codeberg:sigil/sigil-telegram" package: "sigil-telegram")22
```24
Then build a bot:26
```scheme27
(import (sigil telegram))29
(define bot (make-tg-bot token: (getenv "TELEGRAM_BOT_TOKEN")))31
(tg-on-command bot "/hello"32
(lambda (update)33
(tg-reply bot update "Hello!")))35
(tg-on-message bot36
(lambda (update)37
(tg-reply bot update38
(tg-bold "Echo: ")39
(tg-escape-markdown (tg-message-text (tg-update-message update))))))41
(tg-bot-run bot)42
```44
## Modules46
| Module | Description |47
|--------|-------------|48
| `(sigil telegram)` | Top-level re-exports |49
| `(sigil telegram types)` | Data types: tg-user, tg-chat, tg-message, tg-update |50
| `(sigil telegram client)` | Low-level API calls, message/media operations |51
| `(sigil telegram bot)` | Bot framework, handlers, long-polling loop |52
| `(sigil telegram format)` | MarkdownV2 formatting and inline keyboards |54
## Dependencies56
- sigil-stdlib57
- sigil-json58
- sigil-http60
## Building62
```bash63
sigil deps install64
sigil build65
sigil test66
```68
## License70
BSD-3-Clause