From aa333d7c586015b0ca6b402b0ff76699f794df14 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 7 Feb 2020 11:00:21 +0600 Subject: [PATCH] fill CHANGELOG and update README --- CHANGELOG.md | 1 + README.md | 42 ++++++++++++++++++++++++++++-------------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fb182eb04..12fe9c222a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ * `SendInvoice` now return `ContentMessage` * `paymentInfo` inside of `CommonMessageImpl` now can be set only to `SuccessfulPaymentInfo` * Added `RecordVideoNoteAction` and `UploadVideoNoteAction` for `record_video_note` and `upload_video_note` actions +* For most part of messages was added `RequestsExecutor` extensions for more useful way of usage ## 0.22.0 diff --git a/README.md b/README.md index b2ac7d652a..8936cf96eb 100644 --- a/README.md +++ b/README.md @@ -76,10 +76,10 @@ important objects: Types declare different objects representation. For example, `Chat` for now represented as interface and has several realisations: -* PrivateChat -* GroupChat -* SupergroupChat -* ChannelChat +* `PrivateChat` +* `GroupChat` +* `SupergroupChat` +* `ChannelChat` Instead of common garbage with all information as in original [Chat](https://core.telegram.org/bots/api#chat), here it was separated for more obvious difference between chats types and their possible content. @@ -96,7 +96,14 @@ val requestsExecutor: RequestsExecutor = ... requestsExecutor.execute(GetMe()) ``` -The result type of [GetMe](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetMe.kt) +Or you can use new syntax: + +```kotlin +val bot: RequestsExecutor = ... +bot.getMe() +``` + +The result type of [GetMe (and getMe extension)](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetMe.kt) request is [ExtendedBot](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/User.kt). @@ -107,31 +114,38 @@ realisation of `RequestsExecutor`, but it is possible, that in future it will be project. How to create `RequestsExecutor`: ```kotlin -val requestsExecutor = KtorRequestsExecutor(TOKEN) +val requestsExecutor = KtorRequestsExecutor( + TelegramAPIUrlsKeeper(TOKEN) +) ``` -Here `KtorRequestsExecutor` - default realisation with Ktor. `TOKEN` is just a token of bot which was retrieved -according to [instruction](https://core.telegram.org/bots#3-how-do-i-create-a-bot). +Here: -Besides, for correct usage of this, you must implement in your project both one of engines for client and server -Ktor libraries: +* `KtorRequestsExecutor` - default realisation with [ktor](https://ktor.io) +* `TelegramAPIUrlsKeeper` - special keeper, which you can save and use for getting files full urls (`resolveFileURL` +extension inside of `PathedFile.kt`) +* `TOKEN` is just a token of bot which was retrieved according to +[instruction](https://core.telegram.org/bots#3-how-do-i-create-a-bot). + +By default, for JVM there is implemented `CIO` client engine, but there is not server engine. Both can be changed like +here: ```groovy dependencies { // ... - implementation "io.ktor:ktor-server-cio:$ktor_version" - implementation "io.ktor:ktor-client-okhttp:$ktor_version" + implementation "io.ktor:ktor-server-cio:$ktor_version" // for implementing of server engine + implementation "io.ktor:ktor-client-okhttp:$ktor_version" // for implementing of additional client engine // ... } ``` -It is able to avoid using of `server` dependency in case if will not be used `Webhook`s. In this case, +You can avoid using of `server` dependency in case if you will not use `Webhook`s. In this case, dependencies list will be simplify: ```groovy dependencies { // ... - implementation "io.ktor:ktor-client-okhttp:$ktor_version" + implementation "io.ktor:ktor-client-okhttp:$ktor_version" // for implementing of additional client engine // ... } ```