mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-25 19:48:43 +00:00
commit
2d743e4c19
3
.gitignore
vendored
3
.gitignore
vendored
@ -8,3 +8,6 @@ settings.xml
|
|||||||
.gradle/
|
.gradle/
|
||||||
build/
|
build/
|
||||||
out/
|
out/
|
||||||
|
|
||||||
|
local.properties
|
||||||
|
secret.gradle
|
||||||
|
22
CHANGELOG.md
22
CHANGELOG.md
@ -42,6 +42,28 @@
|
|||||||
* `HttpClient#loadFile`
|
* `HttpClient#loadFile`
|
||||||
* `PathedFile#download`
|
* `PathedFile#download`
|
||||||
|
|
||||||
|
### 0.28.3
|
||||||
|
|
||||||
|
* Common:
|
||||||
|
* Version updates:
|
||||||
|
* `Klock`: `0.12.0` -> `0.12.1`
|
||||||
|
* `Kotlin serialization`: `1.0.0-RC` -> `1.0.0-RC2` (dependency `kotlinx-serialization-core` was replaced with
|
||||||
|
`kotlinx-serialization-json` due to [kotlinx.serialization library update](https://github.com/Kotlin/kotlinx.serialization/blob/master/CHANGELOG.md#100-rc2--2020-09-21))
|
||||||
|
* `TelegramBotAPI-core`:
|
||||||
|
* All `InlineQueryResult` has changed their type of id for more obvious relation between `InlineQueryResult#id` and
|
||||||
|
`ChosenInlineResult#resultId`: `String` -> `InlineQueryIdentifier`
|
||||||
|
* `TelegramBotAPI-extensions-utils`:
|
||||||
|
* Several extensions for updates flows based on `InlineQueryUpdate` has been added:
|
||||||
|
* `Flow<InlineQueryUpdate>#onlyBaseInlineQueriesWithUpdates`
|
||||||
|
* `Flow<InlineQueryUpdate>#onlyBaseInlineQueries`
|
||||||
|
* `Flow<InlineQueryUpdate>#onlyLocationInlineQueriesWithUpdates`
|
||||||
|
* `Flow<InlineQueryUpdate>#onlyLocationInlineQueries`
|
||||||
|
* Several extensions for updates flows based on `ChosenInlineResultUpdate` has been added:
|
||||||
|
* `Flow<ChosenInlineResultUpdate>.onlyBaseChosenInlineResultsWithUpdates`
|
||||||
|
* `Flow<ChosenInlineResultUpdate>.onlyBaseChosenInlineResults`
|
||||||
|
* `Flow<ChosenInlineResultUpdate>.onlyLocationChosenInlineResultsWithUpdates`
|
||||||
|
* `Flow<ChosenInlineResultUpdate>.onlyLocationChosenInlineResults`
|
||||||
|
|
||||||
### 0.28.2
|
### 0.28.2
|
||||||
|
|
||||||
* `TelegramBotAPI-extensions-utils`:
|
* `TelegramBotAPI-extensions-utils`:
|
||||||
|
@ -41,7 +41,7 @@ kotlin {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation kotlin('stdlib')
|
implementation kotlin('stdlib')
|
||||||
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
|
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
|
||||||
api "org.jetbrains.kotlinx:kotlinx-serialization-core:$kotlin_serialisation_runtime_version"
|
api "org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlin_serialisation_runtime_version"
|
||||||
api "org.jetbrains.kotlinx:kotlinx-serialization-properties:$kotlin_serialisation_runtime_version"
|
api "org.jetbrains.kotlinx:kotlinx-serialization-properties:$kotlin_serialisation_runtime_version"
|
||||||
|
|
||||||
api "com.soywiz.korlibs.klock:klock:$klock_version"
|
api "com.soywiz.korlibs.klock:klock:$klock_version"
|
||||||
|
@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable
|
|||||||
@Serializable
|
@Serializable
|
||||||
class InlineQueryResultArticle(
|
class InlineQueryResultArticle(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
override val id: String,
|
override val id: InlineQueryIdentifier,
|
||||||
@SerialName(titleField)
|
@SerialName(titleField)
|
||||||
override val title: String,
|
override val title: String,
|
||||||
@SerialName(inputMessageContentField)
|
@SerialName(inputMessageContentField)
|
||||||
|
@ -14,7 +14,7 @@ import kotlinx.serialization.Serializable
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class InlineQueryResultAudioCachedImpl(
|
data class InlineQueryResultAudioCachedImpl(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
override val id: String,
|
override val id: InlineQueryIdentifier,
|
||||||
@SerialName(audioFileIdField)
|
@SerialName(audioFileIdField)
|
||||||
override val fileId: FileId,
|
override val fileId: FileId,
|
||||||
@SerialName(captionField)
|
@SerialName(captionField)
|
||||||
|
@ -13,7 +13,7 @@ import kotlinx.serialization.Serializable
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class InlineQueryResultAudioImpl(
|
data class InlineQueryResultAudioImpl(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
override val id: String,
|
override val id: InlineQueryIdentifier,
|
||||||
@SerialName(audioUrlField)
|
@SerialName(audioUrlField)
|
||||||
override val url: String,
|
override val url: String,
|
||||||
@SerialName(titleField)
|
@SerialName(titleField)
|
||||||
|
@ -11,7 +11,7 @@ import kotlinx.serialization.Serializable
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class InlineQueryResultContact(
|
data class InlineQueryResultContact(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
override val id: String,
|
override val id: InlineQueryIdentifier,
|
||||||
@SerialName(phoneNumberField)
|
@SerialName(phoneNumberField)
|
||||||
override val phoneNumber: String,
|
override val phoneNumber: String,
|
||||||
@SerialName(firstNameField)
|
@SerialName(firstNameField)
|
||||||
|
@ -14,7 +14,7 @@ import kotlinx.serialization.Serializable
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class InlineQueryResultDocumentCachedImpl(
|
data class InlineQueryResultDocumentCachedImpl(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
override val id: String,
|
override val id: InlineQueryIdentifier,
|
||||||
@SerialName(documentFileIdField)
|
@SerialName(documentFileIdField)
|
||||||
override val fileId: FileId,
|
override val fileId: FileId,
|
||||||
@SerialName(titleField)
|
@SerialName(titleField)
|
||||||
|
@ -15,7 +15,7 @@ import kotlinx.serialization.Serializable
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class InlineQueryResultDocumentImpl(
|
data class InlineQueryResultDocumentImpl(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
override val id: String,
|
override val id: InlineQueryIdentifier,
|
||||||
@SerialName(documentUrlField)
|
@SerialName(documentUrlField)
|
||||||
override val url: String,
|
override val url: String,
|
||||||
@SerialName(titleField)
|
@SerialName(titleField)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult
|
package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueryIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.gameShortNameField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.gameShortNameField
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
@ -8,7 +9,7 @@ import kotlinx.serialization.Serializable
|
|||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
class InlineQueryResultGame(
|
class InlineQueryResultGame(
|
||||||
override val id: String,
|
override val id: InlineQueryIdentifier,
|
||||||
@SerialName(gameShortNameField)
|
@SerialName(gameShortNameField)
|
||||||
val gameShortName: String,
|
val gameShortName: String,
|
||||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
@ -14,7 +14,7 @@ import kotlinx.serialization.Serializable
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class InlineQueryResultGifCachedImpl(
|
data class InlineQueryResultGifCachedImpl(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
override val id: String,
|
override val id: InlineQueryIdentifier,
|
||||||
@SerialName(gifFileIdField)
|
@SerialName(gifFileIdField)
|
||||||
override val fileId: FileId,
|
override val fileId: FileId,
|
||||||
@SerialName(titleField)
|
@SerialName(titleField)
|
||||||
|
@ -14,7 +14,7 @@ import kotlinx.serialization.Serializable
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class InlineQueryResultGifImpl(
|
data class InlineQueryResultGifImpl(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
override val id: String,
|
override val id: InlineQueryIdentifier,
|
||||||
@SerialName(gifUrlField)
|
@SerialName(gifUrlField)
|
||||||
override val url: String,
|
override val url: String,
|
||||||
@SerialName(thumbUrlField)
|
@SerialName(thumbUrlField)
|
||||||
|
@ -12,7 +12,7 @@ import kotlinx.serialization.Serializable
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class InlineQueryResultLocation(
|
data class InlineQueryResultLocation(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
override val id: String,
|
override val id: InlineQueryIdentifier,
|
||||||
@SerialName(latitudeField)
|
@SerialName(latitudeField)
|
||||||
override val latitude: Double,
|
override val latitude: Double,
|
||||||
@SerialName(longitudeField)
|
@SerialName(longitudeField)
|
||||||
|
@ -14,7 +14,7 @@ import kotlinx.serialization.Serializable
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class InlineQueryResultMpeg4GifCachedImpl(
|
data class InlineQueryResultMpeg4GifCachedImpl(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
override val id: String,
|
override val id: InlineQueryIdentifier,
|
||||||
@SerialName(mpeg4GifFileIdField)
|
@SerialName(mpeg4GifFileIdField)
|
||||||
override val fileId: FileId,
|
override val fileId: FileId,
|
||||||
@SerialName(titleField)
|
@SerialName(titleField)
|
||||||
|
@ -14,7 +14,7 @@ import kotlinx.serialization.Serializable
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class InlineQueryResultMpeg4GifImpl(
|
data class InlineQueryResultMpeg4GifImpl(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
override val id: String,
|
override val id: InlineQueryIdentifier,
|
||||||
@SerialName(mpeg4GifUrlField)
|
@SerialName(mpeg4GifUrlField)
|
||||||
override val url: String,
|
override val url: String,
|
||||||
@SerialName(thumbUrlField)
|
@SerialName(thumbUrlField)
|
||||||
|
@ -14,7 +14,7 @@ import kotlinx.serialization.Serializable
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class InlineQueryResultPhotoCachedImpl(
|
data class InlineQueryResultPhotoCachedImpl(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
override val id: String,
|
override val id: InlineQueryIdentifier,
|
||||||
@SerialName(photoFileIdField)
|
@SerialName(photoFileIdField)
|
||||||
override val fileId: FileId,
|
override val fileId: FileId,
|
||||||
@SerialName(titleField)
|
@SerialName(titleField)
|
||||||
|
@ -13,7 +13,7 @@ import kotlinx.serialization.Serializable
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class InlineQueryResultPhotoImpl(
|
data class InlineQueryResultPhotoImpl(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
override val id: String,
|
override val id: InlineQueryIdentifier,
|
||||||
@SerialName(photoUrlField)
|
@SerialName(photoUrlField)
|
||||||
override val url: String,
|
override val url: String,
|
||||||
@SerialName(thumbUrlField)
|
@SerialName(thumbUrlField)
|
||||||
|
@ -11,7 +11,7 @@ import kotlinx.serialization.Serializable
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class InlineQueryResultStickerCached(
|
data class InlineQueryResultStickerCached(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
override val id: String,
|
override val id: InlineQueryIdentifier,
|
||||||
@SerialName(stickerFileIdField)
|
@SerialName(stickerFileIdField)
|
||||||
override val fileId: FileId,
|
override val fileId: FileId,
|
||||||
@SerialName(replyMarkupField)
|
@SerialName(replyMarkupField)
|
||||||
|
@ -12,7 +12,7 @@ import kotlinx.serialization.Serializable
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class InlineQueryResultVenue(
|
data class InlineQueryResultVenue(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
override val id: String,
|
override val id: InlineQueryIdentifier,
|
||||||
@SerialName(latitudeField)
|
@SerialName(latitudeField)
|
||||||
override val latitude: Double,
|
override val latitude: Double,
|
||||||
@SerialName(longitudeField)
|
@SerialName(longitudeField)
|
||||||
|
@ -14,7 +14,7 @@ import kotlinx.serialization.Serializable
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class InlineQueryResultVideoCachedImpl(
|
data class InlineQueryResultVideoCachedImpl(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
override val id: String,
|
override val id: InlineQueryIdentifier,
|
||||||
@SerialName(videoFileIdField)
|
@SerialName(videoFileIdField)
|
||||||
override val fileId: FileId,
|
override val fileId: FileId,
|
||||||
@SerialName(titleField)
|
@SerialName(titleField)
|
||||||
|
@ -15,7 +15,7 @@ import kotlinx.serialization.Serializable
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class InlineQueryResultVideoImpl(
|
data class InlineQueryResultVideoImpl(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
override val id: String,
|
override val id: InlineQueryIdentifier,
|
||||||
@SerialName(videoUrlField)
|
@SerialName(videoUrlField)
|
||||||
override val url: String,
|
override val url: String,
|
||||||
@SerialName(thumbUrlField)
|
@SerialName(thumbUrlField)
|
||||||
|
@ -14,7 +14,7 @@ import kotlinx.serialization.Serializable
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class InlineQueryResultVoiceCachedImpl(
|
data class InlineQueryResultVoiceCachedImpl(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
override val id: String,
|
override val id: InlineQueryIdentifier,
|
||||||
@SerialName(voiceFileIdField)
|
@SerialName(voiceFileIdField)
|
||||||
override val fileId: FileId,
|
override val fileId: FileId,
|
||||||
@SerialName(titleField)
|
@SerialName(titleField)
|
||||||
|
@ -13,7 +13,7 @@ import kotlinx.serialization.Serializable
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class InlineQueryResultVoiceImpl(
|
data class InlineQueryResultVoiceImpl(
|
||||||
@SerialName(idField)
|
@SerialName(idField)
|
||||||
override val id: String,
|
override val id: InlineQueryIdentifier,
|
||||||
@SerialName(voiceUrlField)
|
@SerialName(voiceUrlField)
|
||||||
override val url: String,
|
override val url: String,
|
||||||
@SerialName(titleField)
|
@SerialName(titleField)
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts
|
package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.serializers.InlineQueryResultSerializer
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.serializers.InlineQueryResultSerializer
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueryIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable(InlineQueryResultSerializer::class)
|
@Serializable(InlineQueryResultSerializer::class)
|
||||||
interface InlineQueryResult {
|
interface InlineQueryResult {
|
||||||
val type: String
|
val type: String
|
||||||
val id: String
|
val id: InlineQueryIdentifier
|
||||||
val replyMarkup: InlineKeyboardMarkup?
|
val replyMarkup: InlineKeyboardMarkup?
|
||||||
}
|
}
|
@ -8,6 +8,7 @@ internal val nonstrictJsonFormat = Json {
|
|||||||
ignoreUnknownKeys = true
|
ignoreUnknownKeys = true
|
||||||
allowSpecialFloatingPointValues = true
|
allowSpecialFloatingPointValues = true
|
||||||
useArrayPolymorphism = true
|
useArrayPolymorphism = true
|
||||||
|
encodeDefaults = true
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T: Any> T.toJsonWithoutNulls(serializer: SerializationStrategy<T>): JsonObject = toJson(serializer).withoutNulls()
|
fun <T: Any> T.toJsonWithoutNulls(serializer: SerializationStrategy<T>): JsonObject = toJson(serializer).withoutNulls()
|
||||||
|
@ -13,6 +13,7 @@ private val nonstrictJsonFormat = Json {
|
|||||||
ignoreUnknownKeys = true
|
ignoreUnknownKeys = true
|
||||||
allowSpecialFloatingPointValues = true
|
allowSpecialFloatingPointValues = true
|
||||||
useArrayPolymorphism = true
|
useArrayPolymorphism = true
|
||||||
|
encodeDefaults = true
|
||||||
}
|
}
|
||||||
|
|
||||||
class SimpleInputFilesTest {
|
class SimpleInputFilesTest {
|
||||||
|
@ -2,4 +2,6 @@ package com.github.insanusmokrassar.TelegramBotAPI
|
|||||||
|
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
|
||||||
val TestsJsonFormat = Json {}
|
val TestsJsonFormat = Json {
|
||||||
|
encodeDefaults = true
|
||||||
|
}
|
||||||
|
@ -8,4 +8,5 @@ internal val nonstrictJsonFormat = Json {
|
|||||||
ignoreUnknownKeys = true
|
ignoreUnknownKeys = true
|
||||||
allowSpecialFloatingPointValues = true
|
allowSpecialFloatingPointValues = true
|
||||||
useArrayPolymorphism = true
|
useArrayPolymorphism = true
|
||||||
|
encodeDefaults = true
|
||||||
}
|
}
|
||||||
|
@ -8,4 +8,5 @@ internal val nonstrictJsonFormat = Json {
|
|||||||
ignoreUnknownKeys = true
|
ignoreUnknownKeys = true
|
||||||
allowSpecialFloatingPointValues = true
|
allowSpecialFloatingPointValues = true
|
||||||
useArrayPolymorphism = true
|
useArrayPolymorphism = true
|
||||||
|
encodeDefaults = true
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.internal_utils
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import kotlinx.coroutines.flow.mapNotNull
|
||||||
|
|
||||||
|
internal inline fun <reified T : Any, UT : Update> Flow<UT>.onlySpecifiedTypeOfDataWithUpdates(): Flow<Pair<UpdateIdentifier, T>> {
|
||||||
|
return mapNotNull {
|
||||||
|
it.updateId to (it.data as? T ?: return@mapNotNull null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal inline fun <reified T : Any, UT : Update> Flow<UT>.onlySpecifiedTypeOfData(): Flow<T> {
|
||||||
|
return mapNotNull { it as? T }
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.updates
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.internal_utils.onlySpecifiedTypeOfData
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.internal_utils.onlySpecifiedTypeOfDataWithUpdates
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.ChosenInlineResult.BaseChosenInlineResult
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.ChosenInlineResult.LocationChosenInlineResult
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.ChosenInlineResultUpdate
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.InlineQueryUpdate
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Mapped [Flow] with [Pair]s. [Pair.first] in this pair will be [UpdateIdentifier]. It could be useful in
|
||||||
|
* cases you are using [InlineQueryUpdate.updateId] for some reasons. [Pair.second] will always be [BaseChosenInlineResult].
|
||||||
|
*/
|
||||||
|
fun Flow<ChosenInlineResultUpdate>.onlyBaseChosenInlineResultsWithUpdates(): Flow<Pair<UpdateIdentifier, BaseChosenInlineResult>> = onlySpecifiedTypeOfDataWithUpdates()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Filter updates only with [BaseChosenInlineResult] and map it to a [Flow] with values [BaseChosenInlineResult]
|
||||||
|
*
|
||||||
|
* @see onlyBaseChosenInlineResultsWithUpdates
|
||||||
|
*/
|
||||||
|
fun Flow<ChosenInlineResultUpdate>.onlyBaseChosenInlineResults(): Flow<BaseChosenInlineResult> = onlySpecifiedTypeOfData()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Mapped [Flow] with [Pair]s. [Pair.first] in this pair will be [UpdateIdentifier]. It could be useful in
|
||||||
|
* cases you are using [InlineQueryUpdate.updateId] for some reasons. [Pair.second] will always be [LocationChosenInlineResult].
|
||||||
|
*/
|
||||||
|
fun Flow<ChosenInlineResultUpdate>.onlyLocationChosenInlineResultsWithUpdates(): Flow<Pair<UpdateIdentifier, LocationChosenInlineResult>> = onlySpecifiedTypeOfDataWithUpdates()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Filter updates only with [LocationChosenInlineResult] and map it to a [Flow] with values [LocationChosenInlineResult]
|
||||||
|
*
|
||||||
|
* @see onlyLocationChosenInlineResultsWithUpdates
|
||||||
|
*/
|
||||||
|
fun Flow<ChosenInlineResultUpdate>.onlyLocationChosenInlineResults(): Flow<LocationChosenInlineResult> = onlySpecifiedTypeOfData()
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.updates
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.internal_utils.onlySpecifiedTypeOfData
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.internal_utils.onlySpecifiedTypeOfDataWithUpdates
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.query.BaseInlineQuery
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.query.LocationInlineQuery
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.InlineQueryUpdate
|
||||||
|
import kotlinx.coroutines.flow.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Mapped [Flow] with [Pair]s. [Pair.first] in this pair will be [UpdateIdentifier]. It could be useful in
|
||||||
|
* cases you are using [InlineQueryUpdate.updateId] for some reasons. [Pair.second] will always be [BaseInlineQuery].
|
||||||
|
*/
|
||||||
|
fun Flow<InlineQueryUpdate>.onlyBaseInlineQueriesWithUpdates(): Flow<Pair<UpdateIdentifier, BaseInlineQuery>> = onlySpecifiedTypeOfDataWithUpdates()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Filter updates only with [BaseInlineQuery] and map it to a [Flow] with values [BaseInlineQuery]
|
||||||
|
*
|
||||||
|
* @see onlyBaseInlineQueriesWithUpdates
|
||||||
|
*/
|
||||||
|
fun Flow<InlineQueryUpdate>.onlyBaseInlineQueries(): Flow<BaseInlineQuery> = onlySpecifiedTypeOfData()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Mapped [Flow] with [Pair]s. [Pair.first] in this pair will be [UpdateIdentifier]. It could be useful in
|
||||||
|
* cases you are using [InlineQueryUpdate.updateId] for some reasons. [Pair.second] will always be [LocationInlineQuery].
|
||||||
|
*/
|
||||||
|
fun Flow<InlineQueryUpdate>.onlyLocationInlineQueriesWithUpdates(): Flow<Pair<UpdateIdentifier, LocationInlineQuery>> = onlySpecifiedTypeOfDataWithUpdates()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Filter updates only with [LocationInlineQuery] and map it to a [Flow] with values [LocationInlineQuery]
|
||||||
|
*
|
||||||
|
* @see onlyLocationInlineQueriesWithUpdates
|
||||||
|
*/
|
||||||
|
fun Flow<InlineQueryUpdate>.onlyLocationInlineQueries(): Flow<LocationInlineQuery> = onlySpecifiedTypeOfData()
|
30
build.gradle
30
build.gradle
@ -3,12 +3,14 @@ buildscript {
|
|||||||
mavenLocal()
|
mavenLocal()
|
||||||
jcenter()
|
jcenter()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
maven { url "https://plugins.gradle.org/m2/" }
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
||||||
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version"
|
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version"
|
||||||
|
classpath "com.github.breadmoirai:github-release:$github_release_plugin_version"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -16,3 +18,31 @@ plugins {
|
|||||||
id "org.jetbrains.kotlin.multiplatform" version "$kotlin_version" apply false
|
id "org.jetbrains.kotlin.multiplatform" version "$kotlin_version" apply false
|
||||||
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" apply false
|
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlin_version" apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getCurrentVersionChangelog() {
|
||||||
|
OutputStream changelogDataOS = new ByteArrayOutputStream()
|
||||||
|
exec {
|
||||||
|
standardOutput = changelogDataOS
|
||||||
|
commandLine './changelog_info_retriever', "$library_version", 'CHANGELOG.md'
|
||||||
|
}
|
||||||
|
|
||||||
|
return changelogDataOS.toString().trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (new File(projectDir, "secret.gradle").exists()) {
|
||||||
|
apply from: './secret.gradle'
|
||||||
|
apply plugin: "com.github.breadmoirai.github-release"
|
||||||
|
|
||||||
|
githubRelease {
|
||||||
|
token "${project.property('GITHUB_RELEASE_TOKEN')}"
|
||||||
|
|
||||||
|
owner "InsanusMokrassar"
|
||||||
|
repo "TelegramBotAPI"
|
||||||
|
|
||||||
|
tagName "$library_version"
|
||||||
|
releaseName "$library_version"
|
||||||
|
targetCommitish "$library_version"
|
||||||
|
|
||||||
|
body getCurrentVersionChangelog()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
29
changelog_info_retriever
Executable file
29
changelog_info_retriever
Executable file
@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
function parse() {
|
||||||
|
version=$1
|
||||||
|
|
||||||
|
read -r
|
||||||
|
while [ -z "`echo $REPLY | grep -e "^#\+ $version"`" ]
|
||||||
|
do
|
||||||
|
read -r
|
||||||
|
done
|
||||||
|
|
||||||
|
read -r
|
||||||
|
while [ -z "`echo $REPLY | grep -e "^#\+"`" ]
|
||||||
|
do
|
||||||
|
echo "$REPLY"
|
||||||
|
read -r
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
version=$1
|
||||||
|
file=$2
|
||||||
|
|
||||||
|
if [ -n "$file" ]; then
|
||||||
|
parse $version < "$file"
|
||||||
|
else
|
||||||
|
parse $version
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
@ -7,14 +7,15 @@ kotlin.incremental.js=true
|
|||||||
|
|
||||||
kotlin_version=1.4.10
|
kotlin_version=1.4.10
|
||||||
kotlin_coroutines_version=1.3.9
|
kotlin_coroutines_version=1.3.9
|
||||||
kotlin_serialisation_runtime_version=1.0.0-RC
|
kotlin_serialisation_runtime_version=1.0.0-RC2
|
||||||
klock_version=1.12.0
|
klock_version=1.12.1
|
||||||
uuid_version=0.2.2
|
uuid_version=0.2.2
|
||||||
ktor_version=1.4.0
|
ktor_version=1.4.0
|
||||||
|
|
||||||
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.28.2
|
library_version=0.28.3
|
||||||
|
|
||||||
gradle_bintray_plugin_version=1.8.5
|
gradle_bintray_plugin_version=1.8.5
|
||||||
|
github_release_plugin_version=2.2.12
|
||||||
|
Loading…
Reference in New Issue
Block a user