https://github.com/antonmeep/tg.d
Telegram Bot API client library for the D programming language
https://github.com/antonmeep/tg.d
api bot client dlang telegram
Last synced: 4 months ago
JSON representation
Telegram Bot API client library for the D programming language
- Host: GitHub
- URL: https://github.com/antonmeep/tg.d
- Owner: AntonMeep
- License: mit
- Created: 2018-08-17T09:15:42.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-09-06T10:38:41.000Z (almost 8 years ago)
- Last Synced: 2025-10-24T00:59:02.554Z (8 months ago)
- Topics: api, bot, client, dlang, telegram
- Language: D
- Size: 353 KB
- Stars: 9
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
tg.d [](https://gitlab.com/ohboi/tg.d) [](https://gitlab.com/ohboi/tg.d/pipelines) [](https://gitlab.com/ohboi/tg.d/pipelines) [](https://gitlab.com/ohboi/tg.d/blob/master/LICENSE) [](https://gitlab.com/ohboi/tg.d/tags)
========
**tg.d** is a Telegram Bot API client implementation built to make fast and safe bots with the help of the D programming language.
> Note that project's development happens on the [GitLab](https://gitlab.com/ohboi/tg.d).
> GitHub repository is a mirror, it might *not* always be up-to-date.
## Documentation
API reference is available [here](ohboi.gitlab.io/tg.d). Telegram Bot API documentation is available [here](https://core.telegram.org/bots/api).
## Getting updates
Currently, only long polling is supported. Use [`TelegramBot.pollUpdates`](https://ohboi.gitlab.io/tg.d/tg/d/TelegramBot.pollUpdates.html) which provides high-level abstraction over [`TelegramBot.getUpdates`](https://ohboi.gitlab.io/tg.d/tg/d/TelegramBot.getUpdates.html).
```D
import tg.d;
void main() {
while(true) {
foreach(update; TelegramBot("token").pollUpdates) {
// Do something with `update`
}
}
}
```
Data structures such as `Update`, `Message` and others have `isNull` property which can be used to check if field has a value:
```D
if(!update.message.isNull) {
// Update is a message
} else if(!update.edited_message.isNull) {
// Update is a edited message
} else ...
```
## Examples
Are in the `examples` directory:
| name | description |
|------|-------------|
| [action.d](examples/action.d) | Shows all kinds of actions that bot can broadcast to users (for example: `... typing`, `... sending photo`)
| [buttons.d](examples/buttons.d) | Sends messages with attached inline keyboard |
| [echo.d](examples/echo.d) | Sends user's messages back |
| [edit.d](examples/edit.d) | Edits own messages |
| [livelocation.d](examples/livelocation.d) | Sends location and updates it |
| [reply.d](examples/reply.d) | Replies to user's messages |
| [sendthings.d](examples/sendthings.d) | Sends photos, videos, audio files, locations, venues and other kinds of data |