1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-12-26 10:37:13 +00:00
Type-safe library for work with Telegram Bot API
Go to file
2021-01-25 04:42:23 +06:00
.github Create regular-build.yml 2021-01-25 04:42:23 +06:00
badges add link to bot template 2020-11-08 18:58:52 +06:00
docs update dependencies 2020-12-04 16:13:02 +06:00
gradle/wrapper update gradle wrapper 2021-01-22 21:57:23 +06:00
resources fixes in readme 2021-01-08 16:37:03 +06:00
tgbotapi update publication scripts 2021-01-13 14:21:35 +06:00
tgbotapi.core complete tools for handling of encrypted data 2021-01-23 20:50:46 +06:00
tgbotapi.extensions.api start 0.32.0 as a migration from 0.31.1 due to breaking changes in MediaGroupMessage type 2021-01-19 10:52:30 +06:00
tgbotapi.extensions.behaviour_builder add asAction and several variants of oneOf 2021-01-19 20:19:28 +06:00
tgbotapi.extensions.utils update classcasts 2021-01-23 21:10:57 +06:00
_config.yml Set theme jekyll-theme-cayman 2020-01-06 22:44:23 +06:00
.gitignore add publication of github release via changelog 2020-09-22 18:04:10 +06:00
.travis.yml update travis config 2020-10-22 19:19:55 +06:00
build.gradle exprimentally update publishing scripts 2020-11-18 17:18:51 +06:00
changelog_info_retriever update changelog parser 2020-10-04 17:43:25 +06:00
CHANGELOG.md add tools for passport files hashes calculation 2021-01-23 12:21:57 +06:00
CONTRIBUTING.md Create CONTRIBUTING.md 2020-10-02 13:10:01 +06:00
gradle.properties complete tools for handling of encrypted data 2021-01-23 20:50:46 +06:00
gradlew init 2018-12-26 16:21:52 +08:00
gradlew.bat init 2018-12-26 16:21:52 +08:00
LICENSE Update LICENSE 2020-02-19 22:29:53 +06:00
README.md fixes in readme 2021-01-08 16:37:03 +06:00
renovate.json Add renovate.json 2020-08-12 20:21:10 +00:00
settings.gradle rename steps subproject to behaviour_builder 2021-01-07 18:17:50 +06:00
TelegramBotAPI.minder fixes in readme 2021-01-08 16:37:03 +06:00

TelegramBotAPI

I do not wanna read a lot, just give me my bot

You can simply use this template (and button Use template) to get your copy of bot and start to code.

P.S. Do not forget to look into our minidocs and kdocs
Common info Awesome Kotlin Badge Build Status Small survey
Useful links Chat in Telegram Create bot KDocs Examples, Mini tutorial
TelegramBotAPI Core status Download Maven Central
TelegramBotAPI API Extensions status Download Maven Central
TelegramBotAPI Util Extensions status Download Maven Central
TelegramBotAPI Behaviour Builder Extensions status Download Maven Central
TelegramBotAPI All status Download Maven Central

At the time of publication of version 0.28.0 there are errors in serialization plugins like kotlinx.serialization#1004. It is possible, that both JVM and JS version may work improperly in some cases with kotlinx.serialization version 1.0.0-RC

What is it?

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:

Most part of some specific solves or unuseful moments are describing by official Telegram Bot API.

JavaScript notes

Versions before 0.28.0

In case if you are want to use this library inside of browser, you will need additional settings (thanks for help to Alexander Nozik):

Gradle build script help (for versions before 0.28.0)
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")
                }
            }
        }
    }
}

Ok, where should I start?

Libraries hierarchy

In most cases, the most simple way will be to implement TelegramBotAPI - it contains all necessary tools for comfort usage of this library. If you want to exclude some libraries, you can implement just TelegramBotAPI BehaviourBuilder Extensions, TelegramBotAPI API Extensions, TelegramBotAPI Util Extensions or even TelegramBotAPI Core.

If you want to dive deeper in the core of library or develop something for it - welcome to learn more from TelegramBotAPI Core and our Telegram Chat.

Anyway, all libraries are very typical inside of them. Examples:

  • In TelegramBotAPI common request look like requestsExecutor.execute(SomeRequest())
  • tgbotapi.extensions.api typical syntax look like requestsExecutor.someRequest() (in most cases it would be better to use bot name instead of requestsExecutor)
  • tgbotapi.extensions.utils will look like filter.filterBaseMessageUpdates(chatId).filterExactCommands(Regex("^.*$"))...

Build instruction

If you want to build this project or to contribute, there are several recommendations:

Build

In case if you want to just build project, run next command:

./gradlew clean build

On windows:

gradlew.bat clean build

Publishing for work with your version locally

In case, if you want to work in your other projects using your modification (or some state) of this library, you can use next code:

./gradlew clean build publishToMavenLocal

On windows:

gradlew.bat clean build publishToMavenLocal

But you must remember, that in this case your local maven repo must be the first one from your project retrieving libraries:

repositories {
    mavenLocal() // that must be the first one
    jcenter()
    mavenCentral()
}

Besides, for your own version you can change variable library_version in the file gradle.properties.