1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-11-16 12:00:18 +00:00

Compare commits

..

2 Commits

Author SHA1 Message Date
de761c7cf2 Update CHANGELOG.md 2022-11-28 16:41:59 +06:00
d3bff680c3 Update libs.versions.toml 2022-11-28 16:41:23 +06:00
836 changed files with 10236 additions and 62725 deletions

View File

@@ -5,9 +5,6 @@ on: [pull_request, issues]
jobs:
greeting:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/first-interaction@v1
with:

View File

@@ -10,12 +10,12 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 17
java-version: 11
- name: Build
run: ./gradlew dokkaHtmlMultiModule
run: ./gradlew dokkaHtml
- name: Publish KDocs
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build/dokka/htmlMultiModule
publish_dir: ./docs/build/dokka/html
publish_branch: kdocs

View File

@@ -7,30 +7,23 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 17
- name: Setup LibCurl
run: sudo apt update && sudo apt install -y libcurl4-openssl-dev
java-version: 11
- name: Rewrite version
run: |
branch="`echo "${{ github.ref }}" | grep -o "[^/]*$"`"
cat gradle.properties | sed -e "s/^library_version=\([0-9\.]*\)/library_version=\1-branch_$branch-build${{ github.run_number }}/" > gradle.properties.tmp
rm gradle.properties
mv gradle.properties.tmp gradle.properties
- name: KotlinSymbolProcessing execution
run: ./gradlew ksp
- name: Build
run: ./gradlew build
- name: API compatibility check
run: ./gradlew apiCheck
- name: Publish to Gitea
continue-on-error: true
run: ./gradlew publishAllPublicationsToGiteaRepository
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
- name: Publish to GithubPackages
continue-on-error: true
run: ./gradlew publishAllPublicationsToGithubPackagesRepository --no-parallel
env:
GITHUB_USER: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to Gitea
continue-on-error: true
run: ./gradlew publishAllPublicationsToInmoNexusRepository
env:
INMONEXUS_USER: ${{ secrets.INMONEXUS_USER }}
INMONEXUS_PASSWORD: ${{ secrets.INMONEXUS_PASSWORD }}
GITHUBPACKAGES_USER: ${{ github.actor }}
GITHUBPACKAGES_PASSWORD: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -1,534 +1,9 @@
# TelegramBotAPI changelog
## 15.2.0
* `API`:
* Enabled an `explicit mode` for `API` module ([PR #876](https://github.com/InsanusMokrassar/ktgbotapi/pull/876))
* `WebApps`:
* Built-in `onClick` and `offClick` of `MainButton` become public ([PR #875](https://github.com/InsanusMokrassar/ktgbotapi/pull/875))
* Old `MainButton.onClick` extension **has been removed** to avoid collisions of types
## 15.1.0
**THIS UPDATE CONTAINS BREAKING CHANGES**
**THIS UPDATE CONTAINS ADDING OF SUPPORT FOR BOTS API 7.7** (thanks to [bpavuk](https://threads.net/b_pavuchok))
**THIS UPDATE CONTAINS ADDING OF SUPPORT FOR BOTS API 7.6** (with participation and help of [bpavuk](https://threads.net/b_pavuchok))
* Add support of paid media
* Update web apps
* `Version`:
* `MicroUtils`: `0.21.1` -> `0.21.2`
* `Core`:
* `TelegramMedia` has been separated onto two interfaces: `TelegramFreeMedia` and `TelegramPaidMedia`
* `TelegramFreeMedia` has replaced `TelegramMedia` on all old places where it have been used
* `Photo` has been renamed to `PhotoFile`
* `BehaviourBuilder`:
* Add notification when handling of `/privacy` command is absence
* Add several extensions to simplify setting up `/privacy` reaction
## 15.0.0
**THIS UPDATE CONTAINS BREAKING CHANGES**
**THIS UPDATE CONTAINS ADDING OF SUPPORT FOR BOTS API 7.5**
* `Version`:
* `MicroUtils`: `0.21.0` -> `0.21.1`
* A lot of `edit` methods and classes has been changed to support business connection id
## 14.1.0
* `Version`:
* `Coroutines`: `1.8.0` -> `1.8.1`
* `Ktor`: `2.3.10` -> `2.3.11`
* `MicroUtils`: `0.20.45` -> `0.21.0`
* `KSLog`: `1.3.3` -> `1.3.4`
* `BehaviourBuilder`:
* `BehaviourContext` updates listening job will be weakly subscribed. It means that `BehaviourContext` scope will
not be prevented from cancelling by this job anymore
* `BehaviourContext.doInContext` will not stop automatically current `BehaviourContext` job anymore
* `BehaviourContext.createSubContextAndDoWithUpdatesFilter` will use `supervisorScope` instead of
`LinkedSupervisorScope`. That will prevent scope leaking in runtime
## 14.0.1
* In `core` and `api` modules related to invoices changed their APIs to suite current API
## 14.0.0
**Add support of [Telegram Bots API 7.4](https://core.telegram.org/bots/api-changelog#may-28-2024)**
**THIS UPDATE CONTAINS BREAKING CHANGES**
* `Core`:
* `TelegramPaymentChargeId` has been added as value class and replaced raw strings in `SuccessfulPayment` type of `telegramPaymentChargeId`
* All the methods/classes related to sending of messages got `effectId` parameter
* All the methods/classes related to sending of photos/animations/videos got `showCaptionAboveMedia` parameter
## 13.0.0
**Add support of [Telegram Bots API 7.3](https://core.telegram.org/bots/api-changelog#may-6-2024)**
**THIS UPDATE CONTAINS BREAKING CHANGES**
* `Core`:
* For polls, `textSources` now means `question` text sources. For `QuizPoll` there are `explanation` and `explanationTextSources`
for hinting
* `API`:
* A lot of API related to `Poll`s has been changed to include opportunity to pass `ParseMode` and `TextSource`s list
## 12.0.1
* `Version`:
* `Ktor`: `2.3.9` -> `2.3.10`
* `MicroUtils`: `0.20.39` -> `0.20.45`
* `UUID`: `0.8.2` -> `0.8.4`
## 12.0.0
**Add support of [Telegram Bots API 7.2](https://core.telegram.org/bots/api-changelog#march-31-2024)**
**THIS UPDATE CONTAINS A LOT OF BREAKING CHANGES**
## 11.0.0
**THIS UPDATE CONTAINS REMOVES OF DEPRECATED THINGS**
**THIS UPDATE CONTAINS A LOT OF BREAKING CHANGES**
* `Core`:
* `MessageId` now is `value class`. `MessageIdentifier` become deprecated
* `MessageThreadId` now is `value class`
* `InlineQueryIdentifier` now is `value class`
* `MediaGroupIdentifier` has been renamed to `MediaGroupId` and now is `value class`
* `CallbackQueryIdentifier` has been renamed to `CallbackQueryId` and now is `value class`
* `WebAppQueryId` now is `value class`
* `PreCheckoutQueryId` now is `value class`
* `FileUniqueId` has been renamed to `TgFileUniqueId` and now is `value class`
* `UpdateIdentifier` has been renamed to `UpdateId` and now is `value class`
* `InlineMessageIdentifier` has been renamed to `InlineMessageId` and now is `value class`
* `ShippingQueryIdentifier` has been renamed to `ShippingQueryId` and now is `value class`
* `Identifier` has been renamed to `RawChatId` and now is `value class`
* `ShippingOptionIdentifier` has been renamed to `ShippingOptionId` and now is `value class`
* `PollIdentifier` has been renamed to `PollId` and now is `value class`
* `StickerSetName` now is `value class`
## 10.1.2
* `Version`:
* `Kotlin`: `1.9.22` -> `1.9.23`
* `Korlibs`: `5.3.2` -> `5.4.0`
* `Ktor`: `2.3.8` -> `2.3.9`
* `MicroUtils`: `0.20.37` -> `0.20.39`
* `KSLog`: `1.3.2` -> `1.3.3`
## 10.1.1
* `Version`:
* `Serialization`: `1.6.2` -> `1.6.3`
* `MicroUtils`: `0.20.34` -> `0.20.37`
* `Korlibs`: `5.3.1` -> `5.3.2`
## 10.1.0
**Add support of [Telegram Bots API 7.1](https://core.telegram.org/bots/api-changelog#february-16-2024)**
* `Version`:
* `Coroutines`: `1.7.3` -> `1.8.0`
* `MicroUtils`: `0.20.32` -> `0.20.34`
## 10.0.1
* `Version`:
* `Ktor`: `2.3.7` -> `2.3.8`
* `MicroUtils`: `0.20.26` -> `0.20.32`
* `Korlibs`: `5.3.0` -> `5.3.1`
* `KSLog`: `1.3.1` -> `1.3.2`
## 10.0.0
**Add support of [Telegram Bots API 7.0](https://core.telegram.org/bots/api-changelog#december-29-2023)**
**IN THIS UPDATE KLOCK DEPENDENCY CHANGED TO `com.soywiz.korge:korlibs-time` UP TO 5.3.0 VERSION**
**IN THIS UPDATE KRYPTO DEPENDENCY CHANGED TO `com.soywiz.korge:korlibs-crypto` UP TO 5.3.0 VERSION**
* `Version`:
* `MicroUtils`: `0.20.23` -> `0.20.26`
* `Korlibs`: `4.0.10` -> `5.3.0`
* `Core`:
* `Message` now inherited by two variants: `AccessibleMessage` and `InaccessibleMessage`
* `Common`:
* In most places `disableWebPagePreview` has been replaced by new `LinkPreviewOptions`
* In most places arguments `replyToMessageId` and `allowSendingWithoutReply` has been replaced with
`ReplyParameters`
* In `reply` extension two parameters have been added: `replyInChatId` and `replyInThreadId`
## 9.4.3
**IetfLanguageCode has been renamed to IetfLang in MicroUtils**
* `Version`:
* `Kotlin`: `1.9.21` -> `1.9.22`
* `MicroUtils`: `0.20.19` -> `0.20.23`
## 9.4.2
* `Version`:
* `Serialization`: `1.6.1` -> `1.6.2`
* `Ktor`: `2.3.6` -> `2.3.7`
* `MicroUtils`: `0.20.15` -> `0.20.19`
* `UUID`: `0.8.1` -> `0.8.2`
## 9.4.1
* Replace warning about two bots from `LongPolling` to `DefaultKtorRequestsExecutor`
## 9.4.0
* `Version`:
* `Kotlin`: `1.9.20` -> `1.9.21`
* `Serialization`: `1.6.0` -> `1.6.1`
* `Ktor`: `2.3.5` -> `2.3.6`
* `MicroUtils`: `0.20.12` -> `0.20.15`
## 9.3.0
This release become possible thanks to [Anton Lakotka](https://youtrack.jetbrains.com/users/anton.lakotka)
**THIS RELEASE CONTAINS UPDATES UP TO RELEASE CANDIDATES VERSIONS**
**UPDATE MAY HAVE BREAKING CHANGES**
**SINCE THIS UPDATE IT WILL BE REQUIRED TO USE JDK 17+ FOR DEVELOPMENT**
* `Version`:
* `Kotlin`: `1.8.22` -> `1.9.20`
* `Serialization`: `1.5.1` -> `1.6.0`
* `KorLibs`: `4.0.3` -> `4.0.10`
* `UUID`: `0.7.1` -> `0.8.1`
* `Ktor`: `2.3.4` -> `2.3.5`
* `MicroUtils`: `0.19.9` -> `0.20.12`
## 9.2.4
* `Utils`:
* New extensions `*.parseCommandsWithNamedArgs`
* `BehaviourBuilder`:
* In expectaters and triggers of `commands` add `*WithNamedArgs` variants
* In expectaters and triggers of `commands` add opportunity to use custom separator
## 9.2.3
* `Core`:
* Fix in `VoiceContent#createResend`
## 9.2.2
* `Core`:
* Fix of [#793](https://github.com/InsanusMokrassar/ktgbotapi/issues/793): Add `PreviewChat`
## 9.2.1
* `Version`:
* `Ktor`: `2.3.3` -> `2.3.4`
* `Core`:
* All `ChatMember` inheritors have fixes `status` field
## 9.2.0
**Add support of [Telegram Bots API 6.9](https://core.telegram.org/bots/api-changelog#september-22-2023)**
* Rename `ChatAdministratorRightsImpl` -> `ChatCommonAdministratorRights`
* All the request chat keyboards has changed their parameters `ChatAdministratorRights` to `ChatCommonAdministratorRights`
## 9.1.2
* `Core`:
* Fix of `MessageContent` serialization
## 9.1.1
* `Core`:
* Potential fix of incorrect parsing in `RawMessageEntity`
## 9.1.0
**This update contains adding of [Telegram Bot API 6.8](https://core.telegram.org/bots/api-changelog#august-18-2023) support**
* `Version`:
* `Coroutines`: `1.7.2` -> `1.7.3`
* `Ktor`: `2.3.2` -> `2.3.3`
* `MicroUtils`: `0.19.7` -> `0.19.9`
## 9.0.0
**THIS UPDATE CONTAINS BREAKING CHANGES: USERNAMES OF BOTS NOW BECAME NULLABLE**
* `Version`:
* `Coroutines`: `1.6.4` -> `1.7.1`
* `Ktor`: `2.3.1` -> `2.3.2`
* `MicroUtils`: `0.19.4` -> `0.19.7`
* `Core`:
* **All bots now have nullable usernames just like common users ([#772](https://github.com/InsanusMokrassar/ktgbotapi/issues/772))**
* Decrease possible errors in updates handling by additional handling of update deserialization wrapping ([#773](https://github.com/InsanusMokrassar/ktgbotapi/issues/773))
* New interface `GetUpdatesRequest`. You may implement it to show default telegram bot ktor executor that this
request is an updates request and should be handled in a different way
* Now it is possible to get raw updates with `GetUpdatesRaw` request
* `Utils`:
* Improve extension `Update.sourceChat` to add opportunity to select some chats by logic different with the default
## 8.1.0
**PARTIALLY BREAKING CHANGES: Exclude `.*Impl` classcasts from `ClassCastsNew`**
* `Version`:
* `MicroUtils`: `0.19.2` -> `0.19.4`
* `Utils`:
* Add deep links formatting for internal `tg://` prefix (thanks to [@klimatov](https://github.com/klimatov))
* Exclude `.*Impl` classcasts from `ClassCastsNew`
## 8.0.1
* `Version`:
* `UUID`: `0.7.0` -> `0.7.1`
* `Ktor`: `2.3.0` -> `2.3.1`
* `MicroUtils`: `0.19.1` -> `0.19.2`
## 8.0.0
**THIS UPDATE CONTAINS BREAKING CHANGES**
**ALL PROJECT DEPRECATIONS HAVE BEEN REMOVED**
**IN THIS UPDATE KORLIBS HAVE BEEN UPDATED TO VERSION `4.0.2`. SINCE THAT VERSION A LOT OF PACKAGES HAVE BEEN RENAMED.
MIGRATIONS USED IN THIS LIB:**
* `com.soywiz.klock` -> `korlibs.time`
* `com.soywiz.krypto` -> `korlibs.crypto`
* `Versions`:
* `Korlibs`: `3.4.0` -> `4.0.3`
* `MicroUtils`: `0.18.4` -> `0.19.1`
## 7.1.3
* `Versions`:
* `Serialization`: `1.5.0` -> `1.5.1`
* `MicroUtils`: `0.18.1` -> `0.18.4`
* `Core`:
* Actualize kdocs in `InputFile`
* `BehaviourBuilder`:
* Now it is possible to use `waitMediaContent`/`waitMediaContentMessage`/`onMediaContent`
* Add `onMention`/`waitMention` functionality
* Add opportunity to map content with extensions to `Flow`
## 7.1.2
* `Versions`:
* `MicroUtils`: `0.18.0` -> `0.18.1`
* `Core`:
* Now it is possible to serialize `Sticker`s
## 7.1.1
* `Versions`:
* `Kotlin`: `1.8.20` -> `1.8.21`
* `MicroUtils`: `0.17.8` -> `0.18.0`
* `Utils`:
* Fixes in `makeLinkToMessage`
## 7.1.0
**This update contains changes according to the [Telegram Bot API 6.7](https://core.telegram.org/bots/api-changelog#april-21-2023)**
* `API`:
* Rename `editMessageCaption` to `editMessageMedia` due to wrong old naming
* Add `edit` extensions for `InlineMessageIdentifier`s
* `BehaviourBuilder`:
* `BehaviourContext` extensions `onDeepLink` and `waitDeepLinks` now can be used with `Regex` or `String` as first parameters
## 7.0.2
_This update brings experimental support of `linuxX64` and `mingwX64` platforms_
* `Versions`:
* `Kotlin`: `1.8.10` -> `1.8.20`
* `MicroUtils`: `0.17.5` -> `0.17.8`
* `Ktor`: `2.2.4` -> `2.3.0`
* `Core`:
* New `RequestsExecutor` - `MultipleClientKtorRequestsExecutor`
* Old `KtorRequestsExecutor` has been renamed to `DefaultKtorRequestsExecutor`
* `KtorRequestsExecutor` now is `expect class`
* On `JS`, `JVM` and `MinGWX64` platforms it is `DefaultKtorRequestsExecutor`
* On `LinuxX64` platform it is `MultipleClientKtorRequestsExecutor`
## 7.0.1
* `Core`:
* New interface `WithChat` which contains `chat` field
* `Message` now inherits `WithChat`
* `ChatMemberUpdated` now inherits `WithChat`
* `Utils`:
* Improvements in `same`-notations
## 7.0.0
This update contains support of [Telegram Bot API 6.6](https://core.telegram.org/bots/api-changelog#march-9-2023)
**THIS VERSION CONTAINS BREAKING CHANGES**:
* All previous deprecations have been removed
* Fully reworked mechanism of stickers creating and adding
* All separations of stickers types like `Animeted` have been replaces with type `StickerFormat`
* New `InputSticker` type (and all subtypes) as replacements for old raw fields in methods
* Reworked mechanism of files uploading
Other changes
* `Versions`:
* `MicroUtils`: `0.17.3` -> `0.17.5`
## 6.1.0
* `Versions`:
* `MicroUtils`: `0.17.2` -> `0.17.3`
* `API`:
* Fix of [#732](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/732)
## 6.0.3
* `Versions`:
* `MicroUtils`: `0.17.1` -> `0.17.2`
* `Core`:
* `User` in `CallbackQuery` now is `CommonUser` as well as in `from`
* `User` in `InlineQuery` now is `CommonUser` as well as in `from`
* `BehaviourBuilder`:
* Fixes in `DeepLink` triggers and waiters
## 6.0.2
* `Core`:
* Long polling now uses media groups debounce as in webhooks
## 6.0.1
* `Versions`:
* `Ktor`: `2.2.3` -> `2.2.4`
* `MicroUtils`: `0.17.0` -> `0.17.1`
## 6.0.0
* `Versions`:
* `Kotlin`: `1.7.22` -> `1.8.10`
* `MicroUtils`: `0.16.10` -> `0.17.0`
* `Serialization`: `1.4.1` -> `1.5.0`
* `uuid`: `0.6.0` -> `0.7.0`
* `Core`:
* `*.link` extensions have been deprecated with renaming to avoid collisions with `link` methods
* `API`:
* Add `TelegramBot.resend` methods
* `BehaviourBuilder`:
* Add triggers and waiters for `VisualMediaGroupPartContent`
* `Utils`:
* `*.link` extensions have been deprecated with renaming to avoid collisions with `link` methods
## 5.2.1
* `Core`:
* All the `CallbackQuery`es now will receive `CommonUser` instead of `User` due inability of bots to trigger any
inline interaction with others bots
* `API`:
* Now `sentMessageFlow` will take each sent message in `handleLiveLocation`
## 5.2.0
* `Versions`:
* `MicroUtils`: `0.16.8` -> `0.16.10`
## 5.1.1
* `Core`:
* Add opportunity to get user link with `makeUserLink`
* `BehaviourBuilder`:
* Fixes in content waiting expectators
## 5.1.0
[Bot API 6.5](https://core.telegram.org/bots/api-changelog#february-3-2023) support
* `Core`:
* `ChatPermissions` now is interface and have two main realizations: `ChatPermissions.Granular` and
`ChatPermissions.Common`
* `RestrictedChatMember` now implements `ChatPermissions` too
* `API`:
* Now it is possible to pass all long polling parameters in all places used it
* `Issues`:
* Fix of [#697](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/697)
## 5.0.2
* `Versions`:
* `MicroUtils`: `0.16.6` -> `0.16.8`
* `Ktor`: `2.2.2` -> `2.2.3`
* `BehaviourBuilder`:
* Fixes in `BehaviourContext.onEditedContentMessage` - now it will trigger callback on channel post edits too
## 5.0.1
* `Versions`:
* `MicroUtils`: `0.16.4` -> `0.16.6`
* `Ktor`: `2.2.1` -> `2.2.2`
* `Core`:
* Fixes in `SendMediaGroup` request
* Fixes in `SetChatAdministratorCustomTitle` request (thanks to [@madhead](https://github.com/madhead))
## 5.0.0
[Bot API 6.4](https://core.telegram.org/bots/api-changelog#december-30-2022) support!
* Long-polling improvements
## 4.2.4
* `Core`:
* Fixes in webhook parts adapter
* `BehaviourBuilderWithFSM`:
* Fixes in `DefaultBehaviourContextWithFSM`
## 4.2.3
* `Versions`:
* `MicroUtils`: `0.16.2` -> `0.16.4`
* `Core`:
* Simplify default `RequestsLimiter` (`ExceptionsOnlyLimiter`) (thanks to [@y9san9](https://github.com/y9san9) for help)
## 4.2.2
* `Versions`:
* `MicroUtils`: `0.16.0` -> `0.16.2`
* `Core`:
* Fix of [#694](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/694): add opportunity to create `ChatId` and `ChatIdWithThreadId` from `IdChatIdentifier`
## 4.2.1
* `Versions`:
* `MicroUtils`: `0.15.0` -> `0.16.0`
* `Ktor`: `2.1.3` -> `2.2.1`
* `Utils`:
* Improve support of `makeLinkToMessage` extensions
## 4.2.0
* `Versions`:
* `Kotlin`: `1.7.21` -> `1.7.22`
* `MicroUtils`: `0.14.4` -> `0.15.0`
## 4.1.3
* `Versions`:
* `Kotlin`: `1.7.21` -> `1.7.22`
* `MicroUtils`: `0.14.2` -> `0.14.4`
* `Core`:
* `ContentMessage`, `CommonMessage`, `PossiblyMediaGroupMessage` and `PossiblySentViaBotCommonMessage` got `out`

View File

@@ -1,16 +1,14 @@
# TelegramBotAPI [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [![Supported version](https://img.shields.io/badge/Telegram%20Bot%20API-7.7-blue)](https://core.telegram.org/bots/api-changelog#july-7-2024)
# TelegramBotAPI [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [![Supported version](https://img.shields.io/badge/Telegram%20Bot%20API-6.3-blue)](https://core.telegram.org/bots/api-changelog#november-5-2022)
| Docs | [![KDocs](https://img.shields.io/static/v1?label=Dokka&message=KDocs&color=blue&logo=kotlin)](https://tgbotapi.inmo.dev/index.html) [![Mini tutorial](https://img.shields.io/static/v1?label=Mk&message=Docs&color=blue&logo=mkdocs)](https://docs.inmo.dev/tgbotapi/index.html) |
|:----------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
| Useful repos | [![Create bot](https://img.shields.io/static/v1?label=Github&message=Template&color=blue&logo=github)](https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template/generate) [![Examples](https://img.shields.io/static/v1?label=Github&message=Examples&color=blue&logo=github)](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/) |
| Misc | [![Awesome Kotlin Badge](https://kotlin.link/awesome-kotlin.svg)](https://github.com/KotlinBy/awesome-kotlin) [![Small survey](https://img.shields.io/static/v1?label=Google&message=Survey&color=blue&logo=google-sheets)](https://docs.google.com/forms/d/e/1FAIpQLSctdJHT_aEniyYT0-IUAEfo1hsIlezX2owlkEAYX4KPl2V2_A/viewform?usp=sf_link) |
| Platforms | ![JVM](https://img.shields.io/badge/JVM-red?style=plastic&logo=openjdk&logoColor=white) ![Js](https://img.shields.io/badge/JavaScript-323330?style=plastic&logo=javascript&logoColor=F7DF1E) |
| Experimental Platforms | [![Linux x64](https://img.shields.io/badge/LinuxX64-FCC624?style=plastic&logo=linux&logoColor=black)](https://kotlinlang.org/docs/native-target-support.html#tier-1) [![MinGW x64](https://img.shields.io/badge/MinGWX64-black?style=plastic&logo=windows&logoColor=green)](https://kotlinlang.org/docs/native-target-support.html#tier-1) |
| Docs | [![KDocs](https://img.shields.io/static/v1?label=Dokka&message=KDocs&color=blue&logo=kotlin)](https://tgbotapi.inmo.dev/index.html) [![Mini tutorial](https://img.shields.io/static/v1?label=Bookstack&message=Tutorial&color=blue&logo=bookstack)](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) |
|:---:|:---:|
| Useful repos | [![Create bot](https://img.shields.io/static/v1?label=Github&message=Template&color=blue&logo=github)](https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template/generate) [![Examples](https://img.shields.io/static/v1?label=Github&message=Examples&color=blue&logo=github)](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/) |
| Misc | [![Awesome Kotlin Badge](https://kotlin.link/awesome-kotlin.svg)](https://github.com/KotlinBy/awesome-kotlin) [![Small survey](https://img.shields.io/static/v1?label=Google&message=Survey&color=blue&logo=google-sheets)](https://docs.google.com/forms/d/e/1FAIpQLSctdJHT_aEniyYT0-IUAEfo1hsIlezX2owlkEAYX4KPl2V2_A/viewform?usp=sf_link) |
<!--- [![Telegram Channel](./resources/tg_channel_qr.jpg)](https://t.me/ktgbotapi) --->
<!--- [![Telegram Channel](./resources/tg_channel_qr.jpg)](https://t.me/InMoTelegramBotAPI) --->
<p align="center">
<a href="https://t.me/ktgbotapi">
<a href="https://t.me/InMoTelegramBotAPI">
<img src="./resources/tg_channel_qr.jpg">
</a>
</p>
@@ -118,5 +116,5 @@ suspend fun main() {
### More examples
You may find examples in [this project](https://github.com/InsanusMokrassar/TelegramBotAPI-examples). Besides, you are
always welcome in our [docs](https://docs.inmo.dev/tgbotapi/index.html) and
always welcome in our [bookstack](https://bookstack.inmo.dev/books/telegrambotapi) and
[chat](https://t.me/InMoTelegramBotAPIChat).

View File

@@ -14,17 +14,10 @@ buildscript {
}
}
plugins {
alias(libs.plugins.kotlin.dokka)
alias(libs.plugins.versions)
alias(libs.plugins.validator)
}
// temporal crutch until legacy tests will be stabled or legacy target will be removed
allprojects {
repositories {
mavenLocal()
maven { url "https://nexus.inmo.dev/repository/maven-releases/" }
mavenCentral()
google()
}
@@ -55,13 +48,13 @@ if (new File(projectDir, "secret.gradle").exists()) {
githubRelease {
token "${project.property('GITHUB_RELEASE_TOKEN')}"
owner = "InsanusMokrassar"
repo = "TelegramBotAPI"
owner "InsanusMokrassar"
repo "TelegramBotAPI"
tagName = "v$library_version"
releaseName = "$library_version"
targetCommitish = "$library_version"
tagName "v$library_version"
releaseName "$library_version"
targetCommitish "$library_version"
body = getCurrentVersionChangelog()
body getCurrentVersionChangelog()
}
}

View File

@@ -54,8 +54,8 @@ Object callback = {
skipDeprecated.set(true)
sourceLink {
localDirectory.set(file("../"))
remoteUrl.set(new URL("https://github.com/InsanusMokrassar/ktgbotapi/tree/master"))
localDirectory.set(file("./"))
remoteUrl.set(new URL("https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/"))
remoteLineSuffix.set("#L")
}
}

View File

@@ -6,4 +6,4 @@ kotlin.incremental=true
kotlin.incremental.js=true
library_group=dev.inmo
library_version=15.2.0
library_version=4.1.3

View File

@@ -1,27 +1,22 @@
[versions]
kotlin = "1.9.23"
kotlin-serialization = "1.6.3"
kotlin-coroutines = "1.8.1"
kotlin = "1.7.22"
kotlin-serialization = "1.4.1"
kotlin-coroutines = "1.6.4"
javax-activation = "1.1.1"
korlibs = "5.4.0"
uuid = "0.8.4"
ktor = "2.3.11"
korlibs = "3.4.0"
uuid = "0.6.0"
ktor = "2.1.3"
ksp = "1.9.23-1.0.20"
kotlin-poet = "1.16.0"
ksp = "1.7.21-1.0.8"
kotlin-poet = "1.12.0"
microutils = "0.21.2"
kslog = "1.3.4"
microutils = "0.14.4"
versions = "0.51.0"
github-release-plugin = "2.5.2"
dokka = "1.9.20"
validator = "0.14.0"
github-release-plugin = "2.4.1"
dokka = "1.7.20"
[libraries]
@@ -36,30 +31,24 @@ kotlin-test-js = { module = "org.jetbrains.kotlin:kotlin-test-js", version.ref =
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
ktor-client-curl = { module = "io.ktor:ktor-client-curl", version.ref = "ktor" }
ktor-client-winhttp = { module = "io.ktor:ktor-client-winhttp", version.ref = "ktor" }
ktor-server = { module = "io.ktor:ktor-server", version.ref = "ktor" }
ktor-server-host-common = { module = "io.ktor:ktor-server-host-common", version.ref = "ktor" }
javax-activation = { module = "javax.activation:activation", version.ref = "javax-activation" }
korlibs-klock = { module = "com.soywiz.korge:korlibs-time", version.ref = "korlibs" }
korlibs-krypto = { module = "com.soywiz.korge:korlibs-crypto", version.ref = "korlibs" }
korlibs-klock = { module = "com.soywiz.korlibs.klock:klock", version.ref = "korlibs" }
korlibs-krypto = { module = "com.soywiz.korlibs.krypto:krypto", version.ref = "korlibs" }
uuid = { module = "com.benasher44:uuid", version.ref = "uuid" }
microutils-colors-common = { module = "dev.inmo:micro_utils.colors.common", version.ref = "microutils" }
microutils-coroutines = { module = "dev.inmo:micro_utils.coroutines", version.ref = "microutils" }
microutils-serialization-base64 = { module = "dev.inmo:micro_utils.serialization.base64", version.ref = "microutils" }
microutils-serialization-encapsulator = { module = "dev.inmo:micro_utils.serialization.encapsulator", version.ref = "microutils" }
microutils-serialization-typedSerializer = { module = "dev.inmo:micro_utils.serialization.typed_serializer", version.ref = "microutils" }
microutils-serialization-mapper = { module = "dev.inmo:micro_utils.serialization.mapper", version.ref = "microutils" }
microutils-languageCodes = { module = "dev.inmo:micro_utils.language_codes", version.ref = "microutils" }
microutils-ktor-common = { module = "dev.inmo:micro_utils.ktor.common", version.ref = "microutils" }
microutils-fsm-common = { module = "dev.inmo:micro_utils.fsm.common", version.ref = "microutils" }
kslog = { module = "dev.inmo:kslog", version.ref = "kslog" }
# ksp dependencies
kotlin-poet = { module = "com.squareup:kotlinpoet-ksp", version.ref = "kotlin-poet" }
@@ -78,6 +67,3 @@ github-release-plugin = { module = "com.github.breadmoirai:github-release", vers
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
kotlin-dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
versions = { id = "com.github.ben-manes.versions", version.ref = "versions" }
validator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "validator" }

View File

@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip

View File

@@ -5,7 +5,7 @@ kotlin {
jvm {
compilations.main {
kotlinOptions {
jvmTarget = "17"
jvmTarget = "1.8"
}
}
}
@@ -13,9 +13,6 @@ kotlin {
browser()
nodejs()
}
linuxX64()
mingwX64()
linuxArm64()
sourceSets {
commonMain {
@@ -41,18 +38,10 @@ kotlin {
implementation libs.kotlin.test.junit
}
}
all {
languageSettings {
optIn('dev.inmo.tgbotapi.utils.RiskFeature')
optIn('dev.inmo.tgbotapi.utils.PreviewFeature')
optIn('dev.inmo.micro_utils.common.Warning')
optIn('dev.inmo.micro_utils.common.PreviewFeature')
}
}
}
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

View File

@@ -1,7 +1,7 @@
apply plugin: 'maven-publish'
task javadocsJar(type: Jar) {
archiveClassifier = 'javadoc'
classifier = 'javadoc'
}
publishing {
@@ -38,26 +38,30 @@ publishing {
}
}
repositories {
if ((project.hasProperty('GITHUB_USER') || System.getenv('GITHUB_USER') != null) && (project.hasProperty('GITHUB_TOKEN') || System.getenv('GITHUB_TOKEN') != null)) {
if ((project.hasProperty('GITHUBPACKAGES_USER') || System.getenv('GITHUBPACKAGES_USER') != null) && (project.hasProperty('GITHUBPACKAGES_PASSWORD') || System.getenv('GITHUBPACKAGES_PASSWORD') != null)) {
maven {
name = "GithubPackages"
url = uri("https://maven.pkg.github.com/InsanusMokrassar/ktgbotapi")
url = uri("https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI")
credentials {
username = project.hasProperty('GITHUB_USER') ? project.property('GITHUB_USER') : System.getenv('GITHUB_USER')
password = project.hasProperty('GITHUB_TOKEN') ? project.property('GITHUB_TOKEN') : System.getenv('GITHUB_TOKEN')
username = project.hasProperty('GITHUBPACKAGES_USER') ? project.property('GITHUBPACKAGES_USER') : System.getenv('GITHUBPACKAGES_USER')
password = project.hasProperty('GITHUBPACKAGES_PASSWORD') ? project.property('GITHUBPACKAGES_PASSWORD') : System.getenv('GITHUBPACKAGES_PASSWORD')
}
}
}
if ((project.hasProperty('INMONEXUS_USER') || System.getenv('INMONEXUS_USER') != null) && (project.hasProperty('INMONEXUS_PASSWORD') || System.getenv('INMONEXUS_PASSWORD') != null)) {
if (project.hasProperty('GITEA_TOKEN') || System.getenv('GITEA_TOKEN') != null) {
maven {
name = "InmoNexus"
url = uri("https://nexus.inmo.dev/repository/maven-releases/")
name = "Gitea"
url = uri("https://git.inmo.dev/api/packages/InsanusMokrassar/maven")
credentials {
username = project.hasProperty('INMONEXUS_USER') ? project.property('INMONEXUS_USER') : System.getenv('INMONEXUS_USER')
password = project.hasProperty('INMONEXUS_PASSWORD') ? project.property('INMONEXUS_PASSWORD') : System.getenv('INMONEXUS_PASSWORD')
credentials(HttpHeaderCredentials) {
name = "Authorization"
value = project.hasProperty('GITEA_TOKEN') ? project.property('GITEA_TOKEN') : System.getenv('GITEA_TOKEN')
}
authentication {
header(HttpHeaderAuthentication)
}
}
@@ -92,27 +96,4 @@ if (project.hasProperty("signing.gnupg.keyName")) {
dependsOn(it)
}
}
// Workaround to make android sign operations depend on signing tasks
project.getTasks().withType(AbstractPublishToMaven.class).configureEach {
def signingTasks = project.getTasks().withType(Sign.class)
mustRunAfter(signingTasks)
}
// Workaround to make test tasks use sign
project.getTasks().withType(Sign.class).configureEach { signTask ->
def withoutSign = (signTask.name.startsWith("sign") ? signTask.name.minus("sign") : signTask.name)
def pubName = withoutSign.endsWith("Publication") ? withoutSign.substring(0, withoutSign.length() - "Publication".length()) : withoutSign
// These tasks only exist for native targets, hence findByName() to avoid trying to find them for other targets
// Task ':linkDebugTest<platform>' uses this output of task ':sign<platform>Publication' without declaring an explicit or implicit dependency
def debugTestTask = tasks.findByName("linkDebugTest$pubName")
if (debugTestTask != null) {
signTask.mustRunAfter(debugTestTask)
}
// Task ':compileTestKotlin<platform>' uses this output of task ':sign<platform>Publication' without declaring an explicit or implicit dependency
def testTask = tasks.findByName("compileTestKotlin$pubName")
if (testTask != null) {
signTask.mustRunAfter(testTask)
}
}
}

View File

@@ -1 +1 @@
{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"${project.name}","description":"${project.description}","url":"https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}],"repositories":[{"name":"GithubPackages","url":"https://maven.pkg.github.com/InsanusMokrassar/ktgbotapi","credsType":{"type":"dev.inmo.kmppscriptbuilder.core.models.MavenPublishingRepository.CredentialsType.UsernameAndPassword","usernameProperty":"GITHUB_USER","passwordProperty":"GITHUB_TOKEN"}},{"name":"InmoNexus","url":"https://nexus.inmo.dev/repository/maven-releases/"},{"name":"sonatype","url":"https://oss.sonatype.org/service/local/staging/deploy/maven2/"}],"gpgSigning":{"type":"dev.inmo.kmppscriptbuilder.core.models.GpgSigning.Optional"}}}
{"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"${project.name}","description":"${project.description}","url":"https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}],"repositories":[{"name":"GithubPackages","url":"https://maven.pkg.github.com/InsanusMokrassar/TelegramBotAPI"},{"name":"Gitea","url":"https://git.inmo.dev/api/packages/InsanusMokrassar/maven","credsType":{"type":"dev.inmo.kmppscriptbuilder.core.models.MavenPublishingRepository.CredentialsType.HttpHeaderCredentials","headerName":"Authorization","headerValueProperty":"GITEA_TOKEN"}},{"name":"sonatype","url":"https://oss.sonatype.org/service/local/staging/deploy/maven2/"}],"gpgSigning":{"type":"dev.inmo.kmppscriptbuilder.core.models.GpgSigning.Optional"}}}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 448 KiB

After

Width:  |  Height:  |  Size: 593 KiB

View File

@@ -19,3 +19,4 @@ include ":tgbotapi.behaviour_builder"
include ":tgbotapi.behaviour_builder.fsm"
include ":tgbotapi"
include ":tgbotapi.webapps"
include ":docs"

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,6 @@
plugins {
id "org.jetbrains.kotlin.multiplatform"
id "org.jetbrains.kotlin.plugin.serialization"
id "org.jetbrains.dokka"
}
project.description = "API extensions with \"Telegram Bot API\"-like extensions for TelegramBot and RequestsExecutor"
@@ -16,9 +15,6 @@ kotlin {
api project(":tgbotapi.core")
}
}
configureEach {
languageSettings.optIn("kotlinx.serialization.ExperimentalSerializationApi")
}
}
explicitApi()
}

View File

@@ -12,7 +12,7 @@ import io.ktor.client.engine.*
* @param ktorClientEngine Engine like [io.ktor.client.engine.cio.CIO]
* @param ktorClientConfig Config block for preconfiguring of bot [HttpClient]
*/
public data class BotBuilder internal constructor(
data class BotBuilder internal constructor(
var proxy: ProxyConfig? = null,
var ktorClientEngineFactory: HttpClientEngineFactory<HttpClientEngineConfig>? = null,
var ktorClientConfig: (HttpClientConfig<*>.() -> Unit) ? = null
@@ -37,12 +37,12 @@ public data class BotBuilder internal constructor(
* @return Created by [telegramBotWithCustomClientConfig] function [TelegramBot]. This executor will be preconfigured using [token] and
* [block]
*/
public fun buildBot(
fun buildBot(
token: String,
apiUrl: String = telegramBotAPIDefaultUrl,
testServer: Boolean = false,
block: BotBuilder.() -> Unit
): TelegramBot = telegramBot(
) = telegramBot(
TelegramAPIUrlsKeeper(token, testServer, apiUrl),
BotBuilder().apply(block).createHttpClient()
)

View File

@@ -11,7 +11,7 @@ import io.ktor.client.engine.*
/**
* Allows to create bot using bot [urlsKeeper] and already prepared [client]
*/
public fun telegramBot(
fun telegramBot(
urlsKeeper: TelegramAPIUrlsKeeper,
client: HttpClient = HttpClient()
): TelegramBot = telegramBot(urlsKeeper) {
@@ -23,11 +23,11 @@ public fun telegramBot(
* configure it with [clientConfig]
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun <T: HttpClientEngineConfig> telegramBot(
inline fun <T: HttpClientEngineConfig> telegramBot(
urlsKeeper: TelegramAPIUrlsKeeper,
clientFactory: HttpClientEngineFactory<T>,
noinline clientConfig: HttpClientConfig<T>.() -> Unit = {}
): TelegramBot = telegramBot(
) = telegramBot(
urlsKeeper,
HttpClient(clientFactory, clientConfig)
)
@@ -37,11 +37,11 @@ public inline fun <T: HttpClientEngineConfig> telegramBot(
* configure [HttpClient] using [clientConfig]
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun telegramBot(
inline fun telegramBot(
urlsKeeper: TelegramAPIUrlsKeeper,
clientEngine: HttpClientEngine,
noinline clientConfig: HttpClientConfig<*>.() -> Unit = {}
): TelegramBot = telegramBot(
) = telegramBot(
urlsKeeper,
HttpClient(clientEngine, clientConfig)
)
@@ -51,10 +51,10 @@ public inline fun telegramBot(
* [clientConfig]
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun telegramBot(
inline fun telegramBot(
urlsKeeper: TelegramAPIUrlsKeeper,
noinline clientConfig: HttpClientConfig<*>.() -> Unit
): TelegramBot = telegramBot(
) = telegramBot(
urlsKeeper,
HttpClient(clientConfig)
)
@@ -63,7 +63,7 @@ public inline fun telegramBot(
* Allows to create bot using bot [token], [apiUrl] (for custom api servers) and already prepared [client]
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun telegramBot(
inline fun telegramBot(
token: String,
apiUrl: String = telegramBotAPIDefaultUrl,
testServer: Boolean = false,
@@ -71,13 +71,13 @@ public inline fun telegramBot(
): TelegramBot = telegramBot(TelegramAPIUrlsKeeper(token, testServer, apiUrl), client)
@Suppress("NOTHING_TO_INLINE")
public inline fun <T: HttpClientEngineConfig> telegramBot(
inline fun <T: HttpClientEngineConfig> telegramBot(
token: String,
clientFactory: HttpClientEngineFactory<T>,
apiUrl: String = telegramBotAPIDefaultUrl,
testServer: Boolean = false,
noinline clientConfig: HttpClientConfig<T>.() -> Unit = {}
): TelegramBot = telegramBot(
) = telegramBot(
TelegramAPIUrlsKeeper(token, testServer, apiUrl),
clientFactory,
clientConfig
@@ -88,13 +88,13 @@ public inline fun <T: HttpClientEngineConfig> telegramBot(
* configure [HttpClient] using [clientConfig]
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun telegramBot(
inline fun telegramBot(
token: String,
clientEngine: HttpClientEngine,
apiUrl: String = telegramBotAPIDefaultUrl,
testServer: Boolean = false,
noinline clientConfig: HttpClientConfig<*>.() -> Unit = {}
): TelegramBot = telegramBot(
) = telegramBot(
TelegramAPIUrlsKeeper(token, testServer, apiUrl),
clientEngine,
clientConfig
@@ -105,12 +105,12 @@ public inline fun telegramBot(
* [clientConfig]
*/
@Suppress("NOTHING_TO_INLINE")
public inline fun telegramBot(
inline fun telegramBot(
token: String,
apiUrl: String = telegramBotAPIDefaultUrl,
testServer: Boolean = false,
noinline clientConfig: HttpClientConfig<*>.() -> Unit
): TelegramBot = telegramBot(
) = telegramBot(
TelegramAPIUrlsKeeper(token, testServer, apiUrl),
clientConfig
)

View File

@@ -4,4 +4,4 @@ import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.local.Close
@Suppress("unused")
public suspend inline fun TelegramBot.close(): Boolean = execute(Close)
suspend inline fun TelegramBot.close() = execute(Close)

View File

@@ -5,49 +5,38 @@ import dev.inmo.tgbotapi.requests.DeleteMessage
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.content.MediaGroupCollectionContent
import dev.inmo.tgbotapi.types.message.abstracts.Message
public suspend fun TelegramBot.deleteMessage(
suspend fun TelegramBot.deleteMessage(
chatId: ChatIdentifier,
messageId: MessageId
): Boolean = execute(
) = execute(
DeleteMessage(chatId, messageId)
)
public suspend fun TelegramBot.deleteMessage(
suspend fun TelegramBot.deleteMessage(
chat: Chat,
messageId: MessageId
): Boolean = deleteMessage(chat.id, messageId)
) = deleteMessage(chat.id, messageId)
public suspend fun TelegramBot.deleteMessage(
message: AccessibleMessage
): Boolean {
val mediaGroupContent = ((message as? ContentMessage<*>) ?.content as? MediaGroupCollectionContent<*>)
if (mediaGroupContent == null) {
return deleteMessage(message.chat, message.messageId)
} else {
return mediaGroupContent.group.map {
deleteMessage(it.sourceMessage)
}.all { it }
}
}
suspend fun TelegramBot.deleteMessage(
message: Message
) = deleteMessage(message.chat, message.messageId)
public suspend fun TelegramBot.delete(
suspend fun TelegramBot.delete(
chatId: ChatIdentifier,
messageId: MessageId
): Boolean = deleteMessage(chatId, messageId)
) = deleteMessage(chatId, messageId)
public suspend fun TelegramBot.delete(
suspend fun TelegramBot.delete(
chat: Chat,
messageId: MessageId
): Boolean = deleteMessage(chat, messageId)
) = deleteMessage(chat, messageId)
public suspend fun TelegramBot.delete(
message: AccessibleMessage
): Boolean = deleteMessage(message)
suspend fun TelegramBot.delete(
message: Message
) = deleteMessage(message)
public suspend fun AccessibleMessage.delete(
suspend fun Message.delete(
requestsExecutor: TelegramBot
): Boolean = requestsExecutor.deleteMessage(this)
) = requestsExecutor.deleteMessage(this)

View File

@@ -1,61 +0,0 @@
package dev.inmo.tgbotapi.extensions.api
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.DeleteMessages
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.abstracts.Message
import kotlin.jvm.JvmName
public suspend fun TelegramBot.deleteMessages(
chatId: ChatIdentifier,
messageIds: List<MessageId>
): Boolean = messageIds.chunked(deleteMessagesLimit.last).map {
execute(
DeleteMessages(
chatId = chatId,
messageIds = it
)
)
}.all { it }
public suspend fun TelegramBot.deleteMessages(
chatId: ChatIdentifier,
messageIds: Array<MessageId>
): Boolean = deleteMessages(
chatId = chatId,
messageIds = messageIds.toList()
)
public suspend fun TelegramBot.deleteMessages(
messagesMetas: List<Message.MetaInfo>
): Boolean = messagesMetas.groupBy { it.chatId }.map { (chatId, messages) ->
deleteMessages(
chatId = chatId,
messageIds = messages.map { it.messageId }
)
}.all { it }
@JvmName("deleteMessagesWithMessages")
public suspend fun TelegramBot.deleteMessages(
messages: List<AccessibleMessage>
): Boolean = deleteMessages(messages.map { it.metaInfo })
public suspend fun TelegramBot.delete(
chatId: ChatIdentifier,
messageIds: List<MessageId>
): Boolean = deleteMessages(chatId = chatId, messageIds = messageIds)
public suspend fun TelegramBot.delete(
chatId: ChatIdentifier,
messageIds: Array<MessageId>
): Boolean = deleteMessages(chatId = chatId, messageIds = messageIds)
public suspend fun TelegramBot.delete(
messagesMetas: List<Message.MetaInfo>
): Boolean = deleteMessages(messagesMetas)
@JvmName("deleteWithMessages")
public suspend fun TelegramBot.delete(
messages: List<AccessibleMessage>
): Boolean = deleteMessages(messages)

View File

@@ -6,60 +6,59 @@ import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.abstracts.PossiblyForwardedMessage
import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.types.threadId
public suspend fun TelegramBot.forwardMessage(
suspend fun TelegramBot.forwardMessage(
fromChatId: ChatIdentifier,
toChatId: ChatIdentifier,
messageId: MessageId,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false
): PossiblyForwardedMessage = execute(
) = execute(
ForwardMessage(fromChatId, toChatId, messageId, threadId, disableNotification, protectContent)
)
public suspend fun TelegramBot.forwardMessage(
suspend fun TelegramBot.forwardMessage(
fromChat: Chat,
toChatId: ChatIdentifier,
messageId: MessageId,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false
): PossiblyForwardedMessage = forwardMessage(fromChat.id, toChatId, messageId, threadId, disableNotification, protectContent)
) = forwardMessage(fromChat.id, toChatId, messageId, threadId, disableNotification, protectContent)
public suspend fun TelegramBot.forwardMessage(
suspend fun TelegramBot.forwardMessage(
fromChatId: ChatIdentifier,
toChat: Chat,
messageId: MessageId,
threadId: MessageThreadId? = toChat.id.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false
): PossiblyForwardedMessage = forwardMessage(fromChatId, toChat.id, messageId, threadId, disableNotification, protectContent)
) = forwardMessage(fromChatId, toChat.id, messageId, threadId, disableNotification, protectContent)
public suspend fun TelegramBot.forwardMessage(
suspend fun TelegramBot.forwardMessage(
fromChat: Chat,
toChat: Chat,
messageId: MessageId,
threadId: MessageThreadId? = toChat.id.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false
): PossiblyForwardedMessage = forwardMessage(fromChat.id, toChat.id, messageId, threadId, disableNotification, protectContent)
) = forwardMessage(fromChat.id, toChat.id, messageId, threadId, disableNotification, protectContent)
public suspend fun TelegramBot.forwardMessage(
suspend fun TelegramBot.forwardMessage(
toChatId: ChatIdentifier,
message: AccessibleMessage,
message: Message,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false
): PossiblyForwardedMessage = forwardMessage(message.chat, toChatId, message.messageId, threadId, disableNotification, protectContent)
) = forwardMessage(message.chat, toChatId, message.messageId, threadId, disableNotification, protectContent)
public suspend fun TelegramBot.forwardMessage(
suspend fun TelegramBot.forwardMessage(
toChat: Chat,
message: AccessibleMessage,
message: Message,
threadId: MessageThreadId? = toChat.id.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false
): PossiblyForwardedMessage = forwardMessage(message.chat, toChat, message.messageId, threadId, disableNotification, protectContent)
) = forwardMessage(message.chat, toChat, message.messageId, threadId, disableNotification, protectContent)

View File

@@ -1,154 +0,0 @@
package dev.inmo.tgbotapi.extensions.api
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.extensions.api.send.copyMessages
import dev.inmo.tgbotapi.requests.ForwardMessages
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.abstracts.Message
import kotlin.jvm.JvmName
public suspend fun TelegramBot.forwardMessages(
toChatId: ChatIdentifier,
fromChatId: ChatIdentifier,
messageIds: List<MessageId>,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
): List<MessageId> = messageIds.chunked(forwardMessagesLimit.last).flatMap {
execute(
ForwardMessages(
toChatId = toChatId,
fromChatId = fromChatId,
messageIds = it,
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption
)
)
}
public suspend fun TelegramBot.forwardMessages(
toChatId: ChatIdentifier,
fromChatId: ChatIdentifier,
messageIds: Array<MessageId>,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
): List<MessageId> = forwardMessages(
toChatId = toChatId,
fromChatId = fromChatId,
messageIds = messageIds.toList(),
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption
)
public suspend fun TelegramBot.forwardMessages(
toChatId: ChatIdentifier,
messagesMetas: List<Message.MetaInfo>,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
): List<MessageId> = messagesMetas.groupBy { it.chatId }.flatMap { (chatId, messages) ->
forwardMessages(
toChatId = toChatId,
fromChatId = chatId,
messageIds = messages.map { it.messageId },
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption
)
}
@JvmName("forwardMessagesWithMessages")
public suspend fun TelegramBot.forwardMessages(
toChatId: ChatIdentifier,
messages: List<AccessibleMessage>,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
): List<MessageId> = forwardMessages(
toChatId = toChatId,
messagesMetas = messages.map { it.metaInfo },
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption
)
public suspend fun TelegramBot.forward(
toChatId: ChatIdentifier,
fromChatId: ChatIdentifier,
messageIds: List<MessageId>,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
): List<MessageId> = forwardMessages(
toChatId = toChatId,
fromChatId = fromChatId,
messageIds = messageIds,
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption
)
public suspend fun TelegramBot.forward(
toChatId: ChatIdentifier,
fromChatId: ChatIdentifier,
messageIds: Array<MessageId>,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
): List<MessageId> = forwardMessages(
toChatId = toChatId,
fromChatId = fromChatId,
messageIds = messageIds,
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption
)
public suspend fun TelegramBot.forward(
toChatId: ChatIdentifier,
messagesMetas: List<Message.MetaInfo>,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
): List<MessageId> = forwardMessages(
toChatId = toChatId,
messagesMetas = messagesMetas,
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption
)
@JvmName("forwardWithMessages")
public suspend fun TelegramBot.forward(
toChatId: ChatIdentifier,
messages: List<AccessibleMessage>,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
): List<MessageId> = forwardMessages(
toChatId = toChatId,
messages = messages,
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
removeCaption = removeCaption
)

View File

@@ -5,22 +5,22 @@ import dev.inmo.tgbotapi.requests.GetUpdates
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.update.abstracts.Update
public suspend fun TelegramBot.getUpdates(
offset: UpdateId? = null,
suspend fun TelegramBot.getUpdates(
offset: UpdateIdentifier? = null,
limit: Int = getUpdatesLimit.last,
timeout: Seconds? = null,
allowed_updates: List<String>? = ALL_UPDATES_LIST
): List<Update> = execute(
) = execute(
GetUpdates(
offset, limit, timeout, allowed_updates
)
)
public suspend fun TelegramBot.getUpdates(
suspend fun TelegramBot.getUpdates(
lastUpdate: Update,
limit: Int = getUpdatesLimit.last,
timeout: Seconds? = null,
allowed_updates: List<String>? = ALL_UPDATES_LIST
): List<Update> = getUpdates(
) = getUpdates(
lastUpdate.updateId + 1, limit, timeout, allowed_updates
)

View File

@@ -1,27 +0,0 @@
package dev.inmo.tgbotapi.extensions.api
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.GetUpdatesRaw
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.update.abstracts.Update
import kotlinx.serialization.json.JsonArray
public suspend fun TelegramBot.getRawUpdates(
offset: UpdateId? = null,
limit: Int = getUpdatesLimit.last,
timeout: Seconds? = null,
allowed_updates: List<String>? = ALL_UPDATES_LIST
): JsonArray = execute(
GetUpdatesRaw(
offset, limit, timeout, allowed_updates
)
)
public suspend fun TelegramBot.getRawUpdates(
lastUpdate: Update,
limit: Int = getUpdatesLimit.last,
timeout: Seconds? = null,
allowed_updates: List<String>? = ALL_UPDATES_LIST
): JsonArray = getRawUpdates(
lastUpdate.updateId + 1, limit, timeout, allowed_updates
)

View File

@@ -1,6 +1,6 @@
package dev.inmo.tgbotapi.extensions.api.InternalUtils
import dev.inmo.tgbotapi.types.MediaGroupId
import dev.inmo.tgbotapi.types.MediaGroupIdentifier
import dev.inmo.tgbotapi.types.message.abstracts.PossiblySentViaBotCommonMessage
import dev.inmo.tgbotapi.types.message.content.MediaGroupPartContent
import dev.inmo.tgbotapi.types.update.*
@@ -12,7 +12,7 @@ import dev.inmo.tgbotapi.utils.extensions.asMediaGroupMessage
*/
internal fun List<Update>.convertWithMediaGroupUpdates(): List<Update> {
val resultUpdates = mutableListOf<Update>()
val mediaGroups = mutableMapOf<MediaGroupId, MutableList<Pair<BaseSentMessageUpdate, PossiblySentViaBotCommonMessage<MediaGroupPartContent>>>>()
val mediaGroups = mutableMapOf<MediaGroupIdentifier, MutableList<Pair<BaseSentMessageUpdate, PossiblySentViaBotCommonMessage<MediaGroupPartContent>>>>()
for (update in this) {
val message = (update.data as? PossiblySentViaBotCommonMessage<*>) ?.let {

View File

@@ -1,38 +1,30 @@
package dev.inmo.tgbotapi.extensions.api
import dev.inmo.micro_utils.coroutines.LinkedSupervisorScope
import dev.inmo.micro_utils.coroutines.LinkedSupervisorJob
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
import dev.inmo.tgbotapi.abstracts.Headed
import dev.inmo.tgbotapi.abstracts.HorizontallyAccured
import dev.inmo.tgbotapi.abstracts.Locationed
import dev.inmo.tgbotapi.abstracts.ProximityAlertable
import dev.inmo.tgbotapi.abstracts.*
import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.extensions.api.edit.edit
import dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation
import dev.inmo.tgbotapi.extensions.api.send.send
import dev.inmo.tgbotapi.extensions.api.send.sendLiveLocation
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.location.LiveLocation
import dev.inmo.tgbotapi.types.location.Location
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.content.LiveLocationContent
import dev.inmo.tgbotapi.types.message.content.LocationContent
import kotlinx.coroutines.CoroutineStart
import kotlinx.coroutines.currentCoroutineContext
import kotlinx.coroutines.delay
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.FlowCollector
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.isActive
import kotlinx.serialization.Serializable
import kotlin.js.JsName
import kotlin.jvm.JvmName
import kotlin.math.ceil
@Serializable
public data class EditLiveLocationInfo(
data class EditLiveLocationInfo(
override val latitude: Double,
override val longitude: Double,
override val horizontalAccuracy: Meters? = null,
@@ -45,69 +37,53 @@ public data class EditLiveLocationInfo(
* Will [sendLiveLocation] with the first [EditLiveLocationInfo] data and update than. Each [liveTimeMillis] passing,
* the message will be sent again and new edits will be applied to the new message
*/
public suspend fun TelegramBot.handleLiveLocation(
suspend fun TelegramBot.handleLiveLocation(
chatId: ChatIdentifier,
locationsFlow: Flow<EditLiveLocationInfo>,
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
threadId: MessageThreadId? = chatId.threadId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
effectId: EffectId? = null,
replyParameters: ReplyParameters? = null,
sentMessageFlow: FlowCollector<ContentMessage<LiveLocationContent>>? = null
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null
) {
var currentLiveLocationMessage: ContentMessage<LiveLocationContent>? = null
val updateMessageJob = if (liveTimeMillis == indefiniteLivePeriodDelayMillis) { // do not launch refreshing of message for indefinite live locations
null
} else {
val scope = currentCoroutineContext().LinkedSupervisorScope()
scope.launchSafelyWithoutExceptions(start = CoroutineStart.LAZY) {
while (scope.isActive) {
delay(liveTimeMillis)
// Remove previous location message info to resend live location message
currentLiveLocationMessage = null
}
var currentLiveLocationMessage: ContentMessage<LocationContent>? = null
val updateMessageJob = CoroutineScope(currentCoroutineContext().LinkedSupervisorJob()).launchSafelyWithoutExceptions(start = CoroutineStart.LAZY) {
while (isActive) {
delay(liveTimeMillis)
// Remove previous location message info to resend live location message
currentLiveLocationMessage = null
}
}
locationsFlow.collect {
val capturedLiveLocationMessage = currentLiveLocationMessage
if (capturedLiveLocationMessage == null) {
updateMessageJob ?.start()
updateMessageJob.start()
currentLiveLocationMessage = send(
chatId,
it.latitude,
it.longitude,
if (liveTimeMillis == indefiniteLivePeriodDelayMillis) {
LiveLocation.INDEFINITE_LIVE_PERIOD
} else {
ceil(liveTimeMillis.toDouble() / 1000).toInt()
},
ceil(liveTimeMillis.toDouble() / 1000).toInt(),
it.horizontalAccuracy,
it.heading,
it.proximityAlertRadius,
threadId,
businessConnectionId,
disableNotification,
protectContent,
effectId,
replyParameters,
replyToMessageId,
allowSendingWithoutReply,
it.replyMarkup
).also {
sentMessageFlow ?.emit(it)
}
)
} else {
edit(
message = capturedLiveLocationMessage,
latitude = it.latitude,
longitude = it.longitude,
horizontalAccuracy = it.horizontalAccuracy,
heading = it.heading,
proximityAlertRadius = it.proximityAlertRadius,
replyMarkup = it.replyMarkup
).also {
sentMessageFlow ?.emit(it)
}
capturedLiveLocationMessage,
it.latitude,
it.longitude,
it.horizontalAccuracy,
it.heading,
it.proximityAlertRadius,
it.replyMarkup
)
}
}
}
@@ -118,21 +94,19 @@ public suspend fun TelegramBot.handleLiveLocation(
*/
@JvmName("handleLiveLocationWithLocation")
@JsName("handleLiveLocationWithLocation")
public suspend fun TelegramBot.handleLiveLocation(
suspend fun TelegramBot.handleLiveLocation(
chatId: ChatIdentifier,
locationsFlow: Flow<Location>,
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
threadId: MessageThreadId? = chatId.threadId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
effectId: EffectId? = null,
replyParameters: ReplyParameters? = null,
sentMessageFlow: FlowCollector<ContentMessage<LiveLocationContent>>? = null
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null
) {
handleLiveLocation(
chatId = chatId,
locationsFlow = locationsFlow.map {
chatId,
locationsFlow.map {
EditLiveLocationInfo(
it.latitude,
it.longitude,
@@ -142,14 +116,12 @@ public suspend fun TelegramBot.handleLiveLocation(
(it as? WithReplyMarkup) ?.replyMarkup as? InlineKeyboardMarkup
)
},
liveTimeMillis = liveTimeMillis,
threadId = threadId,
businessConnectionId = businessConnectionId,
disableNotification = disableNotification,
protectContent = protectContent,
effectId = effectId,
replyParameters = replyParameters,
sentMessageFlow = sentMessageFlow
liveTimeMillis,
threadId,
disableNotification,
protectContent,
replyToMessageId,
allowSendingWithoutReply
)
}
@@ -159,33 +131,29 @@ public suspend fun TelegramBot.handleLiveLocation(
*/
@JvmName("handleLiveLocationWithLatLong")
@JsName("handleLiveLocationWithLatLong")
public suspend fun TelegramBot.handleLiveLocation(
suspend fun TelegramBot.handleLiveLocation(
chatId: ChatIdentifier,
locationsFlow: Flow<Pair<Double, Double>>,
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
threadId: MessageThreadId? = chatId.threadId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
effectId: EffectId? = null,
replyParameters: ReplyParameters? = null,
sentMessageFlow: FlowCollector<ContentMessage<LiveLocationContent>>? = null
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null
) {
handleLiveLocation(
chatId = chatId,
locationsFlow = locationsFlow.map { (lat, long) ->
chatId,
locationsFlow.map { (lat, long) ->
EditLiveLocationInfo(
lat,
long
)
},
liveTimeMillis = liveTimeMillis,
threadId = threadId,
businessConnectionId = businessConnectionId,
disableNotification = disableNotification,
protectContent = protectContent,
effectId = effectId,
replyParameters = replyParameters,
sentMessageFlow = sentMessageFlow
liveTimeMillis,
threadId,
disableNotification,
protectContent,
replyToMessageId,
allowSendingWithoutReply
)
}

View File

@@ -1,35 +1,32 @@
package dev.inmo.tgbotapi.extensions.api
import korlibs.time.DateTime
import korlibs.time.TimeSpan
import com.soywiz.klock.DateTime
import com.soywiz.klock.TimeSpan
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation
import dev.inmo.tgbotapi.extensions.api.edit.location.live.stopLiveLocation
import dev.inmo.tgbotapi.requests.send.SendLiveLocation
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.location.LiveLocation
import dev.inmo.tgbotapi.types.location.StaticLocation
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.types.message.content.LocationContent
import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull
import io.ktor.utils.io.core.Closeable
import korlibs.time.millisecondsLong
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import kotlin.math.ceil
public const val indefiniteLivePeriodDelayMillis: Long = LiveLocation.INDEFINITE_LIVE_PERIOD * 1000L
public const val defaultLivePeriodDelayMillis: Long = indefiniteLivePeriodDelayMillis
val defaultLivePeriodDelayMillis = (livePeriodLimit.last - 60L) * 1000L
/**
* @see startLiveLocation
*/
public class LiveLocationProvider internal constructor(
class LiveLocationProvider internal constructor(
private val requestsExecutor: TelegramBot,
scope: CoroutineScope,
autoCloseTimeDelay: Double,
@@ -41,23 +38,22 @@ public class LiveLocationProvider internal constructor(
}
}
private val autoCloseTime = DateTime.now() + TimeSpan(autoCloseTimeDelay)
public val leftUntilCloseMillis: TimeSpan
val leftUntilCloseMillis: TimeSpan
get() = autoCloseTime - DateTime.now()
public var isClosed: Boolean = false
var isClosed: Boolean = false
private set
get() = field || leftUntilCloseMillis.millisecondsLong < 0L
public var message: ContentMessage<LocationContent> = initMessage
private set
public val lastLocation: LiveLocation
private var message: ContentMessage<LocationContent> = initMessage
val lastLocation: LiveLocation
get() = message.content.location as LiveLocation
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun updateLocation(
suspend fun updateLocation(
location: LiveLocation,
replyMarkup: InlineKeyboardMarkup? = null
): LiveLocation {
@@ -65,7 +61,7 @@ public class LiveLocationProvider internal constructor(
message = requestsExecutor.editLiveLocation(
message,
location,
replyMarkup = replyMarkup
replyMarkup
)
return lastLocation
} else {
@@ -86,7 +82,7 @@ public class LiveLocationProvider internal constructor(
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/
public suspend fun TelegramBot.startLiveLocation(
suspend fun TelegramBot.startLiveLocation(
scope: CoroutineScope,
chatId: ChatIdentifier,
latitude: Double,
@@ -96,11 +92,10 @@ public suspend fun TelegramBot.startLiveLocation(
initHeading: Degrees? = null,
initProximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = chatId.threadId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
effectId: EffectId? = null,
replyParameters: ReplyParameters? = null,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
): LiveLocationProvider {
val liveTimeAsDouble = liveTimeMillis.toDouble()
@@ -114,11 +109,10 @@ public suspend fun TelegramBot.startLiveLocation(
initHeading,
initProximityAlertRadius,
threadId,
businessConnectionId,
disableNotification,
protectContent,
effectId,
replyParameters,
replyToMessageId,
allowSendingWithoutReply,
replyMarkup
)
)
@@ -135,7 +129,7 @@ public suspend fun TelegramBot.startLiveLocation(
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/
public suspend fun TelegramBot.startLiveLocation(
suspend fun TelegramBot.startLiveLocation(
scope: CoroutineScope,
chat: Chat,
latitude: Double,
@@ -145,11 +139,10 @@ public suspend fun TelegramBot.startLiveLocation(
initHeading: Degrees? = null,
initProximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = chat.id.threadId,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
effectId: EffectId? = null,
replyParameters: ReplyParameters? = null,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
): LiveLocationProvider = startLiveLocation(
scope,
@@ -161,11 +154,10 @@ public suspend fun TelegramBot.startLiveLocation(
initHeading,
initProximityAlertRadius,
threadId,
businessConnectionId,
disableNotification,
protectContent,
effectId,
replyParameters,
replyToMessageId,
allowSendingWithoutReply,
replyMarkup
)
@@ -173,7 +165,7 @@ public suspend fun TelegramBot.startLiveLocation(
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/
public suspend fun TelegramBot.startLiveLocation(
suspend fun TelegramBot.startLiveLocation(
scope: CoroutineScope,
chatId: IdChatIdentifier,
location: StaticLocation,
@@ -182,11 +174,10 @@ public suspend fun TelegramBot.startLiveLocation(
initHeading: Degrees? = null,
initProximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = chatId.threadId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
effectId: EffectId? = null,
replyParameters: ReplyParameters? = null,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
): LiveLocationProvider = startLiveLocation(
scope,
@@ -198,11 +189,10 @@ public suspend fun TelegramBot.startLiveLocation(
initHeading,
initProximityAlertRadius,
threadId,
businessConnectionId,
disableNotification,
protectContent,
effectId,
replyParameters,
replyToMessageId,
allowSendingWithoutReply,
replyMarkup
)
@@ -210,7 +200,7 @@ public suspend fun TelegramBot.startLiveLocation(
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/
public suspend fun TelegramBot.startLiveLocation(
suspend fun TelegramBot.startLiveLocation(
scope: CoroutineScope,
chat: Chat,
location: StaticLocation,
@@ -219,11 +209,10 @@ public suspend fun TelegramBot.startLiveLocation(
initHeading: Degrees? = null,
initProximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = chat.id.threadId,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
effectId: EffectId? = null,
replyParameters: ReplyParameters? = null,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
): LiveLocationProvider = startLiveLocation(
scope,
@@ -235,11 +224,10 @@ public suspend fun TelegramBot.startLiveLocation(
initHeading,
initProximityAlertRadius,
threadId,
businessConnectionId,
disableNotification,
protectContent,
effectId,
replyParameters,
replyToMessageId,
allowSendingWithoutReply,
replyMarkup
)
@@ -247,8 +235,8 @@ public suspend fun TelegramBot.startLiveLocation(
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/
public suspend inline fun TelegramBot.replyWithLiveLocation(
to: AccessibleMessage,
suspend inline fun TelegramBot.replyWithLiveLocation(
to: Message,
scope: CoroutineScope,
latitude: Double,
longitude: Double,
@@ -257,13 +245,11 @@ public suspend inline fun TelegramBot.replyWithLiveLocation(
initHeading: Degrees? = null,
initProximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = to.threadIdOrNull,
businessConnectionId: BusinessConnectionId? = to.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
effectId: EffectId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
): LiveLocationProvider = startLiveLocation(
) = startLiveLocation(
scope,
to.chat,
latitude,
@@ -273,11 +259,10 @@ public suspend inline fun TelegramBot.replyWithLiveLocation(
initHeading,
initProximityAlertRadius,
threadId,
businessConnectionId,
disableNotification,
protectContent,
effectId,
ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply),
to.messageId,
allowSendingWithoutReply,
replyMarkup
)
@@ -285,8 +270,8 @@ public suspend inline fun TelegramBot.replyWithLiveLocation(
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/
public suspend inline fun TelegramBot.replyWithLiveLocation(
to: AccessibleMessage,
suspend inline fun TelegramBot.replyWithLiveLocation(
to: Message,
scope: CoroutineScope,
location: StaticLocation,
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
@@ -294,13 +279,11 @@ public suspend inline fun TelegramBot.replyWithLiveLocation(
initHeading: Degrees? = null,
initProximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = to.threadIdOrNull,
businessConnectionId: BusinessConnectionId? = to.businessConnectionId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
effectId: EffectId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
): LiveLocationProvider = startLiveLocation(
) = startLiveLocation(
scope,
to.chat,
location,
@@ -309,10 +292,9 @@ public suspend inline fun TelegramBot.replyWithLiveLocation(
initHeading,
initProximityAlertRadius,
threadId,
businessConnectionId,
disableNotification,
protectContent,
effectId,
ReplyParameters(to.metaInfo, allowSendingWithoutReply = allowSendingWithoutReply),
to.messageId,
allowSendingWithoutReply,
replyMarkup
)

View File

@@ -3,4 +3,4 @@ package dev.inmo.tgbotapi.extensions.api
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.local.LogOut
public suspend inline fun TelegramBot.logOut(): Boolean = execute(LogOut)
suspend inline fun TelegramBot.logOut() = execute(LogOut)

View File

@@ -3,54 +3,48 @@ package dev.inmo.tgbotapi.extensions.api
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.StopPoll
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.polls.Poll
import dev.inmo.tgbotapi.types.message.abstracts.Message
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.stopPoll(
suspend fun TelegramBot.stopPoll(
chatId: ChatIdentifier,
messageId: MessageId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
replyMarkup: InlineKeyboardMarkup? = null
): Poll = execute(
StopPoll(chatId, messageId, businessConnectionId, replyMarkup)
) = execute(
StopPoll(chatId, messageId, replyMarkup)
)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.stopPoll(
suspend fun TelegramBot.stopPoll(
chat: Chat,
messageId: MessageId,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
replyMarkup: InlineKeyboardMarkup? = null
): Poll = stopPoll(chat.id, messageId, businessConnectionId, replyMarkup)
) = stopPoll(chat.id, messageId, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.stopPoll(
suspend fun TelegramBot.stopPoll(
chatId: IdChatIdentifier,
message: AccessibleMessage,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
message: Message,
replyMarkup: InlineKeyboardMarkup? = null
): Poll = stopPoll(chatId, message.messageId, businessConnectionId, replyMarkup)
) = stopPoll(chatId, message.messageId, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.stopPoll(
suspend fun TelegramBot.stopPoll(
chat: Chat,
message: AccessibleMessage,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
message: Message,
replyMarkup: InlineKeyboardMarkup? = null
): Poll = stopPoll(chat.id, message.messageId, businessConnectionId, replyMarkup)
) = stopPoll(chat.id, message.messageId, replyMarkup)

View File

@@ -3,28 +3,28 @@ package dev.inmo.tgbotapi.extensions.api.answers
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.answers.AnswerCallbackQuery
import dev.inmo.tgbotapi.types.queries.callback.CallbackQuery
import dev.inmo.tgbotapi.types.CallbackQueryId
import dev.inmo.tgbotapi.types.CallbackQueryIdentifier
public suspend fun TelegramBot.answerCallbackQuery(
callbackQueryId: CallbackQueryId,
suspend fun TelegramBot.answerCallbackQuery(
callbackQueryId: CallbackQueryIdentifier,
text: String? = null,
showAlert: Boolean? = null,
url: String? = null,
cachedTimeSeconds: Int? = null
): Boolean = execute(AnswerCallbackQuery(callbackQueryId, text, showAlert, url, cachedTimeSeconds))
) = execute(AnswerCallbackQuery(callbackQueryId, text, showAlert, url, cachedTimeSeconds))
public suspend fun TelegramBot.answerCallbackQuery(
suspend fun TelegramBot.answerCallbackQuery(
callbackQuery: CallbackQuery,
text: String? = null,
showAlert: Boolean? = null,
url: String? = null,
cachedTimeSeconds: Int? = null
): Boolean = answerCallbackQuery(callbackQuery.id, text, showAlert, url, cachedTimeSeconds)
) = answerCallbackQuery(callbackQuery.id, text, showAlert, url, cachedTimeSeconds)
public suspend fun TelegramBot.answer(
suspend fun TelegramBot.answer(
callbackQuery: CallbackQuery,
text: String? = null,
showAlert: Boolean? = null,
url: String? = null,
cachedTimeSeconds: Int? = null
): Boolean = answerCallbackQuery(callbackQuery.id, text, showAlert, url, cachedTimeSeconds)
) = answerCallbackQuery(callbackQuery.id, text, showAlert, url, cachedTimeSeconds)

View File

@@ -2,68 +2,38 @@ package dev.inmo.tgbotapi.extensions.api.answers
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.answers.AnswerInlineQuery
import dev.inmo.tgbotapi.requests.answers.InlineQueryResultsButton
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
import dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery
import dev.inmo.tgbotapi.types.InlineQueryId
import dev.inmo.tgbotapi.types.InlineQueryIdentifier
public suspend fun TelegramBot.answerInlineQuery(
inlineQueryID: InlineQueryId,
suspend fun TelegramBot.answerInlineQuery(
inlineQueryID: InlineQueryIdentifier,
results: List<InlineQueryResult> = emptyList(),
cachedTime: Int? = null,
isPersonal: Boolean? = null,
nextOffset: String? = null,
button: InlineQueryResultsButton? = null
): Boolean = execute(
AnswerInlineQuery(inlineQueryID, results, cachedTime, isPersonal, nextOffset, button)
)
public suspend fun TelegramBot.answerInlineQuery(
inlineQuery: InlineQuery,
results: List<InlineQueryResult> = emptyList(),
cachedTime: Int? = null,
isPersonal: Boolean? = null,
nextOffset: String? = null,
button: InlineQueryResultsButton? = null
): Boolean = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, button)
public suspend fun TelegramBot.answer(
inlineQuery: InlineQuery,
results: List<InlineQueryResult> = emptyList(),
cachedTime: Int? = null,
isPersonal: Boolean? = null,
nextOffset: String? = null,
button: InlineQueryResultsButton? = null
): Boolean = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, button)
public suspend fun TelegramBot.answerInlineQuery(
inlineQueryID: InlineQueryId,
results: List<InlineQueryResult> = emptyList(),
cachedTime: Int? = null,
isPersonal: Boolean? = null,
nextOffset: String? = null,
switchPmText: String?,
switchPmParameter: String?
): Boolean = execute(
switchPmText: String? = null,
switchPmParameter: String? = null
) = execute(
AnswerInlineQuery(inlineQueryID, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)
)
public suspend fun TelegramBot.answerInlineQuery(
suspend fun TelegramBot.answerInlineQuery(
inlineQuery: InlineQuery,
results: List<InlineQueryResult> = emptyList(),
cachedTime: Int? = null,
isPersonal: Boolean? = null,
nextOffset: String? = null,
switchPmText: String?,
switchPmParameter: String?
): Boolean = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)
switchPmText: String? = null,
switchPmParameter: String? = null
) = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)
public suspend fun TelegramBot.answer(
suspend fun TelegramBot.answer(
inlineQuery: InlineQuery,
results: List<InlineQueryResult> = emptyList(),
cachedTime: Int? = null,
isPersonal: Boolean? = null,
nextOffset: String? = null,
switchPmText: String?,
switchPmParameter: String?
): Boolean = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)
switchPmText: String? = null,
switchPmParameter: String? = null
) = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)

View File

@@ -4,14 +4,13 @@ import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.answers.AnswerWebAppQuery
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
import dev.inmo.tgbotapi.types.WebAppQueryId
import dev.inmo.tgbotapi.types.webapps.query.SentWebAppMessage
public suspend fun TelegramBot.answerWebAppQuery(
suspend fun TelegramBot.answerWebAppQuery(
webAppQueryId: WebAppQueryId,
result: InlineQueryResult
): SentWebAppMessage = execute(AnswerWebAppQuery(webAppQueryId, result))
) = execute(AnswerWebAppQuery(webAppQueryId, result))
public suspend fun TelegramBot.answer(
suspend fun TelegramBot.answer(
webAppQueryId: WebAppQueryId,
result: InlineQueryResult
): SentWebAppMessage = execute(AnswerWebAppQuery(webAppQueryId, result))
) = execute(AnswerWebAppQuery(webAppQueryId, result))

View File

@@ -6,18 +6,18 @@ import dev.inmo.tgbotapi.requests.answers.payments.AnswerPreCheckoutQueryOk
import dev.inmo.tgbotapi.types.PreCheckoutQueryId
import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery
public suspend fun TelegramBot.answerPreCheckoutQueryOk(
suspend fun TelegramBot.answerPreCheckoutQueryOk(
id: PreCheckoutQueryId
): Boolean = execute(AnswerPreCheckoutQueryOk(id))
public suspend fun TelegramBot.answerPreCheckoutQueryOk(
) = execute(AnswerPreCheckoutQueryOk(id))
suspend fun TelegramBot.answerPreCheckoutQueryOk(
preCheckoutQuery: PreCheckoutQuery
): Boolean = answerPreCheckoutQueryOk(preCheckoutQuery.id)
) = answerPreCheckoutQueryOk(preCheckoutQuery.id)
public suspend fun TelegramBot.answerPreCheckoutQueryError(
suspend fun TelegramBot.answerPreCheckoutQueryError(
id: PreCheckoutQueryId,
error: String
): Boolean = execute(AnswerPreCheckoutQueryError(id, error))
public suspend fun TelegramBot.answerPreCheckoutQueryError(
) = execute(AnswerPreCheckoutQueryError(id, error))
suspend fun TelegramBot.answerPreCheckoutQueryError(
preCheckoutQuery: PreCheckoutQuery,
error: String
): Boolean = answerPreCheckoutQueryError(preCheckoutQuery.id, error)
) = answerPreCheckoutQueryError(preCheckoutQuery.id, error)

View File

@@ -3,26 +3,26 @@ package dev.inmo.tgbotapi.extensions.api.answers.payments
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.answers.payments.AnswerShippingQueryError
import dev.inmo.tgbotapi.requests.answers.payments.AnswerShippingQueryOk
import dev.inmo.tgbotapi.types.ShippingQueryId
import dev.inmo.tgbotapi.types.ShippingQueryIdentifier
import dev.inmo.tgbotapi.types.payments.ShippingOption
import dev.inmo.tgbotapi.types.payments.ShippingQuery
public suspend fun TelegramBot.answerShippingQueryOk(
id: ShippingQueryId,
suspend fun TelegramBot.answerShippingQueryOk(
id: ShippingQueryIdentifier,
shippingOptions: List<ShippingOption>
): Boolean = execute(AnswerShippingQueryOk(id, shippingOptions))
public suspend fun TelegramBot.answerShippingQueryOk(
) = execute(AnswerShippingQueryOk(id, shippingOptions))
suspend fun TelegramBot.answerShippingQueryOk(
shippingQuery: ShippingQuery,
shippingOptions: List<ShippingOption>
): Boolean = answerShippingQueryOk(shippingQuery.id, shippingOptions)
) = answerShippingQueryOk(shippingQuery.id, shippingOptions)
public suspend fun TelegramBot.answerShippingQueryError(
id: ShippingQueryId,
suspend fun TelegramBot.answerShippingQueryError(
id: ShippingQueryIdentifier,
error: String
): Boolean = execute(AnswerShippingQueryError(id, error))
public suspend fun TelegramBot.answerShippingQueryError(
) = execute(AnswerShippingQueryError(id, error))
suspend fun TelegramBot.answerShippingQueryError(
shippingQuery: ShippingQuery,
error: String
): Boolean = answerShippingQueryError(shippingQuery.id, error)
) = answerShippingQueryError(shippingQuery.id, error)

View File

@@ -3,10 +3,10 @@ package dev.inmo.tgbotapi.extensions.api.bot
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.bot.ClearMyDefaultAdministratorRights
public suspend fun TelegramBot.clearMyDefaultAdministratorRights(
suspend fun TelegramBot.clearMyDefaultAdministratorRights(
forChannels: Boolean? = null
): Boolean = execute(ClearMyDefaultAdministratorRights(forChannels))
) = execute(ClearMyDefaultAdministratorRights(forChannels))
public suspend fun TelegramBot.clearMyDefaultAdministratorRightsForChannels(): Boolean = clearMyDefaultAdministratorRights(forChannels = true)
suspend fun TelegramBot.clearMyDefaultAdministratorRightsForChannels() = clearMyDefaultAdministratorRights(forChannels = true)
public suspend fun TelegramBot.clearMyDefaultAdministratorRightsForGroupsAndSupergroups(): Boolean = clearMyDefaultAdministratorRights(forChannels = false)
suspend fun TelegramBot.clearMyDefaultAdministratorRightsForGroupsAndSupergroups() = clearMyDefaultAdministratorRights(forChannels = false)

View File

@@ -1,17 +1,17 @@
package dev.inmo.tgbotapi.extensions.api.bot
import dev.inmo.micro_utils.language_codes.IetfLang
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.bot.DeleteMyCommands
import dev.inmo.tgbotapi.types.commands.BotCommandScope
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
public suspend fun TelegramBot.deleteMyCommands(
suspend fun TelegramBot.deleteMyCommands(
scope: BotCommandScope = BotCommandScopeDefault,
languageCode: IetfLang?
): Boolean = execute(DeleteMyCommands(scope, languageCode))
languageCode: IetfLanguageCode?
) = execute(DeleteMyCommands(scope, languageCode))
public suspend fun TelegramBot.deleteMyCommands(
suspend fun TelegramBot.deleteMyCommands(
scope: BotCommandScope = BotCommandScopeDefault,
languageCode: String? = null
): Boolean = deleteMyCommands(scope, languageCode ?.let(::IetfLang))
) = deleteMyCommands(scope, languageCode ?.let(::IetfLanguageCode))

View File

@@ -2,6 +2,5 @@ package dev.inmo.tgbotapi.extensions.api.bot
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.bot.GetMe
import dev.inmo.tgbotapi.types.chat.ExtendedBot
public suspend fun TelegramBot.getMe(): ExtendedBot = execute(GetMe)
suspend fun TelegramBot.getMe() = execute(GetMe)

View File

@@ -1,18 +1,17 @@
package dev.inmo.tgbotapi.extensions.api.bot
import dev.inmo.micro_utils.language_codes.IetfLang
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
import dev.inmo.tgbotapi.types.BotCommand
import dev.inmo.tgbotapi.types.commands.BotCommandScope
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
public suspend fun TelegramBot.getMyCommands(
suspend fun TelegramBot.getMyCommands(
scope: BotCommandScope = BotCommandScopeDefault,
languageCode: IetfLang? = null
): List<BotCommand> = execute(GetMyCommands(scope, languageCode))
languageCode: IetfLanguageCode? = null
) = execute(GetMyCommands(scope, languageCode))
public suspend fun TelegramBot.getMyCommands(
suspend fun TelegramBot.getMyCommands(
scope: BotCommandScope = BotCommandScopeDefault,
languageCode: String?
): List<BotCommand> = getMyCommands(scope, languageCode ?.let(::IetfLang))
) = getMyCommands(scope, languageCode ?.let(::IetfLanguageCode))

View File

@@ -2,12 +2,11 @@ package dev.inmo.tgbotapi.extensions.api.bot
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.bot.GetMyDefaultAdministratorRights
import dev.inmo.tgbotapi.types.chat.member.AdministratorChatMember
public suspend fun TelegramBot.getMyDefaultAdministratorRights(
suspend fun TelegramBot.getMyDefaultAdministratorRights(
forChannels: Boolean? = null
): AdministratorChatMember = execute(GetMyDefaultAdministratorRights(forChannels))
) = execute(GetMyDefaultAdministratorRights(forChannels))
public suspend fun TelegramBot.getMyDefaultAdministratorRightsForChannels(): AdministratorChatMember = getMyDefaultAdministratorRights(forChannels = true)
suspend fun TelegramBot.getMyDefaultAdministratorRightsForChannels() = getMyDefaultAdministratorRights(forChannels = true)
public suspend fun TelegramBot.getMyDefaultAdministratorRightsForGroupsAndSupergroups(): AdministratorChatMember = getMyDefaultAdministratorRights(forChannels = false)
suspend fun TelegramBot.getMyDefaultAdministratorRightsForGroupsAndSupergroups() = getMyDefaultAdministratorRights(forChannels = false)

View File

@@ -1,14 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.bot
import dev.inmo.micro_utils.language_codes.IetfLang
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.bot.GetMyDescription
import dev.inmo.tgbotapi.types.BotDescription
public suspend fun TelegramBot.getMyDescription(
languageCode: IetfLang? = null
): BotDescription = execute(GetMyDescription(languageCode))
public suspend fun TelegramBot.getMyDescription(
languageCode: String?
): BotDescription = getMyDescription(languageCode ?.let(::IetfLang))

View File

@@ -1,14 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.bot
import dev.inmo.micro_utils.language_codes.IetfLang
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.bot.GetMyName
import dev.inmo.tgbotapi.types.BotName
public suspend fun TelegramBot.getMyName(
languageCode: IetfLang? = null
): BotName = execute(GetMyName(languageCode))
public suspend fun TelegramBot.getMyName(
languageCode: String?
): BotName = getMyName(languageCode ?.let(::IetfLang))

View File

@@ -1,17 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.bot
import dev.inmo.micro_utils.language_codes.IetfLang
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
import dev.inmo.tgbotapi.requests.bot.GetMyShortDescription
import dev.inmo.tgbotapi.types.BotShortDescription
import dev.inmo.tgbotapi.types.commands.BotCommandScope
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
public suspend fun TelegramBot.getMyShortDescription(
languageCode: IetfLang? = null
): BotShortDescription = execute(GetMyShortDescription(languageCode))
public suspend fun TelegramBot.getMyShortDescription(
languageCode: String?
): BotShortDescription = getMyShortDescription(languageCode ?.let(::IetfLang))

View File

@@ -1,32 +1,32 @@
package dev.inmo.tgbotapi.extensions.api.bot
import dev.inmo.micro_utils.language_codes.IetfLang
import dev.inmo.micro_utils.language_codes.IetfLanguageCode
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.bot.SetMyCommands
import dev.inmo.tgbotapi.types.BotCommand
import dev.inmo.tgbotapi.types.commands.BotCommandScope
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
public suspend fun TelegramBot.setMyCommands(
suspend fun TelegramBot.setMyCommands(
commands: List<BotCommand>,
scope: BotCommandScope = BotCommandScopeDefault,
languageCode: IetfLang?
): Boolean = execute(SetMyCommands(commands, scope, languageCode))
languageCode: IetfLanguageCode?
) = execute(SetMyCommands(commands, scope, languageCode))
public suspend fun TelegramBot.setMyCommands(
suspend fun TelegramBot.setMyCommands(
vararg commands: BotCommand,
scope: BotCommandScope = BotCommandScopeDefault,
languageCode: IetfLang?
): Boolean = setMyCommands(commands.toList(), scope, languageCode)
languageCode: IetfLanguageCode?
) = setMyCommands(commands.toList(), scope, languageCode)
public suspend fun TelegramBot.setMyCommands(
suspend fun TelegramBot.setMyCommands(
commands: List<BotCommand>,
scope: BotCommandScope = BotCommandScopeDefault,
languageCode: String? = null
): Boolean = setMyCommands(commands, scope, languageCode ?.let(::IetfLang))
) = setMyCommands(commands, scope, languageCode ?.let(::IetfLanguageCode))
public suspend fun TelegramBot.setMyCommands(
suspend fun TelegramBot.setMyCommands(
vararg commands: BotCommand,
scope: BotCommandScope = BotCommandScopeDefault,
languageCode: String? = null
): Boolean = setMyCommands(commands.toList(), scope, languageCode)
) = setMyCommands(commands.toList(), scope, languageCode)

View File

@@ -2,17 +2,17 @@ package dev.inmo.tgbotapi.extensions.api.bot
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.bot.SetMyDefaultAdministratorRights
import dev.inmo.tgbotapi.types.chat.member.ChatCommonAdministratorRights
import dev.inmo.tgbotapi.types.chat.member.ChatAdministratorRightsImpl
public suspend fun TelegramBot.setMyDefaultAdministratorRights(
rights: ChatCommonAdministratorRights,
suspend fun TelegramBot.setMyDefaultAdministratorRights(
rights: ChatAdministratorRightsImpl,
forChannels: Boolean? = null
): Boolean = execute(SetMyDefaultAdministratorRights(rights, forChannels))
) = execute(SetMyDefaultAdministratorRights(rights, forChannels))
public suspend fun TelegramBot.setMyDefaultAdministratorRightsForChannels(
rights: ChatCommonAdministratorRights
): Boolean = setMyDefaultAdministratorRights(rights, forChannels = true)
suspend fun TelegramBot.setMyDefaultAdministratorRightsForChannels(
rights: ChatAdministratorRightsImpl
) = setMyDefaultAdministratorRights(rights, forChannels = true)
public suspend fun TelegramBot.setMyDefaultAdministratorRightsForGroupsAndSupergroups(
rights: ChatCommonAdministratorRights
): Boolean = setMyDefaultAdministratorRights(rights, forChannels = false)
suspend fun TelegramBot.setMyDefaultAdministratorRightsForGroupsAndSupergroups(
rights: ChatAdministratorRightsImpl
) = setMyDefaultAdministratorRights(rights, forChannels = false)

View File

@@ -1,19 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.bot
import dev.inmo.micro_utils.language_codes.IetfLang
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
import dev.inmo.tgbotapi.requests.bot.GetMyDescription
import dev.inmo.tgbotapi.requests.bot.SetMyDescription
import dev.inmo.tgbotapi.types.commands.BotCommandScope
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
public suspend fun TelegramBot.setMyDescription(
description: String? = null,
languageCode: IetfLang? = null
): Boolean = execute(SetMyDescription(description, languageCode))
public suspend fun TelegramBot.setMyDescription(
description: String?,
languageCode: String?
): Boolean = setMyDescription(description, languageCode ?.let(::IetfLang))

View File

@@ -1,19 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.bot
import dev.inmo.micro_utils.language_codes.IetfLang
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
import dev.inmo.tgbotapi.requests.bot.GetMyName
import dev.inmo.tgbotapi.requests.bot.SetMyName
import dev.inmo.tgbotapi.types.commands.BotCommandScope
import dev.inmo.tgbotapi.types.commands.BotCommandScopeDefault
public suspend fun TelegramBot.setMyName(
name: String? = null,
languageCode: IetfLang? = null
): Boolean = execute(SetMyName(name, languageCode))
public suspend fun TelegramBot.setMyName(
name: String?,
languageCode: String?
): Boolean = setMyName(name, languageCode ?.let(::IetfLang))

View File

@@ -1,15 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.bot
import dev.inmo.micro_utils.language_codes.IetfLang
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.bot.SetMyShortDescription
public suspend fun TelegramBot.setMyShortDescription(
shortDescription: String? = null,
languageCode: IetfLang? = null
): Boolean = execute(SetMyShortDescription(shortDescription, languageCode))
public suspend fun TelegramBot.setMyShortDescription(
shortDescription: String?,
languageCode: String?
): Boolean = setMyShortDescription(shortDescription, languageCode ?.let(::IetfLang))

View File

@@ -5,10 +5,10 @@ import dev.inmo.tgbotapi.requests.chat.ExportChatInviteLink
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.PublicChat
public suspend fun TelegramBot.exportChatInviteLink(
suspend fun TelegramBot.exportChatInviteLink(
chatId: ChatIdentifier
): String = execute(ExportChatInviteLink(chatId))
) = execute(ExportChatInviteLink(chatId))
public suspend fun TelegramBot.exportChatInviteLink(
suspend fun TelegramBot.exportChatInviteLink(
chat: PublicChat
): String = exportChatInviteLink(chat.id)
) = exportChatInviteLink(chat.id)

View File

@@ -5,10 +5,10 @@ import dev.inmo.tgbotapi.requests.chat.LeaveChat
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.PublicChat
public suspend fun TelegramBot.leaveChat(
suspend fun TelegramBot.leaveChat(
chatId: ChatIdentifier
): Boolean = execute(LeaveChat(chatId))
) = execute(LeaveChat(chatId))
public suspend fun TelegramBot.leaveChat(
suspend fun TelegramBot.leaveChat(
chat: PublicChat
): Boolean = leaveChat(chat.id)
) = leaveChat(chat.id)

View File

@@ -7,22 +7,22 @@ import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.closeForumTopic(
suspend fun TelegramBot.closeForumTopic(
chatId: ChatIdentifier,
messageThreadId: MessageThreadId
): Boolean = execute(
) = execute(
CloseForumTopic(
chatId,
messageThreadId
)
)
public suspend fun TelegramBot.closeForumTopic(
suspend fun TelegramBot.closeForumTopic(
chat: Chat,
messageThreadId: MessageThreadId
): Boolean = closeForumTopic(chat.id, messageThreadId)
) = closeForumTopic(chat.id, messageThreadId)
public suspend fun TelegramBot.closeForumTopic(
suspend fun TelegramBot.closeForumTopic(
chat: Chat,
forumTopic: ForumTopic
): Boolean = closeForumTopic(chat.id, forumTopic.messageThreadId)
) = closeForumTopic(chat.id, forumTopic.messageThreadId)

View File

@@ -1,19 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.forum
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.forum.CloseForumTopic
import dev.inmo.tgbotapi.requests.chat.forum.CloseGeneralForumTopic
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.closeGeneralForumTopic(
chatId: ChatIdentifier
): Boolean = execute(
CloseGeneralForumTopic(chatId)
)
public suspend fun TelegramBot.closeGeneralForumTopic(
chat: Chat
): Boolean = closeGeneralForumTopic(chat.id)

View File

@@ -4,16 +4,15 @@ import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.forum.CreateForumTopic
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.CustomEmojiId
import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.utils.RGBColor
public suspend fun TelegramBot.createForumTopic(
suspend fun TelegramBot.createForumTopic(
chatId: ChatIdentifier,
name: String,
color: RGBColor,
iconEmojiId: CustomEmojiId? = null
): ForumTopic = execute(
) = execute(
CreateForumTopic(
chatId,
name,
@@ -22,9 +21,9 @@ public suspend fun TelegramBot.createForumTopic(
)
)
public suspend fun TelegramBot.createForumTopic(
suspend fun TelegramBot.createForumTopic(
chat: Chat,
name: String,
color: RGBColor,
iconEmojiId: CustomEmojiId? = null
): ForumTopic = createForumTopic(chat.id, name, color, iconEmojiId)
) = createForumTopic(chat.id, name, color, iconEmojiId)

View File

@@ -7,27 +7,27 @@ import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.deleteForumTopic(
suspend fun TelegramBot.deleteForumTopic(
chatId: ChatIdentifier,
messageThreadId: MessageThreadId
): Boolean = execute(
) = execute(
DeleteForumTopic(
chatId,
messageThreadId
)
)
public suspend fun TelegramBot.deleteForumTopic(
suspend fun TelegramBot.deleteForumTopic(
chatId: ChatIdentifier,
forumTopic: ForumTopic
): Boolean = deleteForumTopic(chatId, forumTopic.messageThreadId)
) = deleteForumTopic(chatId, forumTopic.messageThreadId)
public suspend fun TelegramBot.deleteForumTopic(
suspend fun TelegramBot.deleteForumTopic(
chat: Chat,
messageThreadId: MessageThreadId
): Boolean = deleteForumTopic(chat.id, messageThreadId)
) = deleteForumTopic(chat.id, messageThreadId)
public suspend fun TelegramBot.deleteForumTopic(
suspend fun TelegramBot.deleteForumTopic(
chat: Chat,
forumTopic: ForumTopic
): Boolean = deleteForumTopic(chat.id, forumTopic.messageThreadId)
) = deleteForumTopic(chat.id, forumTopic.messageThreadId)

View File

@@ -8,12 +8,12 @@ import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.editForumTopic(
suspend fun TelegramBot.editForumTopic(
chatId: ChatIdentifier,
messageThreadId: MessageThreadId,
name: String? = null,
iconEmojiId: CustomEmojiId? = null
): Boolean = execute(
name: String,
iconEmojiId: CustomEmojiId
) = execute(
EditForumTopic(
chatId,
messageThreadId,
@@ -22,15 +22,15 @@ public suspend fun TelegramBot.editForumTopic(
)
)
public suspend fun TelegramBot.editForumTopic(
suspend fun TelegramBot.editForumTopic(
chat: Chat,
messageThreadId: MessageThreadId,
name: String? = null,
iconEmojiId: CustomEmojiId? = null
): Boolean = editForumTopic(chat.id, messageThreadId, name, iconEmojiId)
name: String,
iconEmojiId: CustomEmojiId
) = editForumTopic(chat.id, messageThreadId, name, iconEmojiId)
public suspend fun TelegramBot.editForumTopic(
suspend fun TelegramBot.editForumTopic(
chatIdentifier: ChatIdentifier,
forumTopic: ForumTopic,
iconEmojiId: CustomEmojiId? = forumTopic.iconEmojiId
): Boolean = editForumTopic(chatIdentifier, forumTopic.messageThreadId, forumTopic.name, iconEmojiId)
iconEmojiId: CustomEmojiId = forumTopic.iconEmojiId ?: error("Icon emoji id in forum topic should be presented when edit forum topic basing on other forum topic object")
) = editForumTopic(chatIdentifier, forumTopic.messageThreadId, forumTopic.name, iconEmojiId)

View File

@@ -1,30 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.forum
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.forum.EditForumTopic
import dev.inmo.tgbotapi.requests.chat.forum.EditGeneralForumTopic
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.CustomEmojiId
import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.editGeneralForumTopic(
chatId: ChatIdentifier,
name: String
): Boolean = execute(
EditGeneralForumTopic(
chatId,
name
)
)
public suspend fun TelegramBot.editGeneralForumTopic(
chat: Chat,
name: String
): Boolean = editGeneralForumTopic(chat.id, name)
public suspend fun TelegramBot.editGeneralForumTopic(
chatIdentifier: ChatIdentifier,
forumTopic: ForumTopic,
): Boolean = editGeneralForumTopic(chatIdentifier, forumTopic.name)

View File

@@ -1,20 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.forum
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.forum.CloseForumTopic
import dev.inmo.tgbotapi.requests.chat.forum.CloseGeneralForumTopic
import dev.inmo.tgbotapi.requests.chat.forum.HideGeneralForumTopic
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.hideGeneralForumTopic(
chatId: ChatIdentifier
): Boolean = execute(
HideGeneralForumTopic(chatId)
)
public suspend fun TelegramBot.hideGeneralForumTopic(
chat: Chat
): Boolean = hideGeneralForumTopic(chat.id)

View File

@@ -7,22 +7,22 @@ import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.reopenForumTopic(
suspend fun TelegramBot.reopenForumTopic(
chatId: ChatIdentifier,
messageThreadId: MessageThreadId
): Boolean = execute(
) = execute(
ReopenForumTopic(
chatId,
messageThreadId
)
)
public suspend fun TelegramBot.reopenForumTopic(
suspend fun TelegramBot.reopenForumTopic(
chat: Chat,
messageThreadId: MessageThreadId
): Boolean = reopenForumTopic(chat.id, messageThreadId)
) = reopenForumTopic(chat.id, messageThreadId)
public suspend fun TelegramBot.reopenForumTopic(
suspend fun TelegramBot.reopenForumTopic(
chat: Chat,
forumTopic: ForumTopic
): Boolean = reopenForumTopic(chat.id, forumTopic.messageThreadId)
) = reopenForumTopic(chat.id, forumTopic.messageThreadId)

View File

@@ -1,19 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.forum
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.forum.ReopenForumTopic
import dev.inmo.tgbotapi.requests.chat.forum.ReopenGeneralForumTopic
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.reopenGeneralForumTopic(
chatId: ChatIdentifier
): Boolean = execute(
ReopenGeneralForumTopic(chatId)
)
public suspend fun TelegramBot.reopenGeneralForumTopic(
chat: Chat
): Boolean = reopenGeneralForumTopic(chat.id)

View File

@@ -1,21 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.forum
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.forum.CloseForumTopic
import dev.inmo.tgbotapi.requests.chat.forum.CloseGeneralForumTopic
import dev.inmo.tgbotapi.requests.chat.forum.HideGeneralForumTopic
import dev.inmo.tgbotapi.requests.chat.forum.UnhideGeneralForumTopic
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.unhideGeneralForumTopic(
chatId: ChatIdentifier
): Boolean = execute(
UnhideGeneralForumTopic(chatId)
)
public suspend fun TelegramBot.unhideGeneralForumTopic(
chat: Chat
): Boolean = unhideGeneralForumTopic(chat.id)

View File

@@ -7,22 +7,22 @@ import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.unpinAllForumTopicMessages(
suspend fun TelegramBot.unpinAllForumTopicMessages(
chatId: ChatIdentifier,
messageThreadId: MessageThreadId
): Boolean = execute(
) = execute(
UnpinAllForumTopicMessages(
chatId,
messageThreadId
)
)
public suspend fun TelegramBot.unpinAllForumTopicMessages(
suspend fun TelegramBot.unpinAllForumTopicMessages(
chat: Chat,
messageThreadId: MessageThreadId
): Boolean = unpinAllForumTopicMessages(chat.id, messageThreadId)
) = unpinAllForumTopicMessages(chat.id, messageThreadId)
public suspend fun TelegramBot.unpinAllForumTopicMessages(
suspend fun TelegramBot.unpinAllForumTopicMessages(
chat: Chat,
forumTopic: ForumTopic
): Boolean = unpinAllForumTopicMessages(chat.id, forumTopic.messageThreadId)
) = unpinAllForumTopicMessages(chat.id, forumTopic.messageThreadId)

View File

@@ -1,21 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.forum
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.forum.UnpinAllForumTopicMessages
import dev.inmo.tgbotapi.requests.chat.forum.UnpinAllGeneralForumTopicMessages
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.unpinAllGeneralForumTopicMessages(
chatId: ChatIdentifier
): Boolean = execute(
UnpinAllGeneralForumTopicMessages(
chatId
)
)
public suspend fun TelegramBot.unpinAllGeneralForumTopicMessages(
chat: Chat
): Boolean = unpinAllGeneralForumTopicMessages(chat.id)

View File

@@ -3,16 +3,36 @@ package dev.inmo.tgbotapi.extensions.api.chat.get
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.get.GetChat
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.*
import dev.inmo.tgbotapi.types.chat.ChannelChat
import dev.inmo.tgbotapi.types.chat.ChannelChatImpl
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.chat.CommonUser
import dev.inmo.tgbotapi.types.chat.ExtendedChannelChat
import dev.inmo.tgbotapi.types.chat.ExtendedChannelChatImpl
import dev.inmo.tgbotapi.types.chat.ExtendedGroupChat
import dev.inmo.tgbotapi.types.chat.ExtendedGroupChatImpl
import dev.inmo.tgbotapi.types.chat.ExtendedPrivateChat
import dev.inmo.tgbotapi.types.chat.ExtendedPrivateChatImpl
import dev.inmo.tgbotapi.types.chat.ExtendedPublicChat
import dev.inmo.tgbotapi.types.chat.ExtendedSupergroupChat
import dev.inmo.tgbotapi.types.chat.ExtendedSupergroupChatImpl
import dev.inmo.tgbotapi.types.chat.ExtendedUser
import dev.inmo.tgbotapi.types.chat.GroupChat
import dev.inmo.tgbotapi.types.chat.GroupChatImpl
import dev.inmo.tgbotapi.types.chat.PrivateChat
import dev.inmo.tgbotapi.types.chat.PrivateChatImpl
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.SupergroupChat
import dev.inmo.tgbotapi.types.chat.SupergroupChatImpl
import dev.inmo.tgbotapi.utils.PreviewFeature
public suspend fun TelegramBot.getChat(
suspend fun TelegramBot.getChat(
chatId: ChatIdentifier
): ExtendedChat = execute(GetChat(chatId))
) = execute(GetChat(chatId))
public suspend fun TelegramBot.getChat(
suspend fun TelegramBot.getChat(
chat: Chat
): ExtendedChat = getChat(chat.id)
) = getChat(chat.id)
/**
* Will cast incoming [dev.inmo.tgbotapi.types.chat.ExtendedChat] to a
@@ -21,9 +41,9 @@ public suspend fun TelegramBot.getChat(
* @throws ClassCastException
*/
@PreviewFeature
public suspend fun TelegramBot.getChat(
suspend fun TelegramBot.getChat(
chat: PublicChat
): ExtendedPublicChat = getChat(chat.id) as ExtendedPublicChat
) = getChat(chat.id) as ExtendedPublicChat
/**
@@ -33,9 +53,9 @@ public suspend fun TelegramBot.getChat(
* @throws ClassCastException
*/
@PreviewFeature
public suspend fun TelegramBot.getChat(
suspend fun TelegramBot.getChat(
chat: ChannelChat
): ExtendedChannelChat = getChat(chat.id) as ExtendedChannelChat
) = getChat(chat.id) as ExtendedChannelChat
/**
* Will cast incoming [dev.inmo.tgbotapi.types.chat.ExtendedChat] to a
@@ -44,9 +64,9 @@ public suspend fun TelegramBot.getChat(
* @throws ClassCastException
*/
@PreviewFeature
public suspend fun TelegramBot.getChat(
suspend fun TelegramBot.getChat(
chat: ChannelChatImpl
): ExtendedChannelChatImpl = getChat(chat.id) as ExtendedChannelChatImpl
) = getChat(chat.id) as ExtendedChannelChatImpl
/**
@@ -56,9 +76,9 @@ public suspend fun TelegramBot.getChat(
* @throws ClassCastException
*/
@PreviewFeature
public suspend fun TelegramBot.getChat(
suspend fun TelegramBot.getChat(
chat: GroupChat
): ExtendedGroupChat = getChat(chat.id) as ExtendedGroupChat
) = getChat(chat.id) as ExtendedGroupChat
/**
* Will cast incoming [dev.inmo.tgbotapi.types.chat.ExtendedChat] to a
@@ -67,9 +87,9 @@ public suspend fun TelegramBot.getChat(
* @throws ClassCastException
*/
@PreviewFeature
public suspend fun TelegramBot.getChat(
suspend fun TelegramBot.getChat(
chat: GroupChatImpl
): ExtendedGroupChatImpl = getChat(chat.id) as ExtendedGroupChatImpl
) = getChat(chat.id) as ExtendedGroupChatImpl
/**
@@ -79,9 +99,9 @@ public suspend fun TelegramBot.getChat(
* @throws ClassCastException
*/
@PreviewFeature
public suspend fun TelegramBot.getChat(
suspend fun TelegramBot.getChat(
chat: SupergroupChat
): ExtendedSupergroupChat = getChat(chat.id) as ExtendedSupergroupChat
) = getChat(chat.id) as ExtendedSupergroupChat
/**
* Will cast incoming [dev.inmo.tgbotapi.types.chat.ExtendedChat] to a
@@ -90,9 +110,9 @@ public suspend fun TelegramBot.getChat(
* @throws ClassCastException
*/
@PreviewFeature
public suspend fun TelegramBot.getChat(
suspend fun TelegramBot.getChat(
chat: SupergroupChatImpl
): ExtendedSupergroupChatImpl = getChat(chat.id) as ExtendedSupergroupChatImpl
) = getChat(chat.id) as ExtendedSupergroupChatImpl
/**
@@ -102,9 +122,9 @@ public suspend fun TelegramBot.getChat(
* @throws ClassCastException
*/
@PreviewFeature
public suspend fun TelegramBot.getChat(
suspend fun TelegramBot.getChat(
chat: PrivateChat
): ExtendedPrivateChat = getChat(chat.id) as ExtendedPrivateChat
) = getChat(chat.id) as ExtendedPrivateChat
/**
* Will cast incoming [dev.inmo.tgbotapi.types.chat.ExtendedChat] to a
@@ -113,9 +133,9 @@ public suspend fun TelegramBot.getChat(
* @throws ClassCastException
*/
@PreviewFeature
public suspend fun TelegramBot.getChat(
suspend fun TelegramBot.getChat(
chat: PrivateChatImpl
): ExtendedPrivateChatImpl = getChat(chat.id) as ExtendedPrivateChatImpl
) = getChat(chat.id) as ExtendedPrivateChatImpl
/**
* Will cast incoming [dev.inmo.tgbotapi.types.chat.ExtendedChat] to a
@@ -124,6 +144,6 @@ public suspend fun TelegramBot.getChat(
* @throws ClassCastException
*/
@PreviewFeature
public suspend fun TelegramBot.getChat(
suspend fun TelegramBot.getChat(
chat: CommonUser
): ExtendedUser = getChat(chat.id) as ExtendedUser
) = getChat(chat.id) as ExtendedUser

View File

@@ -4,12 +4,11 @@ import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.get.GetChatAdministrators
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.member.AdministratorChatMember
public suspend fun TelegramBot.getChatAdministrators(
suspend fun TelegramBot.getChatAdministrators(
chatId: ChatIdentifier
): List<AdministratorChatMember> = execute(GetChatAdministrators(chatId))
) = execute(GetChatAdministrators(chatId))
public suspend fun TelegramBot.getChatAdministrators(
suspend fun TelegramBot.getChatAdministrators(
chat: PublicChat
): List<AdministratorChatMember> = getChatAdministrators(chat.id)
) = getChatAdministrators(chat.id)

View File

@@ -5,10 +5,10 @@ import dev.inmo.tgbotapi.requests.chat.get.GetChatMemberCount
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.PublicChat
public suspend fun TelegramBot.getChatMemberCount(
suspend fun TelegramBot.getChatMemberCount(
chatId: ChatIdentifier
): Int = execute(GetChatMemberCount(chatId))
) = execute(GetChatMemberCount(chatId))
public suspend fun TelegramBot.getChatMemberCount(
suspend fun TelegramBot.getChatMemberCount(
chat: PublicChat
): Int = getChatMemberCount(chat.id)
) = getChatMemberCount(chat.id)

View File

@@ -3,13 +3,12 @@ package dev.inmo.tgbotapi.extensions.api.chat.get
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.get.GetChatMenuButton
import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.MenuButton
import dev.inmo.tgbotapi.types.chat.PrivateChat
public suspend fun TelegramBot.getChatMenuButton(
suspend fun TelegramBot.getChatMenuButton(
chatId: IdChatIdentifier
): MenuButton = execute(GetChatMenuButton(chatId))
) = execute(GetChatMenuButton(chatId))
public suspend fun TelegramBot.getChatMenuButton(
suspend fun TelegramBot.getChatMenuButton(
chat: PrivateChat
): MenuButton = getChatMenuButton(chat.id)
) = getChatMenuButton(chat.id)

View File

@@ -2,6 +2,5 @@ package dev.inmo.tgbotapi.extensions.api.chat.get
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.get.GetDefaultChatMenuButton
import dev.inmo.tgbotapi.types.MenuButton
public suspend fun TelegramBot.getDefaultChatMenuButton(): MenuButton = execute(GetDefaultChatMenuButton)
suspend fun TelegramBot.getDefaultChatMenuButton() = execute(GetDefaultChatMenuButton)

View File

@@ -2,6 +2,5 @@ package dev.inmo.tgbotapi.extensions.api.chat.get
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.get.GetForumTopicIconStickers
import dev.inmo.tgbotapi.types.files.Sticker
public suspend fun TelegramBot.getForumTopicIconStickers(): List<Sticker> = execute(GetForumTopicIconStickers)
suspend fun TelegramBot.getForumTopicIconStickers() = execute(GetForumTopicIconStickers)

View File

@@ -9,34 +9,34 @@ import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.User
import dev.inmo.tgbotapi.types.update.ChatJoinRequestUpdate
public suspend fun TelegramBot.approveChatJoinRequest(
suspend fun TelegramBot.approveChatJoinRequest(
chatId: ChatIdentifier,
userId: UserId
): Boolean = execute(ApproveChatJoinRequest(chatId, userId))
) = execute(ApproveChatJoinRequest(chatId, userId))
public suspend fun TelegramBot.approveChatJoinRequest(
suspend fun TelegramBot.approveChatJoinRequest(
chat: PublicChat,
userId: UserId
): Boolean = approveChatJoinRequest(chat.id, userId)
) = approveChatJoinRequest(chat.id, userId)
public suspend fun TelegramBot.approveChatJoinRequest(
suspend fun TelegramBot.approveChatJoinRequest(
chatId: ChatIdentifier,
user: User
): Boolean = approveChatJoinRequest(chatId, user.id)
) = approveChatJoinRequest(chatId, user.id)
public suspend fun TelegramBot.approveChatJoinRequest(
suspend fun TelegramBot.approveChatJoinRequest(
chat: PublicChat,
user: User
): Boolean = approveChatJoinRequest(chat.id, user.id)
) = approveChatJoinRequest(chat.id, user.id)
public suspend fun TelegramBot.approveChatJoinRequest(
suspend fun TelegramBot.approveChatJoinRequest(
chatJoinRequest: ChatJoinRequest
): Boolean = approveChatJoinRequest(chatJoinRequest.chat, chatJoinRequest.user)
) = approveChatJoinRequest(chatJoinRequest.chat, chatJoinRequest.user)
public suspend fun TelegramBot.approve(
suspend fun TelegramBot.approve(
chatJoinRequest: ChatJoinRequest
): Boolean = approveChatJoinRequest(chatJoinRequest)
) = approveChatJoinRequest(chatJoinRequest)
public suspend fun TelegramBot.approveChatJoinRequest(
suspend fun TelegramBot.approveChatJoinRequest(
chatJoinRequestUpdate: ChatJoinRequestUpdate
): Boolean = approveChatJoinRequest(chatJoinRequestUpdate.data)
) = approveChatJoinRequest(chatJoinRequestUpdate.data)

View File

@@ -1,83 +1,86 @@
package dev.inmo.tgbotapi.extensions.api.chat.invite_links
import korlibs.time.DateTime
import com.soywiz.klock.DateTime
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.invite_links.CreateChatInviteLink
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.MembersLimit
import dev.inmo.tgbotapi.types.TelegramDate
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.toTelegramDate
public suspend fun TelegramBot.createChatInviteLinkUnlimited(
suspend fun TelegramBot.createChatInviteLinkUnlimited(
chatId: ChatIdentifier,
name: String? = null,
expiration: TelegramDate? = null
): ChatInviteLinkUnlimited = execute(CreateChatInviteLink.unlimited(chatId, name, expiration))
) = execute(CreateChatInviteLink.unlimited(chatId, name, expiration))
public suspend fun TelegramBot.createChatInviteLinkUnlimited(
suspend fun TelegramBot.createChatInviteLinkUnlimited(
chat: PublicChat,
name: String? = null,
expiration: TelegramDate? = null,
): ChatInviteLinkUnlimited = createChatInviteLinkUnlimited(chat.id, name, expiration)
) = createChatInviteLinkUnlimited(chat.id, name, expiration)
public suspend fun TelegramBot.createChatInviteLinkUnlimited(
suspend fun TelegramBot.createChatInviteLinkUnlimited(
chatId: ChatIdentifier,
expiration: DateTime,
name: String? = null,
): ChatInviteLinkUnlimited = createChatInviteLinkUnlimited(chatId, name, expiration.toTelegramDate())
) = createChatInviteLinkUnlimited(chatId, name, expiration.toTelegramDate())
public suspend fun TelegramBot.createChatInviteLinkUnlimited(
suspend fun TelegramBot.createChatInviteLinkUnlimited(
chat: PublicChat,
expiration: DateTime,
name: String? = null
): ChatInviteLinkUnlimited = createChatInviteLinkUnlimited(chat.id, name, expiration.toTelegramDate())
) = createChatInviteLinkUnlimited(chat.id, name, expiration.toTelegramDate())
public suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers(
suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers(
chatId: ChatIdentifier,
membersLimit: MembersLimit,
name: String? = null,
expiration: TelegramDate? = null
): ChatInviteLinkWithLimitedMembers = execute(CreateChatInviteLink.withLimitedMembers(chatId, membersLimit, name, expiration))
) = execute(CreateChatInviteLink.withLimitedMembers(chatId, membersLimit, name, expiration))
public suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers(
suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers(
chat: PublicChat,
membersLimit: MembersLimit,
name: String? = null,
expiration: TelegramDate? = null,
): ChatInviteLinkWithLimitedMembers = createChatInviteLinkWithLimitedMembers(chat.id, membersLimit, name, expiration)
) = createChatInviteLinkWithLimitedMembers(chat.id, membersLimit, name, expiration)
public suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers(
suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers(
chatId: ChatIdentifier,
membersLimit: MembersLimit,
expiration: DateTime,
name: String? = null,
): ChatInviteLinkWithLimitedMembers = createChatInviteLinkWithLimitedMembers(chatId, membersLimit, name, expiration.toTelegramDate())
) = createChatInviteLinkWithLimitedMembers(chatId, membersLimit, name, expiration.toTelegramDate())
public suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers(
suspend fun TelegramBot.createChatInviteLinkWithLimitedMembers(
chat: PublicChat,
membersLimit: MembersLimit,
expiration: DateTime,
name: String? = null,
): ChatInviteLinkWithLimitedMembers = createChatInviteLinkWithLimitedMembers(chat.id, membersLimit, name, expiration.toTelegramDate())
) = createChatInviteLinkWithLimitedMembers(chat.id, membersLimit, name, expiration.toTelegramDate())
public suspend fun TelegramBot.createChatInviteLinkWithJoinRequest(
suspend fun TelegramBot.createChatInviteLinkWithJoinRequest(
chatId: ChatIdentifier,
name: String? = null,
expiration: TelegramDate? = null
): ChatInviteLinkWithJoinRequest = execute(CreateChatInviteLink.withJoinRequest(chatId, name, expiration))
) = execute(CreateChatInviteLink.withJoinRequest(chatId, name, expiration))
public suspend fun TelegramBot.createChatInviteLinkWithJoinRequest(
suspend fun TelegramBot.createChatInviteLinkWithJoinRequest(
chat: PublicChat,
name: String? = null,
expiration: TelegramDate? = null,
): ChatInviteLinkWithJoinRequest = createChatInviteLinkWithJoinRequest(chat.id, name, expiration)
) = createChatInviteLinkWithJoinRequest(chat.id, name, expiration)
public suspend fun TelegramBot.createChatInviteLinkWithJoinRequest(
suspend fun TelegramBot.createChatInviteLinkWithJoinRequest(
chatId: ChatIdentifier,
expiration: DateTime,
name: String? = null,
): ChatInviteLinkWithJoinRequest = createChatInviteLinkWithJoinRequest(chatId, name, expiration.toTelegramDate())
) = createChatInviteLinkWithJoinRequest(chatId, name, expiration.toTelegramDate())
public suspend fun TelegramBot.createChatInviteLinkWithJoinRequest(
suspend fun TelegramBot.createChatInviteLinkWithJoinRequest(
chat: PublicChat,
expiration: DateTime,
name: String? = null,
): ChatInviteLinkWithJoinRequest = createChatInviteLinkWithJoinRequest(chat.id, name, expiration.toTelegramDate())
) = createChatInviteLinkWithJoinRequest(chat.id, name, expiration.toTelegramDate())

View File

@@ -9,34 +9,34 @@ import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.User
import dev.inmo.tgbotapi.types.update.ChatJoinRequestUpdate
public suspend fun TelegramBot.declineChatJoinRequest(
suspend fun TelegramBot.declineChatJoinRequest(
chatId: ChatIdentifier,
userId: UserId
): Boolean = execute(DeclineChatJoinRequest(chatId, userId))
) = execute(DeclineChatJoinRequest(chatId, userId))
public suspend fun TelegramBot.declineChatJoinRequest(
suspend fun TelegramBot.declineChatJoinRequest(
chat: PublicChat,
userId: UserId
): Boolean = declineChatJoinRequest(chat.id, userId)
) = declineChatJoinRequest(chat.id, userId)
public suspend fun TelegramBot.declineChatJoinRequest(
suspend fun TelegramBot.declineChatJoinRequest(
chatId: ChatIdentifier,
user: User
): Boolean = declineChatJoinRequest(chatId, user.id)
) = declineChatJoinRequest(chatId, user.id)
public suspend fun TelegramBot.declineChatJoinRequest(
suspend fun TelegramBot.declineChatJoinRequest(
chat: PublicChat,
user: User
): Boolean = declineChatJoinRequest(chat.id, user.id)
) = declineChatJoinRequest(chat.id, user.id)
public suspend fun TelegramBot.declineChatJoinRequest(
suspend fun TelegramBot.declineChatJoinRequest(
chatJoinRequest: ChatJoinRequest
): Boolean = declineChatJoinRequest(chatJoinRequest.chat, chatJoinRequest.user)
) = declineChatJoinRequest(chatJoinRequest.chat, chatJoinRequest.user)
public suspend fun TelegramBot.decline(
suspend fun TelegramBot.decline(
chatJoinRequest: ChatJoinRequest
): Boolean = declineChatJoinRequest(chatJoinRequest)
) = declineChatJoinRequest(chatJoinRequest)
public suspend fun TelegramBot.declineChatJoinRequest(
suspend fun TelegramBot.declineChatJoinRequest(
chatJoinRequestUpdate: ChatJoinRequestUpdate
): Boolean = declineChatJoinRequest(chatJoinRequestUpdate.data)
) = declineChatJoinRequest(chatJoinRequestUpdate.data)

View File

@@ -1,183 +1,187 @@
package dev.inmo.tgbotapi.extensions.api.chat.invite_links
import korlibs.time.DateTime
import com.soywiz.klock.DateTime
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.invite_links.EditChatInviteLink
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.ChatInviteLink
import dev.inmo.tgbotapi.types.MembersLimit
import dev.inmo.tgbotapi.types.TelegramDate
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.toTelegramDate
public suspend fun TelegramBot.editChatInviteLinkUnlimited(
suspend fun TelegramBot.editChatInviteLinkUnlimited(
chatId: ChatIdentifier,
previousLink: String,
name: String? = null,
expiration: TelegramDate? = null
): ChatInviteLinkUnlimited = execute(EditChatInviteLink.unlimited(chatId, previousLink, name, expiration))
) = execute(EditChatInviteLink.unlimited(chatId, previousLink, name, expiration))
public suspend fun TelegramBot.editChatInviteLinkUnlimited(
suspend fun TelegramBot.editChatInviteLinkUnlimited(
chat: PublicChat,
previousLink: String,
name: String? = null,
expiration: TelegramDate? = null,
): ChatInviteLinkUnlimited = editChatInviteLinkUnlimited(chat.id, previousLink, name, expiration)
) = editChatInviteLinkUnlimited(chat.id, previousLink, name, expiration)
public suspend fun TelegramBot.editChatInviteLinkUnlimited(
suspend fun TelegramBot.editChatInviteLinkUnlimited(
chatId: ChatIdentifier,
previousLink: String,
expiration: DateTime,
name: String? = null,
): ChatInviteLinkUnlimited = editChatInviteLinkUnlimited(chatId, previousLink, name , expiration.toTelegramDate())
) = editChatInviteLinkUnlimited(chatId, previousLink, name , expiration.toTelegramDate())
public suspend fun TelegramBot.editChatInviteLinkUnlimited(
suspend fun TelegramBot.editChatInviteLinkUnlimited(
chat: PublicChat,
previousLink: String,
expiration: DateTime,
name: String? = null,
): ChatInviteLinkUnlimited = editChatInviteLinkUnlimited(chat.id, previousLink, name , expiration.toTelegramDate())
) = editChatInviteLinkUnlimited(chat.id, previousLink, name , expiration.toTelegramDate())
public suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
chatId: ChatIdentifier,
previousLink: String,
membersLimit: MembersLimit,
name: String? = null,
expiration: TelegramDate? = null
): ChatInviteLinkWithLimitedMembers = execute(EditChatInviteLink.withLimitedMembers(chatId, previousLink, membersLimit, name, expiration))
) = execute(EditChatInviteLink.withLimitedMembers(chatId, previousLink, membersLimit, name, expiration))
public suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
chat: PublicChat,
previousLink: String,
membersLimit: MembersLimit,
name: String? = null,
expiration: TelegramDate? = null,
): ChatInviteLinkWithLimitedMembers = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, name, expiration)
) = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, name, expiration)
public suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
chatId: ChatIdentifier,
previousLink: String,
membersLimit: MembersLimit,
expiration: DateTime,
name: String? = null,
): ChatInviteLinkWithLimitedMembers = editChatInviteLinkWithLimitedMembers(chatId, previousLink, membersLimit, name , expiration.toTelegramDate())
) = editChatInviteLinkWithLimitedMembers(chatId, previousLink, membersLimit, name , expiration.toTelegramDate())
public suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
chat: PublicChat,
previousLink: String,
membersLimit: MembersLimit,
expiration: DateTime,
name: String? = null,
): ChatInviteLinkWithLimitedMembers = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, name , expiration.toTelegramDate())
) = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, name , expiration.toTelegramDate())
public suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
chatId: ChatIdentifier,
previousLink: String,
name: String? = null,
expiration: TelegramDate? = null
): ChatInviteLinkWithJoinRequest = execute(EditChatInviteLink.withJoinRequest(chatId, previousLink, name, expiration))
) = execute(EditChatInviteLink.withJoinRequest(chatId, previousLink, name, expiration))
public suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
chat: PublicChat,
previousLink: String,
name: String? = null,
expiration: TelegramDate? = null,
): ChatInviteLinkWithJoinRequest = editChatInviteLinkWithJoinRequest(chat.id, previousLink, name, expiration)
) = editChatInviteLinkWithJoinRequest(chat.id, previousLink, name, expiration)
public suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
chatId: ChatIdentifier,
previousLink: String,
expiration: DateTime,
name: String? = null,
): ChatInviteLinkWithJoinRequest = editChatInviteLinkWithJoinRequest(chatId, previousLink, name , expiration.toTelegramDate())
) = editChatInviteLinkWithJoinRequest(chatId, previousLink, name , expiration.toTelegramDate())
public suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
chat: PublicChat,
previousLink: String,
expiration: DateTime,
name: String? = null,
): ChatInviteLinkWithJoinRequest = editChatInviteLinkWithJoinRequest(chat.id, previousLink, name , expiration.toTelegramDate())
) = editChatInviteLinkWithJoinRequest(chat.id, previousLink, name , expiration.toTelegramDate())
public suspend fun TelegramBot.editChatInviteLinkUnlimited(
suspend fun TelegramBot.editChatInviteLinkUnlimited(
chatId: ChatIdentifier,
previousLink: ChatInviteLink,
name: String? = null,
expiration: TelegramDate? = null
): ChatInviteLinkUnlimited = editChatInviteLinkUnlimited(chatId, previousLink.inviteLink, name, expiration)
) = editChatInviteLinkUnlimited(chatId, previousLink.inviteLink, name, expiration)
public suspend fun TelegramBot.editChatInviteLinkUnlimited(
suspend fun TelegramBot.editChatInviteLinkUnlimited(
chat: PublicChat,
previousLink: ChatInviteLink,
name: String? = null,
expiration: TelegramDate? = null,
): ChatInviteLinkUnlimited = editChatInviteLinkUnlimited(chat.id, previousLink, name, expiration)
) = editChatInviteLinkUnlimited(chat.id, previousLink, name, expiration)
public suspend fun TelegramBot.editChatInviteLinkUnlimited(
suspend fun TelegramBot.editChatInviteLinkUnlimited(
chatId: ChatIdentifier,
previousLink: ChatInviteLink,
expiration: DateTime,
name: String? = null,
): ChatInviteLinkUnlimited = editChatInviteLinkUnlimited(chatId, previousLink, name, expiration.toTelegramDate())
) = editChatInviteLinkUnlimited(chatId, previousLink, name, expiration.toTelegramDate())
public suspend fun TelegramBot.editChatInviteLinkUnlimited(
suspend fun TelegramBot.editChatInviteLinkUnlimited(
chat: PublicChat,
previousLink: ChatInviteLink,
expiration: DateTime,
name: String? = null,
): ChatInviteLinkUnlimited = editChatInviteLinkUnlimited(chat.id, previousLink, name , expiration.toTelegramDate())
) = editChatInviteLinkUnlimited(chat.id, previousLink, name , expiration.toTelegramDate())
public suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
chatId: ChatIdentifier,
previousLink: ChatInviteLink,
membersLimit: MembersLimit,
name: String? = null,
expiration: TelegramDate? = null
): ChatInviteLinkWithLimitedMembers = editChatInviteLinkWithLimitedMembers(chatId, previousLink.inviteLink, membersLimit, name, expiration)
) = editChatInviteLinkWithLimitedMembers(chatId, previousLink.inviteLink, membersLimit, name, expiration)
public suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
chat: PublicChat,
previousLink: ChatInviteLink,
membersLimit: MembersLimit,
name: String? = null,
expiration: TelegramDate? = null,
): ChatInviteLinkWithLimitedMembers = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, name, expiration)
) = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, name, expiration)
public suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
chatId: ChatIdentifier,
previousLink: ChatInviteLink,
membersLimit: MembersLimit,
expiration: DateTime,
name: String? = null,
): ChatInviteLinkWithLimitedMembers = editChatInviteLinkWithLimitedMembers(chatId, previousLink, membersLimit, name , expiration.toTelegramDate())
) = editChatInviteLinkWithLimitedMembers(chatId, previousLink, membersLimit, name , expiration.toTelegramDate())
public suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
suspend fun TelegramBot.editChatInviteLinkWithLimitedMembers(
chat: PublicChat,
previousLink: ChatInviteLink,
membersLimit: MembersLimit,
expiration: DateTime,
name: String? = null,
): ChatInviteLinkWithLimitedMembers = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, name , expiration.toTelegramDate())
) = editChatInviteLinkWithLimitedMembers(chat.id, previousLink, membersLimit, name , expiration.toTelegramDate())
public suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
chatId: ChatIdentifier,
previousLink: ChatInviteLink,
name: String? = null,
expiration: TelegramDate? = null
): ChatInviteLinkWithJoinRequest = editChatInviteLinkWithJoinRequest(chatId, previousLink.inviteLink, name, expiration)
) = editChatInviteLinkWithJoinRequest(chatId, previousLink.inviteLink, name, expiration)
public suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
chat: PublicChat,
previousLink: ChatInviteLink,
name: String? = null,
expiration: TelegramDate? = null,
): ChatInviteLinkWithJoinRequest = editChatInviteLinkWithJoinRequest(chat.id, previousLink, name, expiration)
) = editChatInviteLinkWithJoinRequest(chat.id, previousLink, name, expiration)
public suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
chatId: ChatIdentifier,
previousLink: ChatInviteLink,
expiration: DateTime,
name: String? = null,
): ChatInviteLinkWithJoinRequest = editChatInviteLinkWithJoinRequest(chatId, previousLink, name , expiration.toTelegramDate())
) = editChatInviteLinkWithJoinRequest(chatId, previousLink, name , expiration.toTelegramDate())
public suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
suspend fun TelegramBot.editChatInviteLinkWithJoinRequest(
chat: PublicChat,
previousLink: ChatInviteLink,
expiration: DateTime,
name: String? = null,
): ChatInviteLinkWithJoinRequest = editChatInviteLinkWithJoinRequest(chat.id, previousLink, name , expiration.toTelegramDate())
) = editChatInviteLinkWithJoinRequest(chat.id, previousLink, name , expiration.toTelegramDate())

View File

@@ -4,25 +4,24 @@ import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.invite_links.RevokeChatInviteLink
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.ChatInviteLink
import dev.inmo.tgbotapi.types.SecondaryChatInviteLink
import dev.inmo.tgbotapi.types.chat.PublicChat
public suspend fun TelegramBot.revokeChatInviteLink(
suspend fun TelegramBot.revokeChatInviteLink(
chatId: ChatIdentifier,
previousLink: String
): SecondaryChatInviteLink = execute(RevokeChatInviteLink(chatId, previousLink))
) = execute(RevokeChatInviteLink(chatId, previousLink))
public suspend fun TelegramBot.revokeChatInviteLink(
suspend fun TelegramBot.revokeChatInviteLink(
chat: PublicChat,
previousLink: String
): SecondaryChatInviteLink = revokeChatInviteLink(chat.id, previousLink)
) = revokeChatInviteLink(chat.id, previousLink)
public suspend fun TelegramBot.revokeChatInviteLink(
suspend fun TelegramBot.revokeChatInviteLink(
chatId: ChatIdentifier,
previousLink: ChatInviteLink
): SecondaryChatInviteLink = revokeChatInviteLink(chatId, previousLink.inviteLink)
) = revokeChatInviteLink(chatId, previousLink.inviteLink)
public suspend fun TelegramBot.revokeChatInviteLink(
suspend fun TelegramBot.revokeChatInviteLink(
chat: PublicChat,
previousLink: ChatInviteLink
): SecondaryChatInviteLink = revokeChatInviteLink(chat, previousLink.inviteLink)
) = revokeChatInviteLink(chat, previousLink.inviteLink)

View File

@@ -9,30 +9,30 @@ import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.User
public suspend fun TelegramBot.banChatMember(
suspend fun TelegramBot.banChatMember(
chatId: ChatIdentifier,
userId: UserId,
untilDate: TelegramDate? = null,
revokeMessages: Boolean? = null
): Boolean = execute(BanChatMember(chatId, userId, untilDate, revokeMessages))
) = execute(BanChatMember(chatId, userId, untilDate, revokeMessages))
public suspend fun TelegramBot.banChatMember(
suspend fun TelegramBot.banChatMember(
chat: PublicChat,
userId: UserId,
untilDate: TelegramDate? = null,
revokeMessages: Boolean? = null
): Boolean = banChatMember(chat.id, userId, untilDate, revokeMessages)
) = banChatMember(chat.id, userId, untilDate, revokeMessages)
public suspend fun TelegramBot.banChatMember(
suspend fun TelegramBot.banChatMember(
chatId: IdChatIdentifier,
user: User,
untilDate: TelegramDate? = null,
revokeMessages: Boolean? = null
): Boolean = banChatMember(chatId, user.id, untilDate, revokeMessages)
) = banChatMember(chatId, user.id, untilDate, revokeMessages)
public suspend fun TelegramBot.banChatMember(
suspend fun TelegramBot.banChatMember(
chat: PublicChat,
user: User,
untilDate: TelegramDate? = null,
revokeMessages: Boolean? = null
): Boolean = banChatMember(chat.id, user.id, untilDate, revokeMessages)
) = banChatMember(chat.id, user.id, untilDate, revokeMessages)

View File

@@ -6,22 +6,22 @@ import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.PublicChat
public suspend fun TelegramBot.banChatSenderChat(
suspend fun TelegramBot.banChatSenderChat(
chatId: ChatIdentifier,
senderChatId: IdChatIdentifier
): Boolean = execute(BanChatSenderChat(chatId, senderChatId))
) = execute(BanChatSenderChat(chatId, senderChatId))
public suspend fun TelegramBot.banChatSenderChat(
suspend fun TelegramBot.banChatSenderChat(
chat: PublicChat,
senderChatId: IdChatIdentifier
): Boolean = banChatSenderChat(chat.id, senderChatId)
) = banChatSenderChat(chat.id, senderChatId)
public suspend fun TelegramBot.banChatSenderChat(
suspend fun TelegramBot.banChatSenderChat(
chatId: IdChatIdentifier,
senderChat: PublicChat
): Boolean = banChatSenderChat(chatId, senderChat.id)
) = banChatSenderChat(chatId, senderChat.id)
public suspend fun TelegramBot.banChatSenderChat(
suspend fun TelegramBot.banChatSenderChat(
chat: PublicChat,
senderChat: PublicChat,
): Boolean = banChatSenderChat(chat.id, senderChat)
) = banChatSenderChat(chat.id, senderChat)

View File

@@ -7,24 +7,23 @@ import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.User
import dev.inmo.tgbotapi.types.chat.member.ChatMember
public suspend fun TelegramBot.getChatMember(
suspend fun TelegramBot.getChatMember(
chatId: ChatIdentifier,
userId: UserId
): ChatMember = execute(GetChatMember(chatId, userId))
) = execute(GetChatMember(chatId, userId))
public suspend fun TelegramBot.getChatMember(
suspend fun TelegramBot.getChatMember(
chat: PublicChat,
userId: UserId
): ChatMember = getChatMember(chat.id, userId)
) = getChatMember(chat.id, userId)
public suspend fun TelegramBot.getChatMember(
suspend fun TelegramBot.getChatMember(
chatId: IdChatIdentifier,
user: User
): ChatMember = getChatMember(chatId, user.id)
) = getChatMember(chatId, user.id)
public suspend fun TelegramBot.getChatMember(
suspend fun TelegramBot.getChatMember(
chat: PublicChat,
user: User
): ChatMember = getChatMember(chat.id, user.id)
) = getChatMember(chat.id, user.id)

View File

@@ -1,157 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.PromoteChannelAdministrator
import dev.inmo.tgbotapi.requests.chat.members.PromoteChatMember
import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.TelegramDate
import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.User
public suspend fun TelegramBot.promoteChannelAdministrator(
chatId: ChatIdentifier,
userId: UserId,
untilDate: TelegramDate? = null,
isAnonymous: Boolean? = null,
canChangeInfo: Boolean? = null,
canPostMessages: Boolean? = null,
canEditMessages: Boolean? = null,
canDeleteMessages: Boolean? = null,
canInviteUsers: Boolean? = null,
canRestrictMembers: Boolean? = null,
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
canPostStories: Boolean? = null,
canEditStories: Boolean? = null,
canDeleteStories: Boolean? = null
): Boolean = execute(
PromoteChannelAdministrator(
chatId = chatId,
userId = userId,
untilDate = untilDate,
isAnonymous = isAnonymous,
canChangeInfo = canChangeInfo,
canPostMessages = canPostMessages,
canEditMessages = canEditMessages,
canDeleteMessages = canDeleteMessages,
canInviteUsers = canInviteUsers,
canRestrictMembers = canRestrictMembers,
canPromoteMembers = canPromoteMembers,
canManageVideoChats = canManageVideoChats,
canManageChat = canManageChat,
canPostStories = canPostStories,
canEditStories = canEditStories,
canDeleteStories = canDeleteStories
)
)
public suspend fun TelegramBot.promoteChannelAdministrator(
chat: PublicChat,
userId: UserId,
untilDate: TelegramDate? = null,
isAnonymous: Boolean? = null,
canChangeInfo: Boolean? = null,
canPostMessages: Boolean? = null,
canEditMessages: Boolean? = null,
canDeleteMessages: Boolean? = null,
canInviteUsers: Boolean? = null,
canRestrictMembers: Boolean? = null,
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
canPostStories: Boolean? = null,
canEditStories: Boolean? = null,
canDeleteStories: Boolean? = null
): Boolean = promoteChannelAdministrator(
chat.id,
userId,
untilDate = untilDate,
isAnonymous = isAnonymous,
canChangeInfo = canChangeInfo,
canPostMessages = canPostMessages,
canEditMessages = canEditMessages,
canDeleteMessages = canDeleteMessages,
canInviteUsers = canInviteUsers,
canRestrictMembers = canRestrictMembers,
canPromoteMembers = canPromoteMembers,
canManageVideoChats = canManageVideoChats,
canManageChat = canManageChat,
canPostStories = canPostStories,
canEditStories = canEditStories,
canDeleteStories = canDeleteStories
)
public suspend fun TelegramBot.promoteChannelAdministrator(
chatId: IdChatIdentifier,
user: User,
untilDate: TelegramDate? = null,
isAnonymous: Boolean? = null,
canChangeInfo: Boolean? = null,
canPostMessages: Boolean? = null,
canEditMessages: Boolean? = null,
canDeleteMessages: Boolean? = null,
canInviteUsers: Boolean? = null,
canRestrictMembers: Boolean? = null,
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
canPostStories: Boolean? = null,
canEditStories: Boolean? = null,
canDeleteStories: Boolean? = null
): Boolean = promoteChannelAdministrator(
chatId,
user.id,
untilDate = untilDate,
isAnonymous = isAnonymous,
canChangeInfo = canChangeInfo,
canPostMessages = canPostMessages,
canEditMessages = canEditMessages,
canDeleteMessages = canDeleteMessages,
canInviteUsers = canInviteUsers,
canRestrictMembers = canRestrictMembers,
canPromoteMembers = canPromoteMembers,
canManageVideoChats = canManageVideoChats,
canManageChat = canManageChat,
canPostStories = canPostStories,
canEditStories = canEditStories,
canDeleteStories = canDeleteStories
)
public suspend fun TelegramBot.promoteChannelAdministrator(
chat: PublicChat,
user: User,
untilDate: TelegramDate? = null,
isAnonymous: Boolean? = null,
canChangeInfo: Boolean? = null,
canPostMessages: Boolean? = null,
canEditMessages: Boolean? = null,
canDeleteMessages: Boolean? = null,
canInviteUsers: Boolean? = null,
canRestrictMembers: Boolean? = null,
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
canPostStories: Boolean? = null,
canEditStories: Boolean? = null,
canDeleteStories: Boolean? = null
): Boolean = promoteChannelAdministrator(
chat.id,
user.id,
untilDate = untilDate,
isAnonymous = isAnonymous,
canChangeInfo = canChangeInfo,
canPostMessages = canPostMessages,
canEditMessages = canEditMessages,
canDeleteMessages = canDeleteMessages,
canInviteUsers = canInviteUsers,
canRestrictMembers = canRestrictMembers,
canPromoteMembers = canPromoteMembers,
canManageVideoChats = canManageVideoChats,
canManageChat = canManageChat,
canPostStories = canPostStories,
canEditStories = canEditStories,
canDeleteStories = canDeleteStories
)

View File

@@ -1,116 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.PromoteChatMember
import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.TelegramDate
import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.User
public suspend fun TelegramBot.promoteChatAdministrator(
chatId: ChatIdentifier,
userId: UserId,
untilDate: TelegramDate? = null,
isAnonymous: Boolean? = null,
canChangeInfo: Boolean? = null,
canDeleteMessages: Boolean? = null,
canInviteUsers: Boolean? = null,
canRestrictMembers: Boolean? = null,
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
): Boolean = execute(
PromoteChatMember(
chatId,
userId,
untilDate,
isAnonymous,
canChangeInfo,
canDeleteMessages,
canInviteUsers,
canRestrictMembers,
canPromoteMembers,
canManageVideoChats,
canManageChat
)
)
public suspend fun TelegramBot.promoteChatAdministrator(
chat: PublicChat,
userId: UserId,
untilDate: TelegramDate? = null,
isAnonymous: Boolean? = null,
canChangeInfo: Boolean? = null,
canDeleteMessages: Boolean? = null,
canInviteUsers: Boolean? = null,
canRestrictMembers: Boolean? = null,
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
): Boolean = promoteChatAdministrator(
chat.id,
userId,
untilDate,
isAnonymous,
canChangeInfo,
canDeleteMessages,
canInviteUsers,
canRestrictMembers,
canPromoteMembers,
canManageVideoChats,
canManageChat
)
public suspend fun TelegramBot.promoteChatAdministrator(
chatId: IdChatIdentifier,
user: User,
untilDate: TelegramDate? = null,
isAnonymous: Boolean? = null,
canChangeInfo: Boolean? = null,
canDeleteMessages: Boolean? = null,
canInviteUsers: Boolean? = null,
canRestrictMembers: Boolean? = null,
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
): Boolean = promoteChatAdministrator(
chatId,
user.id,
untilDate,
isAnonymous,
canChangeInfo,
canDeleteMessages,
canInviteUsers,
canRestrictMembers,
canPromoteMembers,
canManageVideoChats,
canManageChat
)
public suspend fun TelegramBot.promoteChatAdministrator(
chat: PublicChat,
user: User,
untilDate: TelegramDate? = null,
isAnonymous: Boolean? = null,
canChangeInfo: Boolean? = null,
canDeleteMessages: Boolean? = null,
canInviteUsers: Boolean? = null,
canRestrictMembers: Boolean? = null,
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
): Boolean = promoteChatAdministrator(
chat.id,
user.id,
untilDate,
isAnonymous,
canChangeInfo,
canDeleteMessages,
canInviteUsers,
canRestrictMembers,
canPromoteMembers,
canManageVideoChats,
canManageChat
)

View File

@@ -1,14 +1,15 @@
package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.micro_utils.common.Warning
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.PromoteChatMember
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.TelegramDate
import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.User
@Warning("This method is too common. Use it with caution")
public suspend fun TelegramBot.promoteChatMember(
suspend fun TelegramBot.promoteChatMember(
chatId: ChatIdentifier,
userId: UserId,
untilDate: TelegramDate? = null,
@@ -23,35 +24,28 @@ public suspend fun TelegramBot.promoteChatMember(
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
canManageTopics: Boolean? = null,
canPostStories: Boolean? = null,
canEditStories: Boolean? = null,
canDeleteStories: Boolean? = null
): Boolean = execute(
canManageTopics: Boolean? = null
) = execute(
PromoteChatMember(
chatId = chatId,
userId = userId,
untilDate = untilDate,
isAnonymous = isAnonymous,
canChangeInfo = canChangeInfo,
canPostMessages = canPostMessages,
canEditMessages = canEditMessages,
canDeleteMessages = canDeleteMessages,
canInviteUsers = canInviteUsers,
canRestrictMembers = canRestrictMembers,
canPinMessages = canPinMessages,
canPromoteMembers = canPromoteMembers,
canManageVideoChats = canManageVideoChats,
canManageChat = canManageChat,
canManageTopics = canManageTopics,
canPostStories = canPostStories,
canEditStories = canEditStories,
canDeleteStories = canDeleteStories
chatId,
userId,
untilDate,
isAnonymous,
canChangeInfo,
canPostMessages,
canEditMessages,
canDeleteMessages,
canInviteUsers,
canRestrictMembers,
canPinMessages,
canPromoteMembers,
canManageVideoChats,
canManageChat,
canManageTopics
)
)
@Warning("This method is too common. Use it with caution")
public suspend fun TelegramBot.promoteChatMember(
suspend fun TelegramBot.promoteChatMember(
chat: PublicChat,
userId: UserId,
untilDate: TelegramDate? = null,
@@ -66,33 +60,26 @@ public suspend fun TelegramBot.promoteChatMember(
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
canManageTopics: Boolean? = null,
canPostStories: Boolean? = null,
canEditStories: Boolean? = null,
canDeleteStories: Boolean? = null
): Boolean = promoteChatMember(
canManageTopics: Boolean? = null
) = promoteChatMember(
chat.id,
userId,
untilDate = untilDate,
isAnonymous = isAnonymous,
canChangeInfo = canChangeInfo,
canPostMessages = canPostMessages,
canEditMessages = canEditMessages,
canDeleteMessages = canDeleteMessages,
canInviteUsers = canInviteUsers,
canRestrictMembers = canRestrictMembers,
canPinMessages = canPinMessages,
canPromoteMembers = canPromoteMembers,
canManageVideoChats = canManageVideoChats,
canManageChat = canManageChat,
canManageTopics = canManageTopics,
canPostStories = canPostStories,
canEditStories = canEditStories,
canDeleteStories = canDeleteStories
untilDate,
isAnonymous,
canChangeInfo,
canPostMessages,
canEditMessages,
canDeleteMessages,
canInviteUsers,
canRestrictMembers,
canPinMessages,
canPromoteMembers,
canManageVideoChats,
canManageChat,
canManageTopics
)
@Warning("This method is too common. Use it with caution")
public suspend fun TelegramBot.promoteChatMember(
suspend fun TelegramBot.promoteChatMember(
chatId: IdChatIdentifier,
user: User,
untilDate: TelegramDate? = null,
@@ -107,33 +94,26 @@ public suspend fun TelegramBot.promoteChatMember(
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
canManageTopics: Boolean? = null,
canPostStories: Boolean? = null,
canEditStories: Boolean? = null,
canDeleteStories: Boolean? = null
): Boolean = promoteChatMember(
canManageTopics: Boolean? = null
) = promoteChatMember(
chatId,
user.id,
untilDate = untilDate,
isAnonymous = isAnonymous,
canChangeInfo = canChangeInfo,
canPostMessages = canPostMessages,
canEditMessages = canEditMessages,
canDeleteMessages = canDeleteMessages,
canInviteUsers = canInviteUsers,
canRestrictMembers = canRestrictMembers,
canPinMessages = canPinMessages,
canPromoteMembers = canPromoteMembers,
canManageVideoChats = canManageVideoChats,
canManageChat = canManageChat,
canManageTopics = canManageTopics,
canPostStories = canPostStories,
canEditStories = canEditStories,
canDeleteStories = canDeleteStories
untilDate,
isAnonymous,
canChangeInfo,
canPostMessages,
canEditMessages,
canDeleteMessages,
canInviteUsers,
canRestrictMembers,
canPinMessages,
canPromoteMembers,
canManageVideoChats,
canManageChat,
canManageTopics
)
@Warning("This method is too common. Use it with caution")
public suspend fun TelegramBot.promoteChatMember(
suspend fun TelegramBot.promoteChatMember(
chat: PublicChat,
user: User,
untilDate: TelegramDate? = null,
@@ -148,27 +128,21 @@ public suspend fun TelegramBot.promoteChatMember(
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
canManageTopics: Boolean? = null,
canPostStories: Boolean? = null,
canEditStories: Boolean? = null,
canDeleteStories: Boolean? = null
): Boolean = promoteChatMember(
canManageTopics: Boolean? = null
) = promoteChatMember(
chat.id,
user.id,
untilDate = untilDate,
isAnonymous = isAnonymous,
canChangeInfo = canChangeInfo,
canPostMessages = canPostMessages,
canEditMessages = canEditMessages,
canDeleteMessages = canDeleteMessages,
canInviteUsers = canInviteUsers,
canRestrictMembers = canRestrictMembers,
canPinMessages = canPinMessages,
canPromoteMembers = canPromoteMembers,
canManageVideoChats = canManageVideoChats,
canManageChat = canManageChat,
canManageTopics = canManageTopics,
canPostStories = canPostStories,
canEditStories = canEditStories,
canDeleteStories = canDeleteStories
untilDate,
isAnonymous,
canChangeInfo,
canPostMessages,
canEditMessages,
canDeleteMessages,
canInviteUsers,
canRestrictMembers,
canPinMessages,
canPromoteMembers,
canManageVideoChats,
canManageChat,
canManageTopics
)

View File

@@ -1,133 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.PromoteChatMember
import dev.inmo.tgbotapi.requests.chat.members.PromoteSupergroupAdministrator
import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.TelegramDate
import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.User
public suspend fun TelegramBot.promoteSupergroupAdministrator(
chatId: ChatIdentifier,
userId: UserId,
untilDate: TelegramDate? = null,
isAnonymous: Boolean? = null,
canChangeInfo: Boolean? = null,
canDeleteMessages: Boolean? = null,
canInviteUsers: Boolean? = null,
canRestrictMembers: Boolean? = null,
canPinMessages: Boolean? = null,
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
canManageTopics: Boolean? = null,
): Boolean = execute(
PromoteSupergroupAdministrator(
chatId = chatId,
userId = userId,
untilDate = untilDate,
isAnonymous = isAnonymous,
canChangeInfo = canChangeInfo,
canDeleteMessages = canDeleteMessages,
canInviteUsers = canInviteUsers,
canRestrictMembers = canRestrictMembers,
canPinMessages = canPinMessages,
canPromoteMembers = canPromoteMembers,
canManageVideoChats = canManageVideoChats,
canManageChat = canManageChat,
canManageTopics = canManageTopics
)
)
public suspend fun TelegramBot.promoteSupergroupAdministrator(
chat: PublicChat,
userId: UserId,
untilDate: TelegramDate? = null,
isAnonymous: Boolean? = null,
canChangeInfo: Boolean? = null,
canDeleteMessages: Boolean? = null,
canInviteUsers: Boolean? = null,
canRestrictMembers: Boolean? = null,
canPinMessages: Boolean? = null,
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
canManageTopics: Boolean? = null,
): Boolean = promoteSupergroupAdministrator(
chat.id,
userId,
untilDate = untilDate,
isAnonymous = isAnonymous,
canChangeInfo = canChangeInfo,
canDeleteMessages = canDeleteMessages,
canInviteUsers = canInviteUsers,
canRestrictMembers = canRestrictMembers,
canPinMessages = canPinMessages,
canPromoteMembers = canPromoteMembers,
canManageVideoChats = canManageVideoChats,
canManageChat = canManageChat,
canManageTopics = canManageTopics
)
public suspend fun TelegramBot.promoteSupergroupAdministrator(
chatId: IdChatIdentifier,
user: User,
untilDate: TelegramDate? = null,
isAnonymous: Boolean? = null,
canChangeInfo: Boolean? = null,
canDeleteMessages: Boolean? = null,
canInviteUsers: Boolean? = null,
canRestrictMembers: Boolean? = null,
canPinMessages: Boolean? = null,
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
canManageTopics: Boolean? = null,
): Boolean = promoteSupergroupAdministrator(
chatId,
user.id,
untilDate = untilDate,
isAnonymous = isAnonymous,
canChangeInfo = canChangeInfo,
canDeleteMessages = canDeleteMessages,
canInviteUsers = canInviteUsers,
canRestrictMembers = canRestrictMembers,
canPinMessages = canPinMessages,
canPromoteMembers = canPromoteMembers,
canManageVideoChats = canManageVideoChats,
canManageChat = canManageChat,
canManageTopics = canManageTopics
)
public suspend fun TelegramBot.promoteSupergroupAdministrator(
chat: PublicChat,
user: User,
untilDate: TelegramDate? = null,
isAnonymous: Boolean? = null,
canChangeInfo: Boolean? = null,
canDeleteMessages: Boolean? = null,
canInviteUsers: Boolean? = null,
canRestrictMembers: Boolean? = null,
canPinMessages: Boolean? = null,
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null,
canManageTopics: Boolean? = null,
): Boolean = promoteSupergroupAdministrator(
chat.id,
user.id,
untilDate = untilDate,
isAnonymous = isAnonymous,
canChangeInfo = canChangeInfo,
canDeleteMessages = canDeleteMessages,
canInviteUsers = canInviteUsers,
canRestrictMembers = canRestrictMembers,
canPinMessages = canPinMessages,
canPromoteMembers = canPromoteMembers,
canManageVideoChats = canManageVideoChats,
canManageChat = canManageChat,
canManageTopics = canManageTopics
)

View File

@@ -10,35 +10,31 @@ import dev.inmo.tgbotapi.types.chat.ChatPermissions
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.User
public suspend fun TelegramBot.restrictChatMember(
suspend fun TelegramBot.restrictChatMember(
chatId: ChatIdentifier,
userId: UserId,
untilDate: TelegramDate? = null,
permissions: ChatPermissions = ChatPermissions(),
useIndependentChatPermissions: Boolean? = permissions.isGranular.takeIf { it }
): Boolean = execute(RestrictChatMember(chatId, userId, untilDate, permissions, useIndependentChatPermissions))
permissions: ChatPermissions = ChatPermissions()
) = execute(RestrictChatMember(chatId, userId, untilDate, permissions))
public suspend fun TelegramBot.restrictChatMember(
suspend fun TelegramBot.restrictChatMember(
chat: PublicChat,
userId: UserId,
untilDate: TelegramDate? = null,
permissions: ChatPermissions = ChatPermissions(),
useIndependentChatPermissions: Boolean? = permissions.isGranular.takeIf { it }
): Boolean = restrictChatMember(chat.id, userId, untilDate, permissions, useIndependentChatPermissions)
permissions: ChatPermissions = ChatPermissions()
) = restrictChatMember(chat.id, userId, untilDate, permissions)
public suspend fun TelegramBot.restrictChatMember(
suspend fun TelegramBot.restrictChatMember(
chatId: IdChatIdentifier,
user: User,
untilDate: TelegramDate? = null,
permissions: ChatPermissions = ChatPermissions(),
useIndependentChatPermissions: Boolean? = permissions.isGranular.takeIf { it }
): Boolean = restrictChatMember(chatId, user.id, untilDate, permissions, useIndependentChatPermissions)
permissions: ChatPermissions = ChatPermissions()
) = restrictChatMember(chatId, user.id, untilDate, permissions)
public suspend fun TelegramBot.restrictChatMember(
suspend fun TelegramBot.restrictChatMember(
chat: PublicChat,
user: User,
untilDate: TelegramDate? = null,
permissions: ChatPermissions = ChatPermissions(),
useIndependentChatPermissions: Boolean? = permissions.isGranular.takeIf { it }
): Boolean = restrictChatMember(chat.id, user.id, untilDate, permissions, useIndependentChatPermissions)
permissions: ChatPermissions = ChatPermissions()
) = restrictChatMember(chat.id, user.id, untilDate, permissions)

View File

@@ -7,26 +7,26 @@ import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.User
public suspend fun TelegramBot.setChatAdministratorCustomTitle(
suspend fun TelegramBot.setChatAdministratorCustomTitle(
chatId: IdChatIdentifier,
userId: UserId,
customTitle: String
): Boolean = execute(SetChatAdministratorCustomTitle(chatId, userId, customTitle))
) = execute(SetChatAdministratorCustomTitle(chatId, userId, customTitle))
public suspend fun TelegramBot.setChatAdministratorCustomTitle(
suspend fun TelegramBot.setChatAdministratorCustomTitle(
chat: PublicChat,
userId: UserId,
customTitle: String
): Boolean = setChatAdministratorCustomTitle(chat.id, userId, customTitle)
) = setChatAdministratorCustomTitle(chat.id, userId, customTitle)
public suspend fun TelegramBot.setChatAdministratorCustomTitle(
suspend fun TelegramBot.setChatAdministratorCustomTitle(
chatId: IdChatIdentifier,
user: User,
customTitle: String
): Boolean = setChatAdministratorCustomTitle(chatId, user.id, customTitle)
) = setChatAdministratorCustomTitle(chatId, user.id, customTitle)
public suspend fun TelegramBot.setChatAdministratorCustomTitle(
suspend fun TelegramBot.setChatAdministratorCustomTitle(
chat: PublicChat,
user: User,
customTitle: String
): Boolean = setChatAdministratorCustomTitle(chat.id, user.id, customTitle)
) = setChatAdministratorCustomTitle(chat.id, user.id, customTitle)

View File

@@ -8,27 +8,27 @@ import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.User
public suspend fun TelegramBot.unbanChatMember(
suspend fun TelegramBot.unbanChatMember(
chatId: ChatIdentifier,
userId: UserId,
onlyIfBanned: Boolean? = null
): Boolean = execute(UnbanChatMember(chatId, userId, onlyIfBanned))
) = execute(UnbanChatMember(chatId, userId, onlyIfBanned))
public suspend fun TelegramBot.unbanChatMember(
suspend fun TelegramBot.unbanChatMember(
chat: PublicChat,
userId: UserId,
onlyIfBanned: Boolean? = null
): Boolean = unbanChatMember(chat.id, userId, onlyIfBanned)
) = unbanChatMember(chat.id, userId, onlyIfBanned)
public suspend fun TelegramBot.unbanChatMember(
suspend fun TelegramBot.unbanChatMember(
chatId: IdChatIdentifier,
user: User,
onlyIfBanned: Boolean? = null
): Boolean = unbanChatMember(chatId, user.id, onlyIfBanned)
) = unbanChatMember(chatId, user.id, onlyIfBanned)
public suspend fun TelegramBot.unbanChatMember(
suspend fun TelegramBot.unbanChatMember(
chat: PublicChat,
user: User,
onlyIfBanned: Boolean? = null
): Boolean = unbanChatMember(chat.id, user.id, onlyIfBanned)
) = unbanChatMember(chat.id, user.id, onlyIfBanned)

View File

@@ -6,22 +6,22 @@ import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.PublicChat
public suspend fun TelegramBot.unbanChatSenderChat(
suspend fun TelegramBot.unbanChatSenderChat(
chatId: ChatIdentifier,
senderChatId: IdChatIdentifier
): Boolean = execute(UnbanChatSenderChat(chatId, senderChatId))
) = execute(UnbanChatSenderChat(chatId, senderChatId))
public suspend fun TelegramBot.unbanChatSenderChat(
suspend fun TelegramBot.unbanChatSenderChat(
chat: PublicChat,
senderChatId: IdChatIdentifier
): Boolean = unbanChatSenderChat(chat.id, senderChatId)
) = unbanChatSenderChat(chat.id, senderChatId)
public suspend fun TelegramBot.unbanChatSenderChat(
suspend fun TelegramBot.unbanChatSenderChat(
chatId: IdChatIdentifier,
senderChat: PublicChat
): Boolean = unbanChatSenderChat(chatId, senderChat.id)
) = unbanChatSenderChat(chatId, senderChat.id)
public suspend fun TelegramBot.unbanChatSenderChat(
suspend fun TelegramBot.unbanChatSenderChat(
chat: PublicChat,
senderChat: PublicChat,
): Boolean = unbanChatSenderChat(chat.id, senderChat)
) = unbanChatSenderChat(chat.id, senderChat)

View File

@@ -5,10 +5,10 @@ import dev.inmo.tgbotapi.requests.chat.modify.DeleteChatPhoto
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.PublicChat
public suspend fun TelegramBot.deleteChatPhoto(
suspend fun TelegramBot.deleteChatPhoto(
chatId: ChatIdentifier
): Boolean = execute(DeleteChatPhoto(chatId))
) = execute(DeleteChatPhoto(chatId))
public suspend fun TelegramBot.deleteChatPhoto(
suspend fun TelegramBot.deleteChatPhoto(
chat: PublicChat
): Boolean = deleteChatPhoto(chat.id)
) = deleteChatPhoto(chat.id)

View File

@@ -5,21 +5,21 @@ import dev.inmo.tgbotapi.requests.chat.modify.PinChatMessage
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.abstracts.Message
public suspend fun TelegramBot.pinChatMessage(
suspend fun TelegramBot.pinChatMessage(
chatId: ChatIdentifier,
messageId: MessageId,
disableNotification: Boolean = false
): Boolean = execute(PinChatMessage(chatId, messageId, disableNotification))
) = execute(PinChatMessage(chatId, messageId, disableNotification))
public suspend fun TelegramBot.pinChatMessage(
suspend fun TelegramBot.pinChatMessage(
chat: Chat,
messageId: MessageId,
disableNotification: Boolean = false
): Boolean = pinChatMessage(chat.id, messageId, disableNotification)
) = pinChatMessage(chat.id, messageId, disableNotification)
public suspend fun TelegramBot.pinChatMessage(
message: AccessibleMessage,
suspend fun TelegramBot.pinChatMessage(
message: Message,
disableNotification: Boolean = false
): Boolean = pinChatMessage(message.chat.id, message.messageId, disableNotification)
) = pinChatMessage(message.chat.id, message.messageId, disableNotification)

View File

@@ -5,12 +5,12 @@ import dev.inmo.tgbotapi.requests.chat.modify.SetChatDescription
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.PublicChat
public suspend fun TelegramBot.setChatDescription(
suspend fun TelegramBot.setChatDescription(
chatId: ChatIdentifier,
description: String
): Boolean = execute(SetChatDescription(chatId, description))
) = execute(SetChatDescription(chatId, description))
public suspend fun TelegramBot.setChatDescription(
suspend fun TelegramBot.setChatDescription(
chat: PublicChat,
description: String
): Boolean = setChatDescription(chat.id, description)
) = setChatDescription(chat.id, description)

View File

@@ -6,12 +6,12 @@ import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.MenuButton
import dev.inmo.tgbotapi.types.chat.PrivateChat
public suspend fun TelegramBot.setChatMenuButton(
suspend fun TelegramBot.setChatMenuButton(
chatId: IdChatIdentifier,
menuButton: MenuButton
): Boolean = execute(SetChatMenuButton(chatId, menuButton))
) = execute(SetChatMenuButton(chatId, menuButton))
public suspend fun TelegramBot.setChatMenuButton(
suspend fun TelegramBot.setChatMenuButton(
chat: PrivateChat,
menuButton: MenuButton
): Boolean = setChatMenuButton(chat.id, menuButton)
) = setChatMenuButton(chat.id, menuButton)

View File

@@ -6,14 +6,12 @@ import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.ChatPermissions
import dev.inmo.tgbotapi.types.chat.PublicChat
public suspend fun TelegramBot.setDefaultChatMembersPermissions(
suspend fun TelegramBot.setDefaultChatMembersPermissions(
chatId: ChatIdentifier,
permissions: ChatPermissions,
useIndependentChatPermissions: Boolean? = permissions.isGranular.takeIf { it }
): Boolean = execute(SetChatPermissions(chatId, permissions, useIndependentChatPermissions))
permissions: ChatPermissions
) = execute(SetChatPermissions(chatId, permissions))
public suspend fun TelegramBot.setDefaultChatMembersPermissions(
suspend fun TelegramBot.setDefaultChatMembersPermissions(
chat: PublicChat,
permissions: ChatPermissions,
useIndependentChatPermissions: Boolean? = permissions.isGranular.takeIf { it }
): Boolean = setDefaultChatMembersPermissions(chat.id, permissions, useIndependentChatPermissions)
permissions: ChatPermissions
) = setDefaultChatMembersPermissions(chat.id, permissions)

View File

@@ -6,12 +6,12 @@ import dev.inmo.tgbotapi.requests.chat.modify.SetChatPhoto
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.PublicChat
public suspend fun TelegramBot.setChatPhoto(
suspend fun TelegramBot.setChatPhoto(
chatId: ChatIdentifier,
photo: MultipartFile
): Boolean = execute(SetChatPhoto(chatId, photo))
) = execute(SetChatPhoto(chatId, photo))
public suspend fun TelegramBot.setChatPhoto(
suspend fun TelegramBot.setChatPhoto(
chat: PublicChat,
photo: MultipartFile
): Boolean = setChatPhoto(chat.id, photo)
) = setChatPhoto(chat.id, photo)

View File

@@ -5,12 +5,12 @@ import dev.inmo.tgbotapi.requests.chat.modify.SetChatTitle
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.PublicChat
public suspend fun TelegramBot.setChatTitle(
suspend fun TelegramBot.setChatTitle(
chatId: ChatIdentifier,
title: String
): Boolean = execute(SetChatTitle(chatId, title))
) = execute(SetChatTitle(chatId, title))
public suspend fun TelegramBot.setChatTitle(
suspend fun TelegramBot.setChatTitle(
chat: PublicChat,
title: String
): Boolean = setChatTitle(chat.id, title)
) = setChatTitle(chat.id, title)

View File

@@ -4,6 +4,6 @@ import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.modify.SetDefaultChatMenuButton
import dev.inmo.tgbotapi.types.MenuButton
public suspend fun TelegramBot.setDefaultChatMenuButton(
suspend fun TelegramBot.setDefaultChatMenuButton(
menuButton: MenuButton
): Boolean = execute(SetDefaultChatMenuButton(menuButton))
) = execute(SetDefaultChatMenuButton(menuButton))

View File

@@ -5,10 +5,10 @@ import dev.inmo.tgbotapi.requests.chat.modify.UnpinAllChatMessages
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.Chat
public suspend fun TelegramBot.unpinAllChatMessages(
suspend fun TelegramBot.unpinAllChatMessages(
chatId: ChatIdentifier
): Boolean = execute(UnpinAllChatMessages(chatId))
) = execute(UnpinAllChatMessages(chatId))
public suspend fun TelegramBot.unpinAllChatMessages(
suspend fun TelegramBot.unpinAllChatMessages(
chat: Chat
): Boolean = unpinAllChatMessages(chat.id)
) = unpinAllChatMessages(chat.id)

View File

@@ -5,18 +5,18 @@ import dev.inmo.tgbotapi.requests.chat.modify.UnpinChatMessage
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.abstracts.Message
public suspend fun TelegramBot.unpinChatMessage(
suspend fun TelegramBot.unpinChatMessage(
chatId: ChatIdentifier,
messageId: MessageId? = null
): Boolean = execute(UnpinChatMessage(chatId, messageId))
) = execute(UnpinChatMessage(chatId, messageId))
public suspend fun TelegramBot.unpinChatMessage(
suspend fun TelegramBot.unpinChatMessage(
chat: Chat,
messageId: MessageId? = null
): Boolean = unpinChatMessage(chat.id, messageId)
) = unpinChatMessage(chat.id, messageId)
public suspend fun TelegramBot.unpinChatMessage(
message: AccessibleMessage
): Boolean = unpinChatMessage(message.chat.id, message.messageId)
suspend fun TelegramBot.unpinChatMessage(
message: Message
) = unpinChatMessage(message.chat.id, message.messageId)

View File

@@ -5,10 +5,10 @@ import dev.inmo.tgbotapi.requests.chat.stickers.DeleteChatStickerSet
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.SupergroupChat
public suspend fun TelegramBot.deleteChatStickerSet(
suspend fun TelegramBot.deleteChatStickerSet(
chatId: ChatIdentifier
): Boolean = execute(DeleteChatStickerSet(chatId))
) = execute(DeleteChatStickerSet(chatId))
public suspend fun TelegramBot.deleteChatStickerSet(
suspend fun TelegramBot.deleteChatStickerSet(
chat: SupergroupChat
): Boolean = deleteChatStickerSet(chat.id)
) = deleteChatStickerSet(chat.id)

View File

@@ -6,12 +6,12 @@ import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.StickerSetName
import dev.inmo.tgbotapi.types.chat.SupergroupChat
public suspend fun TelegramBot.setChatStickerSet(
suspend fun TelegramBot.setChatStickerSet(
chatId: ChatIdentifier,
stickerSetName: StickerSetName
): Boolean = execute(SetChatStickerSet(chatId, stickerSetName))
) = execute(SetChatStickerSet(chatId, stickerSetName))
public suspend fun TelegramBot.setChatStickerSet(
suspend fun TelegramBot.setChatStickerSet(
chat: SupergroupChat,
stickerSetName: StickerSetName
): Boolean = setChatStickerSet(chat.id, stickerSetName)
) = setChatStickerSet(chat.id, stickerSetName)

View File

@@ -8,14 +8,13 @@ import dev.inmo.tgbotapi.extensions.api.edit.media.editMessageMedia
import dev.inmo.tgbotapi.extensions.api.edit.reply_markup.editMessageReplyMarkup
import dev.inmo.tgbotapi.extensions.api.edit.text.editMessageText
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.location.LiveLocation
import dev.inmo.tgbotapi.types.media.TelegramFreeMedia
import dev.inmo.tgbotapi.types.media.TelegramMedia
import dev.inmo.tgbotapi.types.message.ParseMode
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.types.message.content.*
import dev.inmo.tgbotapi.types.message.textsources.TextSource
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
@@ -26,313 +25,284 @@ import dev.inmo.tgbotapi.utils.buildEntities
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun <T> TelegramBot.edit(
suspend fun <T> TelegramBot.edit(
message: ContentMessage<T>,
text: String,
parseMode: ParseMode? = null,
businessConnectionId: BusinessConnectionId? = message.chat.id.businessConnectionId,
showCaptionAboveMedia: Boolean = false,
replyMarkup: InlineKeyboardMarkup? = null
): ContentMessage<T> where T : TextedWithTextSources, T : MediaContent {
return editMessageCaption(message, text, parseMode, businessConnectionId, showCaptionAboveMedia, replyMarkup)
return editMessageCaption(message, text, parseMode, replyMarkup)
}
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun <T> TelegramBot.edit(
suspend fun <T> TelegramBot.edit(
message: ContentMessage<T>,
entities: List<TextSource>,
businessConnectionId: BusinessConnectionId? = message.chat.id.businessConnectionId,
showCaptionAboveMedia: Boolean = false,
replyMarkup: InlineKeyboardMarkup? = null
): ContentMessage<T> where T : TextedWithTextSources, T : MediaContent {
return editMessageCaption(message, entities, businessConnectionId, showCaptionAboveMedia, replyMarkup)
return editMessageCaption(message, entities, replyMarkup)
}
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.edit(
suspend fun TelegramBot.edit(
chatId: ChatIdentifier,
messageId: MessageId,
latitude: Double,
longitude: Double,
livePeriod: Seconds? = null,
horizontalAccuracy: Meters? = null,
heading: Degrees? = null,
proximityAlertRadius: Meters? = null,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
replyMarkup: InlineKeyboardMarkup? = null
): ContentMessage<LiveLocationContent> = editLiveLocation(chatId, messageId, latitude, longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, businessConnectionId, replyMarkup)
) = editLiveLocation(chatId, messageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.edit(
suspend fun TelegramBot.edit(
chat: Chat,
messageId: MessageId,
latitude: Double,
longitude: Double,
livePeriod: Seconds? = null,
horizontalAccuracy: Meters? = null,
heading: Degrees? = null,
proximityAlertRadius: Meters? = null,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
replyMarkup: InlineKeyboardMarkup? = null
): ContentMessage<LiveLocationContent> = editLiveLocation(chat, messageId, latitude, longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, businessConnectionId, replyMarkup)
) = editLiveLocation(chat, messageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.edit(
suspend fun TelegramBot.edit(
message: ContentMessage<LocationContent>,
latitude: Double,
longitude: Double,
livePeriod: Seconds? = null,
horizontalAccuracy: Meters? = null,
heading: Degrees? = null,
proximityAlertRadius: Meters? = null,
businessConnectionId: BusinessConnectionId? = message.chat.id.businessConnectionId,
replyMarkup: InlineKeyboardMarkup? = null
): ContentMessage<LiveLocationContent> = editLiveLocation(message, latitude, longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, businessConnectionId, replyMarkup)
) = editLiveLocation(message, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.edit(
suspend fun TelegramBot.edit(
chatId: ChatIdentifier,
messageId: MessageId,
location: LiveLocation,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
replyMarkup: InlineKeyboardMarkup? = null
): ContentMessage<LiveLocationContent> = editLiveLocation(
chatId, messageId, location, businessConnectionId, replyMarkup
) = editLiveLocation(
chatId, messageId, location, replyMarkup
)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.edit(
suspend fun TelegramBot.edit(
chat: Chat,
messageId: MessageId,
location: LiveLocation,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
replyMarkup: InlineKeyboardMarkup? = null
): ContentMessage<LiveLocationContent> = editLiveLocation(chat, messageId, location, businessConnectionId, replyMarkup)
) = editLiveLocation(chat, messageId, location, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.edit(
suspend fun TelegramBot.edit(
message: ContentMessage<LocationContent>,
location: LiveLocation,
businessConnectionId: BusinessConnectionId? = message.chat.id.businessConnectionId,
replyMarkup: InlineKeyboardMarkup? = null
): ContentMessage<LiveLocationContent> = editLiveLocation(message, location, businessConnectionId, replyMarkup)
) = editLiveLocation(message, location, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.edit(
suspend fun TelegramBot.edit(
chatId: ChatIdentifier,
messageId: MessageId,
media: TelegramFreeMedia,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
media: TelegramMedia,
replyMarkup: InlineKeyboardMarkup? = null
): ContentMessage<MediaContent> = editMessageMedia(chatId, messageId, media, businessConnectionId, replyMarkup)
) = editMessageMedia(chatId, messageId, media, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.edit(
suspend fun TelegramBot.edit(
chat: Chat,
messageId: MessageId,
media: TelegramFreeMedia,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
media: TelegramMedia,
replyMarkup: InlineKeyboardMarkup? = null
): ContentMessage<MediaContent> = editMessageMedia(chat, messageId, media, businessConnectionId, replyMarkup)
) = editMessageMedia(chat, messageId, media, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.edit(
suspend fun TelegramBot.edit(
message: ContentMessage<MediaContent>,
media: TelegramFreeMedia,
businessConnectionId: BusinessConnectionId? = message.chat.id.businessConnectionId,
media: TelegramMedia,
replyMarkup: InlineKeyboardMarkup? = null
): ContentMessage<MediaContent> = editMessageMedia(message, media, businessConnectionId, replyMarkup)
) = editMessageMedia(message, media, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.edit(
suspend fun TelegramBot.edit(
chatId: ChatIdentifier,
messageId: MessageId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
replyMarkup: InlineKeyboardMarkup? = null
): ContentMessage<MessageContent> = editMessageReplyMarkup(chatId, messageId, businessConnectionId, replyMarkup)
) = editMessageReplyMarkup(chatId, messageId, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.edit(
suspend fun TelegramBot.edit(
chat: Chat,
messageId: MessageId,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
replyMarkup: InlineKeyboardMarkup? = null
): ContentMessage<MessageContent> = editMessageReplyMarkup(chat, messageId, businessConnectionId, replyMarkup)
) = editMessageReplyMarkup(chat, messageId, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.edit(
message: AccessibleMessage,
businessConnectionId: BusinessConnectionId? = message.chat.id.businessConnectionId,
suspend fun TelegramBot.edit(
message: Message,
replyMarkup: InlineKeyboardMarkup? = null
): ContentMessage<MessageContent> = editMessageReplyMarkup(message, businessConnectionId, replyMarkup)
) = editMessageReplyMarkup(message, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.edit(
suspend fun TelegramBot.edit(
chatId: ChatIdentifier,
messageId: MessageId,
text: String,
parseMode: ParseMode? = null,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
linkPreviewOptions: LinkPreviewOptions? = null,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null
): ContentMessage<TextContent> = editMessageText(chatId, messageId, text, parseMode, businessConnectionId, linkPreviewOptions, replyMarkup)
) = editMessageText(chatId, messageId, text, parseMode, disableWebPagePreview, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.edit(
suspend fun TelegramBot.edit(
chatId: ChatIdentifier,
messageId: MessageId,
entities: TextSourcesList,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
linkPreviewOptions: LinkPreviewOptions? = null,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null
): ContentMessage<TextContent> = editMessageText(chatId, messageId, entities, businessConnectionId, linkPreviewOptions, replyMarkup)
) = editMessageText(chatId, messageId, entities, disableWebPagePreview, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.edit(
suspend fun TelegramBot.edit(
chatId: ChatIdentifier,
messageId: MessageId,
separator: TextSource? = null,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
linkPreviewOptions: LinkPreviewOptions? = null,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
): ContentMessage<TextContent> = edit(chatId, messageId, buildEntities(separator, builderBody), businessConnectionId, linkPreviewOptions, replyMarkup)
) = edit(chatId, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.edit(
suspend fun TelegramBot.edit(
chatId: ChatIdentifier,
messageId: MessageId,
separator: String,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
linkPreviewOptions: LinkPreviewOptions? = null,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
): ContentMessage<TextContent> = edit(chatId, messageId, buildEntities(separator, builderBody), businessConnectionId, linkPreviewOptions, replyMarkup)
) = edit(chatId, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.edit(
suspend fun TelegramBot.edit(
message: ContentMessage<TextContent>,
text: String,
parseMode: ParseMode? = null,
businessConnectionId: BusinessConnectionId? = message.chat.id.businessConnectionId,
linkPreviewOptions: LinkPreviewOptions? = null,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null
): ContentMessage<TextContent> = edit(message.chat.id, message.messageId, text, parseMode, businessConnectionId, linkPreviewOptions, replyMarkup)
) = edit(message.chat.id, message.messageId, text, parseMode, disableWebPagePreview, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.edit(
suspend fun TelegramBot.edit(
message: ContentMessage<TextContent>,
entities: TextSourcesList,
businessConnectionId: BusinessConnectionId? = message.chat.id.businessConnectionId,
linkPreviewOptions: LinkPreviewOptions? = null,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null
): ContentMessage<TextContent> = edit(message.chat.id, message.messageId, entities, businessConnectionId, linkPreviewOptions, replyMarkup)
) = edit(message.chat.id, message.messageId, entities, disableWebPagePreview, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.edit(
suspend fun TelegramBot.edit(
message: ContentMessage<TextContent>,
separator: TextSource? = null,
businessConnectionId: BusinessConnectionId? = message.chat.id.businessConnectionId,
linkPreviewOptions: LinkPreviewOptions? = null,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
): ContentMessage<TextContent> = edit(message, buildEntities(separator, builderBody), businessConnectionId, linkPreviewOptions, replyMarkup)
) = edit(message, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.edit(
suspend fun TelegramBot.edit(
message: ContentMessage<TextContent>,
separator: String,
businessConnectionId: BusinessConnectionId? = message.chat.id.businessConnectionId,
linkPreviewOptions: LinkPreviewOptions? = null,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
): ContentMessage<TextContent> = edit(message, buildEntities(separator, builderBody), businessConnectionId, linkPreviewOptions, replyMarkup)
) = edit(message, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.editMessageText(
suspend fun TelegramBot.editMessageText(
message: ContentMessage<TextContent>,
separator: TextSource? = null,
businessConnectionId: BusinessConnectionId? = message.chat.id.businessConnectionId,
linkPreviewOptions: LinkPreviewOptions? = null,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
): ContentMessage<TextContent> = edit(message, buildEntities(separator, builderBody), businessConnectionId, linkPreviewOptions, replyMarkup)
) = edit(message, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.editMessageText(
suspend fun TelegramBot.editMessageText(
message: ContentMessage<TextContent>,
separator: String,
businessConnectionId: BusinessConnectionId? = message.chat.id.businessConnectionId,
linkPreviewOptions: LinkPreviewOptions? = null,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
): ContentMessage<TextContent> = edit(message, buildEntities(separator, builderBody), businessConnectionId, linkPreviewOptions, replyMarkup)
) = edit(message, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)

View File

@@ -1,112 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.edit
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation
import dev.inmo.tgbotapi.extensions.api.edit.media.editMessageMedia
import dev.inmo.tgbotapi.extensions.api.edit.reply_markup.editMessageReplyMarkup
import dev.inmo.tgbotapi.extensions.api.edit.text.editMessageText
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.location.LiveLocation
import dev.inmo.tgbotapi.types.media.TelegramFreeMedia
import dev.inmo.tgbotapi.types.message.ParseMode
import dev.inmo.tgbotapi.types.message.textsources.TextSource
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
import dev.inmo.tgbotapi.utils.EntitiesBuilderBody
import dev.inmo.tgbotapi.utils.buildEntities
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.edit(
messageId: InlineMessageId,
latitude: Double,
longitude: Double,
horizontalAccuracy: Meters? = null,
heading: Degrees? = null,
proximityAlertRadius: Meters? = null,
replyMarkup: InlineKeyboardMarkup? = null
): Boolean = editLiveLocation(messageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.edit(
messageId: InlineMessageId,
location: LiveLocation,
replyMarkup: InlineKeyboardMarkup? = null
): Boolean = editLiveLocation(
messageId, location, replyMarkup
)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.edit(
messageId: InlineMessageId,
media: TelegramFreeMedia,
replyMarkup: InlineKeyboardMarkup? = null
): Boolean = editMessageMedia(messageId, media, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.edit(
messageId: InlineMessageId,
replyMarkup: InlineKeyboardMarkup? = null
): Boolean = editMessageReplyMarkup(messageId, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.edit(
messageId: InlineMessageId,
text: String,
parseMode: ParseMode? = null,
showCaptionAboveMedia: Boolean = false,
linkPreviewOptions: LinkPreviewOptions? = null,
replyMarkup: InlineKeyboardMarkup? = null
): Boolean = editMessageText(messageId, text, parseMode, showCaptionAboveMedia, linkPreviewOptions, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.edit(
messageId: InlineMessageId,
entities: TextSourcesList,
showCaptionAboveMedia: Boolean = false,
linkPreviewOptions: LinkPreviewOptions? = null,
replyMarkup: InlineKeyboardMarkup? = null
): Boolean = editMessageText(messageId, entities, showCaptionAboveMedia, linkPreviewOptions, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.edit(
messageId: InlineMessageId,
showCaptionAboveMedia: Boolean = false,
separator: TextSource? = null,
linkPreviewOptions: LinkPreviewOptions? = null,
replyMarkup: InlineKeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
): Boolean = edit(messageId, buildEntities(separator, builderBody), showCaptionAboveMedia, linkPreviewOptions, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.edit(
messageId: InlineMessageId,
separator: String,
showCaptionAboveMedia: Boolean = false,
linkPreviewOptions: LinkPreviewOptions? = null,
replyMarkup: InlineKeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
): Boolean = edit(messageId, buildEntities(separator, builderBody), showCaptionAboveMedia, linkPreviewOptions, replyMarkup)

View File

@@ -7,13 +7,11 @@ import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.message.textsources.TextSource
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.businessConnectionId
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.message.ParseMode
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.types.message.content.MediaContent
import dev.inmo.tgbotapi.utils.RiskFeature
@@ -21,89 +19,77 @@ import dev.inmo.tgbotapi.utils.RiskFeature
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.editMessageCaption(
suspend fun TelegramBot.editMessageCaption(
chatId: ChatIdentifier,
messageId: MessageId,
text: String,
parseMode: ParseMode? = null,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
showCaptionAboveMedia: Boolean = false,
replyMarkup: InlineKeyboardMarkup? = null
): ContentMessage<MediaContent> = execute(
EditChatMessageCaption(chatId, messageId, text, parseMode, businessConnectionId, showCaptionAboveMedia, replyMarkup)
) = execute(
EditChatMessageCaption(chatId, messageId, text, parseMode, replyMarkup)
)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.editMessageCaption(
suspend fun TelegramBot.editMessageCaption(
chat: Chat,
messageId: MessageId,
text: String,
parseMode: ParseMode? = null,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
showCaptionAboveMedia: Boolean = false,
replyMarkup: InlineKeyboardMarkup? = null
): ContentMessage<MediaContent> = editMessageCaption(chat.id, messageId, text, parseMode, businessConnectionId, showCaptionAboveMedia, replyMarkup)
) = editMessageCaption(chat.id, messageId, text, parseMode, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun <T> TelegramBot.editMessageCaption(
suspend fun <T> TelegramBot.editMessageCaption(
message: ContentMessage<T>,
text: String,
parseMode: ParseMode? = null,
businessConnectionId: BusinessConnectionId? = message.chat.id.businessConnectionId,
showCaptionAboveMedia: Boolean = false,
replyMarkup: InlineKeyboardMarkup? = null
): ContentMessage<T> where T : TextedWithTextSources, T : MediaContent {
@Suppress("UNCHECKED_CAST")
return editMessageCaption(message.chat.id, message.messageId, text, parseMode, businessConnectionId, showCaptionAboveMedia, replyMarkup) as ContentMessage<T>
return editMessageCaption(message.chat.id, message.messageId, text, parseMode, replyMarkup) as ContentMessage<T>
}
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.editMessageCaption(
suspend fun TelegramBot.editMessageCaption(
chatId: ChatIdentifier,
messageId: MessageId,
entities: TextSourcesList,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
showCaptionAboveMedia: Boolean = false,
replyMarkup: InlineKeyboardMarkup? = null
): ContentMessage<MediaContent> = execute(
EditChatMessageCaption(chatId, messageId, entities, businessConnectionId, showCaptionAboveMedia, replyMarkup)
) = execute(
EditChatMessageCaption(chatId, messageId, entities, replyMarkup)
)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun TelegramBot.editMessageCaption(
suspend fun TelegramBot.editMessageCaption(
chat: Chat,
messageId: MessageId,
entities: TextSourcesList,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
showCaptionAboveMedia: Boolean = false,
entities: List<TextSource>,
replyMarkup: InlineKeyboardMarkup? = null
): ContentMessage<MediaContent> = editMessageCaption(chat.id, messageId, entities, businessConnectionId, showCaptionAboveMedia, replyMarkup)
) = editMessageCaption(chat.id, messageId, entities, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
public suspend fun <T> TelegramBot.editMessageCaption(
suspend fun <T> TelegramBot.editMessageCaption(
message: ContentMessage<T>,
entities: TextSourcesList,
businessConnectionId: BusinessConnectionId? = message.chat.id.businessConnectionId,
showCaptionAboveMedia: Boolean = false,
entities: List<TextSource>,
replyMarkup: InlineKeyboardMarkup? = null
): ContentMessage<T> where T : TextedWithTextSources, T : MediaContent {
@Suppress("UNCHECKED_CAST")
return editMessageCaption(message.chat.id, message.messageId, entities, businessConnectionId, showCaptionAboveMedia, replyMarkup) as ContentMessage<T>
return editMessageCaption(message.chat.id, message.messageId, entities, replyMarkup) as ContentMessage<T>
}
/**
@@ -111,12 +97,10 @@ public suspend fun <T> TelegramBot.editMessageCaption(
* as a builder for that
*/
@RiskFeature("This method is unsafe due to absence of any guaranties about the type of message. In case if message is not media message this method will throw an exception")
public suspend fun <T> TelegramBot.editMessageCaption(
message: AccessibleMessage,
entities: TextSourcesList,
businessConnectionId: BusinessConnectionId? = message.chat.id.businessConnectionId,
showCaptionAboveMedia: Boolean = false,
suspend fun <T> TelegramBot.editMessageCaption(
message: Message,
entities: List<TextSource>,
replyMarkup: InlineKeyboardMarkup? = null
): ContentMessage<MediaContent> where T : TextedWithTextSources, T : MediaContent {
return editMessageCaption(message.chat.id, message.messageId, entities, businessConnectionId, showCaptionAboveMedia, replyMarkup)
return editMessageCaption(message.chat.id, message.messageId, entities, replyMarkup)
}

Some files were not shown because too many files have changed in this diff Show More