1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-12-23 00:57:13 +00:00
Type-safe library for work with Telegram Bot API
Go to file
2019-02-27 15:32:11 +08:00
gradle/wrapper update version of gradle and libs 2019-02-21 12:10:21 +08:00
src/main/kotlin/com/github/insanusmokrassar/TelegramBotAPI rewrite GetWebhookInfo as class for better work with serialization 2019-02-27 14:12:39 +08:00
.gitignore init 2018-12-26 16:21:52 +08:00
build.gradle add main webhooks functionality for using with reverse proxy 2019-02-26 16:01:26 +08:00
CHANGELOG.md WebhookInfo 2019-02-27 14:01:04 +08:00
gradle.properties fixes in serialization 2019-02-21 14:09:04 +08:00
gradlew init 2018-12-26 16:21:52 +08:00
gradlew.bat init 2018-12-26 16:21:52 +08:00
LICENSE init 2018-12-26 16:21:52 +08:00
maven.publish.gradle improve pom creating for maven publication 2018-12-29 18:45:51 +08:00
publish.gradle add opportunity to use properties of project in user and key of bintray publication 2018-12-28 10:40:24 +08:00
README.md update readme 2019-02-27 15:32:11 +08:00
settings.gradle init 2018-12-26 16:21:52 +08:00

TelegramBotAPI

Download Build Status

What is it?

It is one more project which wish to be useful and full Telegram Bots API bridge for Kotlin. Most part of some specific solves or unuseful moments are describing by official Telegram Bot API.

Compatibility

This version compatible with July 2018 update of TelegramBotAPI. That means that most part of API has been implemented (according to last August 2018 update of TelegramBotAPI) except the Passport API which will be included as soon as possible.

How to work with library?

By default in any documentation will be meaning that you have variable in scope with names

Name of variable Description Where to get? (Examples)
executor RequestsExecutor Ktor RequestExecutor realisation

Requests Examples

Get Me

executor.execute(GetMe())

As a result you will receive User object. This object used as is now (as in API documentation), but it is possible that this class will be renamed to RawUser and you will be able to get real realisation of this object like Bot (in cases when isBot == true) or User (otherwise)

Getting updates

In this library currently realised two ways to get updates from telegram:

  • Polling - in this case bot will request updates from time to time (you can set up delay between requests)
  • Webhook via reverse proxy or something like this

Updates filters

Currently webhook method contains UpdatesFilter as necessary argument for getting updates. UpdatesFilter will sort updates and throw their into different callbacks. Currently supporting separate getting updates for media groups - they are accumulating with debounce in one second (for being sure that all objects of media group was received).

Updates polling also support UpdatesFilter but you must not use it and can get updates directly in UpdateReceiver, which you will provide to startGettingOfUpdates method

Webhook set up

If you wish to use webhook method, you will need:

  • White IP - your IP address or host, which available for calling. TelegramBotAPI recommend to use some unique address for each bot which you are using
  • SSL certificate. Usually you can obtain the certificate using your domain provider, Let'sEncrypt or create it
  • Nginx or something like this

Template for Nginx server config you can find in this gist.

For webhook you must provide File with public part of certificate, URL where bot placed and inner PORT which will be used to start receiving of updates.