2018-12-26 08:07:24 +00:00
# TelegramBotAPI
2020-05-13 13:41:46 +00:00
| Common info | [![Awesome Kotlin Badge ](https://kotlin.link/awesome-kotlin.svg )](https://github.com/KotlinBy/awesome-kotlin) [![Chat in Telegram ](badges/chat.svg )](https://teleg.one/InMoTelegramBotAPI) [![Build Status ](https://travis-ci.com/InsanusMokrassar/TelegramBotAPI.svg?branch=master )](https://travis-ci.com/InsanusMokrassar/TelegramBotAPI) |
2020-04-08 08:34:55 +00:00
| -------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| TelegramBotAPI status | [![Download ](https://api.bintray.com/packages/insanusmokrassar/StandardRepository/TelegramBotAPI/images/download.svg )](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI/_latestVersion) [![Maven Central ](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI/badge.svg )](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI) |
| TelegramBotAPI Extensions status | [![Download ](https://api.bintray.com/packages/insanusmokrassar/StandardRepository/TelegramBotAPI-extensions-api/images/download.svg )](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI-extensions-api/_latestVersion) [![Maven Central ](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI-extensions-api/badge.svg )](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI-extensions-api) |
| TelegramBotAPI Util Extensions status | [![Download ](https://api.bintray.com/packages/insanusmokrassar/StandardRepository/TelegramBotAPI-extensions-utils/images/download.svg )](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI-extensions-utils/_latestVersion) [![Maven Central ](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI-extensions-utils/badge.svg )](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI-extensions-utils) |
2018-12-26 08:07:24 +00:00
2020-02-17 09:25:08 +00:00
It is a complex of libraries for working with `TelegramBotAPI` in type-safe and strict way as much as it possible. In
the list of this complex currently next projects:
2018-12-26 08:07:24 +00:00
2020-02-17 09:25:08 +00:00
* [TelegramBotAPI ](TelegramBotAPI/README.md ) - core of library. In fact it is independent library and can be used alone
2020-04-08 08:34:55 +00:00
without any additional library
2020-02-17 09:25:08 +00:00
* [TelegramBotAPI Extensions ](TelegramBotAPI-extensions-api/README.md ) - contains extensions (mostly for
2020-04-08 08:34:55 +00:00
`RequestsExecutor` ), which allows to use the core library in more pleasant way
2020-04-08 09:28:03 +00:00
* [TelegramBotAPI Util Extensions ](TelegramBotAPI-extensions-utils/README.md ) - contains extensions for more comfortable
work with commands, updates and other different things
2018-12-26 08:07:24 +00:00
2020-02-17 09:25:08 +00:00
Most part of some specific solves or unuseful
moments are describing by official [Telegram Bot API ](https://core.telegram.org/bots/api ).
2019-05-05 01:04:48 +00:00
2020-04-17 09:43:43 +00:00
## JavaScript notes
2020-04-17 09:52:47 +00:00
In case if you are want to use this library inside of browser, you will need additional settings (thanks for help to [Alexander Nozik ](https://research.jetbrains.org/researchers/altavir )):
2020-04-17 09:43:43 +00:00
< details >
2020-04-17 09:52:28 +00:00
< summary > Gradle build script help< / summary >
2020-04-17 09:43:43 +00:00
```groovy
dependencies {
/* ... */
implementation "com.github.insanusmokrassar:TelegramBotAPI:$tgbot_api_version"
implementation "com.github.insanusmokrassar:TelegramBotAPI-extensions-api:$tgbot_api_version" // optional
implementation "com.github.insanusmokrassar:TelegramBotAPI-extensions-utils:$tgbot_api_version" // optional
/* Block of dependencies for correct building in browser */
implementation(npm("fs"))
implementation(npm("bufferutil"))
implementation(npm("utf-8-validate"))
implementation(npm("abort-controller"))
implementation(npm("text-encoding"))
}
/* ... */
kotlin {
target {
browser {
/* Block for fix of exception in absence of some functionality, https://github.com/ktorio/ktor/issues/1339 */
dceTask {
dceOptions {
keep("ktor-ktor-io.\$\$importsForInline\$\$.ktor-ktor-io.io.ktor.utils.io")
}
}
}
}
}
```
< / details >
2020-02-17 09:25:08 +00:00
## Ok, where should I start?
2019-05-05 01:04:48 +00:00
2020-04-08 08:34:55 +00:00
In most cases, the most simple way will be to implement
[TelegramBotAPI Extensions ](TelegramBotAPI-extensions-api/README.md ) and
[TelegramBotAPI Util Extensions ](TelegramBotAPI-extensions-utils/README.md ) for the reason that they contains more
simple tools. If you want to dive deeper in the core of library or develop something for it - welcome to
[TelegramBotAPI ](TelegramBotAPI/README.md ).
2019-05-05 01:04:48 +00:00
2020-04-08 09:28:03 +00:00
Anyway, all libraries are very typical inside of them. Examples:
* In `TelegramBotAPI` common request look like `requestsExecutor.execute(SomeRequest())`
* `TelegramBotAPI-extensions-api` typical syntax look like `requestsExecutor.someRequest()` (in most cases it would be
2020-04-08 19:24:55 +00:00
better to use `bot` name instead of `requestsExecutor` )
2020-04-08 09:28:03 +00:00
* `TelegramBotAPI-extensions-utils` will look like `filter.filterBaseMessageUpdates(chatId).filterExactCommands(Regex("^.*$"))...`