mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-17 04:20:13 +00:00
Compare commits
156 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2bd5d53b2a | |||
| 577436843d | |||
| 048aa93044 | |||
| 4e49de0dd7 | |||
| 9dc5a7624d | |||
| 21a15db031 | |||
| a6aa4b8758 | |||
| e85d5df03e | |||
| 6833640c48 | |||
| c22c1bb144 | |||
| 8293d6683c | |||
| 7e6e892c45 | |||
| 43ac09a79b | |||
| ee1f115d77 | |||
| 7d85b6fb88 | |||
| 013944c5c9 | |||
| 55ed3e165b | |||
| 9c0106d229 | |||
| 9cd2a6220c | |||
| 033ec8f2da | |||
| 274afe8efc | |||
| e60630b331 | |||
| f6692a22d1 | |||
| 53257ff131 | |||
| ec70813e49 | |||
| 54589ed17b | |||
| 1d3736c44e | |||
| 8ef7acab2d | |||
| c3fca5c6c4 | |||
| 84d2c88032 | |||
| b7ec2f2b86 | |||
| 97d6d3ad13 | |||
| 3dd428c7d9 | |||
| 688de1053b | |||
| a4fae36b22 | |||
| 909a7fd26a | |||
| 041232e260 | |||
| d4c409107a | |||
| a0db95d929 | |||
| fb34b0bec1 | |||
| d18863b7b3 | |||
| c5c8a743e6 | |||
| 89881a7349 | |||
| 865edf385f | |||
| c85faa73c0 | |||
| 6b3f836096 | |||
| 574ffbc44d | |||
| a0120afb08 | |||
| 0b4b4950c2 | |||
| b3391330a0 | |||
| 518dee46b3 | |||
| c9de4bc79e | |||
| badb138bc1 | |||
| 4b980d3f44 | |||
| b11da02c8b | |||
| 71c0b688e8 | |||
| d61aa8b50e | |||
| be64287c42 | |||
| e7027047cb | |||
| 944d15f326 | |||
| ba2c4cbb30 | |||
| 244a1e5175 | |||
| 9c9a938d94 | |||
| a2a403045b | |||
| 6858af14f8 | |||
| 779009c2a6 | |||
| b22d8a5a25 | |||
| 54e3c43999 | |||
| f8a312acb3 | |||
| a51e68be04 | |||
| 39dab0b970 | |||
| b42a6ca0cf | |||
| a34e67722b | |||
| c0e660c8d3 | |||
| 7cca12930c | |||
| 5da60b4ac2 | |||
| 51dac40e45 | |||
| 51fc33960a | |||
| b89b798eb6 | |||
| a9326bb374 | |||
| edad64c6e3 | |||
| 8c06322586 | |||
| 9684e55c12 | |||
| d7d92cd83f | |||
| 7229d96ce7 | |||
| c32ab031dd | |||
| a8d7104145 | |||
| ff550fafde | |||
| 1dbb0e669d | |||
| 723818f04f | |||
| 0c107bc512 | |||
| 945df1bc5f | |||
| 239d740587 | |||
| 5fdcf252b2 | |||
| a17ae07e50 | |||
| 8bbfa2ee24 | |||
| 4b908f9975 | |||
| 542fcef6da | |||
| 0959c0b0d7 | |||
| 34f606545e | |||
| 0e33b123e9 | |||
| d6bbb0cadc | |||
| 8fd6a09763 | |||
| aa333d7c58 | |||
| fe8c3392fa | |||
| c2c7ac0d1e | |||
| 04e4407b96 | |||
| 60a30f972f | |||
| 9ed1500bee | |||
| 7d0009039f | |||
| e43ad41d2f | |||
| c7d5fdd2e0 | |||
| e7bdc85279 | |||
| dcfa198c8c | |||
| a846d0031c | |||
| 0dd632eb46 | |||
| dfe5595fd3 | |||
| 945dd05cfd | |||
| 09c623c1d7 | |||
| 269a4dd707 | |||
| 2399dc0d0a | |||
| 3a0be49cc5 | |||
| 28898ea2d4 | |||
| 679f282bd2 | |||
| 02fa83c92a | |||
| 69f81785bf | |||
| 86f1e3ea36 | |||
| be4043f3c2 | |||
| b4d0ca507b | |||
| cc433d4091 | |||
| f8ffd5fec3 | |||
| 799eadd7a7 | |||
| bc7cfc0d32 | |||
| 4ca8125637 | |||
| 5475f27a24 | |||
| 6d425cc0f6 | |||
| ff3ef6e957 | |||
| 28eecfa3ef | |||
| 56663d8e73 | |||
| 2fd842746b | |||
| 5e5dc105a5 | |||
| 6cf836708d | |||
| 5e6ff01940 | |||
| 2cfabb1c2a | |||
| de1d6aa70c | |||
| 90d5833021 | |||
| 527b718f55 | |||
| 2eb2d25662 | |||
| 9c25254937 | |||
| 601958a513 | |||
| ab6688bbaa | |||
| 4f2a8e49bc | |||
| 0ce9080efc | |||
| f2701b920f | |||
| a3b29f7db5 | |||
| 43a36072f1 |
5
.github/FUNDING.yml
vendored
Normal file
5
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# These are supported funding model platforms
|
||||||
|
|
||||||
|
patreon: InsanusMokrassar
|
||||||
|
|
||||||
|
custom: ['https://paypal.me/InsanusMokrassar?locale.x=ru_RU']
|
||||||
1
.github/write-good.yml
vendored
Normal file
1
.github/write-good.yml
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
spellchecker: true
|
||||||
10
.travis.yml
Normal file
10
.travis.yml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
language: java
|
||||||
|
install: true
|
||||||
|
|
||||||
|
os: linux
|
||||||
|
dist: trusty
|
||||||
|
jdk: oraclejdk8
|
||||||
|
|
||||||
|
script:
|
||||||
|
- ./gradlew build -s
|
||||||
|
|
||||||
148
CHANGELOG.md
148
CHANGELOG.md
@@ -1,5 +1,121 @@
|
|||||||
# TelegramBotAPI changelog
|
# TelegramBotAPI changelog
|
||||||
|
|
||||||
|
## 0.26.0
|
||||||
|
|
||||||
|
* `Common`:
|
||||||
|
* Versions updates:
|
||||||
|
* `Klock`: `1.10.0` -> `1.10.3`
|
||||||
|
* `TelegramBotAPI`:
|
||||||
|
* Request `SendDice` was added (calling [sendDice](https://core.telegram.org/bots/api#senddice))
|
||||||
|
* Class `Dice` was added (type [dice](https://core.telegram.org/bots/api#dice))
|
||||||
|
* Class `DiceContent` was added (for including it in [message](https://core.telegram.org/bots/api#message) object)
|
||||||
|
* `BotCommand` was added
|
||||||
|
* `GetMyCommands` request was added
|
||||||
|
* `SetMyCommands` request was added
|
||||||
|
* `GetMe` now is object instead of class
|
||||||
|
* `GetMe` was replaced into package `com.github.insanusmokrassar.TelegramBotAPI.requests.bot.GetMe`
|
||||||
|
* `CreateNewStickerSet` renamed to `CreateStaticNewStickerSet`
|
||||||
|
* `CreateNewAnimatedStickerSet` request was added (it handle work with `tgs_sticker`)
|
||||||
|
* `StickerSet#thumb` was added
|
||||||
|
* `AddStickerToSet` renamed to `AddStaticStickerToSet`
|
||||||
|
* `AddAnimatedStickerToSet` request was added
|
||||||
|
* `SetStickerSetThumb` request was added
|
||||||
|
* Most of sticker actions now implements `StandardStickerSetAction` instead of `StickerSetAction`
|
||||||
|
* `getUpdatesLimit` was added to be ensure in get updates limit
|
||||||
|
* `GetUpdates` now will check count of requesting updates and throw exception if it is not in range `1 .. 100`
|
||||||
|
* `GetUpdates#limit` now is not nullable and by default set up to 100
|
||||||
|
* `TelegramBotAPI-extensions-api`:
|
||||||
|
* Extensions `sendDice` was added
|
||||||
|
* Extension `getMyCommands` request was added
|
||||||
|
* Extension `setMyCommands` request was added
|
||||||
|
* Extension `getMe` was replaced into package `com.github.insanusmokrassar.TelegramBotAPI.extensions.api.bot.GetMeKt.getMe`
|
||||||
|
* **All extensions `createNewStickerSet` was renamed to `createNewStaticStickerSet`**
|
||||||
|
* Extensions `createNewAnimatedStickerSet` was added
|
||||||
|
* **All extensions `addStickerToSet` was renamed to `addStaticStickerToSet`**
|
||||||
|
* Extensions `addAnimatedStickerToSet` was added
|
||||||
|
* Extensions `setStickerSetThumb` was added
|
||||||
|
* Extension `startGettingUpdates` now will drop `SentMediaGroupUpdate` in case if it is the last in updates group
|
||||||
|
and size of retrieved updates is equal to 100 (max count of retrieved updates)
|
||||||
|
* Extensions `getUpdates` now will receive only not nullable `limit` parameter
|
||||||
|
|
||||||
|
### 0.26.1
|
||||||
|
|
||||||
|
* `TelegramBotAPI`:
|
||||||
|
* `BotCommand` now will check and throw error in case when command or description lengths is/are incorrect
|
||||||
|
* `StorageFile` now is common for all platforms
|
||||||
|
* JavaScript realization was removed due to its redundancy
|
||||||
|
* JVM realization was replaced with `fun` factory
|
||||||
|
* `StorageFile` now able to accept any factory of `Input`
|
||||||
|
* `StorageFileInfo` was added to avoid strange collisions with throws in `StorageFile`
|
||||||
|
* Fixes issue with `hashTag` for markdown
|
||||||
|
* `InvalidPhotoDimensionsException` was added for cases when `PHOTO_INVALID_DIMENSION` answer received
|
||||||
|
* Other fixes
|
||||||
|
|
||||||
|
## 0.25.0
|
||||||
|
|
||||||
|
* Common:
|
||||||
|
* Versions updates:
|
||||||
|
* `Kotlin`: `1.3.61` -> `1.3.70`
|
||||||
|
* `Kotlin coroutines`: `1.3.3` -> `1.3.5`
|
||||||
|
* `Kotlin serialization`: `0.14.0` -> `0.20.0`
|
||||||
|
* `Ktor`: `1.3.1` -> `1.3.2`
|
||||||
|
* `Klock`: `1.8.7` -> `1.10.0`
|
||||||
|
* `UUID`: `0.0.7` -> `0.1.0`
|
||||||
|
* `TelegramBotAPI`:
|
||||||
|
* `Bot` implementations (as and `Bot` itself) now have not nullable `username`
|
||||||
|
* `File#toInputFile` extension now will throw error when file does not exists
|
||||||
|
* `InlineKeyboardMarkup` will check that `PayInlineKeyboardButton` is the first in case if it is exists in
|
||||||
|
`keyboard`
|
||||||
|
* `makeLinkToMessage` now is not `PreviewFeature`
|
||||||
|
* All deprecations was removed
|
||||||
|
* `RequestException` now extends `io.ktor.utils.io.errors.IOException` instead of `kotlinx.io.IOException`
|
||||||
|
* `Any#toJson` now is NOT `inline`
|
||||||
|
* `FlowsUpdatesFilter` now as marked my annotation `FlowPreview`
|
||||||
|
* `PathedFile#fullUrl` now is not `inline` function
|
||||||
|
* `SimpleRequest#json` now is not `inline` and `internal` function
|
||||||
|
* `FlowsUpdatesFilter` now have two additional flows: `pollAnswerFlow`, `unknownUpdateTypeFlow`
|
||||||
|
* `ExtendedUser` (`typealias`) was added as a `PreviewFeature`
|
||||||
|
|
||||||
|
### 0.25.1
|
||||||
|
|
||||||
|
* Update kotlin: `1.3.70` -> `1.3.71`
|
||||||
|
* Fix of error inside of update utils for media groups
|
||||||
|
|
||||||
|
## 0.24.0
|
||||||
|
|
||||||
|
* `TelegramBotAPI`:
|
||||||
|
* All suspend functions for `RequestsExecutor` was removed (due to replacement into
|
||||||
|
[TelegramBotAPI extensions project](TelegramBotAPI-extensions-api/README.md))
|
||||||
|
* `ForwardFromChannelInfo#channelChat` now is `ChannelChat` instead of `Chat`
|
||||||
|
* `TelegramBotAPI-extensions-api`:
|
||||||
|
* Most part of sending media messages functions was removed and replaced with their `InputFile` args analogs
|
||||||
|
|
||||||
|
### 0.24.1
|
||||||
|
|
||||||
|
* `TelegramBotAPI`:
|
||||||
|
* `UpdateReceiver` was replaced to the package `com.github.insanusmokrassar.TelegramBotAPI.updateshandlers`
|
||||||
|
* All functions inside `com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.UpdatesPolling` are deprecated
|
||||||
|
and will be removed in some soon versions. Their replacement are able inside `TelegramBotAPI-extensions-api`
|
||||||
|
* `UpdatesFilter` is interface for now
|
||||||
|
* Previous `UpdatesFilter` class was renamed to `SimpleUpdatesFilter` and for backward compatibility was added
|
||||||
|
builder function `UpdatesFilter`, which will be removed in near releases
|
||||||
|
* `FlowsUpdatesFilter` now implements `UpdatesFilter`
|
||||||
|
* `BaseSentMessageUpdate` and `BaseEditMessageUpdate` interfaces was added
|
||||||
|
* `EditChannelPostUpdate` now is implementing `BaseEditMessageUpdate` interface
|
||||||
|
* `EditMessageUpdate` now is implementing `BaseEditMessageUpdate` interface
|
||||||
|
* `ChannelPostUpdate` now is implementing `BaseSentMessageUpdate` interface
|
||||||
|
* `MessageUpdate` now is implementing `BaseSentMessageUpdate` interface
|
||||||
|
* `UpdatesPoller` and all its usages, childs and childs usages now are deprecated
|
||||||
|
* `GetUpdates#timeout` type now is `Seconds` (in fact it is `Int` as previously)
|
||||||
|
* `KtorRequestsExecutor` now is using a copy of incoming `HttpClient` object and install `HttpTimeout` feature
|
||||||
|
* `AbstractRequestCallFactory` now setting up a custom delay in case if request is `GetUpdates`
|
||||||
|
* `TelegramBotAPI-extensions-api`:
|
||||||
|
* All functions from `com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.UpdatesPolling` now available
|
||||||
|
in package `com.github.insanusmokrassar.TelegramBotAPI.extensions.api.updates.UpdatesPolling`
|
||||||
|
* Now new method of getting updates available: `startGettingUpdates` with `UpdatesFilter` as incoming first
|
||||||
|
parameter
|
||||||
|
* `startGettingUpdates` with `receiver` and `allowedUpdates` parameters now will handle updates by itself
|
||||||
|
|
||||||
## 0.23.0 TelegramBotAPI 4.6
|
## 0.23.0 TelegramBotAPI 4.6
|
||||||
|
|
||||||
* `Poll` now is sealed class
|
* `Poll` now is sealed class
|
||||||
@@ -35,6 +151,38 @@
|
|||||||
* `GetMe` now return `ExtendedBot` object
|
* `GetMe` now return `ExtendedBot` object
|
||||||
* Now extension `javaLocale` is extension for `CommonUser`
|
* Now extension `javaLocale` is extension for `CommonUser`
|
||||||
|
|
||||||
|
### 0.23.1
|
||||||
|
|
||||||
|
* Versions updates:
|
||||||
|
* Klock `1.8.6` -> `1.8.7`
|
||||||
|
* Ktor `1.3.0` -> `1.3.1`
|
||||||
|
* Now it is possible to get updates by polling with custom executor engine
|
||||||
|
* `CommonMultipartFileRequest` now is internal
|
||||||
|
* Added `LiveLocation` class for more useful tracking live locations
|
||||||
|
* `InvoiceOfPayment` is renamed to `InvoiceContent` and now is `MessageContent` instead of `PaymentInfo`
|
||||||
|
* `SendInvoice` now return `ContentMessage<InvoiceContent>`
|
||||||
|
* `paymentInfo` inside of `CommonMessageImpl` now can be set only to `SuccessfulPaymentInfo`
|
||||||
|
* Added `RecordVideoNoteAction` and `UploadVideoNoteAction` for `record_video_note` and `upload_video_note` actions
|
||||||
|
* For most part of messages was added `RequestsExecutor` extensions for more useful way of usage
|
||||||
|
* `toInputFile` extensions now will return more exact types
|
||||||
|
* Now it is possible to send broadcast channels size for `FlowsUpdatesFilter`
|
||||||
|
|
||||||
|
### 0.23.2
|
||||||
|
|
||||||
|
* Fixes in `InputMedia` - `media` field was not included to serialization
|
||||||
|
|
||||||
|
### 0.23.3 Project separating prepare version
|
||||||
|
|
||||||
|
__API Extensions__
|
||||||
|
|
||||||
|
* Project created
|
||||||
|
* For `SendPhoto` was added new functions for uploading of `MultipartFile`
|
||||||
|
* `deleteWebhook` extension for `RequestsExecutor` was added
|
||||||
|
|
||||||
|
__Telegram Bot API__
|
||||||
|
|
||||||
|
* All `RequestsExecutor` extensions related to Telegram Bots API was replaced into `API Extensions` project
|
||||||
|
|
||||||
## 0.22.0
|
## 0.22.0
|
||||||
|
|
||||||
* **`KtorCallFactory` must return `HttpStatement` instead of `HttpClientCall`**
|
* **`KtorCallFactory` must return `HttpStatement` instead of `HttpClientCall`**
|
||||||
|
|||||||
4
LICENSE
4
LICENSE
@@ -178,7 +178,7 @@
|
|||||||
APPENDIX: How to apply the Apache License to your work.
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following
|
To apply the Apache License to your work, attach the following
|
||||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
replaced with your own identifying information. (Don't include
|
replaced with your own identifying information. (Don't include
|
||||||
the brackets!) The text should be enclosed in the appropriate
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
comment syntax for the file format. We also recommend that a
|
comment syntax for the file format. We also recommend that a
|
||||||
@@ -186,7 +186,7 @@
|
|||||||
same "printed page" as the copyright notice for easier
|
same "printed page" as the copyright notice for easier
|
||||||
identification within third-party archives.
|
identification within third-party archives.
|
||||||
|
|
||||||
Copyright 2018 Insanus
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
203
README.md
203
README.md
@@ -1,192 +1,27 @@
|
|||||||
# TelegramBotAPI
|
# TelegramBotAPI
|
||||||
|
|
||||||
[ ](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI/_latestVersion)
|
| Common info | [](https://github.com/KotlinBy/awesome-kotlin) [](https://t.me/InMoTelegramBotAPI) [](https://travis-ci.com/InsanusMokrassar/TelegramBotAPI) |
|
||||||
[](https://jenkins.insanusmokrassar.com/job/TelegramBotAPI_master__publishing/)
|
| -----------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
|
| TelegramBotAPI status | [](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI/_latestVersion) [](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI) |
|
||||||
|
| TelegramBotAPI Extensions status | [](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI-extensions-api/_latestVersion) [](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI-extensions-api) |
|
||||||
|
|
||||||
## What is it?
|
|
||||||
|
|
||||||
Library for Object-Oriented and type-safe work with Telegram Bot API. Most part of some specific solves or unuseful
|
It is a complex of libraries for working with `TelegramBotAPI` in type-safe and strict way as much as it possible. In
|
||||||
|
the list of this complex currently next projects:
|
||||||
|
|
||||||
|
* [TelegramBotAPI](TelegramBotAPI/README.md) - core of library. In fact it is independent library and can be used alone
|
||||||
|
without any additional library
|
||||||
|
* [TelegramBotAPI Extensions](TelegramBotAPI-extensions-api/README.md) - contains extensions (mostly for
|
||||||
|
`RequestsExecutor`), which allows to use the core library in more pleasant way
|
||||||
|
|
||||||
|
Most part of some specific solves or unuseful
|
||||||
moments are describing by official [Telegram Bot API](https://core.telegram.org/bots/api).
|
moments are describing by official [Telegram Bot API](https://core.telegram.org/bots/api).
|
||||||
|
|
||||||
## Compatibility
|
## Ok, where should I start?
|
||||||
|
|
||||||
This version compatible with [23th of January 2020 update of TelegramBotAPI (version 4.6)](https://core.telegram.org/bots/api#january-23-2020).
|
Firstly, look at the [TelegramBotAPI](TelegramBotAPI/README.md). Here you can find all information about currently
|
||||||
There is Telegram Passport API exception of implemented functionality, which was presented in
|
covered Telegram Bot API and other things. After this you can look at the
|
||||||
[August 2018 update of TelegramBotAPI](https://core.telegram.org/bots/api#august-27-2018) update. It will be implemented
|
[TelegramBotAPI Extensions](TelegramBotAPI-extensions-api/README.md).
|
||||||
as soon as possible. All APIs that are not included are presented
|
|
||||||
[wiki](https://github.com/InsanusMokrassar/TelegramBotAPI/wiki/Not-included-API).
|
|
||||||
|
|
||||||
## How to implement library?
|
Anyway, all libraries are very typical inside of them. For example, any request in TelegramBotAPI look like
|
||||||
|
`requestsExecutor.execute(SomeRequest())`.
|
||||||
Common ways to implement this library are presented here. In some cases it will require additional steps
|
|
||||||
like inserting of additional libraries (like `kotlin stdlib`). In the examples will be used variable
|
|
||||||
`telegrambotapi.version`, which must be set up by developer. Available versions are presented on
|
|
||||||
[bintray](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI), next version is last published:
|
|
||||||
|
|
||||||
[ ](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI/_latestVersion)
|
|
||||||
|
|
||||||
Currently, last versions of library can be available from the Maven repository with errors (for the reason difficult in publishing
|
|
||||||
of signed artifacts in Bintray). You can:
|
|
||||||
|
|
||||||
* Use earlier version (available version you can find
|
|
||||||
[here](https://mvnrepository.com/artifact/com.github.insanusmokrassar/TelegramBotAPI))
|
|
||||||
* Add `jCenter` repository in build config
|
|
||||||
|
|
||||||
### Maven
|
|
||||||
|
|
||||||
Dependency config presented here:
|
|
||||||
|
|
||||||
```xml
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.insanusmokrassar</groupId>
|
|
||||||
<artifactId>TelegramBotAPI</artifactId>
|
|
||||||
<version>${telegrambotapi.version}</version>
|
|
||||||
</dependency>
|
|
||||||
```
|
|
||||||
|
|
||||||
### Gradle
|
|
||||||
|
|
||||||
To use last versions you will need to add one line in repositories block of your `build.gradle`:
|
|
||||||
|
|
||||||
`jcenter()` or `mavenCentral()`
|
|
||||||
|
|
||||||
And add next line to your dependencies block:
|
|
||||||
|
|
||||||
```groovy
|
|
||||||
implementation "com.github.insanusmokrassar:TelegramBotAPI:$telegrambotapi_version"
|
|
||||||
```
|
|
||||||
|
|
||||||
or for old gradle:
|
|
||||||
|
|
||||||
```groovy
|
|
||||||
compile "com.github.insanusmokrassar:TelegramBotAPI:$telegrambotapi_version"
|
|
||||||
```
|
|
||||||
|
|
||||||
## How to work with library?
|
|
||||||
|
|
||||||
For now, this library have no some API god-object. Instead of this, this library has several
|
|
||||||
important objects:
|
|
||||||
|
|
||||||
* [RequestsExecutor](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/RequestsExecutor.kt)
|
|
||||||
* [Requests](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests)
|
|
||||||
* [Types](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types)
|
|
||||||
|
|
||||||
### Types
|
|
||||||
|
|
||||||
Types declare different objects representation. For example, `Chat` for now represented as
|
|
||||||
interface and has several realisations:
|
|
||||||
|
|
||||||
* PrivateChat
|
|
||||||
* GroupChat
|
|
||||||
* SupergroupChat
|
|
||||||
* ChannelChat
|
|
||||||
|
|
||||||
Instead of common garbage with all information as in original [Chat](https://core.telegram.org/bots/api#chat),
|
|
||||||
here it was separated for more obvious difference between chats types and their possible content.
|
|
||||||
|
|
||||||
The same principle work with a lot of others things in this Telegram bot API.
|
|
||||||
|
|
||||||
### Requests
|
|
||||||
|
|
||||||
Requests usually are very simple objects, but some of them are using their own
|
|
||||||
build factories. For example, the next code show, how to get information about bot:
|
|
||||||
|
|
||||||
```kotlin
|
|
||||||
val requestsExecutor: RequestsExecutor = ...
|
|
||||||
requestsExecutor.execute(GetMe())
|
|
||||||
```
|
|
||||||
|
|
||||||
The result type of [GetMe](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetMe.kt)
|
|
||||||
request is
|
|
||||||
[ExtendedBot](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/User.kt).
|
|
||||||
|
|
||||||
### RequestsExecutor
|
|
||||||
|
|
||||||
It is base object which can be used to execute requests in API. For now by default included Ktor
|
|
||||||
realisation of `RequestsExecutor`, but it is possible, that in future it will be extracted in separated
|
|
||||||
project. How to create `RequestsExecutor`:
|
|
||||||
|
|
||||||
```kotlin
|
|
||||||
val requestsExecutor = KtorRequestsExecutor(TOKEN)
|
|
||||||
```
|
|
||||||
|
|
||||||
Here `KtorRequestsExecutor` - default realisation with Ktor. `TOKEN` is just a token of bot which was retrieved
|
|
||||||
according to [instruction](https://core.telegram.org/bots#3-how-do-i-create-a-bot).
|
|
||||||
|
|
||||||
Besides, for correct usage of this, you must implement in your project both one of engines for client and server
|
|
||||||
Ktor libraries:
|
|
||||||
|
|
||||||
```groovy
|
|
||||||
dependencies {
|
|
||||||
// ...
|
|
||||||
implementation "io.ktor:ktor-server-cio:$ktor_version"
|
|
||||||
implementation "io.ktor:ktor-client-okhttp:$ktor_version"
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
It is able to avoid using of `server` dependency in case if will not be used `Webhook`s. In this case,
|
|
||||||
dependencies list will be simplify:
|
|
||||||
|
|
||||||
```groovy
|
|
||||||
dependencies {
|
|
||||||
// ...
|
|
||||||
implementation "io.ktor:ktor-client-okhttp:$ktor_version"
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Here was used `okhttp` realisation of client, but there are several others engines for Ktor. More information
|
|
||||||
available on ktor.io site for [client](https://ktor.io/clients/http-client/engines.html) and [server](https://ktor.io/quickstart/artifacts.html)
|
|
||||||
engines.
|
|
||||||
|
|
||||||
## Getting updates
|
|
||||||
|
|
||||||
In this library currently realised two ways to get updates from telegram:
|
|
||||||
|
|
||||||
* Polling - in this case bot will request updates from time to time (you can set up delay between requests)
|
|
||||||
* Webhook via reverse proxy or something like this
|
|
||||||
|
|
||||||
### Updates filters
|
|
||||||
|
|
||||||
Currently webhook method contains `UpdatesFilter` as necessary argument for getting updates.
|
|
||||||
`UpdatesFilter` will sort updates and throw their into different callbacks. Currently supporting
|
|
||||||
separate getting updates for media groups - they are accumulating with debounce in one second
|
|
||||||
(for being sure that all objects of media group was received).
|
|
||||||
|
|
||||||
Updates polling also support `UpdatesFilter` but it is not required to use it and you can get updates directly
|
|
||||||
in `UpdateReceiver`, which you will provide to `startGettingOfUpdates` method
|
|
||||||
|
|
||||||
### Webhook set up
|
|
||||||
|
|
||||||
If you wish to use webhook method, you will need:
|
|
||||||
|
|
||||||
* White IP - your IP address or host, which available for calling. [TelegramBotAPI](https://core.telegram.org/bots/api#setwebhook)
|
|
||||||
recommend to use some unique address for each bot which you are using
|
|
||||||
* SSL certificate. Usually you can obtain the certificate using your domain provider, [Let'sEncrypt](https://letsencrypt.org/) or [create it](https://core.telegram.org/bots/self-signed)
|
|
||||||
* Nginx or something like this
|
|
||||||
|
|
||||||
Template for Nginx server config you can find in [this gist](https://gist.github.com/InsanusMokrassar/fcc6e09cebd07e46e8f0fdec234750c4#file-nginxssl-conf).
|
|
||||||
|
|
||||||
For webhook you can provide `File` with public part of certificate, `URL` where bot will be available and inner `PORT` which
|
|
||||||
will be used to start receiving of updates. Actually, you can skip passing of `File` when you have something like
|
|
||||||
nginx for proxy forwarding.
|
|
||||||
|
|
||||||
In case of using `nginx` with reverse-proxy config, setting up of Webhook will look like:
|
|
||||||
|
|
||||||
```kotlin
|
|
||||||
requestsExecutor.setWebhook(
|
|
||||||
WEBHOOK_URL,
|
|
||||||
INTERNAL_PORT,
|
|
||||||
filter,
|
|
||||||
ENGINE_FACTORY
|
|
||||||
)
|
|
||||||
```
|
|
||||||
|
|
||||||
Here:
|
|
||||||
|
|
||||||
* `WEBHOOK_URL` - the url which will be used by Telegram system to send updates
|
|
||||||
* `INTERNAL_PORT` - the port which will be used in bot for listening of updates
|
|
||||||
* `filter` - instance of [UpdatesFilter](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/UpdatesFilter.kt),
|
|
||||||
which will be used to filter incoming updates
|
|
||||||
* `ENGINE_FACTORY` - used factory name, for example, `CIO` in case of usage `io.ktor:ktor-server-cio` as server engine
|
|
||||||
|
|||||||
101
TelegramBotAPI-extensions-api/README.md
Normal file
101
TelegramBotAPI-extensions-api/README.md
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
# TelegramBotAPI extensions
|
||||||
|
|
||||||
|
[](https://github.com/KotlinBy/awesome-kotlin)
|
||||||
|
[ ](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI-extensions-api/_latestVersion)
|
||||||
|
[](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI-extensions-api)
|
||||||
|
[](https://jenkins.insanusmokrassar.com/job/TelegramBotAPI-extensions-api_master__publishing/)
|
||||||
|
|
||||||
|
## What is it?
|
||||||
|
|
||||||
|
It is wrapper library for [TelegramBotAPI](../TelegramBotAPI/README.md). Here you can find extensions for
|
||||||
|
`RequestsExecutor`, which are more look like Telegram Bot API requests and in the same time have more obvious signatures
|
||||||
|
to help understand some restrictions in Telegram system.
|
||||||
|
|
||||||
|
## Compatibility
|
||||||
|
|
||||||
|
This library always compatible with original `TelegramBotAPI` library version
|
||||||
|
|
||||||
|
## How to implement library?
|
||||||
|
|
||||||
|
Common ways to implement this library are presented here. In some cases it will require additional steps
|
||||||
|
like inserting of additional libraries (like `kotlin stdlib`). In the examples will be used variable
|
||||||
|
`telegrambotapi-extensions-api.version`, which must be set up by developer. Available versions are presented on
|
||||||
|
[bintray](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI-extensions-api), next version is last published:
|
||||||
|
|
||||||
|
[ ](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI-extensions-api/_latestVersion)
|
||||||
|
|
||||||
|
### Maven
|
||||||
|
|
||||||
|
Dependency config presented here:
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.insanusmokrassar</groupId>
|
||||||
|
<artifactId>TelegramBotAPI-extensions-api</artifactId>
|
||||||
|
<version>${telegrambotapi-extensions-api.version}</version>
|
||||||
|
</dependency>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Gradle
|
||||||
|
|
||||||
|
To use last versions you will need to add one line in repositories block of your `build.gradle`:
|
||||||
|
|
||||||
|
`jcenter()` or `mavenCentral()`
|
||||||
|
|
||||||
|
And add next line to your dependencies block:
|
||||||
|
|
||||||
|
```groovy
|
||||||
|
implementation "com.github.insanusmokrassar:TelegramBotAPI-extensions-api:$telegrambotapi_extensions_api_version"
|
||||||
|
```
|
||||||
|
|
||||||
|
or for old gradle:
|
||||||
|
|
||||||
|
```groovy
|
||||||
|
compile "com.github.insanusmokrassar:TelegramBotAPI-extensions-api:$telegrambotapi_extensions_api_version"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Example of usage and comparison with `TelegramBotAPI`
|
||||||
|
|
||||||
|
Here presented review table for comparison of api from original [TelegramBotAPI](../TelegramBotAPI/README.md#Requests)
|
||||||
|
and extensions-api library:
|
||||||
|
|
||||||
|
In all examples supposed that you have created bot with next approximate lines:
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
val bot: RequestsExecutor = ...
|
||||||
|
```
|
||||||
|
|
||||||
|
| TelegramBotAPI | TelegramBotAPI-extensions-api |
|
||||||
|
|----------------|-------------------------------|
|
||||||
|
| bot.execute(GetMe) | bot.getMe() |
|
||||||
|
| bot.execute(SendTextMessage(someChatId, text)) | bot.sendTextMessage(chat, text) |
|
||||||
|
|
||||||
|
## Updates
|
||||||
|
|
||||||
|
Usually, it is more comfortable to use filter object to get separated types of updates:
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
val filter = FlowsUpdatesFilter(100)
|
||||||
|
```
|
||||||
|
|
||||||
|
In this case you will be able:
|
||||||
|
|
||||||
|
* Separate types of incoming updates (even media groups)
|
||||||
|
* Simplify launch of getting updates:
|
||||||
|
```kotlin
|
||||||
|
bot.startGettingOfUpdates(
|
||||||
|
filter,
|
||||||
|
scope = CoroutineScope(Dispatchers.Default)
|
||||||
|
)
|
||||||
|
```
|
||||||
|
* Use `filter` flows to comfortable filter, map and do other operations with the whole
|
||||||
|
getting updates process:
|
||||||
|
```kotlin
|
||||||
|
filter.messageFlow.mapNotNull {
|
||||||
|
it.data as? ContentMessage<*>
|
||||||
|
}.onEach {
|
||||||
|
println(it)
|
||||||
|
}.launchIn(
|
||||||
|
CoroutineScope(Dispatchers.Default)
|
||||||
|
)
|
||||||
|
```
|
||||||
48
TelegramBotAPI-extensions-api/build.gradle
Normal file
48
TelegramBotAPI-extensions-api/build.gradle
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
jcenter()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
||||||
|
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id "org.jetbrains.kotlin.multiplatform" version "$kotlin_version"
|
||||||
|
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version"
|
||||||
|
}
|
||||||
|
|
||||||
|
project.version = "$library_version"
|
||||||
|
project.group = "$library_group"
|
||||||
|
|
||||||
|
apply from: "publish.gradle"
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
jcenter()
|
||||||
|
mavenCentral()
|
||||||
|
maven { url "https://kotlin.bintray.com/kotlinx" }
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
jvm()
|
||||||
|
js()
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
commonMain {
|
||||||
|
dependencies {
|
||||||
|
implementation kotlin('stdlib')
|
||||||
|
if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") {
|
||||||
|
api "${project.group}:TelegramBotAPI:$library_version"
|
||||||
|
} else {
|
||||||
|
implementation project(":TelegramBotAPI")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
57
TelegramBotAPI-extensions-api/maven.publish.gradle
Normal file
57
TelegramBotAPI-extensions-api/maven.publish.gradle
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
apply plugin: 'maven-publish'
|
||||||
|
|
||||||
|
task javadocsJar(type: Jar) {
|
||||||
|
classifier = 'javadoc'
|
||||||
|
}
|
||||||
|
|
||||||
|
afterEvaluate {
|
||||||
|
project.publishing.publications.all {
|
||||||
|
// rename artifacts
|
||||||
|
groupId "${project.group}"
|
||||||
|
if (it.name.contains('kotlinMultiplatform')) {
|
||||||
|
artifactId = "${project.name}"
|
||||||
|
} else {
|
||||||
|
artifactId = "${project.name}-$name"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications.all {
|
||||||
|
artifact javadocsJar
|
||||||
|
|
||||||
|
pom.withXml {
|
||||||
|
asNode().children().last() + {
|
||||||
|
resolveStrategy = Closure.DELEGATE_FIRST
|
||||||
|
|
||||||
|
description "API extensions which provide work with RequestsExecutor of TelegramBotAPI almost like it is described in original Telegram Bot API reference"
|
||||||
|
name "Telegram Bot API Extensions for API"
|
||||||
|
url "https://insanusmokrassar.github.io/TelegramBotAPI"
|
||||||
|
|
||||||
|
scm {
|
||||||
|
developerConnection "scm:git:[fetch=]https://github.com/insanusmokrassar/TelegramBotAPI.git[push=]https://github.com/insanusmokrassar/TelegramBotAPI.git"
|
||||||
|
url "https://github.com/insanusmokrassar/TelegramBotAPI.git"
|
||||||
|
}
|
||||||
|
|
||||||
|
developers {
|
||||||
|
|
||||||
|
developer {
|
||||||
|
id "InsanusMokrassar"
|
||||||
|
name "Ovsiannikov Aleksei"
|
||||||
|
email "ovsyannikov.alexey95@gmail.com"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
licenses {
|
||||||
|
|
||||||
|
license {
|
||||||
|
name "Apache Software License 2.0"
|
||||||
|
url "https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
1
TelegramBotAPI-extensions-api/mpp_publish_template.json
Normal file
1
TelegramBotAPI-extensions-api/mpp_publish_template.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"bintrayConfig":{"repo":"StandardRepository","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/TelegramBotAPI"},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API Extensions for API","description":"API extensions which provide work with RequestsExecutor of TelegramBotAPI almost like it is described in original Telegram Bot API reference","url":"https://insanusmokrassar.github.io/TelegramBotAPI","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]},"type":"Multiplatform"}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.DeleteMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.deleteMessage(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier
|
||||||
|
) = execute(
|
||||||
|
DeleteMessage(chatId, messageId)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.deleteMessage(
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageIdentifier
|
||||||
|
) = deleteMessage(chat.id, messageId)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.deleteMessage(
|
||||||
|
message: Message
|
||||||
|
) = deleteMessage(message.chat, message.messageId)
|
||||||
|
|
||||||
|
suspend fun Message.delete(
|
||||||
|
requestsExecutor: RequestsExecutor
|
||||||
|
) = requestsExecutor.deleteMessage(this)
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.ForwardMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.forwardMessage(
|
||||||
|
fromChatId: ChatIdentifier,
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
disableNotification: Boolean = false
|
||||||
|
) = execute(
|
||||||
|
ForwardMessage(fromChatId, toChatId, messageId, disableNotification)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.forwardMessage(
|
||||||
|
fromChat: Chat,
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
disableNotification: Boolean = false
|
||||||
|
) = forwardMessage(fromChat.id, toChatId, messageId, disableNotification)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.forwardMessage(
|
||||||
|
fromChatId: ChatIdentifier,
|
||||||
|
toChat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
disableNotification: Boolean = false
|
||||||
|
) = forwardMessage(fromChatId, toChat.id, messageId, disableNotification)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.forwardMessage(
|
||||||
|
fromChat: Chat,
|
||||||
|
toChat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
disableNotification: Boolean = false
|
||||||
|
) = forwardMessage(fromChat.id, toChat.id, messageId, disableNotification)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.forwardMessage(
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
message: Message,
|
||||||
|
disableNotification: Boolean = false
|
||||||
|
) = forwardMessage(message.chat, toChatId, message.messageId, disableNotification)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.forwardMessage(
|
||||||
|
toChat: Chat,
|
||||||
|
message: Message,
|
||||||
|
disableNotification: Boolean = false
|
||||||
|
) = forwardMessage(message.chat, toChat, message.messageId, disableNotification)
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.extensions.api.bot.getMe
|
||||||
|
|
||||||
|
@Deprecated(
|
||||||
|
"Replaced",
|
||||||
|
ReplaceWith("getMe", "com.github.insanusmokrassar.TelegramBotAPI.extensions.api.bot.GetMeKt.getMe")
|
||||||
|
)
|
||||||
|
suspend fun RequestsExecutor.getMe() = getMe()
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.GetUpdates
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getUpdates(
|
||||||
|
offset: UpdateIdentifier? = null,
|
||||||
|
limit: Int = getUpdatesLimit.last,
|
||||||
|
timeout: Seconds? = null,
|
||||||
|
allowed_updates: List<String>? = ALL_UPDATES_LIST
|
||||||
|
) = execute(
|
||||||
|
GetUpdates(
|
||||||
|
offset, limit, timeout, allowed_updates
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getUpdates(
|
||||||
|
lastUpdate: Update,
|
||||||
|
limit: Int = getUpdatesLimit.last,
|
||||||
|
timeout: Seconds? = null,
|
||||||
|
allowed_updates: List<String>? = ALL_UPDATES_LIST
|
||||||
|
) = getUpdates(
|
||||||
|
lastUpdate.updateId + 1, limit, timeout, allowed_updates
|
||||||
|
)
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.InternalUtils
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MediaGroupIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaGroupMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.*
|
||||||
|
|
||||||
|
internal fun Update.lastUpdateIdentifier(): UpdateIdentifier {
|
||||||
|
return if (this is SentMediaGroupUpdate) {
|
||||||
|
origins.last().updateId
|
||||||
|
} else {
|
||||||
|
updateId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun List<Update>.lastUpdateIdentifier(): UpdateIdentifier? {
|
||||||
|
return maxBy { it.updateId } ?.lastUpdateIdentifier()
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun List<Update>.convertWithMediaGroupUpdates(): List<Update> {
|
||||||
|
val resultUpdates = mutableListOf<Update>()
|
||||||
|
val mediaGroups = mutableMapOf<MediaGroupIdentifier, MutableList<BaseSentMessageUpdate>>()
|
||||||
|
for (update in this) {
|
||||||
|
val data = (update.data as? MediaGroupMessage)
|
||||||
|
if (data == null) {
|
||||||
|
resultUpdates.add(update)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
when (update) {
|
||||||
|
is BaseEditMessageUpdate -> resultUpdates.add(
|
||||||
|
update.toEditMediaGroupUpdate()
|
||||||
|
)
|
||||||
|
is BaseSentMessageUpdate -> {
|
||||||
|
mediaGroups.getOrPut(data.mediaGroupId) {
|
||||||
|
mutableListOf()
|
||||||
|
}.add(update)
|
||||||
|
}
|
||||||
|
else -> resultUpdates.add(update)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mediaGroups.values.map {
|
||||||
|
it.toSentMediaGroupUpdate() ?.let { mediaGroupUpdate ->
|
||||||
|
resultUpdates.add(mediaGroupUpdate)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resultUpdates.sortBy { it.updateId }
|
||||||
|
return resultUpdates
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun List<BaseSentMessageUpdate>.toSentMediaGroupUpdate(): SentMediaGroupUpdate? = (this as? SentMediaGroupUpdate) ?: let {
|
||||||
|
if (isEmpty()) {
|
||||||
|
return@let null
|
||||||
|
}
|
||||||
|
val resultList = sortedBy { it.updateId }
|
||||||
|
when (first()) {
|
||||||
|
is MessageUpdate -> MessageMediaGroupUpdate(resultList)
|
||||||
|
is ChannelPostUpdate -> ChannelPostMediaGroupUpdate(resultList)
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun BaseEditMessageUpdate.toEditMediaGroupUpdate(): EditMediaGroupUpdate = (this as? EditMediaGroupUpdate) ?: let {
|
||||||
|
when (this) {
|
||||||
|
is EditMessageUpdate -> EditMessageMediaGroupUpdate(this)
|
||||||
|
is EditChannelPostUpdate -> EditChannelPostMediaGroupUpdate(this)
|
||||||
|
else -> error("Unsupported type of ${BaseEditMessageUpdate::class.simpleName}")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.LiveLocation.editLiveLocation
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.LiveLocation.stopLiveLocation
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendLocation
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.LocationContent
|
||||||
|
import com.soywiz.klock.DateTime
|
||||||
|
import com.soywiz.klock.TimeSpan
|
||||||
|
import io.ktor.utils.io.core.Closeable
|
||||||
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlin.math.ceil
|
||||||
|
|
||||||
|
private val livePeriodDelayMillis = (livePeriodLimit.last - 60L) * 1000L
|
||||||
|
class LiveLocation internal constructor(
|
||||||
|
private val requestsExecutor: RequestsExecutor,
|
||||||
|
scope: CoroutineScope,
|
||||||
|
autoCloseTimeDelay: Double,
|
||||||
|
initMessage: ContentMessage<LocationContent>
|
||||||
|
) : Closeable {
|
||||||
|
private val doWhenClose = {
|
||||||
|
scope.launch {
|
||||||
|
requestsExecutor.stopLiveLocation(message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private val autoCloseTime = DateTime.now() + TimeSpan(autoCloseTimeDelay)
|
||||||
|
val leftUntilCloseMillis: TimeSpan
|
||||||
|
get() = autoCloseTime - DateTime.now()
|
||||||
|
|
||||||
|
var isClosed: Boolean = false
|
||||||
|
private set
|
||||||
|
get() = field || leftUntilCloseMillis.millisecondsLong < 0L
|
||||||
|
|
||||||
|
private var message: ContentMessage<LocationContent> = initMessage
|
||||||
|
val lastLocation: Location
|
||||||
|
get() = message.content.location
|
||||||
|
|
||||||
|
suspend fun updateLocation(
|
||||||
|
location: Location,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
): Location {
|
||||||
|
if (!isClosed) {
|
||||||
|
message = requestsExecutor.editLiveLocation(
|
||||||
|
message,
|
||||||
|
location,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
return lastLocation
|
||||||
|
} else {
|
||||||
|
error("LiveLocation is closed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun close() {
|
||||||
|
if (isClosed) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
isClosed = true
|
||||||
|
doWhenClose()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.startLiveLocation(
|
||||||
|
scope: CoroutineScope,
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
latitude: Double,
|
||||||
|
longitude: Double,
|
||||||
|
liveTimeMillis: Long = livePeriodDelayMillis,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
): LiveLocation {
|
||||||
|
val liveTimeAsDouble = liveTimeMillis.toDouble()
|
||||||
|
val locationMessage = execute(
|
||||||
|
SendLocation(
|
||||||
|
chatId,
|
||||||
|
latitude,
|
||||||
|
longitude,
|
||||||
|
ceil(liveTimeAsDouble / 1000).toLong(),
|
||||||
|
disableNotification,
|
||||||
|
replyToMessageId,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
return LiveLocation(
|
||||||
|
this,
|
||||||
|
scope,
|
||||||
|
liveTimeAsDouble,
|
||||||
|
locationMessage
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.startLiveLocation(
|
||||||
|
scope: CoroutineScope,
|
||||||
|
chat: Chat,
|
||||||
|
latitude: Double,
|
||||||
|
longitude: Double,
|
||||||
|
liveTimeMillis: Long = livePeriodDelayMillis,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
): LiveLocation = startLiveLocation(
|
||||||
|
scope, chat.id, latitude, longitude, liveTimeMillis, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.startLiveLocation(
|
||||||
|
scope: CoroutineScope,
|
||||||
|
chatId: ChatId,
|
||||||
|
location: Location,
|
||||||
|
liveTimeMillis: Long = livePeriodDelayMillis,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
): LiveLocation = startLiveLocation(
|
||||||
|
scope, chatId, location.latitude, location.longitude, liveTimeMillis, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.startLiveLocation(
|
||||||
|
scope: CoroutineScope,
|
||||||
|
chat: Chat,
|
||||||
|
location: Location,
|
||||||
|
liveTimeMillis: Long = livePeriodDelayMillis,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
): LiveLocation = startLiveLocation(
|
||||||
|
scope, chat.id, location.latitude, location.longitude, liveTimeMillis, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.StopPoll
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.stopPoll(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
StopPoll(chatId, messageId, replyMarkup)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.stopPoll(
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = stopPoll(chat.id, messageId, replyMarkup)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.stopPoll(
|
||||||
|
chatId: ChatId,
|
||||||
|
message: Message,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = stopPoll(chatId, message.messageId, replyMarkup)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.stopPoll(
|
||||||
|
chat: Chat,
|
||||||
|
message: Message,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = stopPoll(chat.id, message.messageId, replyMarkup)
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.answers
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.AnswerCallbackQuery
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.CallbackQuery.CallbackQuery
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.CallbackQueryIdentifier
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.answerCallbackQuery(
|
||||||
|
callbackQueryId: CallbackQueryIdentifier,
|
||||||
|
text: String? = null,
|
||||||
|
showAlert: Boolean? = null,
|
||||||
|
url: String? = null,
|
||||||
|
cachedTimeSeconds: Int? = null
|
||||||
|
) = execute(AnswerCallbackQuery(callbackQueryId, text, showAlert, url, cachedTimeSeconds))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.answerCallbackQuery(
|
||||||
|
callbackQuery: CallbackQuery,
|
||||||
|
text: String? = null,
|
||||||
|
showAlert: Boolean? = null,
|
||||||
|
url: String? = null,
|
||||||
|
cachedTimeSeconds: Int? = null
|
||||||
|
) = answerCallbackQuery(callbackQuery.id, text, showAlert, url, cachedTimeSeconds)
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.answers
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.AnswerInlineQuery
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.abstracts.InlineQuery
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueryIdentifier
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.answerInlineQuery(
|
||||||
|
inlineQueryID: InlineQueryIdentifier,
|
||||||
|
results: List<InlineQueryResult> = emptyList(),
|
||||||
|
cachedTime: Int? = null,
|
||||||
|
isPersonal: Boolean? = null,
|
||||||
|
nextOffset: String? = null,
|
||||||
|
switchPmText: String? = null,
|
||||||
|
switchPmParameter: String? = null
|
||||||
|
) = execute(
|
||||||
|
AnswerInlineQuery(inlineQueryID, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.answerInlineQuery(
|
||||||
|
inlineQuery: InlineQuery,
|
||||||
|
results: List<InlineQueryResult> = emptyList(),
|
||||||
|
cachedTime: Int? = null,
|
||||||
|
isPersonal: Boolean? = null,
|
||||||
|
nextOffset: String? = null,
|
||||||
|
switchPmText: String? = null,
|
||||||
|
switchPmParameter: String? = null
|
||||||
|
) = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.answers.payments
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.AnswerPreCheckoutQueryError
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.AnswerPreCheckoutQueryOk
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.PreCheckoutQueryId
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.PreCheckoutQuery
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.answerPreCheckoutQueryOk(
|
||||||
|
id: PreCheckoutQueryId
|
||||||
|
) = execute(AnswerPreCheckoutQueryOk(id))
|
||||||
|
suspend fun RequestsExecutor.answerPreCheckoutQueryOk(
|
||||||
|
preCheckoutQuery: PreCheckoutQuery
|
||||||
|
) = answerPreCheckoutQueryOk(preCheckoutQuery.id)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.answerPreCheckoutQueryError(
|
||||||
|
id: PreCheckoutQueryId,
|
||||||
|
error: String
|
||||||
|
) = execute(AnswerPreCheckoutQueryError(id, error))
|
||||||
|
suspend fun RequestsExecutor.answerPreCheckoutQueryError(
|
||||||
|
preCheckoutQuery: PreCheckoutQuery,
|
||||||
|
error: String
|
||||||
|
) = answerPreCheckoutQueryError(preCheckoutQuery.id, error)
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.answers.payments
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.AnswerShippingQueryError
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.AnswerShippingQueryOk
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ShippingQueryIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.ShippingOption
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.ShippingQuery
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.answerShippingQueryOk(
|
||||||
|
id: ShippingQueryIdentifier,
|
||||||
|
shippingOptions: List<ShippingOption>
|
||||||
|
) = execute(AnswerShippingQueryOk(id, shippingOptions))
|
||||||
|
suspend fun RequestsExecutor.answerShippingQueryOk(
|
||||||
|
shippingQuery: ShippingQuery,
|
||||||
|
shippingOptions: List<ShippingOption>
|
||||||
|
) = answerShippingQueryOk(shippingQuery.id, shippingOptions)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.answerShippingQueryError(
|
||||||
|
id: ShippingQueryIdentifier,
|
||||||
|
error: String
|
||||||
|
) = execute(AnswerShippingQueryError(id, error))
|
||||||
|
suspend fun RequestsExecutor.answerShippingQueryError(
|
||||||
|
shippingQuery: ShippingQuery,
|
||||||
|
error: String
|
||||||
|
) = answerShippingQueryError(shippingQuery.id, error)
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.bot
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.bot.GetMe
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getMe() = execute(GetMe)
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.bot
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.bot.GetMyCommands
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getMyCommands() = execute(GetMyCommands)
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.bot
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.bot.SetMyCommands
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.BotCommand
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setMyCommands(
|
||||||
|
commands: List<BotCommand>
|
||||||
|
) = execute(SetMyCommands(commands))
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.ExportChatInviteLink
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.exportChatInviteLink(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = execute(ExportChatInviteLink(chatId))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.exportChatInviteLink(
|
||||||
|
chat: PublicChat
|
||||||
|
) = exportChatInviteLink(chat.id)
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.LeaveChat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.leaveChat(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = execute(LeaveChat(chatId))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.leaveChat(
|
||||||
|
chat: PublicChat
|
||||||
|
) = leaveChat(chat.id)
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.get
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.get.GetChat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getChat(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = execute(GetChat(chatId))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getChat(
|
||||||
|
chat: Chat
|
||||||
|
) = getChat(chat.id)
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.get
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.get.GetChatAdministrators
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getChatAdministrators(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = execute(GetChatAdministrators(chatId))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getChatAdministrators(
|
||||||
|
chat: PublicChat
|
||||||
|
) = getChatAdministrators(chat.id)
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.get
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.get.GetChatMembersCount
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getChatMembersCount(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = execute(GetChatMembersCount(chatId))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getChatMembersCount(
|
||||||
|
chat: PublicChat
|
||||||
|
) = getChatMembersCount(chat.id)
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.members
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members.GetChatMember
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getChatMember(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
userId: UserId
|
||||||
|
) = execute(GetChatMember(chatId, userId))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getChatMember(
|
||||||
|
chat: PublicChat,
|
||||||
|
userId: UserId
|
||||||
|
) = getChatMember(chat.id, userId)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getChatMember(
|
||||||
|
chatId: ChatId,
|
||||||
|
user: User
|
||||||
|
) = getChatMember(chatId, user.id)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getChatMember(
|
||||||
|
chat: PublicChat,
|
||||||
|
user: User
|
||||||
|
) = getChatMember(chat.id, user.id)
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.members
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members.KickChatMember
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.kickChatMember(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
userId: UserId,
|
||||||
|
untilDate: TelegramDate? = null
|
||||||
|
) = execute(KickChatMember(chatId, userId, untilDate))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.kickChatMember(
|
||||||
|
chat: PublicChat,
|
||||||
|
userId: UserId,
|
||||||
|
untilDate: TelegramDate? = null
|
||||||
|
) = kickChatMember(chat.id, userId, untilDate)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.kickChatMember(
|
||||||
|
chatId: ChatId,
|
||||||
|
user: User,
|
||||||
|
untilDate: TelegramDate? = null
|
||||||
|
) = kickChatMember(chatId, user.id, untilDate)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.kickChatMember(
|
||||||
|
chat: PublicChat,
|
||||||
|
user: User,
|
||||||
|
untilDate: TelegramDate? = null
|
||||||
|
) = kickChatMember(chat.id, user.id, untilDate)
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.members
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members.PromoteChatMember
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.promoteChatMember(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
userId: UserId,
|
||||||
|
untilDate: TelegramDate? = null,
|
||||||
|
canChangeInfo: Boolean? = null,
|
||||||
|
canPostMessages: Boolean? = null,
|
||||||
|
canEditMessages: Boolean? = null,
|
||||||
|
canDeleteMessages: Boolean? = null,
|
||||||
|
canInviteUsers: Boolean? = null,
|
||||||
|
canRestrictMembers: Boolean? = null,
|
||||||
|
canPinMessages: Boolean? = null,
|
||||||
|
canPromoteMembers: Boolean? = null
|
||||||
|
) = execute(
|
||||||
|
PromoteChatMember(
|
||||||
|
chatId,
|
||||||
|
userId,
|
||||||
|
untilDate,
|
||||||
|
canChangeInfo,
|
||||||
|
canPostMessages,
|
||||||
|
canEditMessages,
|
||||||
|
canDeleteMessages,
|
||||||
|
canInviteUsers,
|
||||||
|
canRestrictMembers,
|
||||||
|
canPinMessages,
|
||||||
|
canPromoteMembers
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.promoteChatMember(
|
||||||
|
chat: PublicChat,
|
||||||
|
userId: UserId,
|
||||||
|
untilDate: TelegramDate? = null,
|
||||||
|
canChangeInfo: Boolean? = null,
|
||||||
|
canPostMessages: Boolean? = null,
|
||||||
|
canEditMessages: Boolean? = null,
|
||||||
|
canDeleteMessages: Boolean? = null,
|
||||||
|
canInviteUsers: Boolean? = null,
|
||||||
|
canRestrictMembers: Boolean? = null,
|
||||||
|
canPinMessages: Boolean? = null,
|
||||||
|
canPromoteMembers: Boolean? = null
|
||||||
|
) = promoteChatMember(
|
||||||
|
chat.id,
|
||||||
|
userId,
|
||||||
|
untilDate,
|
||||||
|
canChangeInfo,
|
||||||
|
canPostMessages,
|
||||||
|
canEditMessages,
|
||||||
|
canDeleteMessages,
|
||||||
|
canInviteUsers,
|
||||||
|
canRestrictMembers,
|
||||||
|
canPinMessages,
|
||||||
|
canPromoteMembers
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.promoteChatMember(
|
||||||
|
chatId: ChatId,
|
||||||
|
user: User,
|
||||||
|
untilDate: TelegramDate? = null,
|
||||||
|
canChangeInfo: Boolean? = null,
|
||||||
|
canPostMessages: Boolean? = null,
|
||||||
|
canEditMessages: Boolean? = null,
|
||||||
|
canDeleteMessages: Boolean? = null,
|
||||||
|
canInviteUsers: Boolean? = null,
|
||||||
|
canRestrictMembers: Boolean? = null,
|
||||||
|
canPinMessages: Boolean? = null,
|
||||||
|
canPromoteMembers: Boolean? = null
|
||||||
|
) = promoteChatMember(
|
||||||
|
chatId,
|
||||||
|
user.id,
|
||||||
|
untilDate,
|
||||||
|
canChangeInfo,
|
||||||
|
canPostMessages,
|
||||||
|
canEditMessages,
|
||||||
|
canDeleteMessages,
|
||||||
|
canInviteUsers,
|
||||||
|
canRestrictMembers,
|
||||||
|
canPinMessages,
|
||||||
|
canPromoteMembers
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.promoteChatMember(
|
||||||
|
chat: PublicChat,
|
||||||
|
user: User,
|
||||||
|
untilDate: TelegramDate? = null,
|
||||||
|
canChangeInfo: Boolean? = null,
|
||||||
|
canPostMessages: Boolean? = null,
|
||||||
|
canEditMessages: Boolean? = null,
|
||||||
|
canDeleteMessages: Boolean? = null,
|
||||||
|
canInviteUsers: Boolean? = null,
|
||||||
|
canRestrictMembers: Boolean? = null,
|
||||||
|
canPinMessages: Boolean? = null,
|
||||||
|
canPromoteMembers: Boolean? = null
|
||||||
|
) = promoteChatMember(
|
||||||
|
chat.id,
|
||||||
|
user.id,
|
||||||
|
untilDate,
|
||||||
|
canChangeInfo,
|
||||||
|
canPostMessages,
|
||||||
|
canEditMessages,
|
||||||
|
canDeleteMessages,
|
||||||
|
canInviteUsers,
|
||||||
|
canRestrictMembers,
|
||||||
|
canPinMessages,
|
||||||
|
canPromoteMembers
|
||||||
|
)
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.members
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members.RestrictChatMember
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.restrictChatMember(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
userId: UserId,
|
||||||
|
untilDate: TelegramDate? = null,
|
||||||
|
permissions: ChatPermissions = ChatPermissions()
|
||||||
|
) = execute(RestrictChatMember(chatId, userId, untilDate, permissions))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.restrictChatMember(
|
||||||
|
chat: PublicChat,
|
||||||
|
userId: UserId,
|
||||||
|
untilDate: TelegramDate? = null,
|
||||||
|
permissions: ChatPermissions = ChatPermissions()
|
||||||
|
) = restrictChatMember(chat.id, userId, untilDate, permissions)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.restrictChatMember(
|
||||||
|
chatId: ChatId,
|
||||||
|
user: User,
|
||||||
|
untilDate: TelegramDate? = null,
|
||||||
|
permissions: ChatPermissions = ChatPermissions()
|
||||||
|
) = restrictChatMember(chatId, user.id, untilDate, permissions)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.restrictChatMember(
|
||||||
|
chat: PublicChat,
|
||||||
|
user: User,
|
||||||
|
untilDate: TelegramDate? = null,
|
||||||
|
permissions: ChatPermissions = ChatPermissions()
|
||||||
|
) = restrictChatMember(chat.id, user.id, untilDate, permissions)
|
||||||
|
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.members
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members.SetChatAdministratorCustomTitle
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setChatAdministratorCustomTitle(
|
||||||
|
chatId: ChatId,
|
||||||
|
userId: UserId,
|
||||||
|
customTitle: String
|
||||||
|
) = execute(SetChatAdministratorCustomTitle(chatId, userId, customTitle))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setChatAdministratorCustomTitle(
|
||||||
|
chat: PublicChat,
|
||||||
|
userId: UserId,
|
||||||
|
customTitle: String
|
||||||
|
) = setChatAdministratorCustomTitle(chat.id, userId, customTitle)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setChatAdministratorCustomTitle(
|
||||||
|
chatId: ChatId,
|
||||||
|
user: User,
|
||||||
|
customTitle: String
|
||||||
|
) = setChatAdministratorCustomTitle(chatId, user.id, customTitle)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setChatAdministratorCustomTitle(
|
||||||
|
chat: PublicChat,
|
||||||
|
user: User,
|
||||||
|
customTitle: String
|
||||||
|
) = setChatAdministratorCustomTitle(chat.id, user.id, customTitle)
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.members
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.members.UnbanChatMember
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.unbanChatMember(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
userId: UserId
|
||||||
|
) = execute(UnbanChatMember(chatId, userId))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.unbanChatMember(
|
||||||
|
chat: PublicChat,
|
||||||
|
userId: UserId
|
||||||
|
) = unbanChatMember(chat.id, userId)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.unbanChatMember(
|
||||||
|
chatId: ChatId,
|
||||||
|
user: User
|
||||||
|
) = unbanChatMember(chatId, user.id)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.unbanChatMember(
|
||||||
|
chat: PublicChat,
|
||||||
|
user: User
|
||||||
|
) = unbanChatMember(chat.id, user.id)
|
||||||
|
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.modify
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify.DeleteChatPhoto
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.deleteChatPhoto(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = execute(DeleteChatPhoto(chatId))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.deleteChatPhoto(
|
||||||
|
chat: PublicChat
|
||||||
|
) = deleteChatPhoto(chat.id)
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.modify
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify.PinChatMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.pinChatMessage(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
disableNotification: Boolean = false
|
||||||
|
) = execute(PinChatMessage(chatId, messageId, disableNotification))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.pinChatMessage(
|
||||||
|
chat: PublicChat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
disableNotification: Boolean = false
|
||||||
|
) = pinChatMessage(chat.id, messageId, disableNotification)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.pinChatMessage(
|
||||||
|
message: Message,
|
||||||
|
disableNotification: Boolean = false
|
||||||
|
) = if (message.chat is PublicChat) {
|
||||||
|
pinChatMessage(message.chat.id, message.messageId, disableNotification)
|
||||||
|
} else {
|
||||||
|
error("It is possible to pin messages only in non one-to-one chats")
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.modify
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify.SetChatDescription
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setChatDescription(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
description: String
|
||||||
|
) = execute(SetChatDescription(chatId, description))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setChatDescription(
|
||||||
|
chat: PublicChat,
|
||||||
|
description: String
|
||||||
|
) = setChatDescription(chat.id, description)
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.modify
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify.SetChatPermissions
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.ChatPermissions
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setDefaultChatMembersPermissions(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
permissions: ChatPermissions
|
||||||
|
) = execute(SetChatPermissions(chatId, permissions))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setDefaultChatMembersPermissions(
|
||||||
|
chat: PublicChat,
|
||||||
|
permissions: ChatPermissions
|
||||||
|
) = setDefaultChatMembersPermissions(chat.id, permissions)
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.modify
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify.SetChatPhoto
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setChatPhoto(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
photo: MultipartFile
|
||||||
|
) = execute(SetChatPhoto(chatId, photo))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setChatPhoto(
|
||||||
|
chat: PublicChat,
|
||||||
|
photo: MultipartFile
|
||||||
|
) = setChatPhoto(chat.id, photo)
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.modify
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify.SetChatTitle
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setChatTitle(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
title: String
|
||||||
|
) = execute(SetChatTitle(chatId, title))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setChatTitle(
|
||||||
|
chat: PublicChat,
|
||||||
|
title: String
|
||||||
|
) = setChatTitle(chat.id, title)
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.modify
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify.UnpinChatMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.unpinChatMessage(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = execute(UnpinChatMessage(chatId))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.unpinChatMessage(
|
||||||
|
chat: PublicChat
|
||||||
|
) = unpinChatMessage(chat.id)
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.stickers
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.stickers.DeleteChatStickerSet
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.SupergroupChat
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.deleteChatStickerSet(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = execute(DeleteChatStickerSet(chatId))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.deleteChatStickerSet(
|
||||||
|
chat: SupergroupChat
|
||||||
|
) = deleteChatStickerSet(chat.id)
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.stickers
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.chat.stickers.SetChatStickerSet
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.StickerSetName
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.SupergroupChat
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setChatStickerSet(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
stickerSetName: StickerSetName
|
||||||
|
) = execute(SetChatStickerSet(chatId, stickerSetName))
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setChatStickerSet(
|
||||||
|
chat: SupergroupChat,
|
||||||
|
stickerSetName: StickerSetName
|
||||||
|
) = setChatStickerSet(chat.id, stickerSetName)
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.LiveLocation
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation.EditChatMessageLiveLocation
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.LocationContent
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editLiveLocation(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
latitude: Double,
|
||||||
|
longitude: Double,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
EditChatMessageLiveLocation(
|
||||||
|
chatId, messageId, latitude, longitude, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editLiveLocation(
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
latitude: Double,
|
||||||
|
longitude: Double,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editLiveLocation(chat.id, messageId, latitude, longitude, replyMarkup)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editLiveLocation(
|
||||||
|
message: ContentMessage<LocationContent>,
|
||||||
|
latitude: Double,
|
||||||
|
longitude: Double,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editLiveLocation(message.chat, message.messageId, latitude, longitude, replyMarkup)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editLiveLocation(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
location: Location,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
EditChatMessageLiveLocation(
|
||||||
|
chatId, messageId, location.latitude, location.longitude, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editLiveLocation(
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
location: Location,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editLiveLocation(chat.id, messageId, location.latitude, location.longitude, replyMarkup)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editLiveLocation(
|
||||||
|
message: ContentMessage<LocationContent>,
|
||||||
|
location: Location,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editLiveLocation(message.chat, message.messageId, location.latitude, location.longitude, replyMarkup)
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.LiveLocation
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation.EditInlineMessageLiveLocation
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineMessageIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.Location
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editLiveLocation(
|
||||||
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
|
latitude: Double,
|
||||||
|
longitude: Double,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
EditInlineMessageLiveLocation(
|
||||||
|
inlineMessageId, latitude, longitude, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
suspend fun RequestsExecutor.editLiveLocation(
|
||||||
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
|
location: Location,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editLiveLocation(inlineMessageId, location.latitude, location.longitude, replyMarkup)
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.LiveLocation
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation.StopChatMessageLiveLocation
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.LocationContent
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.stopLiveLocation(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
StopChatMessageLiveLocation(
|
||||||
|
chatId, messageId, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.stopLiveLocation(
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = stopLiveLocation(chat.id, messageId, replyMarkup)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.stopLiveLocation(
|
||||||
|
message: ContentMessage<LocationContent>,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = stopLiveLocation(message.chat, message.messageId, replyMarkup)
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.LiveLocation
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation.StopInlineMessageLiveLocation
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineMessageIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.stopLiveLocation(
|
||||||
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
StopInlineMessageLiveLocation(
|
||||||
|
inlineMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.ReplyMarkup
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.ReplyMarkup.EditChatMessageReplyMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editMessageReplyMarkup(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
EditChatMessageReplyMarkup(chatId, messageId, replyMarkup)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editMessageReplyMarkup(
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editMessageReplyMarkup(chat.id, messageId, replyMarkup)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editMessageReplyMarkup(
|
||||||
|
message: Message,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editMessageReplyMarkup(message.chat.id, message.messageId, replyMarkup)
|
||||||
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.ReplyMarkup
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.ReplyMarkup.EditInlineMessageReplyMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineMessageIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editMessageReplyMarkup(
|
||||||
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(EditInlineMessageReplyMarkup(inlineMessageId, replyMarkup))
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.caption
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CaptionedInput
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.caption.EditChatMessageCaption
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editMessageCaption(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
text: String,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
EditChatMessageCaption(chatId, messageId, text, parseMode, replyMarkup)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editMessageCaption(
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
text: String,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editMessageCaption(chat.id, messageId, text, parseMode, replyMarkup)
|
||||||
|
|
||||||
|
suspend fun <T> RequestsExecutor.editMessageCaption(
|
||||||
|
message: ContentMessage<T>,
|
||||||
|
text: String,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
): ContentMessage<MediaContent> where T : CaptionedInput, T : MediaContent {
|
||||||
|
return editMessageCaption(message.chat.id, message.messageId, text, parseMode, replyMarkup)
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.caption
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.caption.EditInlineMessageCaption
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineMessageIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editMessageCaption(
|
||||||
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
|
text: String,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(EditInlineMessageCaption(inlineMessageId, text, parseMode, replyMarkup))
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.media
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media.EditChatMessageMedia
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.InputMedia
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editMessageMedia(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
media: InputMedia,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
EditChatMessageMedia(chatId, messageId, media, replyMarkup)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editMessageMedia(
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
media: InputMedia,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editMessageMedia(chat.id, messageId, media, replyMarkup)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editMessageMedia(
|
||||||
|
message: ContentMessage<out MediaContent>,
|
||||||
|
media: InputMedia,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editMessageMedia(message.chat.id, message.messageId, media, replyMarkup)
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.media
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.media.EditInlineMessageMedia
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineMessageIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.InputMedia
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editMessageCaption(
|
||||||
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
|
media: InputMedia,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(EditInlineMessageMedia(inlineMessageId, media, replyMarkup))
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.text
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.text.EditChatMessageText
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editMessageText(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
text: String,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableWebPagePreview: Boolean? = null,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
EditChatMessageText(chatId, messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editMessageText(
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
text: String,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableWebPagePreview: Boolean? = null,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editMessageText(chat.id, messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editMessageText(
|
||||||
|
message: ContentMessage<TextContent>,
|
||||||
|
text: String,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableWebPagePreview: Boolean? = null,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editMessageText(message.chat.id, message.messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.edit.text
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.text.EditInlineMessageText
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineMessageIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.editMessageText(
|
||||||
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
|
text: String,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableWebPagePreview: Boolean? = null,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(EditInlineMessageText(inlineMessageId, text, parseMode, disableWebPagePreview, replyMarkup))
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.games
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.GetGameHighScoresByChat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.GameContent
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getGameScore(
|
||||||
|
userId: UserId,
|
||||||
|
chatId: ChatId,
|
||||||
|
messageId: MessageIdentifier
|
||||||
|
) = execute(
|
||||||
|
GetGameHighScoresByChat(userId, chatId, messageId)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getGameScore(
|
||||||
|
user: CommonUser,
|
||||||
|
chatId: ChatId,
|
||||||
|
messageId: MessageIdentifier
|
||||||
|
) = getGameScore(
|
||||||
|
user.id, chatId, messageId
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getGameScore(
|
||||||
|
userId: UserId,
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageIdentifier
|
||||||
|
) = getGameScore(
|
||||||
|
userId, chat.id, messageId
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getGameScore(
|
||||||
|
user: CommonUser,
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageIdentifier
|
||||||
|
) = getGameScore(
|
||||||
|
user.id, chat.id, messageId
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getGameScore(
|
||||||
|
userId: UserId,
|
||||||
|
message: ContentMessage<GameContent>
|
||||||
|
) = getGameScore(
|
||||||
|
userId, message.chat.id, message.messageId
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getGameScore(
|
||||||
|
user: CommonUser,
|
||||||
|
message: ContentMessage<GameContent>
|
||||||
|
) = getGameScore(
|
||||||
|
user.id, message.chat.id, message.messageId
|
||||||
|
)
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.games
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.GetGameHighScoresByInlineMessageId
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getGameScore(
|
||||||
|
userId: UserId,
|
||||||
|
inlineMessageId: InlineMessageIdentifier
|
||||||
|
) = execute(
|
||||||
|
GetGameHighScoresByInlineMessageId(
|
||||||
|
userId, inlineMessageId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getGameScore(
|
||||||
|
user: CommonUser,
|
||||||
|
inlineMessageId: InlineMessageIdentifier
|
||||||
|
) = getGameScore(user.id, inlineMessageId)
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.games
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.SetGameScoreByChatId
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.GameContent
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setGameScore(
|
||||||
|
userId: UserId,
|
||||||
|
score: Long,
|
||||||
|
chatId: ChatId,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
force: Boolean = false,
|
||||||
|
disableEditMessage: Boolean = false
|
||||||
|
) = execute(
|
||||||
|
SetGameScoreByChatId(userId, score, chatId, messageId, force, disableEditMessage)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setGameScore(
|
||||||
|
user: CommonUser,
|
||||||
|
score: Long,
|
||||||
|
chatId: ChatId,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
force: Boolean = false,
|
||||||
|
disableEditMessage: Boolean = false
|
||||||
|
) = setGameScore(
|
||||||
|
user.id, score, chatId, messageId, force, disableEditMessage
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setGameScore(
|
||||||
|
userId: UserId,
|
||||||
|
score: Long,
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
force: Boolean = false,
|
||||||
|
disableEditMessage: Boolean = false
|
||||||
|
) = setGameScore(
|
||||||
|
userId, score, chat.id, messageId, force, disableEditMessage
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setGameScore(
|
||||||
|
user: CommonUser,
|
||||||
|
score: Long,
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
force: Boolean = false,
|
||||||
|
disableEditMessage: Boolean = false
|
||||||
|
) = setGameScore(
|
||||||
|
user.id, score, chat.id, messageId, force, disableEditMessage
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setGameScore(
|
||||||
|
userId: UserId,
|
||||||
|
score: Long,
|
||||||
|
message: ContentMessage<GameContent>,
|
||||||
|
force: Boolean = false,
|
||||||
|
disableEditMessage: Boolean = false
|
||||||
|
) = setGameScore(
|
||||||
|
userId, score, message.chat.id, message.messageId, force, disableEditMessage
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setGameScore(
|
||||||
|
user: CommonUser,
|
||||||
|
score: Long,
|
||||||
|
message: ContentMessage<GameContent>,
|
||||||
|
force: Boolean = false,
|
||||||
|
disableEditMessage: Boolean = false
|
||||||
|
) = setGameScore(
|
||||||
|
user.id, score, message.chat.id, message.messageId, force, disableEditMessage
|
||||||
|
)
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.games
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.SetGameScoreByInlineMessageId
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setGameScore(
|
||||||
|
userId: UserId,
|
||||||
|
score: Long,
|
||||||
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
|
force: Boolean = false,
|
||||||
|
disableEditMessage: Boolean = false
|
||||||
|
) = execute(
|
||||||
|
SetGameScoreByInlineMessageId(
|
||||||
|
userId, score, inlineMessageId, force, disableEditMessage
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setGameScore(
|
||||||
|
user: CommonUser,
|
||||||
|
score: Long,
|
||||||
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
|
force: Boolean = false,
|
||||||
|
disableEditMessage: Boolean = false
|
||||||
|
) = setGameScore(user.id, score, inlineMessageId, force, disableEditMessage)
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.get
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.get.GetFile
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.abstracts.TelegramMediaFile
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getFileAdditionalInfo(
|
||||||
|
fileId: FileId
|
||||||
|
) = execute(
|
||||||
|
GetFile(fileId)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getFileAdditionalInfo(
|
||||||
|
file: TelegramMediaFile
|
||||||
|
) = getFileAdditionalInfo(file.fileId)
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.get
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.get.GetStickerSet
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.Sticker
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getStickerSet(
|
||||||
|
name: String
|
||||||
|
) = execute(
|
||||||
|
GetStickerSet(name)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getStickerSet(
|
||||||
|
sticker: Sticker
|
||||||
|
) = getStickerSet(
|
||||||
|
sticker.stickerSetName ?: error("Sticker must contains stickerSetName to be correctly used in getStickerSet method")
|
||||||
|
)
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.get
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.get.GetUserProfilePhotos
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.CommonUser
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.UserId
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getUserProfilePhotos(
|
||||||
|
userId: UserId,
|
||||||
|
offset: Int? = null,
|
||||||
|
limit: Int? = null
|
||||||
|
) = execute(
|
||||||
|
GetUserProfilePhotos(
|
||||||
|
userId, offset, limit
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getUserProfilePhotos(
|
||||||
|
user: CommonUser,
|
||||||
|
offset: Int? = null,
|
||||||
|
limit: Int? = null
|
||||||
|
) = getUserProfilePhotos(user.id, offset, limit)
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendAction
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.actions.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendBotAction(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
action: BotAction
|
||||||
|
) = execute(
|
||||||
|
SendAction(chatId, action)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendBotAction(
|
||||||
|
chat: Chat,
|
||||||
|
action: BotAction
|
||||||
|
) = sendBotAction(chat.id, action)
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionTyping(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = sendBotAction(chatId, TypingAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionUploadPhoto(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = sendBotAction(chatId, UploadPhotoAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionRecordVideo(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = sendBotAction(chatId, RecordVideoAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionUploadVideo(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = sendBotAction(chatId, UploadVideoAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionRecordAudio(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = sendBotAction(chatId, RecordAudioAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionUploadAudio(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = sendBotAction(chatId, UploadAudioAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionUploadDocument(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = sendBotAction(chatId, UploadDocumentAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionFindLocation(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = sendBotAction(chatId, FindLocationAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionRecordVideoNote(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = sendBotAction(chatId, RecordVideoNoteAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionUploadVideoNote(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = sendBotAction(chatId, UploadVideoNoteAction)
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionTyping(
|
||||||
|
chat: Chat
|
||||||
|
) = sendBotAction(chat, TypingAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionUploadPhoto(
|
||||||
|
chat: Chat
|
||||||
|
) = sendBotAction(chat, UploadPhotoAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionRecordVideo(
|
||||||
|
chat: Chat
|
||||||
|
) = sendBotAction(chat, RecordVideoAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionUploadVideo(
|
||||||
|
chat: Chat
|
||||||
|
) = sendBotAction(chat, UploadVideoAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionRecordAudio(
|
||||||
|
chat: Chat
|
||||||
|
) = sendBotAction(chat, RecordAudioAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionUploadAudio(
|
||||||
|
chat: Chat
|
||||||
|
) = sendBotAction(chat, UploadAudioAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionUploadDocument(
|
||||||
|
chat: Chat
|
||||||
|
) = sendBotAction(chat, UploadDocumentAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionFindLocation(
|
||||||
|
chat: Chat
|
||||||
|
) = sendBotAction(chat, FindLocationAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionRecordVideoNote(
|
||||||
|
chat: Chat
|
||||||
|
) = sendBotAction(chat, RecordVideoNoteAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionUploadVideoNote(
|
||||||
|
chat: Chat
|
||||||
|
) = sendBotAction(chat, UploadVideoNoteAction)
|
||||||
|
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendContact
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendContact(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
phoneNumber: String,
|
||||||
|
firstName: String,
|
||||||
|
lastName: String? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendContact(
|
||||||
|
chatId, phoneNumber, firstName, lastName, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendContact(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
contact: Contact,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendContact(
|
||||||
|
chatId, contact, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendContact(
|
||||||
|
chat: Chat,
|
||||||
|
phoneNumber: String,
|
||||||
|
firstName: String,
|
||||||
|
lastName: String? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendContact(
|
||||||
|
chat.id, phoneNumber, firstName, lastName, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendContact(
|
||||||
|
chat: Chat,
|
||||||
|
contact: Contact,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendContact(
|
||||||
|
chat.id, contact, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendDice
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendDice(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendDice(chatId, disableNotification, replyToMessageId, replyMarkup)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendDice(
|
||||||
|
chat: Chat,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendDice(chat.id, disableNotification, replyToMessageId, replyMarkup)
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendLocation
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendLocation(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
latitude: Double,
|
||||||
|
longitude: Double,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendLocation(
|
||||||
|
chatId,
|
||||||
|
latitude,
|
||||||
|
longitude,
|
||||||
|
disableNotification = disableNotification,
|
||||||
|
replyToMessageId = replyToMessageId,
|
||||||
|
replyMarkup = replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendLocation(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
location: Location,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendLocation(
|
||||||
|
chatId,
|
||||||
|
location.latitude,
|
||||||
|
location.longitude,
|
||||||
|
disableNotification,
|
||||||
|
replyToMessageId,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendLocation(
|
||||||
|
chat: Chat,
|
||||||
|
latitude: Double,
|
||||||
|
longitude: Double,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendLocation(
|
||||||
|
chat.id,
|
||||||
|
latitude,
|
||||||
|
longitude,
|
||||||
|
disableNotification,
|
||||||
|
replyToMessageId,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendLocation(
|
||||||
|
chat: Chat,
|
||||||
|
location: Location,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendLocation(
|
||||||
|
chat.id,
|
||||||
|
location.latitude,
|
||||||
|
location.longitude,
|
||||||
|
disableNotification,
|
||||||
|
replyToMessageId,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendTextMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendMessage(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
text: String,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableWebPagePreview: Boolean? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendTextMessage(chatId, text, parseMode, disableWebPagePreview, disableNotification, replyToMessageId, replyMarkup)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendTextMessage(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
text: String,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableWebPagePreview: Boolean? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendMessage(
|
||||||
|
chatId, text, parseMode, disableWebPagePreview, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendMessage(
|
||||||
|
chat: Chat,
|
||||||
|
text: String,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableWebPagePreview: Boolean? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendMessage(chat.id, text, parseMode, disableWebPagePreview, disableNotification, replyToMessageId, replyMarkup)
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendTextMessage(
|
||||||
|
chat: Chat,
|
||||||
|
text: String,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableWebPagePreview: Boolean? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendTextMessage(chat.id, text, parseMode, disableWebPagePreview, disableNotification, replyToMessageId, replyMarkup)
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendVenue
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVenue(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
latitude: Double,
|
||||||
|
longitude: Double,
|
||||||
|
title: String,
|
||||||
|
address: String,
|
||||||
|
foursquareId: String? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendVenue(
|
||||||
|
chatId, latitude, longitude, title, address, foursquareId, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVenue(
|
||||||
|
chat: Chat,
|
||||||
|
latitude: Double,
|
||||||
|
longitude: Double,
|
||||||
|
title: String,
|
||||||
|
address: String,
|
||||||
|
foursquareId: String? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendVenue(
|
||||||
|
chat.id, latitude, longitude, title, address, foursquareId, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVenue(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
venue: Venue,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendVenue(
|
||||||
|
chatId, venue, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVenue(
|
||||||
|
chat: Chat,
|
||||||
|
venue: Venue,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendVenue(
|
||||||
|
chat.id, venue, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.games
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.games.SendGame
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.games.Game
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendGame(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
gameShortName: String,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendGame(
|
||||||
|
chatId, gameShortName, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendGame(
|
||||||
|
chat: Chat,
|
||||||
|
gameShortName: String,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendGame(
|
||||||
|
chat.id, gameShortName, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendGame(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
game: Game,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendGame(
|
||||||
|
chatId, game.title, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendGame(
|
||||||
|
chat: Chat,
|
||||||
|
game: Game,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendGame(
|
||||||
|
chat.id, game.title, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.InputFile
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendAnimation
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.AnimationFile
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendAnimation(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
animation: InputFile,
|
||||||
|
thumb: InputFile? = null,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
duration: Long? = null,
|
||||||
|
width: Int? = null,
|
||||||
|
height: Int? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendAnimation(
|
||||||
|
chatId,
|
||||||
|
animation,
|
||||||
|
thumb,
|
||||||
|
text,
|
||||||
|
parseMode,
|
||||||
|
duration,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
disableNotification,
|
||||||
|
replyToMessageId,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendAnimation(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
animation: AnimationFile,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
duration: Long? = null,
|
||||||
|
width: Int? = null,
|
||||||
|
height: Int? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendAnimation(
|
||||||
|
chatId, animation.fileId, animation.thumb ?.fileId, text, parseMode, duration, width, height, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.InputFile
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendAudio
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.AudioFile
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendAudio(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
audio: InputFile,
|
||||||
|
thumb: InputFile? = null,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
duration: Long? = null,
|
||||||
|
performer: String? = null,
|
||||||
|
title: String? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendAudio(
|
||||||
|
chatId,
|
||||||
|
audio,
|
||||||
|
thumb,
|
||||||
|
text,
|
||||||
|
parseMode,
|
||||||
|
duration,
|
||||||
|
performer,
|
||||||
|
title,
|
||||||
|
disableNotification,
|
||||||
|
replyToMessageId,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendAudio(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
audio: AudioFile,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
title: String? = audio.title,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendAudio(
|
||||||
|
chatId, audio.fileId, audio.thumb ?.fileId, text, parseMode, audio.duration, audio.performer, title, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.InputFile
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendDocument
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.DocumentFile
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendDocument(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
document: InputFile,
|
||||||
|
thumb: InputFile? = null,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendDocument(
|
||||||
|
chatId,
|
||||||
|
document,
|
||||||
|
thumb,
|
||||||
|
text,
|
||||||
|
parseMode,
|
||||||
|
disableNotification,
|
||||||
|
replyToMessageId,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendDocument(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
document: DocumentFile,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendDocument(
|
||||||
|
chatId, document.fileId, document.thumb ?.fileId, text, parseMode, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendMediaGroup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.MediaGroupMemberInputMedia
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendMediaGroup(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
media: List<MediaGroupMemberInputMedia>,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null
|
||||||
|
) = execute(
|
||||||
|
SendMediaGroup(
|
||||||
|
chatId, media, disableNotification, replyToMessageId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendMediaGroup(
|
||||||
|
chat: Chat,
|
||||||
|
media: List<MediaGroupMemberInputMedia>,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null
|
||||||
|
) = sendMediaGroup(
|
||||||
|
chat.id, media, disableNotification, replyToMessageId
|
||||||
|
)
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.InputFile
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendPhoto
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendPhoto(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
fileId: InputFile,
|
||||||
|
caption: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendPhoto(
|
||||||
|
chatId,
|
||||||
|
fileId,
|
||||||
|
caption,
|
||||||
|
parseMode,
|
||||||
|
disableNotification,
|
||||||
|
replyToMessageId,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.InputFile
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendSticker
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendSticker(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
sticker: InputFile,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendSticker(chatId, sticker, disableNotification, replyToMessageId, replyMarkup)
|
||||||
|
)
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.InputFile
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendVideo
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.VideoFile
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVideo(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
video: InputFile,
|
||||||
|
thumb: InputFile? = null,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
duration: Long? = null,
|
||||||
|
width: Int? = null,
|
||||||
|
height: Int? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendVideo(
|
||||||
|
chatId,
|
||||||
|
video,
|
||||||
|
thumb,
|
||||||
|
text,
|
||||||
|
parseMode,
|
||||||
|
duration,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
null,
|
||||||
|
disableNotification,
|
||||||
|
replyToMessageId,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVideo(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
video: VideoFile,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendVideo(
|
||||||
|
chatId, video.fileId, video.thumb ?.fileId, text, parseMode, video.duration, video.width, video.height, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.InputFile
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendVideoNote
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.VideoFile
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVideoNote(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
videoNote: InputFile,
|
||||||
|
thumb: InputFile? = null,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
duration: Long? = null,
|
||||||
|
size: Int? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendVideoNote(
|
||||||
|
chatId,
|
||||||
|
videoNote,
|
||||||
|
thumb,
|
||||||
|
text,
|
||||||
|
parseMode,
|
||||||
|
duration,
|
||||||
|
size,
|
||||||
|
disableNotification,
|
||||||
|
replyToMessageId,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVideoNote(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
videoNote: VideoFile,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendVideoNote(
|
||||||
|
chatId, videoNote.fileId, videoNote.thumb ?.fileId, text, parseMode, videoNote.duration, videoNote.width, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.InputFile
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendVoice
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.AudioFile
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVoice(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
voice: InputFile,
|
||||||
|
thumb: InputFile? = null,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
duration: Long? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendVoice(
|
||||||
|
chatId,
|
||||||
|
voice,
|
||||||
|
thumb,
|
||||||
|
text,
|
||||||
|
parseMode,
|
||||||
|
duration,
|
||||||
|
disableNotification,
|
||||||
|
replyToMessageId,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVoice(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
voice: AudioFile,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendVoice(
|
||||||
|
chatId, voice.fileId, voice.thumb ?.fileId, text, parseMode, voice.duration, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.payments
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.payments.SendInvoice
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.LabeledPrice
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.abstracts.Currency
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendInvoice(
|
||||||
|
chatId: ChatId,
|
||||||
|
title: String,
|
||||||
|
description: String,
|
||||||
|
payload: String,
|
||||||
|
providerToken: String,
|
||||||
|
startParameter: StartParameter,
|
||||||
|
currency: Currency,
|
||||||
|
prices: List<LabeledPrice>,
|
||||||
|
providerData: String? = null,
|
||||||
|
requireName: Boolean = false,
|
||||||
|
requirePhoneNumber: Boolean = false,
|
||||||
|
requireEmail: Boolean = false,
|
||||||
|
requireShippingAddress: Boolean = false,
|
||||||
|
shouldSendPhoneNumberToProvider: Boolean = false,
|
||||||
|
shouldSendEmailToProvider: Boolean = false,
|
||||||
|
priceDependOnShipAddress: Boolean = false,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendInvoice(chatId, title, description, payload, providerToken, startParameter, currency, prices, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, replyToMessageId, replyMarkup)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendInvoice(
|
||||||
|
user: CommonUser,
|
||||||
|
title: String,
|
||||||
|
description: String,
|
||||||
|
payload: String,
|
||||||
|
providerToken: String,
|
||||||
|
startParameter: StartParameter,
|
||||||
|
currency: Currency,
|
||||||
|
prices: List<LabeledPrice>,
|
||||||
|
providerData: String? = null,
|
||||||
|
requireName: Boolean = false,
|
||||||
|
requirePhoneNumber: Boolean = false,
|
||||||
|
requireEmail: Boolean = false,
|
||||||
|
requireShippingAddress: Boolean = false,
|
||||||
|
shouldSendPhoneNumberToProvider: Boolean = false,
|
||||||
|
shouldSendEmailToProvider: Boolean = false,
|
||||||
|
priceDependOnShipAddress: Boolean = false,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = sendInvoice(user.id, title, description, payload, providerToken, startParameter, currency, prices, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, replyToMessageId, replyMarkup)
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.polls
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.polls.SendQuizPoll
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.polls.SendRegularPoll
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.QuizPoll
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.RegularPoll
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendRegularPoll(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
question: String,
|
||||||
|
options: List<String>,
|
||||||
|
isAnonymous: Boolean = true,
|
||||||
|
isClosed: Boolean = false,
|
||||||
|
allowMultipleAnswers: Boolean = false,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendRegularPoll(
|
||||||
|
chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
suspend fun RequestsExecutor.sendRegularPoll(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
poll: RegularPoll,
|
||||||
|
isClosed: Boolean = false,
|
||||||
|
question: String = poll.question,
|
||||||
|
options: List<String> = poll.options.map { it.text },
|
||||||
|
isAnonymous: Boolean = poll.isAnonymous,
|
||||||
|
allowMultipleAnswers: Boolean = poll.allowMultipleAnswers,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendRegularPoll(
|
||||||
|
chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendRegularPoll(
|
||||||
|
chat: Chat,
|
||||||
|
question: String,
|
||||||
|
options: List<String>,
|
||||||
|
isAnonymous: Boolean = true,
|
||||||
|
isClosed: Boolean = false,
|
||||||
|
allowMultipleAnswers: Boolean = false,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendRegularPoll(
|
||||||
|
chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendRegularPoll(
|
||||||
|
chat: Chat,
|
||||||
|
poll: RegularPoll,
|
||||||
|
isClosed: Boolean = false,
|
||||||
|
question: String = poll.question,
|
||||||
|
options: List<String> = poll.options.map { it.text },
|
||||||
|
isAnonymous: Boolean = poll.isAnonymous,
|
||||||
|
allowMultipleAnswers: Boolean = poll.allowMultipleAnswers,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendRegularPoll(
|
||||||
|
chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendQuizPoll(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
question: String,
|
||||||
|
options: List<String>,
|
||||||
|
correctOptionId: Int,
|
||||||
|
isAnonymous: Boolean = true,
|
||||||
|
isClosed: Boolean = false,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendQuizPoll(
|
||||||
|
chatId, question, options, correctOptionId, isAnonymous, isClosed, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendQuizPoll(
|
||||||
|
chat: Chat,
|
||||||
|
question: String,
|
||||||
|
options: List<String>,
|
||||||
|
correctOptionId: Int,
|
||||||
|
isAnonymous: Boolean = true,
|
||||||
|
isClosed: Boolean = false,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendQuizPoll(
|
||||||
|
chat.id, question, options, correctOptionId, isAnonymous, isClosed, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendQuizPoll(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
isClosed: Boolean = false,
|
||||||
|
quizPoll: QuizPoll,
|
||||||
|
question: String = quizPoll.question,
|
||||||
|
options: List<String> = quizPoll.options.map { it.text },
|
||||||
|
correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"),
|
||||||
|
isAnonymous: Boolean = quizPoll.isAnonymous,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
SendQuizPoll(
|
||||||
|
chatId, question, options, correctOptionId, isAnonymous, isClosed, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendQuizPoll(
|
||||||
|
chat: Chat,
|
||||||
|
isClosed: Boolean = false,
|
||||||
|
quizPoll: QuizPoll,
|
||||||
|
question: String = quizPoll.question,
|
||||||
|
options: List<String> = quizPoll.options.map { it.text },
|
||||||
|
correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"),
|
||||||
|
isAnonymous: Boolean = quizPoll.isAnonymous,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendQuizPoll(
|
||||||
|
chat.id, question, options, correctOptionId, isAnonymous, isClosed, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.stickers
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.AddAnimatedStickerToSet
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.CommonUser
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.UserId
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.StickerSet
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.addAnimatedStickerToSet(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSetName: String,
|
||||||
|
sticker: FileId,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = execute(
|
||||||
|
AddAnimatedStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.addAnimatedStickerToSet(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSetName: String,
|
||||||
|
sticker: MultipartFile,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = execute(
|
||||||
|
AddAnimatedStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.addAnimatedStickerToSet(
|
||||||
|
user: CommonUser,
|
||||||
|
stickerSetName: String,
|
||||||
|
sticker: FileId,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = addAnimatedStickerToSet(
|
||||||
|
user.id, stickerSetName, sticker, emojis, maskPosition
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.addAnimatedStickerToSet(
|
||||||
|
user: CommonUser,
|
||||||
|
stickerSetName: String,
|
||||||
|
sticker: MultipartFile,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = addAnimatedStickerToSet(
|
||||||
|
user.id, stickerSetName, sticker, emojis, maskPosition
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.addAnimatedStickerToSet(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: FileId,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = addAnimatedStickerToSet(
|
||||||
|
userId, stickerSet.name, sticker, emojis, maskPosition
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.addAnimatedStickerToSet(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: MultipartFile,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = addAnimatedStickerToSet(
|
||||||
|
userId, stickerSet.name, sticker, emojis, maskPosition
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.addAnimatedStickerToSet(
|
||||||
|
user: CommonUser,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: FileId,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = addAnimatedStickerToSet(
|
||||||
|
user.id, stickerSet.name, sticker, emojis, maskPosition
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.addAnimatedStickerToSet(
|
||||||
|
user: CommonUser,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: MultipartFile,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = addAnimatedStickerToSet(
|
||||||
|
user.id, stickerSet.name, sticker, emojis, maskPosition
|
||||||
|
)
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.stickers
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.AddStaticStickerToSet
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.CommonUser
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.UserId
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.StickerSet
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.addStaticStickerToSet(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSetName: String,
|
||||||
|
sticker: FileId,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = execute(
|
||||||
|
AddStaticStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.addStaticStickerToSet(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSetName: String,
|
||||||
|
sticker: MultipartFile,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = execute(
|
||||||
|
AddStaticStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.addStaticStickerToSet(
|
||||||
|
user: CommonUser,
|
||||||
|
stickerSetName: String,
|
||||||
|
sticker: FileId,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = addStaticStickerToSet(
|
||||||
|
user.id, stickerSetName, sticker, emojis, maskPosition
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.addStaticStickerToSet(
|
||||||
|
user: CommonUser,
|
||||||
|
stickerSetName: String,
|
||||||
|
sticker: MultipartFile,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = addStaticStickerToSet(
|
||||||
|
user.id, stickerSetName, sticker, emojis, maskPosition
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.addStaticStickerToSet(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: FileId,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = addStaticStickerToSet(
|
||||||
|
userId, stickerSet.name, sticker, emojis, maskPosition
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.addStaticStickerToSet(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: MultipartFile,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = addStaticStickerToSet(
|
||||||
|
userId, stickerSet.name, sticker, emojis, maskPosition
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.addStaticStickerToSet(
|
||||||
|
user: CommonUser,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: FileId,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = addStaticStickerToSet(
|
||||||
|
user.id, stickerSet.name, sticker, emojis, maskPosition
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.addStaticStickerToSet(
|
||||||
|
user: CommonUser,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: MultipartFile,
|
||||||
|
emojis: String,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = addStaticStickerToSet(
|
||||||
|
user.id, stickerSet.name, sticker, emojis, maskPosition
|
||||||
|
)
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.stickers
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.CreateNewAnimatedStickerSet
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.CommonUser
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.UserId
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.createNewAnimatedStickerSet(
|
||||||
|
userId: UserId,
|
||||||
|
name: String,
|
||||||
|
sticker: FileId,
|
||||||
|
emojis: String,
|
||||||
|
containsMasks: Boolean? = null,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = execute(
|
||||||
|
CreateNewAnimatedStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.createNewAnimatedStickerSet(
|
||||||
|
userId: UserId,
|
||||||
|
name: String,
|
||||||
|
sticker: MultipartFile,
|
||||||
|
emojis: String,
|
||||||
|
containsMasks: Boolean? = null,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = execute(
|
||||||
|
CreateNewAnimatedStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.createNewAnimatedStickerSet(
|
||||||
|
user: CommonUser,
|
||||||
|
name: String,
|
||||||
|
sticker: FileId,
|
||||||
|
emojis: String,
|
||||||
|
containsMasks: Boolean? = null,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = createNewAnimatedStickerSet(
|
||||||
|
user.id, name, sticker, emojis, containsMasks, maskPosition
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.createNewAnimatedStickerSet(
|
||||||
|
user: CommonUser,
|
||||||
|
name: String,
|
||||||
|
sticker: MultipartFile,
|
||||||
|
emojis: String,
|
||||||
|
containsMasks: Boolean? = null,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = createNewAnimatedStickerSet(
|
||||||
|
user.id, name, sticker, emojis, containsMasks, maskPosition
|
||||||
|
)
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.stickers
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.CreateNewStaticStickerSet
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.CommonUser
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.UserId
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.MaskPosition
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.createNewStaticStickerSet(
|
||||||
|
userId: UserId,
|
||||||
|
name: String,
|
||||||
|
sticker: FileId,
|
||||||
|
emojis: String,
|
||||||
|
containsMasks: Boolean? = null,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = execute(
|
||||||
|
CreateNewStaticStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.createNewStaticStickerSet(
|
||||||
|
userId: UserId,
|
||||||
|
name: String,
|
||||||
|
sticker: MultipartFile,
|
||||||
|
emojis: String,
|
||||||
|
containsMasks: Boolean? = null,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = execute(
|
||||||
|
CreateNewStaticStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.createNewStaticStickerSet(
|
||||||
|
user: CommonUser,
|
||||||
|
name: String,
|
||||||
|
sticker: FileId,
|
||||||
|
emojis: String,
|
||||||
|
containsMasks: Boolean? = null,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = createNewStaticStickerSet(
|
||||||
|
user.id, name, sticker, emojis, containsMasks, maskPosition
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.createNewStaticStickerSet(
|
||||||
|
user: CommonUser,
|
||||||
|
name: String,
|
||||||
|
sticker: MultipartFile,
|
||||||
|
emojis: String,
|
||||||
|
containsMasks: Boolean? = null,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = createNewStaticStickerSet(
|
||||||
|
user.id, name, sticker, emojis, containsMasks, maskPosition
|
||||||
|
)
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.stickers
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.DeleteStickerFromSet
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.Sticker
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.deleteStickerFromSet(
|
||||||
|
sticker: FileId
|
||||||
|
) = execute(
|
||||||
|
DeleteStickerFromSet(
|
||||||
|
sticker
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.deleteStickerFromSet(
|
||||||
|
sticker: Sticker
|
||||||
|
) = deleteStickerFromSet(
|
||||||
|
sticker.fileId
|
||||||
|
)
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.stickers
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.SetStickerPositionInSet
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.Sticker
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setStickerPositionInSet(
|
||||||
|
sticker: FileId,
|
||||||
|
position: Int
|
||||||
|
) = execute(
|
||||||
|
SetStickerPositionInSet(
|
||||||
|
sticker,
|
||||||
|
position
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setStickerPositionInSet(
|
||||||
|
sticker: Sticker,
|
||||||
|
position: Int
|
||||||
|
) = setStickerPositionInSet(
|
||||||
|
sticker.fileId,
|
||||||
|
position
|
||||||
|
)
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.thumbs
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.SetStickerSetThumb
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.CommonUser
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.UserId
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.stickers.StickerSet
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setStickerSetThumb(
|
||||||
|
userId: UserId,
|
||||||
|
thumbSetName: String,
|
||||||
|
thumb: FileId
|
||||||
|
) = execute(
|
||||||
|
SetStickerSetThumb(userId, thumbSetName, thumb)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setStickerSetThumb(
|
||||||
|
userId: UserId,
|
||||||
|
thumbSetName: String,
|
||||||
|
thumb: MultipartFile
|
||||||
|
) = execute(
|
||||||
|
SetStickerSetThumb(userId, thumbSetName, thumb)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setStickerSetThumb(
|
||||||
|
user: CommonUser,
|
||||||
|
thumbSetName: String,
|
||||||
|
thumb: FileId
|
||||||
|
) = setStickerSetThumb(
|
||||||
|
user.id, thumbSetName, thumb
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setStickerSetThumb(
|
||||||
|
user: CommonUser,
|
||||||
|
thumbSetName: String,
|
||||||
|
thumb: MultipartFile
|
||||||
|
) = setStickerSetThumb(
|
||||||
|
user.id, thumbSetName, thumb
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setStickerSetThumb(
|
||||||
|
userId: UserId,
|
||||||
|
thumbSet: StickerSet,
|
||||||
|
thumb: FileId
|
||||||
|
) = setStickerSetThumb(
|
||||||
|
userId, thumbSet.name, thumb
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setStickerSetThumb(
|
||||||
|
userId: UserId,
|
||||||
|
thumbSet: StickerSet,
|
||||||
|
thumb: MultipartFile
|
||||||
|
) = setStickerSetThumb(
|
||||||
|
userId, thumbSet.name, thumb
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setStickerSetThumb(
|
||||||
|
user: CommonUser,
|
||||||
|
thumbSet: StickerSet,
|
||||||
|
thumb: FileId
|
||||||
|
) = setStickerSetThumb(
|
||||||
|
user.id, thumbSet.name, thumb
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setStickerSetThumb(
|
||||||
|
user: CommonUser,
|
||||||
|
thumbSet: StickerSet,
|
||||||
|
thumb: MultipartFile
|
||||||
|
) = setStickerSetThumb(
|
||||||
|
user.id, thumbSet.name, thumb
|
||||||
|
)
|
||||||
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.stickers
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.stickers.UploadStickerFile
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.CommonUser
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.UserId
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.uploadStickerFile(
|
||||||
|
userId: UserId,
|
||||||
|
sticker: MultipartFile
|
||||||
|
) = execute(
|
||||||
|
UploadStickerFile(userId, sticker)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.uploadStickerFile(
|
||||||
|
user: CommonUser,
|
||||||
|
sticker: MultipartFile
|
||||||
|
) = execute(
|
||||||
|
UploadStickerFile(user.id, sticker)
|
||||||
|
)
|
||||||
@@ -0,0 +1,158 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.updates
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.exceptions.RequestException
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.extensions.api.InternalUtils.convertWithMediaGroupUpdates
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.extensions.api.InternalUtils.lastUpdateIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.extensions.api.getUpdates
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.*
|
||||||
|
import io.ktor.client.features.HttpRequestTimeoutException
|
||||||
|
import kotlinx.coroutines.*
|
||||||
|
|
||||||
|
fun RequestsExecutor.startGettingOfUpdates(
|
||||||
|
timeoutSeconds: Seconds = 30,
|
||||||
|
scope: CoroutineScope = CoroutineScope(Dispatchers.Default),
|
||||||
|
exceptionsHandler: (suspend (Exception) -> Unit)? = null,
|
||||||
|
allowedUpdates: List<String>? = null,
|
||||||
|
updatesReceiver: UpdateReceiver<Update>
|
||||||
|
): Job = scope.launch {
|
||||||
|
var lastUpdateIdentifier: UpdateIdentifier? = null
|
||||||
|
|
||||||
|
while (isActive) {
|
||||||
|
try {
|
||||||
|
supervisorScope {
|
||||||
|
val updates = getUpdates(
|
||||||
|
offset = lastUpdateIdentifier?.plus(1),
|
||||||
|
timeout = timeoutSeconds,
|
||||||
|
allowed_updates = allowedUpdates
|
||||||
|
).let { originalUpdates ->
|
||||||
|
val converted = originalUpdates.convertWithMediaGroupUpdates()
|
||||||
|
/**
|
||||||
|
* Dirty hack for cases when the media group was retrieved not fully:
|
||||||
|
*
|
||||||
|
* We are throw out the last media group and will reretrieve it again in the next get updates
|
||||||
|
* and it will guarantee that it is full
|
||||||
|
*/
|
||||||
|
if (originalUpdates.size == getUpdatesLimit.last && converted.last() is SentMediaGroupUpdate) {
|
||||||
|
converted - converted.last()
|
||||||
|
} else {
|
||||||
|
converted
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
supervisorScope {
|
||||||
|
for (update in updates) {
|
||||||
|
updatesReceiver(update)
|
||||||
|
|
||||||
|
lastUpdateIdentifier = update.lastUpdateIdentifier()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e: HttpRequestTimeoutException) {
|
||||||
|
exceptionsHandler ?.invoke(e) // it is ok due to mechanism of long polling
|
||||||
|
} catch (e: RequestException) {
|
||||||
|
exceptionsHandler ?.invoke(e) // it is not ok, but in most cases it will mean that there is some limit for requests count
|
||||||
|
delay(1000L)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
exceptionsHandler ?.invoke(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun RequestsExecutor.startGettingOfUpdates(
|
||||||
|
updatesFilter: UpdatesFilter,
|
||||||
|
timeoutSeconds: Seconds = 30,
|
||||||
|
exceptionsHandler: (suspend (Exception) -> Unit)? = null,
|
||||||
|
scope: CoroutineScope = CoroutineScope(Dispatchers.Default)
|
||||||
|
): Job = startGettingOfUpdates(
|
||||||
|
timeoutSeconds,
|
||||||
|
scope,
|
||||||
|
exceptionsHandler,
|
||||||
|
updatesFilter.allowedUpdates,
|
||||||
|
updatesFilter.asUpdateReceiver
|
||||||
|
)
|
||||||
|
|
||||||
|
fun RequestsExecutor.startGettingOfUpdates(
|
||||||
|
messageCallback: UpdateReceiver<MessageUpdate>? = null,
|
||||||
|
messageMediaGroupCallback: UpdateReceiver<MessageMediaGroupUpdate>? = null,
|
||||||
|
editedMessageCallback: UpdateReceiver<EditMessageUpdate>? = null,
|
||||||
|
editedMessageMediaGroupCallback: UpdateReceiver<EditMessageMediaGroupUpdate>? = null,
|
||||||
|
channelPostCallback: UpdateReceiver<ChannelPostUpdate>? = null,
|
||||||
|
channelPostMediaGroupCallback: UpdateReceiver<ChannelPostMediaGroupUpdate>? = null,
|
||||||
|
editedChannelPostCallback: UpdateReceiver<EditChannelPostUpdate>? = null,
|
||||||
|
editedChannelPostMediaGroupCallback: UpdateReceiver<EditChannelPostMediaGroupUpdate>? = null,
|
||||||
|
chosenInlineResultCallback: UpdateReceiver<ChosenInlineResultUpdate>? = null,
|
||||||
|
inlineQueryCallback: UpdateReceiver<InlineQueryUpdate>? = null,
|
||||||
|
callbackQueryCallback: UpdateReceiver<CallbackQueryUpdate>? = null,
|
||||||
|
shippingQueryCallback: UpdateReceiver<ShippingQueryUpdate>? = null,
|
||||||
|
preCheckoutQueryCallback: UpdateReceiver<PreCheckoutQueryUpdate>? = null,
|
||||||
|
pollCallback: UpdateReceiver<PollUpdate>? = null,
|
||||||
|
pollAnswerCallback: UpdateReceiver<PollAnswerUpdate>? = null,
|
||||||
|
timeoutSeconds: Seconds = 30,
|
||||||
|
exceptionsHandler: (suspend (Exception) -> Unit)? = null,
|
||||||
|
scope: CoroutineScope = GlobalScope
|
||||||
|
): Job {
|
||||||
|
return startGettingOfUpdates(
|
||||||
|
SimpleUpdatesFilter(
|
||||||
|
messageCallback,
|
||||||
|
messageMediaGroupCallback,
|
||||||
|
editedMessageCallback,
|
||||||
|
editedMessageMediaGroupCallback,
|
||||||
|
channelPostCallback,
|
||||||
|
channelPostMediaGroupCallback,
|
||||||
|
editedChannelPostCallback,
|
||||||
|
editedChannelPostMediaGroupCallback,
|
||||||
|
chosenInlineResultCallback,
|
||||||
|
inlineQueryCallback,
|
||||||
|
callbackQueryCallback,
|
||||||
|
shippingQueryCallback,
|
||||||
|
preCheckoutQueryCallback,
|
||||||
|
pollCallback,
|
||||||
|
pollAnswerCallback
|
||||||
|
),
|
||||||
|
timeoutSeconds,
|
||||||
|
exceptionsHandler,
|
||||||
|
scope
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun RequestsExecutor.startGettingOfUpdates(
|
||||||
|
messageCallback: UpdateReceiver<MessageUpdate>? = null,
|
||||||
|
mediaGroupCallback: UpdateReceiver<MediaGroupUpdate>? = null,
|
||||||
|
editedMessageCallback: UpdateReceiver<EditMessageUpdate>? = null,
|
||||||
|
channelPostCallback: UpdateReceiver<ChannelPostUpdate>? = null,
|
||||||
|
editedChannelPostCallback: UpdateReceiver<EditChannelPostUpdate>? = null,
|
||||||
|
chosenInlineResultCallback: UpdateReceiver<ChosenInlineResultUpdate>? = null,
|
||||||
|
inlineQueryCallback: UpdateReceiver<InlineQueryUpdate>? = null,
|
||||||
|
callbackQueryCallback: UpdateReceiver<CallbackQueryUpdate>? = null,
|
||||||
|
shippingQueryCallback: UpdateReceiver<ShippingQueryUpdate>? = null,
|
||||||
|
preCheckoutQueryCallback: UpdateReceiver<PreCheckoutQueryUpdate>? = null,
|
||||||
|
pollCallback: UpdateReceiver<PollUpdate>? = null,
|
||||||
|
pollAnswerCallback: UpdateReceiver<PollAnswerUpdate>? = null,
|
||||||
|
timeoutSeconds: Seconds = 30,
|
||||||
|
exceptionsHandler: (suspend (Exception) -> Unit)? = null,
|
||||||
|
scope: CoroutineScope = CoroutineScope(Dispatchers.Default)
|
||||||
|
): Job = startGettingOfUpdates(
|
||||||
|
messageCallback = messageCallback,
|
||||||
|
messageMediaGroupCallback = mediaGroupCallback,
|
||||||
|
editedMessageCallback = editedMessageCallback,
|
||||||
|
editedMessageMediaGroupCallback = mediaGroupCallback,
|
||||||
|
channelPostCallback = channelPostCallback,
|
||||||
|
channelPostMediaGroupCallback = mediaGroupCallback,
|
||||||
|
editedChannelPostCallback = editedChannelPostCallback,
|
||||||
|
editedChannelPostMediaGroupCallback = mediaGroupCallback,
|
||||||
|
chosenInlineResultCallback = chosenInlineResultCallback,
|
||||||
|
inlineQueryCallback = inlineQueryCallback,
|
||||||
|
callbackQueryCallback = callbackQueryCallback,
|
||||||
|
shippingQueryCallback = shippingQueryCallback,
|
||||||
|
preCheckoutQueryCallback = preCheckoutQueryCallback,
|
||||||
|
pollCallback = pollCallback,
|
||||||
|
pollAnswerCallback = pollAnswerCallback,
|
||||||
|
timeoutSeconds = timeoutSeconds,
|
||||||
|
exceptionsHandler = exceptionsHandler,
|
||||||
|
scope = scope
|
||||||
|
)
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.webhook
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.webhook.DeleteWebhook
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.deleteWebhook() = execute(DeleteWebhook())
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.webhook
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.webhook.GetWebhookInfo
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getWebhookInfo() = execute(GetWebhookInfo())
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.webhook
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.webhook.SetWebhook
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setWebhookInfo(
|
||||||
|
url: String,
|
||||||
|
certificate: FileId,
|
||||||
|
maxAllowedConnections: Int? = null,
|
||||||
|
allowedUpdates: List<String>? = null
|
||||||
|
) = execute(
|
||||||
|
SetWebhook(
|
||||||
|
url, certificate, maxAllowedConnections, allowedUpdates
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setWebhookInfo(
|
||||||
|
url: String,
|
||||||
|
certificate: MultipartFile,
|
||||||
|
maxAllowedConnections: Int? = null,
|
||||||
|
allowedUpdates: List<String>? = null
|
||||||
|
) = execute(
|
||||||
|
SetWebhook(
|
||||||
|
url, certificate, maxAllowedConnections, allowedUpdates
|
||||||
|
)
|
||||||
|
)
|
||||||
203
TelegramBotAPI/README.md
Normal file
203
TelegramBotAPI/README.md
Normal file
@@ -0,0 +1,203 @@
|
|||||||
|
# TelegramBotAPI
|
||||||
|
|
||||||
|
[](https://github.com/KotlinBy/awesome-kotlin)
|
||||||
|
[ ](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI/_latestVersion)
|
||||||
|
[](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI)
|
||||||
|
[](https://jenkins.insanusmokrassar.com/job/TelegramBotAPI_master__publishing/)
|
||||||
|
|
||||||
|
## What is it?
|
||||||
|
|
||||||
|
Library for Object-Oriented and type-safe work with Telegram Bot API. Most part of some specific solves or unuseful
|
||||||
|
moments are describing by official [Telegram Bot API](https://core.telegram.org/bots/api).
|
||||||
|
|
||||||
|
## Compatibility
|
||||||
|
|
||||||
|
This version compatible with [30th of March 2020 update of TelegramBotAPI (version 4.7)](https://core.telegram.org/bots/api#march-30-2020).
|
||||||
|
There is only one exception of implemented functionality - Telegram Passport API, which was presented in
|
||||||
|
[August 2018 update of TelegramBotAPI](https://core.telegram.org/bots/api-changelog#august-27-2018) update. It will be implemented
|
||||||
|
as soon as possible.
|
||||||
|
|
||||||
|
## How to implement library?
|
||||||
|
|
||||||
|
Common ways to implement this library are presented here. In some cases it will require additional steps
|
||||||
|
like inserting of additional libraries (like `kotlin stdlib`). In the examples will be used variable
|
||||||
|
`telegrambotapi.version`, which must be set up by developer. Available versions are presented on
|
||||||
|
[bintray](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI), next version is last published:
|
||||||
|
|
||||||
|
[ ](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI/_latestVersion)
|
||||||
|
|
||||||
|
Currently, last versions of library can be available from the Maven repository with errors (for the reason difficult in publishing
|
||||||
|
of signed artifacts in Bintray). You can:
|
||||||
|
|
||||||
|
* Use earlier version (available version you can find
|
||||||
|
[here](https://mvnrepository.com/artifact/com.github.insanusmokrassar/TelegramBotAPI))
|
||||||
|
* Add `jCenter` repository in build config
|
||||||
|
|
||||||
|
### Maven
|
||||||
|
|
||||||
|
Dependency config presented here:
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.insanusmokrassar</groupId>
|
||||||
|
<artifactId>TelegramBotAPI</artifactId>
|
||||||
|
<version>${telegrambotapi.version}</version>
|
||||||
|
</dependency>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Gradle
|
||||||
|
|
||||||
|
To use last versions you will need to add one line in repositories block of your `build.gradle`:
|
||||||
|
|
||||||
|
`jcenter()` or `mavenCentral()`
|
||||||
|
|
||||||
|
And add next line to your dependencies block:
|
||||||
|
|
||||||
|
```groovy
|
||||||
|
implementation "com.github.insanusmokrassar:TelegramBotAPI:$telegrambotapi_version"
|
||||||
|
```
|
||||||
|
|
||||||
|
or for old gradle:
|
||||||
|
|
||||||
|
```groovy
|
||||||
|
compile "com.github.insanusmokrassar:TelegramBotAPI:$telegrambotapi_version"
|
||||||
|
```
|
||||||
|
|
||||||
|
## How to work with library?
|
||||||
|
|
||||||
|
For now, this library have no some API god-object. Instead of this, this library has several
|
||||||
|
important objects:
|
||||||
|
|
||||||
|
* [RequestsExecutor](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/RequestsExecutor.kt)
|
||||||
|
* [Requests](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests)
|
||||||
|
* [Types](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types)
|
||||||
|
|
||||||
|
### Types
|
||||||
|
|
||||||
|
Types declare different objects representation. For example, `Chat` for now represented as
|
||||||
|
interface and has several realisations:
|
||||||
|
|
||||||
|
* `PrivateChat`
|
||||||
|
* `GroupChat`
|
||||||
|
* `SupergroupChat`
|
||||||
|
* `ChannelChat`
|
||||||
|
|
||||||
|
Instead of common garbage with all information as in original [Chat](https://core.telegram.org/bots/api#chat),
|
||||||
|
here it was separated for more obvious difference between chats types and their possible content.
|
||||||
|
|
||||||
|
The same principle work with a lot of others things in this Telegram bot API.
|
||||||
|
|
||||||
|
### Requests
|
||||||
|
|
||||||
|
Requests usually are very simple objects, but some of them are using their own
|
||||||
|
build factories. For example, the next code show, how to get information about bot:
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
val requestsExecutor: RequestsExecutor = ...
|
||||||
|
requestsExecutor.execute(GetMe())
|
||||||
|
```
|
||||||
|
|
||||||
|
Also there is an alternative syntax for requests (like `requestsExecutor.getMe()` in project
|
||||||
|
[TelegramBotAPI-extensions-api](../TelegramBotAPI-extensions-api/README.md))
|
||||||
|
|
||||||
|
The result type of [GetMe (and getMe extension)](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetMe.kt)
|
||||||
|
request is
|
||||||
|
[ExtendedBot](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/User.kt).
|
||||||
|
|
||||||
|
### RequestsExecutor
|
||||||
|
|
||||||
|
It is base object which can be used to execute requests in API. For now by default included Ktor
|
||||||
|
realisation of `RequestsExecutor`, but it is possible, that in future it will be extracted in separated
|
||||||
|
project. How to create `RequestsExecutor`:
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
val requestsExecutor = KtorRequestsExecutor(
|
||||||
|
TelegramAPIUrlsKeeper(TOKEN)
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
Here:
|
||||||
|
|
||||||
|
* `KtorRequestsExecutor` - default realisation with [ktor](https://ktor.io)
|
||||||
|
* `TelegramAPIUrlsKeeper` - special keeper, which you can save and use for getting files full urls (`resolveFileURL`
|
||||||
|
extension inside of `PathedFile.kt`)
|
||||||
|
* `TOKEN` is just a token of bot which was retrieved according to
|
||||||
|
[instruction](https://core.telegram.org/bots#3-how-do-i-create-a-bot).
|
||||||
|
|
||||||
|
By default, for JVM there is implemented `CIO` client engine, but there is not server engine. Both can be changed like
|
||||||
|
here:
|
||||||
|
|
||||||
|
```groovy
|
||||||
|
dependencies {
|
||||||
|
// ...
|
||||||
|
implementation "io.ktor:ktor-server-cio:$ktor_version" // for implementing of server engine
|
||||||
|
implementation "io.ktor:ktor-client-okhttp:$ktor_version" // for implementing of additional client engine
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
You can avoid using of `server` dependency in case if you will not use `Webhook`s. In this case,
|
||||||
|
dependencies list will be simplify:
|
||||||
|
|
||||||
|
```groovy
|
||||||
|
dependencies {
|
||||||
|
// ...
|
||||||
|
implementation "io.ktor:ktor-client-okhttp:$ktor_version" // for implementing of additional client engine
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Here was used `okhttp` realisation of client, but there are several others engines for Ktor. More information
|
||||||
|
available on ktor.io site for [client](https://ktor.io/clients/http-client/engines.html) and [server](https://ktor.io/quickstart/artifacts.html)
|
||||||
|
engines.
|
||||||
|
|
||||||
|
## Getting updates
|
||||||
|
|
||||||
|
In this library currently realised two ways to get updates from telegram:
|
||||||
|
|
||||||
|
* Polling - in this case bot will request updates from time to time (you can set up delay between requests)
|
||||||
|
* Webhook via reverse proxy or something like this
|
||||||
|
|
||||||
|
### Updates filters
|
||||||
|
|
||||||
|
Currently webhook method contains `UpdatesFilter` as necessary argument for getting updates.
|
||||||
|
`UpdatesFilter` will sort updates and throw their into different callbacks. Currently supporting
|
||||||
|
separate getting updates for media groups - they are accumulating with debounce in one second
|
||||||
|
(for being sure that all objects of media group was received).
|
||||||
|
|
||||||
|
Updates polling also support `UpdatesFilter` but it is not required to use it and you can get updates directly
|
||||||
|
in `UpdateReceiver`, which you will provide to `startGettingOfUpdates` method
|
||||||
|
|
||||||
|
### Webhook set up
|
||||||
|
|
||||||
|
If you wish to use webhook method, you will need:
|
||||||
|
|
||||||
|
* White IP - your IP address or host, which available for calling. [TelegramBotAPI](https://core.telegram.org/bots/api#setwebhook)
|
||||||
|
recommend to use some unique address for each bot which you are using
|
||||||
|
* SSL certificate. Usually you can obtain the certificate using your domain provider, [Let'sEncrypt](https://letsencrypt.org/) or [create it](https://core.telegram.org/bots/self-signed)
|
||||||
|
* Nginx or something like this
|
||||||
|
|
||||||
|
Template for Nginx server config you can find in [this gist](https://gist.github.com/InsanusMokrassar/fcc6e09cebd07e46e8f0fdec234750c4#file-nginxssl-conf).
|
||||||
|
|
||||||
|
For webhook you can provide `File` with public part of certificate, `URL` where bot will be available and inner `PORT` which
|
||||||
|
will be used to start receiving of updates. Actually, you can skip passing of `File` when you have something like
|
||||||
|
nginx for proxy forwarding.
|
||||||
|
|
||||||
|
In case of using `nginx` with reverse-proxy config, setting up of Webhook will look like:
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
requestsExecutor.setWebhook(
|
||||||
|
WEBHOOK_URL,
|
||||||
|
INTERNAL_PORT,
|
||||||
|
filter,
|
||||||
|
ENGINE_FACTORY
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
Here:
|
||||||
|
|
||||||
|
* `WEBHOOK_URL` - the url which will be used by Telegram system to send updates
|
||||||
|
* `INTERNAL_PORT` - the port which will be used in bot for listening of updates
|
||||||
|
* `filter` - instance of [UpdatesFilter](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/updateshandlers/UpdatesFilter.kt),
|
||||||
|
which will be used to filter incoming updates
|
||||||
|
* `ENGINE_FACTORY` - used factory name, for example, `CIO` in case of usage `io.ktor:ktor-server-cio` as server engine
|
||||||
@@ -17,8 +17,8 @@ plugins {
|
|||||||
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version"
|
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
project.version = "0.23.0"
|
project.version = "$library_version"
|
||||||
project.group = "com.github.insanusmokrassar"
|
project.group = "$library_group"
|
||||||
|
|
||||||
apply from: "publish.gradle"
|
apply from: "publish.gradle"
|
||||||
|
|
||||||
@@ -39,6 +39,7 @@ kotlin {
|
|||||||
implementation kotlin('stdlib')
|
implementation kotlin('stdlib')
|
||||||
api "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$kotlin_coroutines_version"
|
api "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$kotlin_coroutines_version"
|
||||||
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$kotlin_serialisation_runtime_version"
|
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$kotlin_serialisation_runtime_version"
|
||||||
|
api "org.jetbrains.kotlinx:kotlinx-serialization-properties-common:$kotlin_serialisation_runtime_version"
|
||||||
|
|
||||||
api "com.soywiz.korlibs.klock:klock:$klock_version"
|
api "com.soywiz.korlibs.klock:klock:$klock_version"
|
||||||
api "com.benasher44:uuid:$uuid_version"
|
api "com.benasher44:uuid:$uuid_version"
|
||||||
@@ -56,6 +57,7 @@ kotlin {
|
|||||||
jvmMain {
|
jvmMain {
|
||||||
dependencies {
|
dependencies {
|
||||||
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$kotlin_serialisation_runtime_version"
|
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$kotlin_serialisation_runtime_version"
|
||||||
|
api "org.jetbrains.kotlinx:kotlinx-serialization-properties:$kotlin_serialisation_runtime_version"
|
||||||
|
|
||||||
api "io.ktor:ktor-client:$ktor_version"
|
api "io.ktor:ktor-client:$ktor_version"
|
||||||
api "io.ktor:ktor-server:$ktor_version"
|
api "io.ktor:ktor-server:$ktor_version"
|
||||||
@@ -73,9 +75,19 @@ kotlin {
|
|||||||
jsMain {
|
jsMain {
|
||||||
dependencies {
|
dependencies {
|
||||||
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$kotlin_serialisation_runtime_version"
|
api "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$kotlin_serialisation_runtime_version"
|
||||||
|
api "org.jetbrains.kotlinx:kotlinx-serialization-properties-js:$kotlin_serialisation_runtime_version"
|
||||||
api "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$kotlin_coroutines_version"
|
api "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$kotlin_coroutines_version"
|
||||||
api "io.ktor:ktor-client-js:$ktor_version"
|
api "io.ktor:ktor-client-js:$ktor_version"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
targets.all {
|
||||||
|
compilations.all {
|
||||||
|
kotlinOptions {
|
||||||
|
freeCompilerArgs += ["-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi", "-Xopt-in=kotlin.RequiresOptIn"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
55
TelegramBotAPI/publish.gradle
Normal file
55
TelegramBotAPI/publish.gradle
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
apply plugin: 'com.jfrog.bintray'
|
||||||
|
|
||||||
|
apply from: "maven.publish.gradle"
|
||||||
|
|
||||||
|
bintray {
|
||||||
|
user = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER')
|
||||||
|
key = project.hasProperty('BINTRAY_KEY') ? project.property('BINTRAY_KEY') : System.getenv('BINTRAY_KEY')
|
||||||
|
filesSpec {
|
||||||
|
from "${buildDir}/publications/"
|
||||||
|
eachFile {
|
||||||
|
String directorySubname = it.getFile().parentFile.name
|
||||||
|
if (it.getName() == "module.json") {
|
||||||
|
if (directorySubname == "kotlinMultiplatform") {
|
||||||
|
it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.module")
|
||||||
|
} else {
|
||||||
|
it.setPath("${project.name}-${directorySubname}/${project.version}/${project.name}-${directorySubname}-${project.version}.module")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (directorySubname == "kotlinMultiplatform" && it.getName() == "pom-default.xml") {
|
||||||
|
it.setPath("${project.name}/${project.version}/${project.name}-${project.version}.pom")
|
||||||
|
} else {
|
||||||
|
it.exclude()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
into "${project.group}".replace(".", "/")
|
||||||
|
}
|
||||||
|
pkg {
|
||||||
|
repo = "StandardRepository"
|
||||||
|
name = "${project.name}"
|
||||||
|
vcsUrl = "https://github.com/InsanusMokrassar/TelegramBotAPI"
|
||||||
|
licenses = ["Apache-2.0"]
|
||||||
|
version {
|
||||||
|
name = "${project.version}"
|
||||||
|
released = new Date()
|
||||||
|
vcsTag = "${project.version}"
|
||||||
|
gpg {
|
||||||
|
sign = true
|
||||||
|
passphrase = project.hasProperty('signing.gnupg.passphrase') ? project.property('signing.gnupg.passphrase') : System.getenv('signing.gnupg.passphrase')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bintrayUpload.doFirst {
|
||||||
|
publications = publishing.publications.collect {
|
||||||
|
if (it.name.contains('kotlinMultiplatform')) {
|
||||||
|
null
|
||||||
|
} else {
|
||||||
|
it.name
|
||||||
|
}
|
||||||
|
} - null
|
||||||
|
}
|
||||||
|
|
||||||
|
bintrayUpload.dependsOn publishToMavenLocal
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user