mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 16:23:48 +00:00
commit
9471df1f2d
14
CHANGELOG.md
14
CHANGELOG.md
@ -49,6 +49,20 @@
|
|||||||
* `closePollExactAfter`
|
* `closePollExactAfter`
|
||||||
* `closePollAfter`
|
* `closePollAfter`
|
||||||
|
|
||||||
|
### 0.27.4
|
||||||
|
|
||||||
|
* `TelegramBotAPI-extensions-utils`:
|
||||||
|
* Several extensions for updates was added:
|
||||||
|
* `onlyBaseMessageUpdates`
|
||||||
|
* `onlySentMessageUpdates`
|
||||||
|
* `onlyEditMessageUpdates`
|
||||||
|
* `onlyMediaGroupsUpdates`
|
||||||
|
* `onlySentMediaGroupUpdates`
|
||||||
|
* `onlyEditMediaGroupUpdates`
|
||||||
|
* Renames in chat filters extensions:
|
||||||
|
* `filterBaseMessageUpdates` -> `filterBaseMessageUpdatesByChatId` and `filterBaseMessageUpdatesByChat`
|
||||||
|
* `filterSentMediaGroupUpdates` -> `filterSentMediaGroupUpdatesByChatId` and `filterSentMediaGroupUpdatesByChat`
|
||||||
|
|
||||||
### 0.27.3
|
### 0.27.3
|
||||||
|
|
||||||
* `TelegramBotAPI`:
|
* `TelegramBotAPI`:
|
||||||
|
@ -20,25 +20,22 @@ publishing {
|
|||||||
publications.all {
|
publications.all {
|
||||||
artifact javadocsJar
|
artifact javadocsJar
|
||||||
|
|
||||||
pom.withXml {
|
pom {
|
||||||
asNode().children().last() + {
|
description = "This project just include all subproject of TelegramBotAPI"
|
||||||
resolveStrategy = Closure.DELEGATE_FIRST
|
name = "Telegram Bot API All"
|
||||||
|
url = "https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-all"
|
||||||
description "This project just include all subproject of TelegramBotAPI"
|
|
||||||
name "Telegram Bot API All"
|
|
||||||
url "https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-all"
|
|
||||||
|
|
||||||
scm {
|
scm {
|
||||||
developerConnection "scm:git:[fetch=]https://github.com/insanusmokrassar/TelegramBotAPI.git[push=]https://github.com/insanusmokrassar/TelegramBotAPI.git"
|
developerConnection = "scm:git:[fetch=]https://github.com/insanusmokrassar/TelegramBotAPI.git[push=]https://github.com/insanusmokrassar/TelegramBotAPI.git"
|
||||||
url "https://github.com/insanusmokrassar/TelegramBotAPI.git"
|
url = "https://github.com/insanusmokrassar/TelegramBotAPI.git"
|
||||||
}
|
}
|
||||||
|
|
||||||
developers {
|
developers {
|
||||||
|
|
||||||
developer {
|
developer {
|
||||||
id "InsanusMokrassar"
|
id = "InsanusMokrassar"
|
||||||
name "Ovsiannikov Aleksei"
|
name = "Ovsiannikov Aleksei"
|
||||||
email "ovsyannikov.alexey95@gmail.com"
|
email = "ovsyannikov.alexey95@gmail.com"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -46,12 +43,11 @@ publishing {
|
|||||||
licenses {
|
licenses {
|
||||||
|
|
||||||
license {
|
license {
|
||||||
name "Apache Software License 2.0"
|
name = "Apache Software License 2.0"
|
||||||
url "https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"
|
url = "https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
@ -20,25 +20,22 @@ publishing {
|
|||||||
publications.all {
|
publications.all {
|
||||||
artifact javadocsJar
|
artifact javadocsJar
|
||||||
|
|
||||||
pom.withXml {
|
pom {
|
||||||
asNode().children().last() + {
|
description = "API extensions which provide work with RequestsExecutor of TelegramBotAPI almost like it is described in original Telegram Bot API reference"
|
||||||
resolveStrategy = Closure.DELEGATE_FIRST
|
name = "Telegram Bot API Extensions for API"
|
||||||
|
url = "https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-extensions-api"
|
||||||
description "API extensions which provide work with RequestsExecutor of TelegramBotAPI almost like it is described in original Telegram Bot API reference"
|
|
||||||
name "Telegram Bot API Extensions for API"
|
|
||||||
url "https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-extensions-api"
|
|
||||||
|
|
||||||
scm {
|
scm {
|
||||||
developerConnection "scm:git:[fetch=]https://github.com/insanusmokrassar/TelegramBotAPI.git[push=]https://github.com/insanusmokrassar/TelegramBotAPI.git"
|
developerConnection = "scm:git:[fetch=]https://github.com/insanusmokrassar/TelegramBotAPI.git[push=]https://github.com/insanusmokrassar/TelegramBotAPI.git"
|
||||||
url "https://github.com/insanusmokrassar/TelegramBotAPI.git"
|
url = "https://github.com/insanusmokrassar/TelegramBotAPI.git"
|
||||||
}
|
}
|
||||||
|
|
||||||
developers {
|
developers {
|
||||||
|
|
||||||
developer {
|
developer {
|
||||||
id "InsanusMokrassar"
|
id = "InsanusMokrassar"
|
||||||
name "Ovsiannikov Aleksei"
|
name = "Ovsiannikov Aleksei"
|
||||||
email "ovsyannikov.alexey95@gmail.com"
|
email = "ovsyannikov.alexey95@gmail.com"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -46,12 +43,11 @@ publishing {
|
|||||||
licenses {
|
licenses {
|
||||||
|
|
||||||
license {
|
license {
|
||||||
name "Apache Software License 2.0"
|
name = "Apache Software License 2.0"
|
||||||
url "https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"
|
url = "https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
@ -166,6 +166,32 @@ application without creating of new one server (as it is happening in `startList
|
|||||||
|
|
||||||
There are several filters for flows.
|
There are several filters for flows.
|
||||||
|
|
||||||
|
#### Updates
|
||||||
|
|
||||||
|
In the next table it is supposed that you are using some `Flow` with type from `Base type of update` and apply
|
||||||
|
extension `Extension` and will get `Flow` with type from `Result type of update` column.
|
||||||
|
|
||||||
|
| Base type of update | Extension | Result type of update |
|
||||||
|
| ------------------- | --------- | --------------------- |
|
||||||
|
| `Update` | `onlyBaseMessageUpdates` | `BaseMessageUpdate` |
|
||||||
|
| | | |
|
||||||
|
| `BaseMessageUpdate` | `onlySentMessageUpdates` | `BaseSentMessageUpdate` |
|
||||||
|
| `BaseMessageUpdate` | `onlyEditMessageUpdates` | `BaseEditMessageUpdate` |
|
||||||
|
| `BaseMessageUpdate` | `onlyMediaGroupsUpdates` | `MediaGroupUpdate` |
|
||||||
|
| | | |
|
||||||
|
| `MediaGroupUpdate` | `onlySentMediaGroupUpdates` | `SentMediaGroupUpdate` |
|
||||||
|
| `MediaGroupUpdate` | `onlyEditMediaGroupUpdates` | `EditMediaGroupUpdate` |
|
||||||
|
|
||||||
|
All of these extensions was made for more simple work with the others:
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
val flow: Flow<BaseMessageUpdate> = ...; // here we are getting flow from somewhere,
|
||||||
|
// for example, FlowsUpdatesFilter#messageFlow
|
||||||
|
flow.onlySentMessageUpdates().filterExactCommands(Regex("start"))
|
||||||
|
```
|
||||||
|
|
||||||
|
Here we have used filter `filterExactCommands` which will pass only `ContentMessage` with only one command `start`
|
||||||
|
|
||||||
#### Sent messages
|
#### Sent messages
|
||||||
|
|
||||||
All sent messages can be filtered for three types:
|
All sent messages can be filtered for three types:
|
||||||
|
@ -20,25 +20,22 @@ publishing {
|
|||||||
publications.all {
|
publications.all {
|
||||||
artifact javadocsJar
|
artifact javadocsJar
|
||||||
|
|
||||||
pom.withXml {
|
pom {
|
||||||
asNode().children().last() + {
|
description = "Util extensions for more useful work with updates and other things"
|
||||||
resolveStrategy = Closure.DELEGATE_FIRST
|
name = "Telegram Bot API Utility Extensions"
|
||||||
|
url = "https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-extensions-utils"
|
||||||
description "Util extensions for more useful work with updates and other things"
|
|
||||||
name "Telegram Bot API Utility Extensions"
|
|
||||||
url "https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-extensions-utils"
|
|
||||||
|
|
||||||
scm {
|
scm {
|
||||||
developerConnection "scm:git:[fetch=]https://github.com/insanusmokrassar/TelegramBotAPI.git[push=]https://github.com/insanusmokrassar/TelegramBotAPI.git"
|
developerConnection = "scm:git:[fetch=]https://github.com/insanusmokrassar/TelegramBotAPI.git[push=]https://github.com/insanusmokrassar/TelegramBotAPI.git"
|
||||||
url "https://github.com/insanusmokrassar/TelegramBotAPI.git"
|
url = "https://github.com/insanusmokrassar/TelegramBotAPI.git"
|
||||||
}
|
}
|
||||||
|
|
||||||
developers {
|
developers {
|
||||||
|
|
||||||
developer {
|
developer {
|
||||||
id "InsanusMokrassar"
|
id = "InsanusMokrassar"
|
||||||
name "Ovsiannikov Aleksei"
|
name = "Ovsiannikov Aleksei"
|
||||||
email "ovsyannikov.alexey95@gmail.com"
|
email = "ovsyannikov.alexey95@gmail.com"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -46,12 +43,11 @@ publishing {
|
|||||||
licenses {
|
licenses {
|
||||||
|
|
||||||
license {
|
license {
|
||||||
name "Apache Software License 2.0"
|
name = "Apache Software License 2.0"
|
||||||
url "https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"
|
url = "https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
@ -0,0 +1,49 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.updates
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.*
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import kotlinx.coroutines.flow.mapNotNull
|
||||||
|
|
||||||
|
fun Flow<Update>.onlyBaseMessageUpdates(): Flow<BaseMessageUpdate> = mapNotNull {
|
||||||
|
it as? BaseMessageUpdate
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts flow to [Flow] of [BaseSentMessageUpdate]
|
||||||
|
*/
|
||||||
|
fun Flow<BaseMessageUpdate>.onlySentMessageUpdates(): Flow<BaseSentMessageUpdate> = mapNotNull {
|
||||||
|
it as? BaseSentMessageUpdate
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts flow to [Flow] of [BaseSentMessageUpdate]
|
||||||
|
*/
|
||||||
|
fun Flow<BaseMessageUpdate>.onlyEditMessageUpdates(): Flow<BaseEditMessageUpdate> = mapNotNull {
|
||||||
|
it as? BaseEditMessageUpdate
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts flow to [Flow] of [MediaGroupUpdate]. Please, remember that it could be either [EditMediaGroupUpdate]
|
||||||
|
* or [SentMediaGroupUpdate]
|
||||||
|
*
|
||||||
|
* @see onlySentMediaGroupUpdates
|
||||||
|
* @see onlyEditMediaGroupUpdates
|
||||||
|
*/
|
||||||
|
fun Flow<BaseMessageUpdate>.onlyMediaGroupsUpdates(): Flow<MediaGroupUpdate> = mapNotNull {
|
||||||
|
it as? MediaGroupUpdate
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts flow to [Flow] of [SentMediaGroupUpdate]
|
||||||
|
*/
|
||||||
|
fun Flow<MediaGroupUpdate>.onlySentMediaGroupUpdates(): Flow<SentMediaGroupUpdate> = mapNotNull {
|
||||||
|
it as? SentMediaGroupUpdate
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts flow to [Flow] of [EditMediaGroupUpdate]
|
||||||
|
*/
|
||||||
|
fun Flow<MediaGroupUpdate>.onlyEditMediaGroupUpdates(): Flow<EditMediaGroupUpdate> = mapNotNull {
|
||||||
|
it as? EditMediaGroupUpdate
|
||||||
|
}
|
@ -10,22 +10,38 @@ import kotlinx.coroutines.flow.filter
|
|||||||
/**
|
/**
|
||||||
* [Flow.filter] incoming [BaseMessageUpdate]s by their [ChatId]
|
* [Flow.filter] incoming [BaseMessageUpdate]s by their [ChatId]
|
||||||
*/
|
*/
|
||||||
fun <T : BaseMessageUpdate> Flow<T>.filterBaseMessageUpdates(chatId: ChatId): Flow<T> = filter {
|
fun <T : BaseMessageUpdate> Flow<T>.filterBaseMessageUpdatesByChatId(chatId: ChatId): Flow<T> = filter { it.data.chat.id == chatId }
|
||||||
it.data.chat.id == chatId
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* [Flow.filter] incoming [BaseMessageUpdate]s by their [ChatId] using [Chat.id] of [chat]
|
* [Flow.filter] incoming [BaseMessageUpdate]s by their [ChatId] using [Chat.id] of [chat]
|
||||||
*/
|
*/
|
||||||
fun <T : BaseMessageUpdate> Flow<T>.filterBaseMessageUpdates(chat: Chat): Flow<T> = filterBaseMessageUpdates(chat.id)
|
fun <T : BaseMessageUpdate> Flow<T>.filterBaseMessageUpdatesByChat(chat: Chat): Flow<T> = filterBaseMessageUpdatesByChatId(chat.id)
|
||||||
|
/**
|
||||||
|
* [Flow.filter] incoming [BaseMessageUpdate]s by their [ChatId]
|
||||||
|
*/
|
||||||
|
@Deprecated("Renamed", ReplaceWith("filterBaseMessageUpdatesByChatId"))
|
||||||
|
fun <T : BaseMessageUpdate> Flow<T>.filterBaseMessageUpdates(chatId: ChatId): Flow<T> = filterBaseMessageUpdatesByChatId(chatId)
|
||||||
|
/**
|
||||||
|
* [Flow.filter] incoming [BaseMessageUpdate]s by their [ChatId] using [Chat.id] of [chat]
|
||||||
|
*/
|
||||||
|
@Deprecated("Renamed", ReplaceWith("filterBaseMessageUpdatesByChat"))
|
||||||
|
fun <T : BaseMessageUpdate> Flow<T>.filterBaseMessageUpdates(chat: Chat): Flow<T> = filterBaseMessageUpdatesByChatId(chat.id)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [Flow.filter] incoming [SentMediaGroupUpdate]s by their [ChatId]
|
* [Flow.filter] incoming [SentMediaGroupUpdate]s by their [ChatId]
|
||||||
*/
|
*/
|
||||||
fun <T : SentMediaGroupUpdate> Flow<T>.filterSentMediaGroupUpdates(chatId: ChatId): Flow<T> = filter {
|
fun <T : SentMediaGroupUpdate> Flow<T>.filterSentMediaGroupUpdatesByChatId(chatId: ChatId): Flow<T> = filter { it.data.first().chat.id == chatId }
|
||||||
it.data.first().chat.id == chatId
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* [Flow.filter] incoming [SentMediaGroupUpdate]s by their [ChatId] using [Chat.id] of [chat]
|
* [Flow.filter] incoming [SentMediaGroupUpdate]s by their [ChatId] using [Chat.id] of [chat]
|
||||||
*/
|
*/
|
||||||
fun <T : SentMediaGroupUpdate> Flow<T>.filterSentMediaGroupUpdates(chat: Chat): Flow<T> = filterSentMediaGroupUpdates(chat.id)
|
fun <T : SentMediaGroupUpdate> Flow<T>.filterSentMediaGroupUpdatesByChat(chat: Chat): Flow<T> = filterSentMediaGroupUpdatesByChatId(chat.id)
|
||||||
|
/**
|
||||||
|
* [Flow.filter] incoming [SentMediaGroupUpdate]s by their [ChatId]
|
||||||
|
*/
|
||||||
|
@Deprecated("Renamed", ReplaceWith("filterSentMediaGroupUpdatesByChatId"))
|
||||||
|
fun <T : SentMediaGroupUpdate> Flow<T>.filterSentMediaGroupUpdates(chatId: ChatId): Flow<T> = filterSentMediaGroupUpdatesByChatId(chatId)
|
||||||
|
/**
|
||||||
|
* [Flow.filter] incoming [SentMediaGroupUpdate]s by their [ChatId] using [Chat.id] of [chat]
|
||||||
|
*/
|
||||||
|
@Deprecated("Renamed", ReplaceWith("filterSentMediaGroupUpdatesByChat"))
|
||||||
|
fun <T : SentMediaGroupUpdate> Flow<T>.filterSentMediaGroupUpdates(chat: Chat): Flow<T> = filterSentMediaGroupUpdatesByChatId(chat.id)
|
||||||
|
@ -20,25 +20,22 @@ publishing {
|
|||||||
publications.all {
|
publications.all {
|
||||||
artifact javadocsJar
|
artifact javadocsJar
|
||||||
|
|
||||||
pom.withXml {
|
pom {
|
||||||
asNode().children().last() + {
|
description = "Library for Object-Oriented and type-safe work with Telegram Bot API"
|
||||||
resolveStrategy = Closure.DELEGATE_FIRST
|
name = "Telegram Bot API"
|
||||||
|
url = "https://insanusmokrassar.github.io/TelegramBotAPI"
|
||||||
description "Library for Object-Oriented and type-safe work with Telegram Bot API"
|
|
||||||
name "Telegram Bot API"
|
|
||||||
url "https://insanusmokrassar.github.io/TelegramBotAPI"
|
|
||||||
|
|
||||||
scm {
|
scm {
|
||||||
developerConnection "scm:git:[fetch=]https://github.com/insanusmokrassar/TelegramBotAPI.git[push=]https://github.com/insanusmokrassar/TelegramBotAPI.git"
|
developerConnection = "scm:git:[fetch=]https://github.com/insanusmokrassar/TelegramBotAPI.git[push=]https://github.com/insanusmokrassar/TelegramBotAPI.git"
|
||||||
url "https://github.com/insanusmokrassar/TelegramBotAPI.git"
|
url = "https://github.com/insanusmokrassar/TelegramBotAPI.git"
|
||||||
}
|
}
|
||||||
|
|
||||||
developers {
|
developers {
|
||||||
|
|
||||||
developer {
|
developer {
|
||||||
id "InsanusMokrassar"
|
id = "InsanusMokrassar"
|
||||||
name "Ovsiannikov Aleksei"
|
name = "Ovsiannikov Aleksei"
|
||||||
email "ovsyannikov.alexey95@gmail.com"
|
email = "ovsyannikov.alexey95@gmail.com"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -46,12 +43,11 @@ publishing {
|
|||||||
licenses {
|
licenses {
|
||||||
|
|
||||||
license {
|
license {
|
||||||
name "Apache Software License 2.0"
|
name = "Apache Software License 2.0"
|
||||||
url "https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"
|
url = "https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
@ -9,6 +9,6 @@ ktor_version=1.3.2
|
|||||||
javax_activation_version=1.1.1
|
javax_activation_version=1.1.1
|
||||||
|
|
||||||
library_group=com.github.insanusmokrassar
|
library_group=com.github.insanusmokrassar
|
||||||
library_version=0.27.3
|
library_version=0.27.4
|
||||||
|
|
||||||
gradle_bintray_plugin_version=1.8.4
|
gradle_bintray_plugin_version=1.8.4
|
||||||
|
Loading…
Reference in New Issue
Block a user