1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-11-19 13:55:57 +00:00

Compare commits

..

27 Commits

Author SHA1 Message Date
4b980d3f44 remove redundant import from webhooks 2020-03-18 22:58:23 +06:00
b11da02c8b refactor UpdatesUtils 2020-03-18 22:56:57 +06:00
71c0b688e8 fixes and improvements 2020-03-17 21:24:04 +06:00
d61aa8b50e getting updates refactoring 2020-03-17 20:24:31 +06:00
be64287c42 copypaste functions from TelegramBotAPI to TelegramBotAPI-extensions-api with adaptation of updates 2020-03-17 19:50:25 +06:00
e7027047cb abstracts for difference between sent and edited messages updates 2020-03-17 19:46:42 +06:00
944d15f326 new startGettingUpdates method 2020-03-17 17:20:42 +06:00
ba2c4cbb30 UpdatesFilter now is interface 2020-03-17 17:16:14 +06:00
244a1e5175 replacement of UpdatesPolling help functions 2020-03-17 16:59:28 +06:00
9c9a938d94 started 0.24.1 2020-03-17 16:47:59 +06:00
a2a403045b a little fix on README 2020-03-17 13:30:01 +06:00
6858af14f8 update info sections 2020-03-17 13:25:10 +06:00
779009c2a6 Merge pull request #66 from InsanusMokrassar/0.24.0
0.24.0
2020-02-25 21:01:46 +06:00
b22d8a5a25 ForwardFromChannelInfo#channelChat now is ChannelChat 2020-02-25 13:45:32 +06:00
54e3c43999 Most part of sending media messages functions was removed and replaced with their InputFile args analogs 2020-02-23 21:29:31 +06:00
f8a312acb3 removing of deprecations 2020-02-23 20:23:33 +06:00
a51e68be04 Update LICENSE 2020-02-19 22:29:53 +06:00
39dab0b970 Replace build badge and link it with travis 2020-02-19 20:12:54 +06:00
b42a6ca0cf Create .travis.yml 2020-02-19 20:08:15 +06:00
a34e67722b update telegrambotapi-extensions-api readme 2020-02-18 19:10:08 +06:00
c0e660c8d3 replace awesome badge 2020-02-17 15:35:33 +06:00
7cca12930c fixes and fill up 2020-02-17 15:33:28 +06:00
5da60b4ac2 update README 2020-02-17 15:25:08 +06:00
51dac40e45 now for extensions api system environment will be checked too 2020-02-17 11:49:48 +06:00
51fc33960a now group is common 2020-02-17 11:47:43 +06:00
b89b798eb6 remove redundant readme 2020-02-15 16:58:26 +06:00
a9326bb374 Merge pull request #65 from InsanusMokrassar/0.23.3
0.23.3
2020-02-15 16:57:29 +06:00
82 changed files with 557 additions and 2921 deletions

10
.travis.yml Normal file
View File

@@ -0,0 +1,10 @@
language: java
install: true
os: linux
dist: trusty
jdk: oraclejdk8
script:
- ./gradlew build -s

View File

@@ -1,5 +1,40 @@
# TelegramBotAPI changelog # TelegramBotAPI changelog
## 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

View File

@@ -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.

259
README.md
View File

@@ -1,250 +1,27 @@
# TelegramBotAPI # TelegramBotAPI
[![Awesome Kotlin Badge](https://kotlin.link/awesome-kotlin.svg)](https://github.com/KotlinBy/awesome-kotlin) | Common info | [![Awesome Kotlin Badge](https://kotlin.link/awesome-kotlin.svg)](https://github.com/KotlinBy/awesome-kotlin) [![Chat in Telegram](badges/chat.svg)](https://t.me/InMoTelegramBotAPI) [![Build Status](https://travis-ci.com/InsanusMokrassar/TelegramBotAPI.svg?branch=master)](https://travis-ci.com/InsanusMokrassar/TelegramBotAPI) |
[![Download](https://api.bintray.com/packages/insanusmokrassar/StandardRepository/TelegramBotAPI/images/download.svg) ](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI/_latestVersion) | -----------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI) | TelegramBotAPI status | [![Download](https://api.bintray.com/packages/insanusmokrassar/StandardRepository/TelegramBotAPI/images/download.svg)](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI/_latestVersion) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI) |
[![Build Status](https://jenkins.insanusmokrassar.com/buildStatus/icon?job=TelegramBotAPI_master__publishing)](https://jenkins.insanusmokrassar.com/job/TelegramBotAPI_master__publishing/) | TelegramBotAPI Extensions status | [![Download](https://api.bintray.com/packages/insanusmokrassar/StandardRepository/TelegramBotAPI-extensions-api/images/download.svg)](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI-extensions-api/_latestVersion) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI-extensions-api/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI-extensions-api) |
[![Chat in Telegram](badges/chat.svg)](https://t.me/InMoTelegramBotAPI)
## What is it? It is a complex of libraries for working with `TelegramBotAPI` in type-safe and strict way as much as it possible. In
the list of this complex currently next projects:
Library for Object-Oriented and type-safe work with Telegram Bot API. Most part of some specific solves or unuseful * [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-changelog#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:
[![Download](https://api.bintray.com/packages/insanusmokrassar/StandardRepository/TelegramBotAPI/images/download.svg) ](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
### TelegramBotAPI
Contains core and most required things, like types, requests and `KtorRequestsExecutor`.
#### 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"
```
### API extensions
Contains extensions for `RequestsExecutor` which usually more obvious than original ones in `TelegramBotAPI` and more
useful.
#### Maven
Dependency config presented here:
```xml
<dependency>
<groupId>com.github.insanusmokrassar</groupId>
<artifactId>TelegramBotAPI-extensions-api</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-extensions-api:$telegrambotapi_version"
```
or for old gradle:
```groovy
compile "com.github.insanusmokrassar:TelegramBotAPI-extensions-api:$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())
```
Or you can use new syntax (available by implementing of project [API extensions](#API-extensions):
```kotlin
val bot: RequestsExecutor = ...
bot.getMe()
```
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

View File

@@ -0,0 +1,75 @@
# TelegramBotAPI extensions
[![Awesome Kotlin Badge](https://kotlin.link/awesome-kotlin.svg)](https://github.com/KotlinBy/awesome-kotlin)
[![Download](https://api.bintray.com/packages/insanusmokrassar/StandardRepository/TelegramBotAPI-extensions-api/images/download.svg) ](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI-extensions-api/_latestVersion)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI-extensions-api/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI-extensions-api)
[![Build Status](https://jenkins.insanusmokrassar.com/buildStatus/icon?job=TelegramBotAPI-extensions-api_master__publishing)](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:
[![Download](https://api.bintray.com/packages/insanusmokrassar/StandardRepository/TelegramBotAPI-extensions-api/images/download.svg) ](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`
As said in [TelegramBotAPI](../TelegramBotAPI/README.md#Requests), it is possible to use next syntax for requests:
```kotlin
val requestsExecutor: RequestsExecutor = ...
requestsExecutor.execute(GetMe())
```
This library offer a little bit another way for this:
```kotlin
val bot: RequestsExecutor = ...
bot.getMe()
```
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).

View File

@@ -18,7 +18,7 @@ plugins {
} }
project.version = "$library_version" project.version = "$library_version"
project.group = "com.github.insanusmokrassar" project.group = "$library_group"
apply from: "publish.gradle" apply from: "publish.gradle"
@@ -37,7 +37,7 @@ kotlin {
commonMain { commonMain {
dependencies { dependencies {
implementation kotlin('stdlib') implementation kotlin('stdlib')
if (project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") { if ((project.hasProperty('RELEASE_MODE') && project.property('RELEASE_MODE') == "true") || System.getenv('RELEASE_MODE') == "true") {
api "${project.group}:TelegramBotAPI:$library_version" api "${project.group}:TelegramBotAPI:$library_version"
} else { } else {
implementation project(":TelegramBotAPI") implementation project(":TelegramBotAPI")

View File

@@ -2,14 +2,13 @@ package com.github.insanusmokrassar.TelegramBotAPI.extensions.api
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.GetUpdates import com.github.insanusmokrassar.TelegramBotAPI.requests.GetUpdates
import com.github.insanusmokrassar.TelegramBotAPI.types.ALL_UPDATES_LIST import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
suspend fun RequestsExecutor.getUpdates( suspend fun RequestsExecutor.getUpdates(
offset: UpdateIdentifier? = null, offset: UpdateIdentifier? = null,
limit: Int? = null, limit: Int? = null,
timeout: Int? = null, timeout: Seconds? = null,
allowed_updates: List<String>? = ALL_UPDATES_LIST allowed_updates: List<String>? = ALL_UPDATES_LIST
) = execute( ) = execute(
GetUpdates( GetUpdates(
@@ -20,7 +19,7 @@ suspend fun RequestsExecutor.getUpdates(
suspend fun RequestsExecutor.getUpdates( suspend fun RequestsExecutor.getUpdates(
lastUpdate: Update, lastUpdate: Update,
limit: Int? = null, limit: Int? = null,
timeout: Int? = null, timeout: Seconds? = null,
allowed_updates: List<String>? = ALL_UPDATES_LIST allowed_updates: List<String>? = ALL_UPDATES_LIST
) = getUpdates( ) = getUpdates(
lastUpdate.updateId + 1, limit, timeout, allowed_updates lastUpdate.updateId + 1, limit, timeout, allowed_updates

View File

@@ -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) {
when (update) {
is BaseEditMessageUpdate -> resultUpdates.add(
update.toEditMediaGroupUpdate()
)
is BaseSentMessageUpdate -> {
val data = update.data
if (data is MediaGroupMessage) {
mediaGroups.getOrPut(data.mediaGroupId) {
mutableListOf()
}.add(update)
} else {
resultUpdates.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}")
}
}

View File

@@ -1,8 +1,7 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendAnimation import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendAnimation
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
@@ -13,8 +12,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize
suspend fun RequestsExecutor.sendAnimation( suspend fun RequestsExecutor.sendAnimation(
chatId: ChatIdentifier, chatId: ChatIdentifier,
animation: FileId, animation: InputFile,
thumb: FileId? = null, thumb: InputFile? = null,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
duration: Long? = null, duration: Long? = null,
@@ -42,104 +41,6 @@ suspend fun RequestsExecutor.sendAnimation(
suspend fun RequestsExecutor.sendAnimation( suspend fun RequestsExecutor.sendAnimation(
chatId: ChatIdentifier, chatId: ChatIdentifier,
animation: AnimationFile, animation: AnimationFile,
thumb: PhotoSize? = animation.thumb,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAnimation(
chatId, animation.fileId, thumb ?.fileId, text, parseMode, animation.duration, animation.width, animation.height, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendAnimation(
chatId: ChatIdentifier,
animation: MultipartFile,
thumb: FileId? = 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: MultipartFile,
thumb: MultipartFile? = 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: FileId,
thumb: MultipartFile,
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: MultipartFile,
thumb: PhotoSize? = null,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
duration: Long? = null, duration: Long? = null,
@@ -149,19 +50,6 @@ suspend fun RequestsExecutor.sendAnimation(
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendAnimation( ) = sendAnimation(
chatId, animation, thumb ?.fileId , text, parseMode, duration, width, height, disableNotification, replyToMessageId, replyMarkup chatId, animation.fileId, animation.thumb ?.fileId, text, parseMode, duration, width, height, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendAnimation(
chatId: ChatIdentifier,
animation: AnimationFile,
thumb: MultipartFile,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAnimation(
chatId, animation.fileId, thumb, text, parseMode, animation.duration, animation.width, animation.height, disableNotification, replyToMessageId, replyMarkup
) )

View File

@@ -1,8 +1,7 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendAudio import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendAudio
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
@@ -13,8 +12,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize
suspend fun RequestsExecutor.sendAudio( suspend fun RequestsExecutor.sendAudio(
chatId: ChatIdentifier, chatId: ChatIdentifier,
audio: FileId, audio: InputFile,
thumb: FileId? = null, thumb: InputFile? = null,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
duration: Long? = null, duration: Long? = null,
@@ -42,7 +41,6 @@ suspend fun RequestsExecutor.sendAudio(
suspend fun RequestsExecutor.sendAudio( suspend fun RequestsExecutor.sendAudio(
chatId: ChatIdentifier, chatId: ChatIdentifier,
audio: AudioFile, audio: AudioFile,
thumb: PhotoSize? = audio.thumb,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
title: String? = audio.title, title: String? = audio.title,
@@ -50,119 +48,5 @@ suspend fun RequestsExecutor.sendAudio(
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendAudio( ) = sendAudio(
chatId, audio.fileId, thumb ?.fileId, text, parseMode, audio.duration, audio.performer, title, disableNotification, replyToMessageId, replyMarkup chatId, audio.fileId, audio.thumb ?.fileId, text, parseMode, audio.duration, audio.performer, title, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendAudio(
chatId: ChatIdentifier,
audio: MultipartFile,
thumb: FileId? = 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: MultipartFile,
thumb: MultipartFile? = 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: FileId,
thumb: MultipartFile,
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: MultipartFile,
thumb: PhotoSize? = 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
) = sendAudio(
chatId, audio, thumb ?.fileId , text, parseMode, duration, performer, title, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendAudio(
chatId: ChatIdentifier,
audio: AudioFile,
thumb: MultipartFile,
text: String? = null,
parseMode: ParseMode? = null,
title: String? = audio.title,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAudio(
chatId, audio.fileId, thumb, text, parseMode, audio.duration, audio.performer, title, disableNotification, replyToMessageId, replyMarkup
) )

View File

@@ -1,8 +1,7 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendDocument import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendDocument
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
@@ -13,8 +12,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize
suspend fun RequestsExecutor.sendDocument( suspend fun RequestsExecutor.sendDocument(
chatId: ChatIdentifier, chatId: ChatIdentifier,
document: FileId, document: InputFile,
thumb: FileId? = null, thumb: InputFile? = null,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
disableNotification: Boolean = false, disableNotification: Boolean = false,
@@ -36,104 +35,11 @@ suspend fun RequestsExecutor.sendDocument(
suspend fun RequestsExecutor.sendDocument( suspend fun RequestsExecutor.sendDocument(
chatId: ChatIdentifier, chatId: ChatIdentifier,
document: DocumentFile, document: DocumentFile,
thumb: PhotoSize? = document.thumb,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendDocument( ) = sendDocument(
chatId, document.fileId, thumb ?.fileId, text, parseMode, disableNotification, replyToMessageId, replyMarkup chatId, document.fileId, document.thumb ?.fileId, text, parseMode, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendDocument(
chatId: ChatIdentifier,
document: MultipartFile,
thumb: FileId? = 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: MultipartFile,
thumb: MultipartFile? = 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: FileId,
thumb: MultipartFile,
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: MultipartFile,
thumb: PhotoSize? = null,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendDocument(
chatId, document, thumb ?.fileId , text, parseMode, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendDocument(
chatId: ChatIdentifier,
document: DocumentFile,
thumb: MultipartFile,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendDocument(
chatId, document.fileId, thumb, text, parseMode, disableNotification, replyToMessageId, replyMarkup
) )

View File

@@ -1,8 +1,7 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendPhoto import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendPhoto
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
@@ -13,7 +12,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.files.*
suspend fun RequestsExecutor.sendPhoto( suspend fun RequestsExecutor.sendPhoto(
chatId: ChatIdentifier, chatId: ChatIdentifier,
fileId: FileId, fileId: InputFile,
caption: String? = null, caption: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
disableNotification: Boolean = false, disableNotification: Boolean = false,
@@ -30,107 +29,3 @@ suspend fun RequestsExecutor.sendPhoto(
replyMarkup replyMarkup
) )
) )
suspend fun RequestsExecutor.sendPhoto(
chatId: ChatIdentifier,
photo: MultipartFile,
caption: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendPhoto(
chatId,
photo,
caption,
parseMode,
disableNotification,
replyToMessageId,
replyMarkup
)
)
suspend fun RequestsExecutor.sendPhoto(
chatId: ChatIdentifier,
file: PhotoSize,
caption: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(
chatId, file.fileId, caption, parseMode, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendPhoto(
chatId: ChatIdentifier,
photo: Photo,
caption: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(
chatId, photo.biggest() ?: throw IllegalArgumentException("Photo $photo is empty"), caption, parseMode, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendPhoto(
chat: Chat,
fileId: FileId,
caption: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(
chat.id,
fileId,
caption,
parseMode,
disableNotification,
replyToMessageId,
replyMarkup
)
suspend fun RequestsExecutor.sendPhoto(
chat: Chat,
file: PhotoSize,
caption: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(
chat.id, file.fileId, caption, parseMode, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendPhoto(
chat: Chat,
photo: Photo,
caption: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(
chat.id, photo.biggest() ?: throw IllegalArgumentException("Photo $photo is empty"), caption, parseMode, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendPhoto(
chat: Chat,
fileId: MultipartFile,
caption: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(
chat.id,
fileId,
caption,
parseMode,
disableNotification,
replyToMessageId,
replyMarkup
)

View File

@@ -1,8 +1,7 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendSticker import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendSticker
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
@@ -12,55 +11,10 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.files.Sticker
suspend fun RequestsExecutor.sendSticker( suspend fun RequestsExecutor.sendSticker(
chatId: ChatIdentifier, chatId: ChatIdentifier,
sticker: FileId, sticker: InputFile,
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = execute( ) = execute(
SendSticker(chatId, sticker, disableNotification, replyToMessageId, replyMarkup) SendSticker(chatId, sticker, disableNotification, replyToMessageId, replyMarkup)
) )
suspend fun RequestsExecutor.sendSticker(
chatId: ChatIdentifier,
sticker: MultipartFile,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendSticker(chatId, sticker, disableNotification, replyToMessageId, replyMarkup)
)
suspend fun RequestsExecutor.sendSticker(
chat: Chat,
sticker: FileId,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendSticker(chat.id, sticker, disableNotification, replyToMessageId, replyMarkup)
suspend fun RequestsExecutor.sendSticker(
chat: Chat,
sticker: MultipartFile,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendSticker(chat.id, sticker, disableNotification, replyToMessageId, replyMarkup)
suspend fun RequestsExecutor.sendSticker(
chatId: ChatIdentifier,
sticker: Sticker,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendSticker(
chatId, sticker.fileId, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendSticker(
chat: Chat,
sticker: Sticker,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendSticker(chat.id, sticker.fileId, disableNotification, replyToMessageId, replyMarkup)

View File

@@ -1,8 +1,7 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendVideo import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendVideo
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
@@ -13,8 +12,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.files.VideoFile
suspend fun RequestsExecutor.sendVideo( suspend fun RequestsExecutor.sendVideo(
chatId: ChatIdentifier, chatId: ChatIdentifier,
video: FileId, video: InputFile,
thumb: FileId? = null, thumb: InputFile? = null,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
duration: Long? = null, duration: Long? = null,
@@ -43,93 +42,11 @@ suspend fun RequestsExecutor.sendVideo(
suspend fun RequestsExecutor.sendVideo( suspend fun RequestsExecutor.sendVideo(
chatId: ChatIdentifier, chatId: ChatIdentifier,
video: VideoFile, video: VideoFile,
thumb: PhotoSize? = video.thumb,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendVideo( ) = sendVideo(
chatId, video.fileId, thumb ?.fileId, text, parseMode, video.duration, video.width, video.height, disableNotification, replyToMessageId, replyMarkup chatId, video.fileId, video.thumb ?.fileId, text, parseMode, video.duration, video.width, video.height, disableNotification, replyToMessageId, replyMarkup
) )
suspend fun RequestsExecutor.sendVideo(
chatId: ChatIdentifier,
video: MultipartFile,
thumb: FileId? = null,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
supportStreaming: Boolean? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendVideo(chatId, video, thumb, text, parseMode, duration, width, height, supportStreaming, disableNotification, replyToMessageId, replyMarkup)
)
suspend fun RequestsExecutor.sendVideo(
chatId: ChatIdentifier,
video: MultipartFile,
thumb: MultipartFile? = null,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
supportStreaming: Boolean? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendVideo(chatId, video, thumb, text, parseMode, duration, width, height, supportStreaming, disableNotification, replyToMessageId, replyMarkup)
)
suspend fun RequestsExecutor.sendVideo(
chatId: ChatIdentifier,
video: FileId,
thumb: MultipartFile,
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: MultipartFile,
thumb: PhotoSize? = null,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
supportStreaming: Boolean? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(
chatId, video, thumb ?.fileId , text, parseMode, duration, width, height, supportStreaming, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendVideo(
chatId: ChatIdentifier,
video: VideoFile,
thumb: MultipartFile,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(
chatId, video.fileId, thumb, text, parseMode, video.duration, video.width, video.height, disableNotification, replyToMessageId, replyMarkup
)

View File

@@ -1,8 +1,7 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendVideoNote import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendVideoNote
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
@@ -13,8 +12,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.files.VideoFile
suspend fun RequestsExecutor.sendVideoNote( suspend fun RequestsExecutor.sendVideoNote(
chatId: ChatIdentifier, chatId: ChatIdentifier,
videoNote: FileId, videoNote: InputFile,
thumb: FileId? = null, thumb: InputFile? = null,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
duration: Long? = null, duration: Long? = null,
@@ -40,118 +39,11 @@ suspend fun RequestsExecutor.sendVideoNote(
suspend fun RequestsExecutor.sendVideoNote( suspend fun RequestsExecutor.sendVideoNote(
chatId: ChatIdentifier, chatId: ChatIdentifier,
videoNote: VideoFile, videoNote: VideoFile,
thumb: PhotoSize? = videoNote.thumb,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendVideoNote( ) = sendVideoNote(
chatId, videoNote.fileId, thumb ?.fileId, text, parseMode, videoNote.duration, videoNote.width, disableNotification, replyToMessageId, replyMarkup chatId, videoNote.fileId, videoNote.thumb ?.fileId, text, parseMode, videoNote.duration, videoNote.width, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendVideoNote(
chatId: ChatIdentifier,
videoNote: MultipartFile,
thumb: FileId? = 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: MultipartFile,
thumb: MultipartFile? = 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: FileId,
thumb: MultipartFile,
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: MultipartFile,
thumb: PhotoSize? = null,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
size: Int? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideoNote(
chatId, videoNote, thumb ?.fileId , text, parseMode, duration, size, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendVideoNote(
chatId: ChatIdentifier,
videoNote: VideoFile,
thumb: MultipartFile,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideoNote(
chatId, videoNote.fileId, thumb, text, parseMode, videoNote.duration, videoNote.width, disableNotification, replyToMessageId, replyMarkup
) )

View File

@@ -1,8 +1,7 @@
package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media package com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.FileId import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendVoice import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendVoice
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
@@ -13,8 +12,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize
suspend fun RequestsExecutor.sendVoice( suspend fun RequestsExecutor.sendVoice(
chatId: ChatIdentifier, chatId: ChatIdentifier,
voice: FileId, voice: InputFile,
thumb: FileId? = null, thumb: InputFile? = null,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
duration: Long? = null, duration: Long? = null,
@@ -38,112 +37,11 @@ suspend fun RequestsExecutor.sendVoice(
suspend fun RequestsExecutor.sendVoice( suspend fun RequestsExecutor.sendVoice(
chatId: ChatIdentifier, chatId: ChatIdentifier,
voice: AudioFile, voice: AudioFile,
thumb: PhotoSize? = voice.thumb,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
disableNotification: Boolean = false, disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null, replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendVoice( ) = sendVoice(
chatId, voice.fileId, thumb ?.fileId, text, parseMode, voice.duration, disableNotification, replyToMessageId, replyMarkup chatId, voice.fileId, voice.thumb ?.fileId, text, parseMode, voice.duration, disableNotification, replyToMessageId, replyMarkup
) )
suspend fun RequestsExecutor.sendVoice(
chatId: ChatIdentifier,
voice: MultipartFile,
thumb: FileId? = 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: MultipartFile,
thumb: MultipartFile? = 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: FileId,
thumb: MultipartFile,
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: MultipartFile,
thumb: PhotoSize? = null,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVoice(
chatId, voice, thumb ?.fileId , text, parseMode, duration, disableNotification, replyToMessageId, replyMarkup
)
suspend fun RequestsExecutor.sendVoice(
chatId: ChatIdentifier,
voice: AudioFile,
thumb: MultipartFile,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVoice(
chatId, voice.fileId, thumb, text, parseMode, voice.duration, disableNotification, replyToMessageId, replyMarkup
)

View File

@@ -0,0 +1,137 @@
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.Seconds
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
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),
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
).convertWithMediaGroupUpdates()
supervisorScope {
for (update in updates) {
updatesReceiver(update)
lastUpdateIdentifier = update.lastUpdateIdentifier()
}
}
}
} catch (e: HttpRequestTimeoutException) {
e // it is ok due to mechanism of long polling
} catch (e: RequestException) {
e // it is not ok, but in most cases it will mean that there is some limit for requests count
delay(1000L)
}
}
}
fun RequestsExecutor.startGettingOfUpdates(
updatesFilter: UpdatesFilter,
timeoutSeconds: Seconds = 30,
scope: CoroutineScope = CoroutineScope(Dispatchers.Default)
): Job = startGettingOfUpdates(
timeoutSeconds,
scope,
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,
scope: CoroutineScope = GlobalScope
): Job {
return startGettingOfUpdates(
SimpleUpdatesFilter(
messageCallback,
messageMediaGroupCallback,
editedMessageCallback,
editedMessageMediaGroupCallback,
channelPostCallback,
channelPostMediaGroupCallback,
editedChannelPostCallback,
editedChannelPostMediaGroupCallback,
chosenInlineResultCallback,
inlineQueryCallback,
callbackQueryCallback,
shippingQueryCallback,
preCheckoutQueryCallback,
pollCallback,
pollAnswerCallback
),
timeoutSeconds,
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,
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,
scope = scope
)

View File

@@ -69,9 +69,9 @@ compile "com.github.insanusmokrassar:TelegramBotAPI:$telegrambotapi_version"
For now, this library have no some API god-object. Instead of this, this library has several For now, this library have no some API god-object. Instead of this, this library has several
important objects: important objects:
* [RequestsExecutor](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/bot/RequestsExecutor.kt) * [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/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests) * [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/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types) * [Types](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types)
### Types ### Types
@@ -98,16 +98,12 @@ val requestsExecutor: RequestsExecutor = ...
requestsExecutor.execute(GetMe()) requestsExecutor.execute(GetMe())
``` ```
Or you can use new syntax: Also there is an alternative syntax for requests (like `requestsExecutor.getMe()` in project
[TelegramBotAPI-extensions-api](../TelegramBotAPI-extensions-api/README.md))
```kotlin 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)
val bot: RequestsExecutor = ...
bot.getMe()
```
The result type of [GetMe (and getMe extension)](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/GetMe.kt)
request is request is
[ExtendedBot](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/User.kt). [ExtendedBot](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/User.kt).
### RequestsExecutor ### RequestsExecutor
@@ -203,6 +199,6 @@ Here:
* `WEBHOOK_URL` - the url which will be used by Telegram system to send updates * `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 * `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), * `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 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 * `ENGINE_FACTORY` - used factory name, for example, `CIO` in case of usage `io.ktor:ktor-server-cio` as server engine

View File

@@ -18,7 +18,7 @@ plugins {
} }
project.version = "$library_version" project.version = "$library_version"
project.group = "com.github.insanusmokrassar" project.group = "$library_group"
apply from: "publish.gradle" apply from: "publish.gradle"

View File

@@ -13,14 +13,16 @@ import com.github.insanusmokrassar.TelegramBotAPI.utils.TelegramAPIUrlsKeeper
import io.ktor.client.HttpClient import io.ktor.client.HttpClient
import io.ktor.client.call.receive import io.ktor.client.call.receive
import io.ktor.client.features.ClientRequestException import io.ktor.client.features.ClientRequestException
import io.ktor.client.features.HttpTimeout
import io.ktor.client.statement.HttpStatement import io.ktor.client.statement.HttpStatement
import io.ktor.client.statement.readText import io.ktor.client.statement.readText
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.supervisorScope
import kotlinx.serialization.json.Json import kotlinx.serialization.json.Json
class KtorRequestsExecutor( class KtorRequestsExecutor(
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper, telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
private val client: HttpClient = HttpClient(), client: HttpClient = HttpClient(),
callsFactories: List<KtorCallFactory> = emptyList(), callsFactories: List<KtorCallFactory> = emptyList(),
excludeDefaultFactories: Boolean = false, excludeDefaultFactories: Boolean = false,
private val requestsLimiter: RequestLimiter = EmptyLimiter, private val requestsLimiter: RequestLimiter = EmptyLimiter,
@@ -34,50 +36,59 @@ class KtorRequestsExecutor(
} }
} }
private val client = client.config {
install(HttpTimeout)
}
override suspend fun <T : Any> execute(request: Request<T>): T { override suspend fun <T : Any> execute(request: Request<T>): T {
return requestsLimiter.limit { return try {
var statement: HttpStatement? = null supervisorScope {
for (factory in callsFactories) { requestsLimiter.limit {
statement = factory.prepareCall( var statement: HttpStatement? = null
client, for (factory in callsFactories) {
telegramAPIUrlsKeeper.commonAPIUrl, statement = factory.prepareCall(
request client,
) telegramAPIUrlsKeeper.commonAPIUrl,
if (statement != null) { request
break )
if (statement != null) {
break
}
}
val response = statement?.execute() ?: throw IllegalArgumentException("Can't execute request: $request")
val content = response.receive<String>()
val responseObject = jsonFormatter.parse(Response.serializer(), content)
(responseObject.result?.let {
jsonFormatter.fromJson(request.resultDeserializer, it)
} ?: responseObject.parameters?.let {
val error = it.error
if (error is RetryAfterError) {
delay(error.leftToRetry)
execute(request)
} else {
null
}
} ?: response.let {
throw newRequestException(
responseObject,
content,
"Can't get result object from $content"
)
})
} }
} }
try { } catch (e: ClientRequestException) {
val response = statement ?.execute() ?: throw IllegalArgumentException("Can't execute request: $request") val content = e.response.readText()
val content = response.receive<String>() val responseObject = jsonFormatter.parse(Response.serializer(), content)
val responseObject = jsonFormatter.parse(Response.serializer(), content) throw newRequestException(
responseObject,
(responseObject.result?.let { content,
jsonFormatter.fromJson(request.resultDeserializer, it) "Can't get result object from $content"
} ?: responseObject.parameters?.let { )
val error = it.error } catch (e: Exception) {
if (error is RetryAfterError) { throw e
delay(error.leftToRetry)
execute(request)
} else {
null
}
} ?: response.let {
throw newRequestException(
responseObject,
content,
"Can't get result object from $content"
)
})
} catch (e: ClientRequestException) {
val content = e.response.readText()
val responseObject = jsonFormatter.parse(Response.serializer(), content)
throw newRequestException(
responseObject,
content,
"Can't get result object from $content"
)
}
} }
} }

View File

@@ -1,8 +1,10 @@
package com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.base package com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.base
import com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.KtorCallFactory import com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.KtorCallFactory
import com.github.insanusmokrassar.TelegramBotAPI.requests.GetUpdates
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
import io.ktor.client.HttpClient import io.ktor.client.HttpClient
import io.ktor.client.features.timeout
import io.ktor.client.request.* import io.ktor.client.request.*
import io.ktor.client.statement.HttpStatement import io.ktor.client.statement.HttpStatement
import io.ktor.http.ContentType import io.ktor.http.ContentType
@@ -28,6 +30,16 @@ abstract class AbstractRequestCallFactory : KtorCallFactory {
method = HttpMethod.Post method = HttpMethod.Post
accept(ContentType.Application.Json) accept(ContentType.Application.Json)
if (request is GetUpdates) {
request.timeout ?.times(1000L) ?.let { customTimeoutMillis ->
if (customTimeoutMillis > 0) {
timeout {
requestTimeoutMillis = customTimeoutMillis
}
}
}
}
body = preparedBody body = preparedBody
}, },
client client

View File

@@ -4,6 +4,7 @@ import io.ktor.utils.io.core.Closeable
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@Deprecated("Deprecated due to more simple way to get updates using TelegramBotAPI-extensions-api")
interface UpdatesPoller : Closeable { interface UpdatesPoller : Closeable {
fun start(scope: CoroutineScope = CoroutineScope(Dispatchers.Default)) fun start(scope: CoroutineScope = CoroutineScope(Dispatchers.Default))
} }

View File

@@ -23,26 +23,3 @@ data class DeleteMessage(
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.deleteMessage(
chatId: ChatIdentifier,
messageId: MessageIdentifier
) = execute(
DeleteMessage(chatId, messageId)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.deleteMessage(
chat: Chat,
messageId: MessageIdentifier
) = deleteMessage(chat.id, messageId)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.deleteMessage(
message: Message
) = deleteMessage(message.chat, message.messageId)
suspend fun Message.delete(
requestsExecutor: RequestsExecutor
) = requestsExecutor.deleteMessage(this)

View File

@@ -31,51 +31,3 @@ data class ForwardMessage(
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.forwardMessage(
fromChatId: ChatIdentifier,
toChatId: ChatIdentifier,
messageId: MessageIdentifier,
disableNotification: Boolean = false
) = execute(
ForwardMessage(fromChatId, toChatId, messageId, disableNotification)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.forwardMessage(
fromChat: Chat,
toChatId: ChatIdentifier,
messageId: MessageIdentifier,
disableNotification: Boolean = false
) = forwardMessage(fromChat.id, toChatId, messageId, disableNotification)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.forwardMessage(
fromChatId: ChatIdentifier,
toChat: Chat,
messageId: MessageIdentifier,
disableNotification: Boolean = false
) = forwardMessage(fromChatId, toChat.id, messageId, disableNotification)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.forwardMessage(
fromChat: Chat,
toChat: Chat,
messageId: MessageIdentifier,
disableNotification: Boolean = false
) = forwardMessage(fromChat.id, toChat.id, messageId, disableNotification)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.forwardMessage(
toChatId: ChatIdentifier,
message: Message,
disableNotification: Boolean = false
) = forwardMessage(message.chat, toChatId, message.messageId, disableNotification)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.forwardMessage(
toChat: Chat,
message: Message,
disableNotification: Boolean = false
) = forwardMessage(message.chat, toChat, message.messageId, disableNotification)

View File

@@ -13,6 +13,3 @@ class GetMe : SimpleRequest<ExtendedBot> {
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.getMe() = execute(GetMe())

View File

@@ -1,9 +1,7 @@
package com.github.insanusmokrassar.TelegramBotAPI.requests package com.github.insanusmokrassar.TelegramBotAPI.requests
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
import com.github.insanusmokrassar.TelegramBotAPI.types.ALL_UPDATES_LIST import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.UpdateSerializerWithoutDeserialization import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.UpdateSerializerWithoutDeserialization
import kotlinx.serialization.* import kotlinx.serialization.*
@@ -17,7 +15,7 @@ private val updatesListSerializer = ArrayListSerializer(
data class GetUpdates( data class GetUpdates(
val offset: UpdateIdentifier? = null,// set `last update id + 1` to receive next part of updates val offset: UpdateIdentifier? = null,// set `last update id + 1` to receive next part of updates
val limit: Int? = null, val limit: Int? = null,
val timeout: Int? = null, val timeout: Seconds? = null,
val allowed_updates: List<String>? = ALL_UPDATES_LIST val allowed_updates: List<String>? = ALL_UPDATES_LIST
): SimpleRequest<List<Update>> { ): SimpleRequest<List<Update>> {
override fun method(): String = "getUpdates" override fun method(): String = "getUpdates"
@@ -28,25 +26,3 @@ data class GetUpdates(
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.getUpdates(
offset: UpdateIdentifier? = null,
limit: Int? = null,
timeout: Int? = null,
allowed_updates: List<String>? = ALL_UPDATES_LIST
) = execute(
GetUpdates(
offset, limit, timeout, allowed_updates
)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.getUpdates(
lastUpdate: Update,
limit: Int? = null,
timeout: Int? = null,
allowed_updates: List<String>? = ALL_UPDATES_LIST
) = getUpdates(
lastUpdate.updateId + 1, limit, timeout, allowed_updates
)

View File

@@ -1,140 +0,0 @@
package com.github.insanusmokrassar.TelegramBotAPI.requests
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.edit.LiveLocation.editLiveLocation
import com.github.insanusmokrassar.TelegramBotAPI.requests.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
@Deprecated("Deprecated due to extracting into separated library")
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()
}
}
@Deprecated("Deprecated due to extracting into separated library")
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
)
}
@Deprecated("Deprecated due to extracting into separated library")
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
)
@Deprecated("Deprecated due to extracting into separated library")
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
)
@Deprecated("Deprecated due to extracting into separated library")
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
)

View File

@@ -26,33 +26,3 @@ data class StopPoll(
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.stopPoll(
chatId: ChatIdentifier,
messageId: MessageIdentifier,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(
StopPoll(chatId, messageId, replyMarkup)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.stopPoll(
chat: Chat,
messageId: MessageIdentifier,
replyMarkup: InlineKeyboardMarkup? = null
) = stopPoll(chat.id, messageId, replyMarkup)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.stopPoll(
chatId: ChatId,
message: Message,
replyMarkup: InlineKeyboardMarkup? = null
) = stopPoll(chatId, message.messageId, replyMarkup)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.stopPoll(
chat: Chat,
message: Message,
replyMarkup: InlineKeyboardMarkup? = null
) = stopPoll(chat.id, message.messageId, replyMarkup)

View File

@@ -33,21 +33,3 @@ fun CallbackQuery.createAnswer(
url: String? = null, url: String? = null,
cachedTimeSeconds: Int? = null cachedTimeSeconds: Int? = null
): AnswerCallbackQuery = AnswerCallbackQuery(id, text, showAlert, url, cachedTimeSeconds) ): AnswerCallbackQuery = AnswerCallbackQuery(id, text, showAlert, url, cachedTimeSeconds)
@Deprecated("Deprecated due to extracting into separated library")
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))
@Deprecated("Deprecated due to extracting into separated library")
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)

View File

@@ -52,30 +52,6 @@ fun InlineQuery.createAnswer(
switchPmParameter switchPmParameter
) )
@Deprecated("Deprecated due to extracting into separated library")
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)
)
@Deprecated("Deprecated due to extracting into separated library")
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)
internal object InlineQueryAnswersResultsSerializer: KSerializer<List<InlineQueryResult>> by ArrayListSerializer( internal object InlineQueryAnswersResultsSerializer: KSerializer<List<InlineQueryResult>> by ArrayListSerializer(
InlineQueryResultSerializer InlineQueryResultSerializer
) )

View File

@@ -41,23 +41,3 @@ fun PreCheckoutQuery.createAnswerError(
id, id,
error error
) )
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.answerPreCheckoutQueryOk(
id: PreCheckoutQueryId
) = execute(AnswerPreCheckoutQueryOk(id))
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.answerPreCheckoutQueryOk(
preCheckoutQuery: PreCheckoutQuery
) = answerPreCheckoutQueryOk(preCheckoutQuery.id)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.answerPreCheckoutQueryError(
id: PreCheckoutQueryId,
error: String
) = execute(AnswerPreCheckoutQueryError(id, error))
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.answerPreCheckoutQueryError(
preCheckoutQuery: PreCheckoutQuery,
error: String
) = answerPreCheckoutQueryError(preCheckoutQuery.id, error)

View File

@@ -52,27 +52,3 @@ fun ShippingQuery.createAnswerError(
id, id,
error error
) )
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.answerShippingQueryOk(
id: ShippingQueryIdentifier,
shippingOptions: List<ShippingOption>
) = execute(AnswerShippingQueryOk(id, shippingOptions))
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.answerShippingQueryOk(
shippingQuery: ShippingQuery,
shippingOptions: List<ShippingOption>
) = answerShippingQueryOk(shippingQuery.id, shippingOptions)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.answerShippingQueryError(
id: ShippingQueryIdentifier,
error: String
) = execute(AnswerShippingQueryError(id, error))
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.answerShippingQueryError(
shippingQuery: ShippingQuery,
error: String
) = answerShippingQueryError(shippingQuery.id, error)

View File

@@ -20,13 +20,3 @@ data class ExportChatInviteLink(
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.exportChatInviteLink(
chatId: ChatIdentifier
) = execute(ExportChatInviteLink(chatId))
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.exportChatInviteLink(
chat: PublicChat
) = exportChatInviteLink(chat.id)

View File

@@ -20,13 +20,3 @@ data class LeaveChat(
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.leaveChat(
chatId: ChatIdentifier
) = execute(LeaveChat(chatId))
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.leaveChat(
chat: PublicChat
) = leaveChat(chat.id)

View File

@@ -23,31 +23,3 @@ data class KickChatMember(
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.kickChatMember(
chatId: ChatIdentifier,
userId: UserId,
untilDate: TelegramDate? = null
) = execute(KickChatMember(chatId, userId, untilDate))
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.kickChatMember(
chat: PublicChat,
userId: UserId,
untilDate: TelegramDate? = null
) = kickChatMember(chat.id, userId, untilDate)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.kickChatMember(
chatId: ChatId,
user: User,
untilDate: TelegramDate? = null
) = kickChatMember(chatId, user.id, untilDate)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.kickChatMember(
chat: PublicChat,
user: User,
untilDate: TelegramDate? = null
) = kickChatMember(chat.id, user.id, untilDate)

View File

@@ -39,113 +39,3 @@ data class PromoteChatMember(
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
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
)
)
@Deprecated("Deprecated due to extracting into separated library")
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
)
@Deprecated("Deprecated due to extracting into separated library")
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
)
@Deprecated("Deprecated due to extracting into separated library")
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
)

View File

@@ -20,28 +20,3 @@ data class UnbanChatMember(
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.unbanChatMember(
chatId: ChatIdentifier,
userId: UserId
) = execute(UnbanChatMember(chatId, userId))
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.unbanChatMember(
chat: PublicChat,
userId: UserId
) = unbanChatMember(chat.id, userId)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.unbanChatMember(
chatId: ChatId,
user: User
) = unbanChatMember(chatId, user.id)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.unbanChatMember(
chat: PublicChat,
user: User
) = unbanChatMember(chat.id, user.id)

View File

@@ -20,13 +20,3 @@ data class DeleteChatPhoto(
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.deleteChatPhoto(
chatId: ChatIdentifier
) = execute(DeleteChatPhoto(chatId))
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.deleteChatPhoto(
chat: PublicChat
) = deleteChatPhoto(chat.id)

View File

@@ -24,27 +24,3 @@ data class PinChatMessage (
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.pinChatMessage(
chatId: ChatIdentifier,
messageId: MessageIdentifier,
disableNotification: Boolean = false
) = execute(PinChatMessage(chatId, messageId, disableNotification))
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.pinChatMessage(
chat: PublicChat,
messageId: MessageIdentifier,
disableNotification: Boolean = false
) = pinChatMessage(chat.id, messageId, disableNotification)
@Deprecated("Deprecated due to extracting into separated library")
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")
}

View File

@@ -27,15 +27,3 @@ data class SetChatTitle (
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.setChatTitle(
chatId: ChatIdentifier,
title: String
) = execute(SetChatTitle(chatId, title))
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.setChatTitle(
chat: PublicChat,
title: String
) = setChatTitle(chat.id, title)

View File

@@ -20,13 +20,3 @@ data class UnpinChatMessage(
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.unpinChatMessage(
chatId: ChatIdentifier
) = execute(UnpinChatMessage(chatId))
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.unpinChatMessage(
chat: PublicChat
) = unpinChatMessage(chat.id)

View File

@@ -20,13 +20,3 @@ data class DeleteChatStickerSet(
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.deleteChatStickerSet(
chatId: ChatIdentifier
) = execute(DeleteChatStickerSet(chatId))
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.deleteChatStickerSet(
chat: SupergroupChat
) = deleteChatStickerSet(chat.id)

View File

@@ -21,15 +21,3 @@ data class SetChatStickerSet(
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.setChatStickerSet(
chatId: ChatIdentifier,
stickerSetName: StickerSetName
) = execute(SetChatStickerSet(chatId, stickerSetName))
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.setChatStickerSet(
chat: SupergroupChat,
stickerSetName: StickerSetName
) = setChatStickerSet(chat.id, stickerSetName)

View File

@@ -31,60 +31,3 @@ data class EditChatMessageLiveLocation(
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.editLiveLocation(
chatId: ChatIdentifier,
messageId: MessageIdentifier,
latitude: Double,
longitude: Double,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(
EditChatMessageLiveLocation(
chatId, messageId, latitude, longitude, replyMarkup
)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.editLiveLocation(
chat: Chat,
messageId: MessageIdentifier,
latitude: Double,
longitude: Double,
replyMarkup: InlineKeyboardMarkup? = null
) = editLiveLocation(chat.id, messageId, latitude, longitude, replyMarkup)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.editLiveLocation(
message: ContentMessage<LocationContent>,
latitude: Double,
longitude: Double,
replyMarkup: InlineKeyboardMarkup? = null
) = editLiveLocation(message.chat, message.messageId, latitude, longitude, replyMarkup)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.editLiveLocation(
chatId: ChatIdentifier,
messageId: MessageIdentifier,
location: Location,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(
EditChatMessageLiveLocation(
chatId, messageId, location.latitude, location.longitude, replyMarkup
)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.editLiveLocation(
chat: Chat,
messageId: MessageIdentifier,
location: Location,
replyMarkup: InlineKeyboardMarkup? = null
) = editLiveLocation(chat.id, messageId, location.latitude, location.longitude, replyMarkup)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.editLiveLocation(
message: ContentMessage<LocationContent>,
location: Location,
replyMarkup: InlineKeyboardMarkup? = null
) = editLiveLocation(message.chat, message.messageId, location.latitude, location.longitude, replyMarkup)

View File

@@ -21,21 +21,3 @@ data class EditInlineMessageLiveLocation(
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.editLiveLocation(
inlineMessageId: InlineMessageIdentifier,
latitude: Double,
longitude: Double,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(
EditInlineMessageLiveLocation(
inlineMessageId, latitude, longitude, replyMarkup
)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.editLiveLocation(
inlineMessageId: InlineMessageIdentifier,
location: Location,
replyMarkup: InlineKeyboardMarkup? = null
) = editLiveLocation(inlineMessageId, location.latitude, location.longitude, replyMarkup)

View File

@@ -28,28 +28,3 @@ data class StopChatMessageLiveLocation(
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.stopLiveLocation(
chatId: ChatIdentifier,
messageId: MessageIdentifier,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(
StopChatMessageLiveLocation(
chatId, messageId, replyMarkup
)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.stopLiveLocation(
chat: Chat,
messageId: MessageIdentifier,
replyMarkup: InlineKeyboardMarkup? = null
) = stopLiveLocation(chat.id, messageId, replyMarkup)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.stopLiveLocation(
message: ContentMessage<LocationContent>,
replyMarkup: InlineKeyboardMarkup? = null
) = stopLiveLocation(message.chat, message.messageId, replyMarkup)

View File

@@ -18,13 +18,3 @@ data class StopInlineMessageLiveLocation(
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.stopLiveLocation(
inlineMessageId: InlineMessageIdentifier,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(
StopInlineMessageLiveLocation(
inlineMessageId, replyMarkup
)
)

View File

@@ -30,26 +30,3 @@ data class EditChatMessageReplyMarkup(
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.editMessageReplyMarkup(
chatId: ChatIdentifier,
messageId: MessageIdentifier,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(
EditChatMessageReplyMarkup(chatId, messageId, replyMarkup)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.editMessageReplyMarkup(
chat: Chat,
messageId: MessageIdentifier,
replyMarkup: InlineKeyboardMarkup? = null
) = editMessageReplyMarkup(chat.id, messageId, replyMarkup)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.editMessageReplyMarkup(
message: Message,
replyMarkup: InlineKeyboardMarkup? = null
) = editMessageReplyMarkup(message.chat.id, message.messageId, replyMarkup)

View File

@@ -18,9 +18,3 @@ data class EditInlineMessageReplyMarkup(
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.editMessageReplyMarkup(
inlineMessageId: InlineMessageIdentifier,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(EditInlineMessageReplyMarkup(inlineMessageId, replyMarkup))

View File

@@ -26,12 +26,3 @@ data class EditInlineMessageText(
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.editMessageText(
inlineMessageId: InlineMessageIdentifier,
text: String,
parseMode: ParseMode? = null,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(EditInlineMessageText(inlineMessageId, text, parseMode, disableWebPagePreview, replyMarkup))

View File

@@ -21,56 +21,3 @@ data class GetGameHighScoresByChat (
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.getGameScore(
userId: UserId,
chatId: ChatId,
messageId: MessageIdentifier
) = execute(
GetGameHighScoresByChat(userId, chatId, messageId)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.getGameScore(
user: CommonUser,
chatId: ChatId,
messageId: MessageIdentifier
) = getGameScore(
user.id, chatId, messageId
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.getGameScore(
userId: UserId,
chat: Chat,
messageId: MessageIdentifier
) = getGameScore(
userId, chat.id, messageId
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.getGameScore(
user: CommonUser,
chat: Chat,
messageId: MessageIdentifier
) = getGameScore(
user.id, chat.id, messageId
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.getGameScore(
userId: UserId,
message: ContentMessage<GameContent>
) = getGameScore(
userId, message.chat.id, message.messageId
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.getGameScore(
user: CommonUser,
message: ContentMessage<GameContent>
) = getGameScore(
user.id, message.chat.id, message.messageId
)

View File

@@ -16,19 +16,3 @@ data class GetGameHighScoresByInlineMessageId (
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.getGameScore(
userId: UserId,
inlineMessageId: InlineMessageIdentifier
) = execute(
GetGameHighScoresByInlineMessageId(
userId, inlineMessageId
)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.getGameScore(
user: CommonUser,
inlineMessageId: InlineMessageIdentifier
) = getGameScore(user.id, inlineMessageId)

View File

@@ -27,74 +27,3 @@ data class SetGameScoreByChatId (
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
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)
)
@Deprecated("Deprecated due to extracting into separated library")
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
)
@Deprecated("Deprecated due to extracting into separated library")
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
)
@Deprecated("Deprecated due to extracting into separated library")
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
)
@Deprecated("Deprecated due to extracting into separated library")
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
)
@Deprecated("Deprecated due to extracting into separated library")
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
)

View File

@@ -22,25 +22,3 @@ data class SetGameScoreByInlineMessageId (
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.setGameScore(
userId: UserId,
score: Long,
inlineMessageId: InlineMessageIdentifier,
force: Boolean = false,
disableEditMessage: Boolean = false
) = execute(
SetGameScoreByInlineMessageId(
userId, score, inlineMessageId, force, disableEditMessage
)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.setGameScore(
user: CommonUser,
score: Long,
inlineMessageId: InlineMessageIdentifier,
force: Boolean = false,
disableEditMessage: Boolean = false
) = setGameScore(user.id, score, inlineMessageId, force, disableEditMessage)

View File

@@ -24,121 +24,3 @@ data class SendAction(
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendBotAction(
chatId: ChatIdentifier,
action: BotAction
) = execute(
SendAction(chatId, action)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendBotAction(
chat: Chat,
action: BotAction
) = sendBotAction(chat.id, action)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendActionTyping(
chatId: ChatIdentifier
) = sendBotAction(chatId, TypingAction)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendActionUploadPhoto(
chatId: ChatIdentifier
) = sendBotAction(chatId, UploadPhotoAction)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendActionRecordVideo(
chatId: ChatIdentifier
) = sendBotAction(chatId, RecordVideoAction)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendActionUploadVideo(
chatId: ChatIdentifier
) = sendBotAction(chatId, UploadVideoAction)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendActionRecordAudio(
chatId: ChatIdentifier
) = sendBotAction(chatId, RecordAudioAction)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendActionUploadAudio(
chatId: ChatIdentifier
) = sendBotAction(chatId, UploadAudioAction)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendActionUploadDocument(
chatId: ChatIdentifier
) = sendBotAction(chatId, UploadDocumentAction)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendActionFindLocation(
chatId: ChatIdentifier
) = sendBotAction(chatId, FindLocationAction)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendActionRecordVideoNote(
chatId: ChatIdentifier
) = sendBotAction(chatId, RecordVideoNoteAction)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendActionUploadVideoNote(
chatId: ChatIdentifier
) = sendBotAction(chatId, UploadVideoNoteAction)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendActionTyping(
chat: Chat
) = sendBotAction(chat, TypingAction)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendActionUploadPhoto(
chat: Chat
) = sendBotAction(chat, UploadPhotoAction)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendActionRecordVideo(
chat: Chat
) = sendBotAction(chat, RecordVideoAction)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendActionUploadVideo(
chat: Chat
) = sendBotAction(chat, UploadVideoAction)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendActionRecordAudio(
chat: Chat
) = sendBotAction(chat, RecordAudioAction)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendActionUploadAudio(
chat: Chat
) = sendBotAction(chat, UploadAudioAction)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendActionUploadDocument(
chat: Chat
) = sendBotAction(chat, UploadDocumentAction)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendActionFindLocation(
chat: Chat
) = sendBotAction(chat, FindLocationAction)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendActionRecordVideoNote(
chat: Chat
) = sendBotAction(chat, RecordVideoNoteAction)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendActionUploadVideoNote(
chat: Chat
) = sendBotAction(chat, UploadVideoNoteAction)

View File

@@ -68,55 +68,3 @@ fun Contact.toRequest(
replyToMessageId, replyToMessageId,
replyMarkup replyMarkup
) )
@Deprecated("Deprecated due to extracting into separated library")
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
)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendContact(
chatId: ChatIdentifier,
contact: Contact,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendContact(
chatId, contact, disableNotification, replyToMessageId, replyMarkup
)
)
@Deprecated("Deprecated due to extracting into separated library")
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
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendContact(
chat: Chat,
contact: Contact,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendContact(
chat.id, contact, disableNotification, replyToMessageId, replyMarkup
)

View File

@@ -49,71 +49,3 @@ data class SendLocation(
} }
} }
} }
@Deprecated("Deprecated due to extracting into separated library")
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
)
)
@Deprecated("Deprecated due to extracting into separated library")
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
)
@Deprecated("Deprecated due to extracting into separated library")
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
)
@Deprecated("Deprecated due to extracting into separated library")
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
)

View File

@@ -49,60 +49,3 @@ data class SendTextMessage(
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated(
"This declaration is deprecated due violation of common naming rules",
ReplaceWith(
"SendTextMessage"
)
)
typealias SendMessage = SendTextMessage
@Deprecated("Deprecated due to extracting into separated library")
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)
)
@Deprecated("Deprecated due to extracting into separated library")
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
)
@Deprecated("Deprecated due to extracting into separated library")
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)
@Deprecated("Deprecated due to extracting into separated library")
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)

View File

@@ -35,49 +35,3 @@ data class SendGame (
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendGame(
chatId: ChatIdentifier,
gameShortName: String,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendGame(
chatId, gameShortName, disableNotification, replyToMessageId, replyMarkup
)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendGame(
chat: Chat,
gameShortName: String,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendGame(
chat.id, gameShortName, disableNotification, replyToMessageId, replyMarkup
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendGame(
chatId: ChatIdentifier,
game: Game,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendGame(
chatId, game.title, disableNotification, replyToMessageId, replyMarkup
)
@Deprecated("Deprecated due to extracting into separated library")
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
)

View File

@@ -117,145 +117,3 @@ data class SendAudioFiles internal constructor(
audioField to audio, audioField to audio,
thumbField to thumb thumbField to thumb
) )
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendAudio(
chatId: ChatIdentifier,
audio: FileId,
thumb: FileId? = 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(
SendAudioData(
chatId,
audio.fileId,
thumb ?.fileId,
text,
parseMode,
duration,
performer,
title,
disableNotification,
replyToMessageId,
replyMarkup
)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendAudio(
chatId: ChatIdentifier,
audio: AudioFile,
thumb: PhotoSize? = audio.thumb,
text: String? = null,
parseMode: ParseMode? = null,
title: String? = audio.title,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAudio(
chatId, audio.fileId, thumb ?.fileId, text, parseMode, audio.duration, audio.performer, title, disableNotification, replyToMessageId, replyMarkup
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendAudio(
chatId: ChatIdentifier,
audio: MultipartFile,
thumb: FileId? = 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(
MultipartRequestImpl(
SendAudioData(
chatId, null, thumb ?.fileId, text, parseMode, duration, performer, title, disableNotification, replyToMessageId, replyMarkup
),
SendAudioFiles(audio)
)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendAudio(
chatId: ChatIdentifier,
audio: MultipartFile,
thumb: MultipartFile? = 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(
MultipartRequestImpl(
SendAudioData(
chatId, null, null, text, parseMode, duration, performer, title, disableNotification, replyToMessageId, replyMarkup
),
SendAudioFiles(audio, thumb)
)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendAudio(
chatId: ChatIdentifier,
audio: FileId,
thumb: MultipartFile,
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(
MultipartRequestImpl(
SendAudioData(
chatId, audio.fileId, null, text, parseMode, duration, performer, title, disableNotification, replyToMessageId, replyMarkup
),
SendAudioFiles(null, thumb)
)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendAudio(
chatId: ChatIdentifier,
audio: MultipartFile,
thumb: PhotoSize? = 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
) = sendAudio(
chatId, audio, thumb ?.fileId , text, parseMode, duration, performer, title, disableNotification, replyToMessageId, replyMarkup
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendAudio(
chatId: ChatIdentifier,
audio: AudioFile,
thumb: MultipartFile,
text: String? = null,
parseMode: ParseMode? = null,
title: String? = audio.title,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAudio(
chatId, audio.fileId, thumb, text, parseMode, audio.duration, audio.performer, title, disableNotification, replyToMessageId, replyMarkup
)

View File

@@ -101,125 +101,3 @@ data class SendDocumentFiles internal constructor(
documentField to document, documentField to document,
thumbField to thumb thumbField to thumb
) )
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendDocument(
chatId: ChatIdentifier,
document: FileId,
thumb: FileId? = null,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendDocumentData(
chatId,
document.fileId,
thumb ?.fileId,
text,
parseMode,
disableNotification,
replyToMessageId,
replyMarkup
)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendDocument(
chatId: ChatIdentifier,
document: DocumentFile,
thumb: PhotoSize? = document.thumb,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendDocument(
chatId, document.fileId, thumb ?.fileId, text, parseMode, disableNotification, replyToMessageId, replyMarkup
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendDocument(
chatId: ChatIdentifier,
document: MultipartFile,
thumb: FileId? = null,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
MultipartRequestImpl(
SendDocumentData(
chatId, null, thumb ?.fileId, text, parseMode, disableNotification, replyToMessageId, replyMarkup
),
SendDocumentFiles(document)
)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendDocument(
chatId: ChatIdentifier,
document: MultipartFile,
thumb: MultipartFile? = null,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
MultipartRequestImpl(
SendDocumentData(
chatId, null, null, text, parseMode, disableNotification, replyToMessageId, replyMarkup
),
SendDocumentFiles(document, thumb)
)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendDocument(
chatId: ChatIdentifier,
document: FileId,
thumb: MultipartFile,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
MultipartRequestImpl(
SendDocumentData(
chatId, document.fileId, null, text, parseMode, disableNotification, replyToMessageId, replyMarkup
),
SendDocumentFiles(null, thumb)
)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendDocument(
chatId: ChatIdentifier,
document: MultipartFile,
thumb: PhotoSize? = null,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendDocument(
chatId, document, thumb ?.fileId , text, parseMode, disableNotification, replyToMessageId, replyMarkup
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendDocument(
chatId: ChatIdentifier,
document: DocumentFile,
thumb: MultipartFile,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendDocument(
chatId, document.fileId, thumb, text, parseMode, disableNotification, replyToMessageId, replyMarkup
)

View File

@@ -114,137 +114,3 @@ data class SendVideoNoteFiles internal constructor(
videoNoteField to videoNote, videoNoteField to videoNote,
thumbField to thumb thumbField to thumb
) )
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendVideoNote(
chatId: ChatIdentifier,
videoNote: FileId,
thumb: FileId? = null,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
size: Int? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendVideoNoteData(
chatId,
videoNote.fileId,
thumb ?.fileId,
text,
parseMode,
duration,
size,
disableNotification,
replyToMessageId,
replyMarkup
)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendVideoNote(
chatId: ChatIdentifier,
videoNote: VideoFile,
thumb: PhotoSize? = videoNote.thumb,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideoNote(
chatId, videoNote.fileId, thumb ?.fileId, text, parseMode, videoNote.duration, videoNote.width, disableNotification, replyToMessageId, replyMarkup
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendVideoNote(
chatId: ChatIdentifier,
videoNote: MultipartFile,
thumb: FileId? = null,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
size: Int? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
MultipartRequestImpl(
SendVideoNoteData(
chatId, null, thumb ?.fileId, text, parseMode, duration, size, disableNotification, replyToMessageId, replyMarkup
),
SendVideoNoteFiles(videoNote)
)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendVideoNote(
chatId: ChatIdentifier,
videoNote: MultipartFile,
thumb: MultipartFile? = null,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
size: Int? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
MultipartRequestImpl(
SendVideoNoteData(
chatId, null, null, text, parseMode, duration, size, disableNotification, replyToMessageId, replyMarkup
),
SendVideoNoteFiles(videoNote, thumb)
)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendVideoNote(
chatId: ChatIdentifier,
videoNote: FileId,
thumb: MultipartFile,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
size: Int? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
MultipartRequestImpl(
SendVideoNoteData(
chatId, videoNote.fileId, null, text, parseMode, duration, size, disableNotification, replyToMessageId, replyMarkup
),
SendVideoNoteFiles(null, thumb)
)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendVideoNote(
chatId: ChatIdentifier,
videoNote: MultipartFile,
thumb: PhotoSize? = null,
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
size: Int? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideoNote(
chatId, videoNote, thumb ?.fileId , text, parseMode, duration, size, disableNotification, replyToMessageId, replyMarkup
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.sendVideoNote(
chatId: ChatIdentifier,
videoNote: VideoFile,
thumb: MultipartFile,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideoNote(
chatId, videoNote.fileId, thumb, text, parseMode, videoNote.duration, videoNote.width, disableNotification, replyToMessageId, replyMarkup
)

View File

@@ -52,56 +52,3 @@ data class CreateNewStickerSet internal constructor(
override fun method(): String = "createNewStickerSet" override fun method(): String = "createNewStickerSet"
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.createNewStickerSet(
userId: UserId,
name: String,
sticker: FileId,
emojis: String,
containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null
) = execute(
CreateNewStickerSet(userId, name, emojis, sticker, containsMasks, maskPosition)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.createNewStickerSet(
userId: UserId,
name: String,
sticker: MultipartFile,
emojis: String,
containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null
) = execute(
CommonMultipartFileRequest(
CreateNewStickerSet(userId, name, emojis, null, containsMasks, maskPosition),
mapOf(pngStickerField to sticker)
)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.createNewStickerSet(
user: CommonUser,
name: String,
sticker: FileId,
emojis: String,
containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null
) = createNewStickerSet(
user.id, name, sticker, emojis, containsMasks, maskPosition
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.createNewStickerSet(
user: CommonUser,
name: String,
sticker: MultipartFile,
emojis: String,
containsMasks: Boolean? = null,
maskPosition: MaskPosition? = null
) = createNewStickerSet(
user.id, name, sticker, emojis, containsMasks, maskPosition
)

View File

@@ -19,21 +19,3 @@ data class DeleteStickerFromSet(
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.deleteStickerFromSet(
sticker: FileId
) = execute(
DeleteStickerFromSet(
sticker
)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.deleteStickerFromSet(
sticker: Sticker
) = deleteStickerFromSet(
sticker.fileId
)

View File

@@ -28,23 +28,3 @@ data class SetStickerPositionInSet(
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.setStickerPositionInSet(
sticker: FileId,
position: Int
) = execute(
SetStickerPositionInSet(
sticker,
position
)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.setStickerPositionInSet(
sticker: Sticker,
position: Int
) = setStickerPositionInSet(
sticker.fileId,
position
)

View File

@@ -28,20 +28,3 @@ data class UploadStickerFile(
override val resultDeserializer: DeserializationStrategy<File> override val resultDeserializer: DeserializationStrategy<File>
get() = File.serializer() get() = File.serializer()
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.uploadStickerFile(
userId: UserId,
sticker: MultipartFile
) = execute(
UploadStickerFile(userId, sticker)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.uploadStickerFile(
user: CommonUser,
sticker: MultipartFile
) = execute(
UploadStickerFile(user.id, sticker)
)

View File

@@ -65,30 +65,3 @@ data class SetWebhook internal constructor(
} }
} }
} }
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.setWebhookInfo(
url: String,
certificate: FileId,
maxAllowedConnections: Int? = null,
allowedUpdates: List<String>? = null
) = execute(
SetWebhook(
url, certificate.fileId, maxAllowedConnections, allowedUpdates
)
)
@Deprecated("Deprecated due to extracting into separated library")
suspend fun RequestsExecutor.setWebhookInfo(
url: String,
certificate: MultipartFile,
maxAllowedConnections: Int? = null,
allowedUpdates: List<String>? = null
) = execute(
MultipartRequestImpl(
SetWebhook(
url, null, maxAllowedConnections, allowedUpdates
),
mapOf(certificateField to certificate)
)
)

View File

@@ -20,6 +20,8 @@ typealias PollIdentifier = String
typealias StickerSetName = String typealias StickerSetName = String
typealias FileUniqueId = String typealias FileUniqueId = String
typealias Seconds = Int
val callbackQueryAnswerLength = 0 until 200 val callbackQueryAnswerLength = 0 until 200
val captionLength = 0 until 1024 val captionLength = 0 until 1024
val textLength = 0 until 4096 val textLength = 0 until 4096

View File

@@ -1,6 +1,7 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.message package com.github.insanusmokrassar.TelegramBotAPI.types.message
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.ChannelChat
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
@Deprecated( @Deprecated(
@@ -52,6 +53,6 @@ typealias ForwardedFromChannelMessage = ForwardFromChannelInfo
data class ForwardFromChannelInfo( data class ForwardFromChannelInfo(
override val dateOfOriginal: TelegramDate, override val dateOfOriginal: TelegramDate,
val messageId: MessageIdentifier, val messageId: MessageIdentifier,
val channelChat: Chat, val channelChat: ChannelChat,
val signature: String? = null val signature: String? = null
) : ForwardInfo() ) : ForwardInfo()

View File

@@ -142,7 +142,7 @@ internal data class RawMessage(
forward_date, forward_date,
forward_sender_name forward_sender_name
) )
forward_from_chat != null -> ForwardFromChannelInfo( forward_from_chat is ChannelChat -> ForwardFromChannelInfo(
forward_date, forward_date,
forward_from_message_id ?: throw IllegalStateException("Channel forwarded message must contain message id, but was not"), forward_from_message_id ?: throw IllegalStateException("Channel forwarded message must contain message id, but was not"),
forward_from_chat, forward_from_chat,

View File

@@ -3,8 +3,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.update
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseSentMessageUpdate
data class ChannelPostUpdate( data class ChannelPostUpdate(
override val updateId: UpdateIdentifier, override val updateId: UpdateIdentifier,
override val data: Message override val data: Message
) : BaseMessageUpdate ) : BaseSentMessageUpdate

View File

@@ -2,9 +2,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.update
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseEditMessageUpdate
data class EditChannelPostUpdate( data class EditChannelPostUpdate(
override val updateId: UpdateIdentifier, override val updateId: UpdateIdentifier,
override val data: Message override val data: Message
) : BaseMessageUpdate ) : BaseEditMessageUpdate

View File

@@ -2,9 +2,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.update
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseEditMessageUpdate
data class EditMessageUpdate( data class EditMessageUpdate(
override val updateId: UpdateIdentifier, override val updateId: UpdateIdentifier,
override val data: Message override val data: Message
) : BaseMessageUpdate ) : BaseEditMessageUpdate

View File

@@ -3,8 +3,9 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.update
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseSentMessageUpdate
data class MessageUpdate( data class MessageUpdate(
override val updateId: UpdateIdentifier, override val updateId: UpdateIdentifier,
override val data: Message override val data: Message
) : BaseMessageUpdate ) : BaseSentMessageUpdate

View File

@@ -0,0 +1,3 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts
interface BaseEditMessageUpdate : BaseMessageUpdate

View File

@@ -0,0 +1,3 @@
package com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts
interface BaseSentMessageUpdate : BaseMessageUpdate

View File

@@ -2,7 +2,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.updateshandlers
import com.github.insanusmokrassar.TelegramBotAPI.types.update.* import com.github.insanusmokrassar.TelegramBotAPI.types.update.*
import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates.* import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates.*
import com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.UpdateReceiver import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
import kotlinx.coroutines.channels.BroadcastChannel import kotlinx.coroutines.channels.BroadcastChannel
import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
@@ -12,7 +12,7 @@ private fun <T> BroadcastChannel<T>.createUpdateReceiver(): UpdateReceiver<T> =
class FlowsUpdatesFilter( class FlowsUpdatesFilter(
broadcastChannelsSize: Int = Channel.CONFLATED broadcastChannelsSize: Int = Channel.CONFLATED
) { ): UpdatesFilter {
private val messageChannel: BroadcastChannel<MessageUpdate> = BroadcastChannel(broadcastChannelsSize) private val messageChannel: BroadcastChannel<MessageUpdate> = BroadcastChannel(broadcastChannelsSize)
private val messageMediaGroupChannel: BroadcastChannel<MessageMediaGroupUpdate> = BroadcastChannel(broadcastChannelsSize) private val messageMediaGroupChannel: BroadcastChannel<MessageMediaGroupUpdate> = BroadcastChannel(broadcastChannelsSize)
private val editedMessageChannel: BroadcastChannel<EditMessageUpdate> = BroadcastChannel(broadcastChannelsSize) private val editedMessageChannel: BroadcastChannel<EditMessageUpdate> = BroadcastChannel(broadcastChannelsSize)
@@ -28,7 +28,12 @@ class FlowsUpdatesFilter(
private val preCheckoutQueryChannel: BroadcastChannel<PreCheckoutQueryUpdate> = BroadcastChannel(broadcastChannelsSize) private val preCheckoutQueryChannel: BroadcastChannel<PreCheckoutQueryUpdate> = BroadcastChannel(broadcastChannelsSize)
private val pollChannel: BroadcastChannel<PollUpdate> = BroadcastChannel(broadcastChannelsSize) private val pollChannel: BroadcastChannel<PollUpdate> = BroadcastChannel(broadcastChannelsSize)
val filter = UpdatesFilter( override val allowedUpdates: List<String>
get() = filter.allowedUpdates
override val asUpdateReceiver: UpdateReceiver<Update>
get() = filter.asUpdateReceiver
val filter = SimpleUpdatesFilter(
messageChannel.createUpdateReceiver(), messageChannel.createUpdateReceiver(),
messageMediaGroupChannel.createUpdateReceiver(), messageMediaGroupChannel.createUpdateReceiver(),
editedMessageChannel.createUpdateReceiver(), editedMessageChannel.createUpdateReceiver(),

View File

@@ -11,13 +11,13 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaG
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
import com.github.insanusmokrassar.TelegramBotAPI.utils.* import com.github.insanusmokrassar.TelegramBotAPI.utils.*
import com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.UpdateReceiver
import com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.executeUnsafe import com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.executeUnsafe
import io.ktor.client.HttpClient import io.ktor.client.HttpClient
import io.ktor.client.engine.HttpClientEngine import io.ktor.client.engine.HttpClientEngine
import kotlinx.coroutines.* import kotlinx.coroutines.*
import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.channels.Channel
@Deprecated("Deprecated due to more simple way to get updates using TelegramBotAPI-extensions-api")
fun KtorUpdatesPoller( fun KtorUpdatesPoller(
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper, telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
engine: HttpClientEngine, engine: HttpClientEngine,
@@ -42,6 +42,7 @@ fun KtorUpdatesPoller(
) )
} }
@Deprecated("Deprecated due to more simple way to get updates using TelegramBotAPI-extensions-api")
class KtorUpdatesPoller( class KtorUpdatesPoller(
private val executor: RequestsExecutor, private val executor: RequestsExecutor,
private val timeoutSeconds: Int? = null, private val timeoutSeconds: Int? = null,

View File

@@ -5,9 +5,58 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.update.*
import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates.* import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates.*
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.UnknownUpdateType import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.UnknownUpdateType
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
import com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.UpdateReceiver
data class UpdatesFilter( typealias UpdateReceiver<T> = suspend (T) -> Unit
interface UpdatesFilter {
val asUpdateReceiver: UpdateReceiver<Update>
val allowedUpdates: List<String>
}
@Deprecated(
"It is builder function for SimpleUpdatesFilter",
ReplaceWith(
"SimpleUpdatesFilter",
"com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.SimpleUpdatesFilter"
)
)
fun UpdatesFilter(
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,
pollUpdateCallback: UpdateReceiver<PollUpdate>? = null,
pollAnswerUpdateCallback: UpdateReceiver<PollAnswerUpdate>? = null,
unknownUpdateTypeCallback: UpdateReceiver<UnknownUpdateType>? = null
) = SimpleUpdatesFilter(
messageCallback,
messageMediaGroupCallback,
editedMessageCallback,
editedMessageMediaGroupCallback,
channelPostCallback,
channelPostMediaGroupCallback,
editedChannelPostCallback,
editedChannelPostMediaGroupCallback,
chosenInlineResultCallback,
inlineQueryCallback,
callbackQueryCallback,
shippingQueryCallback,
preCheckoutQueryCallback,
pollUpdateCallback,
pollAnswerUpdateCallback,
unknownUpdateTypeCallback
)
data class SimpleUpdatesFilter(
private val messageCallback: UpdateReceiver<MessageUpdate>? = null, private val messageCallback: UpdateReceiver<MessageUpdate>? = null,
private val messageMediaGroupCallback: UpdateReceiver<MessageMediaGroupUpdate>? = null, private val messageMediaGroupCallback: UpdateReceiver<MessageMediaGroupUpdate>? = null,
private val editedMessageCallback: UpdateReceiver<EditMessageUpdate>? = null, private val editedMessageCallback: UpdateReceiver<EditMessageUpdate>? = null,
@@ -24,9 +73,9 @@ data class UpdatesFilter(
private val pollUpdateCallback: UpdateReceiver<PollUpdate>? = null, private val pollUpdateCallback: UpdateReceiver<PollUpdate>? = null,
private val pollAnswerUpdateCallback: UpdateReceiver<PollAnswerUpdate>? = null, private val pollAnswerUpdateCallback: UpdateReceiver<PollAnswerUpdate>? = null,
private val unknownUpdateTypeCallback: UpdateReceiver<UnknownUpdateType>? = null private val unknownUpdateTypeCallback: UpdateReceiver<UnknownUpdateType>? = null
) { ) : UpdatesFilter {
val asUpdateReceiver: UpdateReceiver<Update> = this::invoke override val asUpdateReceiver: UpdateReceiver<Update> = this::invoke
val allowedUpdates = listOfNotNull( override val allowedUpdates = listOfNotNull(
(messageCallback ?: messageMediaGroupCallback) ?.let { UPDATE_MESSAGE }, (messageCallback ?: messageMediaGroupCallback) ?.let { UPDATE_MESSAGE },
(editedMessageCallback ?: editedMessageMediaGroupCallback) ?.let { UPDATE_EDITED_MESSAGE }, (editedMessageCallback ?: editedMessageMediaGroupCallback) ?.let { UPDATE_EDITED_MESSAGE },
(channelPostCallback ?: channelPostMediaGroupCallback) ?.let { UPDATE_CHANNEL_POST }, (channelPostCallback ?: channelPostMediaGroupCallback) ?.let { UPDATE_CHANNEL_POST },
@@ -96,7 +145,7 @@ fun createSimpleUpdateFilter(
pollCallback: UpdateReceiver<PollUpdate>? = null, pollCallback: UpdateReceiver<PollUpdate>? = null,
pollAnswerCallback: UpdateReceiver<PollAnswerUpdate>? = null, pollAnswerCallback: UpdateReceiver<PollAnswerUpdate>? = null,
unknownCallback: UpdateReceiver<UnknownUpdateType>? = null unknownCallback: UpdateReceiver<UnknownUpdateType>? = null
): UpdatesFilter = UpdatesFilter( ): UpdatesFilter = SimpleUpdatesFilter(
messageCallback = messageCallback, messageCallback = messageCallback,
messageMediaGroupCallback = mediaGroupCallback, messageMediaGroupCallback = mediaGroupCallback,
editedMessageCallback = editedMessageCallback, editedMessageCallback = editedMessageCallback,
@@ -113,4 +162,4 @@ fun createSimpleUpdateFilter(
pollUpdateCallback = pollCallback, pollUpdateCallback = pollCallback,
pollAnswerUpdateCallback = pollAnswerCallback, pollAnswerUpdateCallback = pollAnswerCallback,
unknownUpdateTypeCallback = unknownCallback unknownUpdateTypeCallback = unknownCallback
) )

View File

@@ -10,8 +10,16 @@ import com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.KtorUpdatesPol
import com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.UpdatesFilter import com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.UpdatesFilter
import kotlinx.coroutines.* import kotlinx.coroutines.*
typealias UpdateReceiver<T> = suspend (T) -> Unit @Deprecated(
"Replaced",
ReplaceWith(
"UpdateReceiver",
"com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.UpdateReceiver"
)
)
typealias UpdateReceiver<T> = com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.UpdateReceiver<T>
@Deprecated("Replaced into TelegramBotAPI-extensions-api")
fun RequestsExecutor.startGettingOfUpdates( fun RequestsExecutor.startGettingOfUpdates(
timeoutMillis: Long = 30 * 1000, timeoutMillis: Long = 30 * 1000,
scope: CoroutineScope = CoroutineScope(Dispatchers.Default), scope: CoroutineScope = CoroutineScope(Dispatchers.Default),
@@ -28,6 +36,7 @@ fun RequestsExecutor.startGettingOfUpdates(
} }
} }
@Deprecated("Replaced into TelegramBotAPI-extensions-api")
fun RequestsExecutor.startGettingOfUpdates( fun RequestsExecutor.startGettingOfUpdates(
messageCallback: UpdateReceiver<MessageUpdate>? = null, messageCallback: UpdateReceiver<MessageUpdate>? = null,
messageMediaGroupCallback: UpdateReceiver<MessageMediaGroupUpdate>? = null, messageMediaGroupCallback: UpdateReceiver<MessageMediaGroupUpdate>? = null,
@@ -72,6 +81,7 @@ fun RequestsExecutor.startGettingOfUpdates(
) )
} }
@Deprecated("Replaced into TelegramBotAPI-extensions-api")
fun RequestsExecutor.startGettingOfUpdates( fun RequestsExecutor.startGettingOfUpdates(
messageCallback: UpdateReceiver<MessageUpdate>? = null, messageCallback: UpdateReceiver<MessageUpdate>? = null,
mediaGroupCallback: UpdateReceiver<MediaGroupUpdate>? = null, mediaGroupCallback: UpdateReceiver<MediaGroupUpdate>? = null,

View File

@@ -4,13 +4,13 @@ import com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.KtorRequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.types.ALL_UPDATES_LIST import com.github.insanusmokrassar.TelegramBotAPI.types.ALL_UPDATES_LIST
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
import com.github.insanusmokrassar.TelegramBotAPI.utils.TelegramAPIUrlsKeeper import com.github.insanusmokrassar.TelegramBotAPI.utils.TelegramAPIUrlsKeeper
import com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.UpdateReceiver
import io.ktor.client.HttpClient import io.ktor.client.HttpClient
import io.ktor.client.engine.HttpClientEngine import io.ktor.client.engine.HttpClientEngine
import io.ktor.client.engine.cio.CIO import io.ktor.client.engine.cio.CIO
import io.ktor.client.engine.cio.endpoint import io.ktor.client.engine.cio.endpoint
import io.ktor.util.KtorExperimentalAPI import io.ktor.util.KtorExperimentalAPI
@Deprecated("Deprecated due to more simple way to get updates using TelegramBotAPI-extensions-api")
@KtorExperimentalAPI @KtorExperimentalAPI
fun KtorUpdatesPoller( fun KtorUpdatesPoller(
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper, telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
@@ -44,6 +44,7 @@ fun KtorUpdatesPoller(
) )
} }
@Deprecated("Deprecated due to more simple way to get updates using TelegramBotAPI-extensions-api")
@KtorExperimentalAPI @KtorExperimentalAPI
fun KtorUpdatesPoller( fun KtorUpdatesPoller(
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper, telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,

View File

@@ -6,6 +6,7 @@ klock_version=1.8.7
uuid_version=0.0.7 uuid_version=0.0.7
ktor_version=1.3.1 ktor_version=1.3.1
library_version=0.23.3 library_group=com.github.insanusmokrassar
library_version=0.24.1
gradle_bintray_plugin_version=1.8.4 gradle_bintray_plugin_version=1.8.4