mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-25 03:28:44 +00:00
commit
8d9ebb754b
16
CHANGELOG.md
16
CHANGELOG.md
@ -49,12 +49,28 @@
|
|||||||
* `closePollExactAfter`
|
* `closePollExactAfter`
|
||||||
* `closePollAfter`
|
* `closePollAfter`
|
||||||
|
|
||||||
|
### 0.27.8
|
||||||
|
|
||||||
|
* `TelegramBotAPI`:
|
||||||
|
* `UnknownUpdateType` was renamed to `UnknownUpdate`
|
||||||
|
* Refactoring and optimization of `FlowsUpdatesFilter`
|
||||||
|
* `Venue` type was replaced to a new package: `com.github.insanusmokrassar.TelegramBotAPI.types.venue.Venue`
|
||||||
|
* `Venue` type now implements `Locationed` and delegate realisation to its `location` field
|
||||||
|
* `FoursquareId` and `FoursquareType` typealiases were added
|
||||||
|
* `TelegramBotAPI-extensions-utils`:
|
||||||
|
* Several new functions `makeLinkToMessage` was added
|
||||||
|
* `Foursquare` data class was added
|
||||||
|
* Extension `Venue#foursquare` was added
|
||||||
|
* Factory function `Venue` with `Foursquare` parameter was added
|
||||||
|
|
||||||
### 0.27.7
|
### 0.27.7
|
||||||
|
|
||||||
* `TelegramBotAPI`:
|
* `TelegramBotAPI`:
|
||||||
* Operator function `unaryPlus` was added to `RowBuilder`. Now it is possible to write `row { +button }`
|
* Operator function `unaryPlus` was added to `RowBuilder`. Now it is possible to write `row { +button }`
|
||||||
* Function `flatMatrix` was added for single-row columns
|
* Function `flatMatrix` was added for single-row columns
|
||||||
* Operator extension `RowBuilder#plus` was added to be able to write things like `row { this + button }`
|
* Operator extension `RowBuilder#plus` was added to be able to write things like `row { this + button }`
|
||||||
|
* `TelegramBotAPI-extensions-api`:
|
||||||
|
* Extensions `RequestsExecutor#sendVenue` with `Location` args were added
|
||||||
* `TelegramBotAPI-extensions-utils`:
|
* `TelegramBotAPI-extensions-utils`:
|
||||||
* Function `InlineKeyboardMarkup` for flat keyboards was added
|
* Function `InlineKeyboardMarkup` for flat keyboards was added
|
||||||
* Function `ReplyKeyboardMarkup` for flat keyboards was added
|
* Function `ReplyKeyboardMarkup` for flat keyboards was added
|
||||||
|
@ -2,10 +2,7 @@
|
|||||||
|
|
||||||
| Common info | [![Awesome Kotlin Badge](https://kotlin.link/awesome-kotlin.svg)](https://github.com/KotlinBy/awesome-kotlin) [![Build Status](https://travis-ci.com/InsanusMokrassar/TelegramBotAPI.svg?branch=master)](https://travis-ci.com/InsanusMokrassar/TelegramBotAPI) |
|
| Common info | [![Awesome Kotlin Badge](https://kotlin.link/awesome-kotlin.svg)](https://github.com/KotlinBy/awesome-kotlin) [![Build Status](https://travis-ci.com/InsanusMokrassar/TelegramBotAPI.svg?branch=master)](https://travis-ci.com/InsanusMokrassar/TelegramBotAPI) |
|
||||||
| -------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
| -------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||||
| Useful links | • [Examples](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/) |
|
| Useful links | [![Chat in Telegram](badges/chat.svg)](https://teleg.one/InMoTelegramBotAPI) [![KDocs](badges/kdocs.svg)](https://tgbotapi.inmo.dev/docs/index.html) [Examples](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/), [Mini tutorial](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) |
|
||||||
| | • [Mini tutorial](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) |
|
|
||||||
| | • [![Chat in Telegram](badges/chat.svg)](https://teleg.one/InMoTelegramBotAPI) |
|
|
||||||
| | • [![KDocs](badges/kdocs.svg)](https://tgbotapi.inmo.dev/docs/index.html) |
|
|
||||||
| 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) |
|
| 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) |
|
||||||
| 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) |
|
| 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) |
|
||||||
| TelegramBotAPI Util Extensions status | [![Download](https://api.bintray.com/packages/insanusmokrassar/StandardRepository/TelegramBotAPI-extensions-utils/images/download.svg)](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI-extensions-utils/_latestVersion) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI-extensions-utils/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI-extensions-utils) |
|
| TelegramBotAPI Util Extensions status | [![Download](https://api.bintray.com/packages/insanusmokrassar/StandardRepository/TelegramBotAPI-extensions-utils/images/download.svg)](https://bintray.com/insanusmokrassar/StandardRepository/TelegramBotAPI-extensions-utils/_latestVersion) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI-extensions-utils/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.insanusmokrassar/TelegramBotAPI-extensions-utils) |
|
||||||
|
@ -5,6 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendVenue
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.venue.Venue
|
||||||
|
|
||||||
suspend fun RequestsExecutor.sendVenue(
|
suspend fun RequestsExecutor.sendVenue(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
@ -36,6 +37,32 @@ suspend fun RequestsExecutor.sendVenue(
|
|||||||
chat.id, latitude, longitude, title, address, foursquareId, disableNotification, replyToMessageId, replyMarkup
|
chat.id, latitude, longitude, title, address, foursquareId, disableNotification, replyToMessageId, replyMarkup
|
||||||
)
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVenue(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
location: Location,
|
||||||
|
title: String,
|
||||||
|
address: String,
|
||||||
|
foursquareId: String? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendVenue(
|
||||||
|
chatId, location.latitude, location.longitude, title, address, foursquareId, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendVenue(
|
||||||
|
chat: Chat,
|
||||||
|
location: Location,
|
||||||
|
title: String,
|
||||||
|
address: String,
|
||||||
|
foursquareId: String? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendVenue(
|
||||||
|
chat.id, location.latitude, location.longitude, title, address, foursquareId, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
suspend fun RequestsExecutor.sendVenue(
|
suspend fun RequestsExecutor.sendVenue(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
venue: Venue,
|
venue: Venue,
|
||||||
|
@ -76,7 +76,7 @@ fun RequestsExecutor.startGettingFlowsUpdates(
|
|||||||
timeoutSeconds: Seconds = 30,
|
timeoutSeconds: Seconds = 30,
|
||||||
scope: CoroutineScope = CoroutineScope(Dispatchers.Default),
|
scope: CoroutineScope = CoroutineScope(Dispatchers.Default),
|
||||||
exceptionsHandler: (suspend (Exception) -> Unit)? = null,
|
exceptionsHandler: (suspend (Exception) -> Unit)? = null,
|
||||||
flowsUpdatesFilterUpdatesKeeperCount: Int = 64,
|
flowsUpdatesFilterUpdatesKeeperCount: Int = 100,
|
||||||
flowUpdatesPreset: FlowsUpdatesFilter.() -> Unit = {}
|
flowUpdatesPreset: FlowsUpdatesFilter.() -> Unit = {}
|
||||||
): FlowsUpdatesFilter = FlowsUpdatesFilter(flowsUpdatesFilterUpdatesKeeperCount).apply {
|
): FlowsUpdatesFilter = FlowsUpdatesFilter(flowsUpdatesFilterUpdatesKeeperCount).apply {
|
||||||
flowUpdatesPreset()
|
flowUpdatesPreset()
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.extensions.venue
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.venue.Venue
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
val Venue.foursquare: Foursquare?
|
||||||
|
get() = foursquareId ?.let {
|
||||||
|
Foursquare(it, foursquareType)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Venue(
|
||||||
|
location: Location,
|
||||||
|
title: String,
|
||||||
|
address: String,
|
||||||
|
foursquare: Foursquare
|
||||||
|
) = Venue(location, title, address, foursquare.id, foursquare.type)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Foursquare(
|
||||||
|
@SerialName(foursquareIdField)
|
||||||
|
val id: FoursquareId,
|
||||||
|
@SerialName(foursquareTypeField)
|
||||||
|
val type: FoursquareType? = null
|
||||||
|
)
|
@ -1,8 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.formatting
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.formatting
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.StickerSetName
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PrivateChat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PrivateChat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.UsernameChat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.UsernameChat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.extended.ExtendedChat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.extended.ExtendedChat
|
||||||
@ -14,6 +13,14 @@ fun makeLinkToMessage(
|
|||||||
username: String,
|
username: String,
|
||||||
messageId: MessageIdentifier
|
messageId: MessageIdentifier
|
||||||
): String = "$internalLinkBeginning/$username/$messageId"
|
): String = "$internalLinkBeginning/$username/$messageId"
|
||||||
|
fun makeLinkToMessage(
|
||||||
|
username: Username,
|
||||||
|
messageId: MessageIdentifier
|
||||||
|
): String = makeLinkToMessage(username.username, messageId)
|
||||||
|
fun makeLinkToMessage(
|
||||||
|
chat: UsernameChat,
|
||||||
|
messageId: MessageIdentifier
|
||||||
|
): String? = chat.username ?.let { makeLinkToMessage(it, messageId) }
|
||||||
|
|
||||||
private val linkIdRedundantPartRegex = Regex("^-100")
|
private val linkIdRedundantPartRegex = Regex("^-100")
|
||||||
private val usernameBeginSymbolRegex = Regex("^@")
|
private val usernameBeginSymbolRegex = Regex("^@")
|
||||||
|
@ -4,7 +4,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendMediaG
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.ForwardInfo
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.ForwardInfo
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaGroupMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates.SentMediaGroupUpdate
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates.SentMediaGroupUpdate
|
||||||
|
|
||||||
val List<MediaGroupMessage>.forwardInfo: ForwardInfo?
|
val List<MediaGroupMessage>.forwardInfo: ForwardInfo?
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.types.buttons
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.types.buttons
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardButtons.InlineKeyboardButton
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardButtons.InlineKeyboardButton
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.flatMatrix
|
||||||
|
|
||||||
fun InlineKeyboardMarkup(
|
fun InlineKeyboardMarkup(
|
||||||
vararg buttons: InlineKeyboardButton
|
vararg buttons: InlineKeyboardButton
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.types.buttons
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.types.buttons
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.ReplyKeyboardMarkup
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardButton
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardButton
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.ReplyKeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.flatMatrix
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.flatMatrix
|
||||||
|
|
||||||
fun ReplyKeyboardMarkup(
|
fun ReplyKeyboardMarkup(
|
||||||
|
@ -3,25 +3,19 @@ package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.updates
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.*
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.mapNotNull
|
import kotlinx.coroutines.flow.filterIsInstance
|
||||||
|
|
||||||
fun Flow<Update>.onlyBaseMessageUpdates(): Flow<BaseMessageUpdate> = mapNotNull {
|
fun Flow<Update>.onlyBaseMessageUpdates(): Flow<BaseMessageUpdate> = filterIsInstance()
|
||||||
it as? BaseMessageUpdate
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts flow to [Flow] of [BaseSentMessageUpdate]
|
* Converts flow to [Flow] of [BaseSentMessageUpdate]
|
||||||
*/
|
*/
|
||||||
fun Flow<BaseMessageUpdate>.onlySentMessageUpdates(): Flow<BaseSentMessageUpdate> = mapNotNull {
|
fun Flow<BaseMessageUpdate>.onlySentMessageUpdates(): Flow<BaseSentMessageUpdate> = filterIsInstance()
|
||||||
it as? BaseSentMessageUpdate
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts flow to [Flow] of [BaseSentMessageUpdate]
|
* Converts flow to [Flow] of [BaseSentMessageUpdate]
|
||||||
*/
|
*/
|
||||||
fun Flow<BaseMessageUpdate>.onlyEditMessageUpdates(): Flow<BaseEditMessageUpdate> = mapNotNull {
|
fun Flow<BaseMessageUpdate>.onlyEditMessageUpdates(): Flow<BaseEditMessageUpdate> = filterIsInstance()
|
||||||
it as? BaseEditMessageUpdate
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts flow to [Flow] of [MediaGroupUpdate]. Please, remember that it could be either [EditMediaGroupUpdate]
|
* Converts flow to [Flow] of [MediaGroupUpdate]. Please, remember that it could be either [EditMediaGroupUpdate]
|
||||||
@ -30,20 +24,14 @@ fun Flow<BaseMessageUpdate>.onlyEditMessageUpdates(): Flow<BaseEditMessageUpdate
|
|||||||
* @see onlySentMediaGroupUpdates
|
* @see onlySentMediaGroupUpdates
|
||||||
* @see onlyEditMediaGroupUpdates
|
* @see onlyEditMediaGroupUpdates
|
||||||
*/
|
*/
|
||||||
fun Flow<BaseMessageUpdate>.onlyMediaGroupsUpdates(): Flow<MediaGroupUpdate> = mapNotNull {
|
fun Flow<BaseMessageUpdate>.onlyMediaGroupsUpdates(): Flow<MediaGroupUpdate> = filterIsInstance()
|
||||||
it as? MediaGroupUpdate
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts flow to [Flow] of [SentMediaGroupUpdate]
|
* Converts flow to [Flow] of [SentMediaGroupUpdate]
|
||||||
*/
|
*/
|
||||||
fun Flow<MediaGroupUpdate>.onlySentMediaGroupUpdates(): Flow<SentMediaGroupUpdate> = mapNotNull {
|
fun Flow<MediaGroupUpdate>.onlySentMediaGroupUpdates(): Flow<SentMediaGroupUpdate> = filterIsInstance()
|
||||||
it as? SentMediaGroupUpdate
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts flow to [Flow] of [EditMediaGroupUpdate]
|
* Converts flow to [Flow] of [EditMediaGroupUpdate]
|
||||||
*/
|
*/
|
||||||
fun Flow<MediaGroupUpdate>.onlyEditMediaGroupUpdates(): Flow<EditMediaGroupUpdate> = mapNotNull {
|
fun Flow<MediaGroupUpdate>.onlyEditMediaGroupUpdates(): Flow<EditMediaGroupUpdate> = filterIsInstance()
|
||||||
it as? EditMediaGroupUpdate
|
|
||||||
}
|
|
||||||
|
@ -8,7 +8,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.FlowsUpdatesFi
|
|||||||
* @see flowsUpdatesFilter
|
* @see flowsUpdatesFilter
|
||||||
*/
|
*/
|
||||||
inline fun flowsUpdatesFilter(
|
inline fun flowsUpdatesFilter(
|
||||||
internalChannelsSizes: Int = 64,
|
internalChannelsSizes: Int = 100,
|
||||||
block: FlowsUpdatesFilter.() -> Unit
|
block: FlowsUpdatesFilter.() -> Unit
|
||||||
): FlowsUpdatesFilter {
|
): FlowsUpdatesFilter {
|
||||||
val filter = FlowsUpdatesFilter(internalChannelsSizes)
|
val filter = FlowsUpdatesFilter(internalChannelsSizes)
|
||||||
|
@ -76,7 +76,7 @@ fun RequestsExecutor.startGettingFlowsUpdatesByLongPolling(
|
|||||||
timeoutSeconds: Seconds = 30,
|
timeoutSeconds: Seconds = 30,
|
||||||
scope: CoroutineScope = CoroutineScope(Dispatchers.Default),
|
scope: CoroutineScope = CoroutineScope(Dispatchers.Default),
|
||||||
exceptionsHandler: ExceptionHandler<Unit>? = null,
|
exceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||||
flowsUpdatesFilterUpdatesKeeperCount: Int = 64,
|
flowsUpdatesFilterUpdatesKeeperCount: Int = 100,
|
||||||
flowUpdatesPreset: FlowsUpdatesFilter.() -> Unit = {}
|
flowUpdatesPreset: FlowsUpdatesFilter.() -> Unit = {}
|
||||||
): FlowsUpdatesFilter = FlowsUpdatesFilter(flowsUpdatesFilterUpdatesKeeperCount).apply {
|
): FlowsUpdatesFilter = FlowsUpdatesFilter(flowsUpdatesFilterUpdatesKeeperCount).apply {
|
||||||
flowUpdatesPreset()
|
flowUpdatesPreset()
|
||||||
|
@ -18,7 +18,8 @@ import io.ktor.request.receiveText
|
|||||||
import io.ktor.response.respond
|
import io.ktor.response.respond
|
||||||
import io.ktor.routing.*
|
import io.ktor.routing.*
|
||||||
import io.ktor.server.engine.*
|
import io.ktor.server.engine.*
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.asCoroutineDispatcher
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.VenueContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.VenueContent
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.venue.Venue
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<VenueContent>>
|
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<VenueContent>>
|
||||||
|
@ -22,6 +22,8 @@ typealias PollIdentifier = String
|
|||||||
typealias StickerSetName = String
|
typealias StickerSetName = String
|
||||||
typealias FileUniqueId = String
|
typealias FileUniqueId = String
|
||||||
typealias DiceResult = Int
|
typealias DiceResult = Int
|
||||||
|
typealias FoursquareId = String
|
||||||
|
typealias FoursquareType = String
|
||||||
|
|
||||||
typealias Seconds = Int
|
typealias Seconds = Int
|
||||||
typealias LongSeconds = Long
|
typealias LongSeconds = Long
|
||||||
|
@ -1,19 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types
|
package com.github.insanusmokrassar.TelegramBotAPI.types
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CommonVenueData
|
import com.github.insanusmokrassar.TelegramBotAPI.types.venue.Venue
|
||||||
import kotlinx.serialization.SerialName
|
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
|
|
||||||
@Serializable
|
@Deprecated("Replaced", ReplaceWith("Venue", "com.github.insanusmokrassar.TelegramBotAPI.types.venue.Venue"))
|
||||||
data class Venue(
|
typealias Venue = Venue
|
||||||
@SerialName(locationField)
|
|
||||||
val location: Location,
|
|
||||||
@SerialName(titleField)
|
|
||||||
override val title: String,
|
|
||||||
@SerialName(addressField)
|
|
||||||
override val address: String,
|
|
||||||
@SerialName(foursquareIdField)
|
|
||||||
override val foursquareId: String? = null,
|
|
||||||
@SerialName(foursquareTypeField)
|
|
||||||
override val foursquareType: String? = null
|
|
||||||
) : CommonVenueData
|
|
||||||
|
@ -3,7 +3,7 @@ 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.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.PossiblySentViaBotCommonMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.PossiblySentViaBotCommonMessage
|
||||||
import com.soywiz.klock.DateTime
|
import com.soywiz.klock.DateTime
|
||||||
|
@ -3,7 +3,8 @@ 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.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.FromUserMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.PossiblySentViaBotCommonMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.PossiblySentViaBotCommonMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.SuccessfulPaymentInfo
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.SuccessfulPaymentInfo
|
||||||
|
@ -20,6 +20,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.Success
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.Invoice
|
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.Invoice
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.SuccessfulPayment
|
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.SuccessfulPayment
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll
|
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.venue.Venue
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
@ -2,10 +2,12 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message.content
|
|||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendVenue
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendVenue
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.venue.Venue
|
||||||
|
|
||||||
data class VenueContent(
|
data class VenueContent(
|
||||||
val venue: Venue
|
val venue: Venue
|
||||||
|
@ -9,7 +9,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.payments.PreCheckoutQuer
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.ShippingQuery
|
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.ShippingQuery
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll
|
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.PollAnswer
|
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.PollAnswer
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.UnknownUpdateType
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.UnknownUpdate
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.updateIdField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.updateIdField
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
@ -57,7 +57,7 @@ internal data class RawUpdate constructor(
|
|||||||
pre_checkout_query != null -> PreCheckoutQueryUpdate(updateId, pre_checkout_query)
|
pre_checkout_query != null -> PreCheckoutQueryUpdate(updateId, pre_checkout_query)
|
||||||
poll != null -> PollUpdate(updateId, poll)
|
poll != null -> PollUpdate(updateId, poll)
|
||||||
poll_answer != null -> PollAnswerUpdate(updateId, poll_answer)
|
poll_answer != null -> PollAnswerUpdate(updateId, poll_answer)
|
||||||
else -> UnknownUpdateType(
|
else -> UnknownUpdate(
|
||||||
updateId,
|
updateId,
|
||||||
raw.toString(),
|
raw.toString(),
|
||||||
raw
|
raw
|
||||||
@ -66,7 +66,7 @@ internal data class RawUpdate constructor(
|
|||||||
} catch (e: Error) {
|
} catch (e: Error) {
|
||||||
when (e) {
|
when (e) {
|
||||||
is SerializationException,
|
is SerializationException,
|
||||||
is NotImplementedError -> UnknownUpdateType(
|
is NotImplementedError -> UnknownUpdate(
|
||||||
updateId,
|
updateId,
|
||||||
raw.toString(),
|
raw.toString(),
|
||||||
raw
|
raw
|
||||||
|
@ -12,11 +12,13 @@ interface Update {
|
|||||||
val data: Any
|
val data: Any
|
||||||
}
|
}
|
||||||
|
|
||||||
data class UnknownUpdateType(
|
data class UnknownUpdate(
|
||||||
override val updateId: UpdateIdentifier,
|
override val updateId: UpdateIdentifier,
|
||||||
override val data: String,
|
override val data: String,
|
||||||
val rawJson: JsonElement
|
val rawJson: JsonElement
|
||||||
) : Update
|
) : Update
|
||||||
|
@Deprecated("Renamed", ReplaceWith("UnknownUpdate"))
|
||||||
|
typealias UnknownUpdateType = UnknownUpdate
|
||||||
|
|
||||||
internal object UpdateSerializerWithoutSerialization : KSerializer<Update> {
|
internal object UpdateSerializerWithoutSerialization : KSerializer<Update> {
|
||||||
override val descriptor: SerialDescriptor = JsonElementSerializer.descriptor
|
override val descriptor: SerialDescriptor = JsonElementSerializer.descriptor
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.venue
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.CommonVenueData
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.Locationed
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Venue(
|
||||||
|
@SerialName(locationField)
|
||||||
|
val location: Location,
|
||||||
|
@SerialName(titleField)
|
||||||
|
override val title: String,
|
||||||
|
@SerialName(addressField)
|
||||||
|
override val address: String,
|
||||||
|
@SerialName(foursquareIdField)
|
||||||
|
override val foursquareId: FoursquareId? = null,
|
||||||
|
@SerialName(foursquareTypeField)
|
||||||
|
override val foursquareType: FoursquareType? = null
|
||||||
|
) : CommonVenueData, Locationed by location
|
@ -1,74 +1,41 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.updateshandlers
|
package com.github.insanusmokrassar.TelegramBotAPI.updateshandlers
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ALL_UPDATES_LIST
|
||||||
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.types.update.abstracts.UnknownUpdate
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
|
||||||
import kotlinx.coroutines.channels.BroadcastChannel
|
import kotlinx.coroutines.channels.BroadcastChannel
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.*
|
||||||
import kotlinx.coroutines.flow.asFlow
|
|
||||||
|
|
||||||
@Suppress("EXPERIMENTAL_API_USAGE")
|
|
||||||
private fun <T> BroadcastChannel<T>.createUpdateReceiver(): UpdateReceiver<T> = ::send
|
|
||||||
|
|
||||||
@Suppress("EXPERIMENTAL_API_USAGE", "unused")
|
@Suppress("EXPERIMENTAL_API_USAGE", "unused")
|
||||||
class FlowsUpdatesFilter(
|
class FlowsUpdatesFilter(
|
||||||
broadcastChannelsSize: Int = 64
|
broadcastChannelsSize: Int = 100
|
||||||
): UpdatesFilter {
|
): UpdatesFilter {
|
||||||
private val messageChannel: BroadcastChannel<MessageUpdate> = BroadcastChannel(broadcastChannelsSize)
|
private val updatesReceivingChannel = BroadcastChannel<Update>(broadcastChannelsSize)
|
||||||
private val messageMediaGroupChannel: BroadcastChannel<MessageMediaGroupUpdate> = BroadcastChannel(broadcastChannelsSize)
|
@Suppress("MemberVisibilityCanBePrivate")
|
||||||
private val editedMessageChannel: BroadcastChannel<EditMessageUpdate> = BroadcastChannel(broadcastChannelsSize)
|
val allUpdatesFlow: Flow<Update> = updatesReceivingChannel.asFlow()
|
||||||
private val editedMessageMediaGroupChannel: BroadcastChannel<EditMessageMediaGroupUpdate> = BroadcastChannel(broadcastChannelsSize)
|
|
||||||
private val channelPostChannel: BroadcastChannel<ChannelPostUpdate> = BroadcastChannel(broadcastChannelsSize)
|
|
||||||
private val channelPostMediaGroupChannel: BroadcastChannel<ChannelPostMediaGroupUpdate> = BroadcastChannel(broadcastChannelsSize)
|
|
||||||
private val editedChannelPostChannel: BroadcastChannel<EditChannelPostUpdate> = BroadcastChannel(broadcastChannelsSize)
|
|
||||||
private val editedChannelPostMediaGroupChannel: BroadcastChannel<EditChannelPostMediaGroupUpdate> = BroadcastChannel(broadcastChannelsSize)
|
|
||||||
private val chosenInlineResultChannel: BroadcastChannel<ChosenInlineResultUpdate> = BroadcastChannel(broadcastChannelsSize)
|
|
||||||
private val inlineQueryChannel: BroadcastChannel<InlineQueryUpdate> = BroadcastChannel(broadcastChannelsSize)
|
|
||||||
private val callbackQueryChannel: BroadcastChannel<CallbackQueryUpdate> = BroadcastChannel(broadcastChannelsSize)
|
|
||||||
private val shippingQueryChannel: BroadcastChannel<ShippingQueryUpdate> = BroadcastChannel(broadcastChannelsSize)
|
|
||||||
private val preCheckoutQueryChannel: BroadcastChannel<PreCheckoutQueryUpdate> = BroadcastChannel(broadcastChannelsSize)
|
|
||||||
private val pollChannel: BroadcastChannel<PollUpdate> = BroadcastChannel(broadcastChannelsSize)
|
|
||||||
private val pollAnswerChannel: BroadcastChannel<PollAnswerUpdate> = BroadcastChannel(broadcastChannelsSize)
|
|
||||||
private val unknownUpdateChannel: BroadcastChannel<Update> = BroadcastChannel(broadcastChannelsSize)
|
|
||||||
|
|
||||||
override val allowedUpdates: List<String>
|
override val allowedUpdates: List<String>
|
||||||
get() = filter.allowedUpdates
|
get() = ALL_UPDATES_LIST
|
||||||
override val asUpdateReceiver: UpdateReceiver<Update>
|
override val asUpdateReceiver: UpdateReceiver<Update> = {
|
||||||
get() = filter.asUpdateReceiver
|
updatesReceivingChannel.send(it)
|
||||||
|
}
|
||||||
val filter = SimpleUpdatesFilter(
|
|
||||||
messageChannel.createUpdateReceiver(),
|
val messageFlow: Flow<MessageUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
messageMediaGroupChannel.createUpdateReceiver(),
|
val messageMediaGroupFlow: Flow<MessageMediaGroupUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
editedMessageChannel.createUpdateReceiver(),
|
val editedMessageFlow: Flow<EditMessageUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
editedMessageMediaGroupChannel.createUpdateReceiver(),
|
val editedMessageMediaGroupFlow: Flow<EditMessageMediaGroupUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
channelPostChannel.createUpdateReceiver(),
|
val channelPostFlow: Flow<ChannelPostUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
channelPostMediaGroupChannel.createUpdateReceiver(),
|
val channelPostMediaGroupFlow: Flow<ChannelPostMediaGroupUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
editedChannelPostChannel.createUpdateReceiver(),
|
val editedChannelPostFlow: Flow<EditChannelPostUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
editedChannelPostMediaGroupChannel.createUpdateReceiver(),
|
val editedChannelPostMediaGroupFlow: Flow<EditChannelPostMediaGroupUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
chosenInlineResultChannel.createUpdateReceiver(),
|
val chosenInlineResultFlow: Flow<ChosenInlineResultUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
inlineQueryChannel.createUpdateReceiver(),
|
val inlineQueryFlow: Flow<InlineQueryUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
callbackQueryChannel.createUpdateReceiver(),
|
val callbackQueryFlow: Flow<CallbackQueryUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
shippingQueryChannel.createUpdateReceiver(),
|
val shippingQueryFlow: Flow<ShippingQueryUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
preCheckoutQueryChannel.createUpdateReceiver(),
|
val preCheckoutQueryFlow: Flow<PreCheckoutQueryUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
pollChannel.createUpdateReceiver(),
|
val pollFlow: Flow<PollUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
pollAnswerChannel.createUpdateReceiver(),
|
val pollAnswerFlow: Flow<PollAnswerUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
unknownUpdateChannel.createUpdateReceiver()
|
val unknownUpdateTypeFlow: Flow<UnknownUpdate> = allUpdatesFlow.filterIsInstance()
|
||||||
)
|
|
||||||
|
|
||||||
val messageFlow: Flow<MessageUpdate> = messageChannel.asFlow()
|
|
||||||
val messageMediaGroupFlow: Flow<MessageMediaGroupUpdate> = messageMediaGroupChannel.asFlow()
|
|
||||||
val editedMessageFlow: Flow<EditMessageUpdate> = editedMessageChannel.asFlow()
|
|
||||||
val editedMessageMediaGroupFlow: Flow<EditMessageMediaGroupUpdate> = editedMessageMediaGroupChannel.asFlow()
|
|
||||||
val channelPostFlow: Flow<ChannelPostUpdate> = channelPostChannel.asFlow()
|
|
||||||
val channelPostMediaGroupFlow: Flow<ChannelPostMediaGroupUpdate> = channelPostMediaGroupChannel.asFlow()
|
|
||||||
val editedChannelPostFlow: Flow<EditChannelPostUpdate> = editedChannelPostChannel.asFlow()
|
|
||||||
val editedChannelPostMediaGroupFlow: Flow<EditChannelPostMediaGroupUpdate> = editedChannelPostMediaGroupChannel.asFlow()
|
|
||||||
val chosenInlineResultFlow: Flow<ChosenInlineResultUpdate> = chosenInlineResultChannel.asFlow()
|
|
||||||
val inlineQueryFlow: Flow<InlineQueryUpdate> = inlineQueryChannel.asFlow()
|
|
||||||
val callbackQueryFlow: Flow<CallbackQueryUpdate> = callbackQueryChannel.asFlow()
|
|
||||||
val shippingQueryFlow: Flow<ShippingQueryUpdate> = shippingQueryChannel.asFlow()
|
|
||||||
val preCheckoutQueryFlow: Flow<PreCheckoutQueryUpdate> = preCheckoutQueryChannel.asFlow()
|
|
||||||
val pollFlow: Flow<PollUpdate> = pollChannel.asFlow()
|
|
||||||
val pollAnswerFlow: Flow<PollAnswerUpdate> = pollAnswerChannel.asFlow()
|
|
||||||
val unknownUpdateTypeFlow: Flow<Update> = unknownUpdateChannel.asFlow()
|
|
||||||
}
|
}
|
@ -3,7 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.updateshandlers
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
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.types.update.abstracts.UnknownUpdateType
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.UnknownUpdate
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
|
||||||
|
|
||||||
typealias UpdateReceiver<T> = suspend (T) -> Unit
|
typealias UpdateReceiver<T> = suspend (T) -> Unit
|
||||||
@ -29,7 +29,7 @@ data class SimpleUpdatesFilter(
|
|||||||
private val preCheckoutQueryCallback: UpdateReceiver<PreCheckoutQueryUpdate>? = null,
|
private val preCheckoutQueryCallback: UpdateReceiver<PreCheckoutQueryUpdate>? = null,
|
||||||
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<UnknownUpdate>? = null
|
||||||
) : UpdatesFilter {
|
) : UpdatesFilter {
|
||||||
override val asUpdateReceiver: UpdateReceiver<Update> = this::invoke
|
override val asUpdateReceiver: UpdateReceiver<Update> = this::invoke
|
||||||
override val allowedUpdates = listOfNotNull(
|
override val allowedUpdates = listOfNotNull(
|
||||||
@ -83,7 +83,7 @@ data class SimpleUpdatesFilter(
|
|||||||
is PreCheckoutQueryUpdate -> preCheckoutQueryCallback ?.invoke(update)
|
is PreCheckoutQueryUpdate -> preCheckoutQueryCallback ?.invoke(update)
|
||||||
is PollUpdate -> pollUpdateCallback ?.invoke(update)
|
is PollUpdate -> pollUpdateCallback ?.invoke(update)
|
||||||
is PollAnswerUpdate -> pollAnswerUpdateCallback ?.invoke(update)
|
is PollAnswerUpdate -> pollAnswerUpdateCallback ?.invoke(update)
|
||||||
is UnknownUpdateType -> unknownUpdateTypeCallback ?.invoke(update)
|
is UnknownUpdate -> unknownUpdateTypeCallback ?.invoke(update)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,7 +101,7 @@ fun createSimpleUpdateFilter(
|
|||||||
preCheckoutQueryCallback: UpdateReceiver<PreCheckoutQueryUpdate>? = null,
|
preCheckoutQueryCallback: UpdateReceiver<PreCheckoutQueryUpdate>? = null,
|
||||||
pollCallback: UpdateReceiver<PollUpdate>? = null,
|
pollCallback: UpdateReceiver<PollUpdate>? = null,
|
||||||
pollAnswerCallback: UpdateReceiver<PollAnswerUpdate>? = null,
|
pollAnswerCallback: UpdateReceiver<PollAnswerUpdate>? = null,
|
||||||
unknownCallback: UpdateReceiver<UnknownUpdateType>? = null
|
unknownCallback: UpdateReceiver<UnknownUpdate>? = null
|
||||||
): UpdatesFilter = SimpleUpdatesFilter(
|
): UpdatesFilter = SimpleUpdatesFilter(
|
||||||
messageCallback = messageCallback,
|
messageCallback = messageCallback,
|
||||||
messageMediaGroupCallback = mediaGroupCallback,
|
messageMediaGroupCallback = mediaGroupCallback,
|
||||||
|
@ -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.7
|
library_version=0.27.8
|
||||||
|
|
||||||
gradle_bintray_plugin_version=1.8.4
|
gradle_bintray_plugin_version=1.8.4
|
||||||
|
Loading…
Reference in New Issue
Block a user