Skip to content

AntonMeep/tg.d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tg.d Repository pipeline status coverage report MIT Licence Package version

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. GitHub repository is a mirror, it might not always be up-to-date.

Documentation

API reference is available here. Telegram Bot API documentation is available here.

Getting updates

Currently, only long polling is supported. Use TelegramBot.pollUpdates which provides high-level abstraction over TelegramBot.getUpdates.

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:

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 Shows all kinds of actions that bot can broadcast to users (for example: ... typing, ... sending photo)
buttons.d Sends messages with attached inline keyboard
echo.d Sends user's messages back
edit.d Edits own messages
livelocation.d Sends location and updates it
reply.d Replies to user's messages
sendthings.d Sends photos, videos, audio files, locations, venues and other kinds of data

About

Telegram Bot API client library for the D programming language

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages