mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-17 04:20:13 +00:00
Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e10e257c80 | |||
| 5e7bc96b44 | |||
| 79d0eda61d | |||
| 9916b3f469 | |||
| 2bac5f0eed | |||
|
|
01eb072caa | ||
| 496af479b0 | |||
| 386e91e28b | |||
| 91dbcecefc | |||
| 2d743e4c19 | |||
| 8804a24013 | |||
| 8b5244d8df | |||
| 034901a479 | |||
| 7043647584 | |||
| acd9505a5d | |||
| 46c33d5ec4 | |||
| 89dc7a4b2a | |||
| e4f305b3ec | |||
| d56c132201 | |||
| d336e177dd | |||
| 15e29286fb | |||
| 314ceed78e | |||
| 3fa3aa50d9 | |||
| 571296b9a0 | |||
| 3f13e5d062 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -8,3 +8,6 @@ settings.xml
|
||||
.gradle/
|
||||
build/
|
||||
out/
|
||||
|
||||
local.properties
|
||||
secret.gradle
|
||||
|
||||
50
CHANGELOG.md
50
CHANGELOG.md
@@ -42,6 +42,56 @@
|
||||
* `HttpClient#loadFile`
|
||||
* `PathedFile#download`
|
||||
|
||||
### 0.28.4
|
||||
|
||||
* `Common`:
|
||||
* Version updates:
|
||||
* `Ktor`: `1.4.0` -> `1.4.1`
|
||||
* `TelegramBotAPI-core`
|
||||
* Interface `GroupEventMessage` has been added ([#140](https://github.com/InsanusMokrassar/TelegramBotAPI/pull/140))
|
||||
* Old `GroupEventMessage` was renamed to `CommonGroupEventMessage` ([#140](https://github.com/InsanusMokrassar/TelegramBotAPI/pull/140))
|
||||
* Interface `SupergroupEventMessage` has been added ([#140](https://github.com/InsanusMokrassar/TelegramBotAPI/pull/140))
|
||||
* Old `SupergroupEventMessage` was renamed to `CommonSupergroupEventMessage` ([#140](https://github.com/InsanusMokrassar/TelegramBotAPI/pull/140))
|
||||
* Any `GroupEventMessage` now have `from` field ([#140](https://github.com/InsanusMokrassar/TelegramBotAPI/pull/140))
|
||||
* `TelegramBotAPI-extensions-utils`
|
||||
* Extensions `Flow<ChatEventMessage>#onlyGroupEvents` and `Flow<ChatEventMessage>#onlySupergroupEvents` now returns
|
||||
`CommonGroupEventMessage` and `CommonSupergroupEventMessage`
|
||||
|
||||
### 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
|
||||
|
||||
* `TelegramBotAPI-extensions-utils`:
|
||||
* Several commands shortcuts for `Flow<ContentMessage<TextContent>>` has been added:
|
||||
* `filterExactCommands`
|
||||
* `filterCommandsInsideTextMessages`
|
||||
* `filterCommandsWithArgs`
|
||||
* Extension `Flow<BaseSentMessageUpdate>.filterCommandsWithArgs` has changed its signature: now it will also have
|
||||
original message paired with list of text sources
|
||||
* Shortcut method `commonMessages` for `onlyCommonMessages`
|
||||
* Shortcuts `onlySentViaBot` and `withoutSentViaBot` now are extensions for any `Flow` with types which implementing
|
||||
`ContentMessage`
|
||||
|
||||
### 0.28.1
|
||||
|
||||
* Common:
|
||||
|
||||
@@ -41,7 +41,7 @@ kotlin {
|
||||
dependencies {
|
||||
implementation kotlin('stdlib')
|
||||
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 "com.soywiz.korlibs.klock:klock:$klock_version"
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"bintrayConfig":{"repo":"StandardRepository","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/TelegramBotAPI"},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API Core","description":"Library for Object-Oriented and type-safe work with Telegram Bot API","url":"https://insanusmokrassar.github.io/TelegramBotAPI","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]},"type":"Multiplatform"}
|
||||
{"bintrayConfig":{"repo":"StandardRepository","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/TelegramBotAPI","autoPublish":true},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API Core","description":"Library for Object-Oriented and type-safe work with Telegram Bot API","url":"https://insanusmokrassar.github.io/TelegramBotAPI","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]},"type":"Multiplatform"}
|
||||
@@ -25,6 +25,9 @@ bintray {
|
||||
}
|
||||
into "${project.group}".replace(".", "/")
|
||||
}
|
||||
|
||||
publish = true
|
||||
|
||||
pkg {
|
||||
repo = "StandardRepository"
|
||||
name = "${project.name}"
|
||||
|
||||
@@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
class InlineQueryResultArticle(
|
||||
@SerialName(idField)
|
||||
override val id: String,
|
||||
override val id: InlineQueryIdentifier,
|
||||
@SerialName(titleField)
|
||||
override val title: String,
|
||||
@SerialName(inputMessageContentField)
|
||||
|
||||
@@ -14,7 +14,7 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class InlineQueryResultAudioCachedImpl(
|
||||
@SerialName(idField)
|
||||
override val id: String,
|
||||
override val id: InlineQueryIdentifier,
|
||||
@SerialName(audioFileIdField)
|
||||
override val fileId: FileId,
|
||||
@SerialName(captionField)
|
||||
|
||||
@@ -13,7 +13,7 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class InlineQueryResultAudioImpl(
|
||||
@SerialName(idField)
|
||||
override val id: String,
|
||||
override val id: InlineQueryIdentifier,
|
||||
@SerialName(audioUrlField)
|
||||
override val url: String,
|
||||
@SerialName(titleField)
|
||||
|
||||
@@ -11,7 +11,7 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class InlineQueryResultContact(
|
||||
@SerialName(idField)
|
||||
override val id: String,
|
||||
override val id: InlineQueryIdentifier,
|
||||
@SerialName(phoneNumberField)
|
||||
override val phoneNumber: String,
|
||||
@SerialName(firstNameField)
|
||||
|
||||
@@ -14,7 +14,7 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class InlineQueryResultDocumentCachedImpl(
|
||||
@SerialName(idField)
|
||||
override val id: String,
|
||||
override val id: InlineQueryIdentifier,
|
||||
@SerialName(documentFileIdField)
|
||||
override val fileId: FileId,
|
||||
@SerialName(titleField)
|
||||
|
||||
@@ -15,7 +15,7 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class InlineQueryResultDocumentImpl(
|
||||
@SerialName(idField)
|
||||
override val id: String,
|
||||
override val id: InlineQueryIdentifier,
|
||||
@SerialName(documentUrlField)
|
||||
override val url: String,
|
||||
@SerialName(titleField)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.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.gameShortNameField
|
||||
import kotlinx.serialization.SerialName
|
||||
@@ -8,7 +9,7 @@ import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
class InlineQueryResultGame(
|
||||
override val id: String,
|
||||
override val id: InlineQueryIdentifier,
|
||||
@SerialName(gameShortNameField)
|
||||
val gameShortName: String,
|
||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||
|
||||
@@ -14,7 +14,7 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class InlineQueryResultGifCachedImpl(
|
||||
@SerialName(idField)
|
||||
override val id: String,
|
||||
override val id: InlineQueryIdentifier,
|
||||
@SerialName(gifFileIdField)
|
||||
override val fileId: FileId,
|
||||
@SerialName(titleField)
|
||||
|
||||
@@ -14,7 +14,7 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class InlineQueryResultGifImpl(
|
||||
@SerialName(idField)
|
||||
override val id: String,
|
||||
override val id: InlineQueryIdentifier,
|
||||
@SerialName(gifUrlField)
|
||||
override val url: String,
|
||||
@SerialName(thumbUrlField)
|
||||
|
||||
@@ -12,7 +12,7 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class InlineQueryResultLocation(
|
||||
@SerialName(idField)
|
||||
override val id: String,
|
||||
override val id: InlineQueryIdentifier,
|
||||
@SerialName(latitudeField)
|
||||
override val latitude: Double,
|
||||
@SerialName(longitudeField)
|
||||
|
||||
@@ -14,7 +14,7 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class InlineQueryResultMpeg4GifCachedImpl(
|
||||
@SerialName(idField)
|
||||
override val id: String,
|
||||
override val id: InlineQueryIdentifier,
|
||||
@SerialName(mpeg4GifFileIdField)
|
||||
override val fileId: FileId,
|
||||
@SerialName(titleField)
|
||||
|
||||
@@ -14,7 +14,7 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class InlineQueryResultMpeg4GifImpl(
|
||||
@SerialName(idField)
|
||||
override val id: String,
|
||||
override val id: InlineQueryIdentifier,
|
||||
@SerialName(mpeg4GifUrlField)
|
||||
override val url: String,
|
||||
@SerialName(thumbUrlField)
|
||||
|
||||
@@ -14,7 +14,7 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class InlineQueryResultPhotoCachedImpl(
|
||||
@SerialName(idField)
|
||||
override val id: String,
|
||||
override val id: InlineQueryIdentifier,
|
||||
@SerialName(photoFileIdField)
|
||||
override val fileId: FileId,
|
||||
@SerialName(titleField)
|
||||
|
||||
@@ -13,7 +13,7 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class InlineQueryResultPhotoImpl(
|
||||
@SerialName(idField)
|
||||
override val id: String,
|
||||
override val id: InlineQueryIdentifier,
|
||||
@SerialName(photoUrlField)
|
||||
override val url: String,
|
||||
@SerialName(thumbUrlField)
|
||||
|
||||
@@ -11,7 +11,7 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class InlineQueryResultStickerCached(
|
||||
@SerialName(idField)
|
||||
override val id: String,
|
||||
override val id: InlineQueryIdentifier,
|
||||
@SerialName(stickerFileIdField)
|
||||
override val fileId: FileId,
|
||||
@SerialName(replyMarkupField)
|
||||
|
||||
@@ -12,7 +12,7 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class InlineQueryResultVenue(
|
||||
@SerialName(idField)
|
||||
override val id: String,
|
||||
override val id: InlineQueryIdentifier,
|
||||
@SerialName(latitudeField)
|
||||
override val latitude: Double,
|
||||
@SerialName(longitudeField)
|
||||
|
||||
@@ -14,7 +14,7 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class InlineQueryResultVideoCachedImpl(
|
||||
@SerialName(idField)
|
||||
override val id: String,
|
||||
override val id: InlineQueryIdentifier,
|
||||
@SerialName(videoFileIdField)
|
||||
override val fileId: FileId,
|
||||
@SerialName(titleField)
|
||||
|
||||
@@ -15,7 +15,7 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class InlineQueryResultVideoImpl(
|
||||
@SerialName(idField)
|
||||
override val id: String,
|
||||
override val id: InlineQueryIdentifier,
|
||||
@SerialName(videoUrlField)
|
||||
override val url: String,
|
||||
@SerialName(thumbUrlField)
|
||||
|
||||
@@ -14,7 +14,7 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class InlineQueryResultVoiceCachedImpl(
|
||||
@SerialName(idField)
|
||||
override val id: String,
|
||||
override val id: InlineQueryIdentifier,
|
||||
@SerialName(voiceFileIdField)
|
||||
override val fileId: FileId,
|
||||
@SerialName(titleField)
|
||||
|
||||
@@ -13,7 +13,7 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class InlineQueryResultVoiceImpl(
|
||||
@SerialName(idField)
|
||||
override val id: String,
|
||||
override val id: InlineQueryIdentifier,
|
||||
@SerialName(voiceUrlField)
|
||||
override val url: String,
|
||||
@SerialName(titleField)
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
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.InlineQueryIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable(InlineQueryResultSerializer::class)
|
||||
interface InlineQueryResult {
|
||||
val type: String
|
||||
val id: String
|
||||
val id: InlineQueryIdentifier
|
||||
val replyMarkup: InlineKeyboardMarkup?
|
||||
}
|
||||
@@ -1,14 +1,19 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.types.message
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.User
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.GroupChat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.ChatEvents.abstracts.GroupEvent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ChatEventMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.GroupEventMessage
|
||||
import com.soywiz.klock.DateTime
|
||||
|
||||
data class GroupEventMessage(
|
||||
@Deprecated("Renamed", ReplaceWith("CommonGroupEventMessage"))
|
||||
typealias GroupEventMessage = CommonGroupEventMessage
|
||||
|
||||
data class CommonGroupEventMessage(
|
||||
override val messageId: MessageIdentifier,
|
||||
override val user: User,
|
||||
override val chat: GroupChat,
|
||||
override val chatEvent: GroupEvent,
|
||||
override val date: DateTime
|
||||
) : ChatEventMessage
|
||||
) : GroupEventMessage
|
||||
@@ -1,14 +1,19 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.types.message
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.User
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.SupergroupChat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.ChatEvents.abstracts.SupergroupEvent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ChatEventMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.SupergroupEventMessage
|
||||
import com.soywiz.klock.DateTime
|
||||
|
||||
data class SupergroupEventMessage(
|
||||
@Deprecated("Renamed", ReplaceWith("CommonSupergroupEventMessage"))
|
||||
typealias SupergroupEventMessage = CommonSupergroupEventMessage
|
||||
|
||||
data class CommonSupergroupEventMessage(
|
||||
override val messageId: MessageIdentifier,
|
||||
override val user: User,
|
||||
override val chat: SupergroupChat,
|
||||
override val chatEvent: SupergroupEvent,
|
||||
override val date: DateTime
|
||||
) : ChatEventMessage
|
||||
) : SupergroupEventMessage
|
||||
@@ -192,14 +192,16 @@ internal data class RawMessage(
|
||||
try {
|
||||
chatEvent?.let { chatEvent ->
|
||||
when (chat) {
|
||||
is SupergroupChat -> SupergroupEventMessage(
|
||||
is SupergroupChat -> CommonSupergroupEventMessage(
|
||||
messageId,
|
||||
from ?: error("Supergroup events are expected to contain 'from' field"),
|
||||
chat,
|
||||
chatEvent as? SupergroupEvent ?: throwWrongChatEvent(SupergroupEvent::class, chatEvent),
|
||||
date.asDate
|
||||
)
|
||||
is GroupChat -> GroupEventMessage(
|
||||
is GroupChat -> CommonGroupEventMessage(
|
||||
messageId,
|
||||
from ?: error("Supergroup events are expected to contain 'from' field"),
|
||||
chat,
|
||||
chatEvent as? GroupEvent ?: throwWrongChatEvent(GroupChat::class, chatEvent),
|
||||
date.asDate
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts
|
||||
|
||||
interface GroupEventMessage : ChatEventMessage, FromUserMessage
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts
|
||||
|
||||
interface SupergroupEventMessage : GroupEventMessage
|
||||
@@ -8,6 +8,7 @@ internal val nonstrictJsonFormat = Json {
|
||||
ignoreUnknownKeys = true
|
||||
allowSpecialFloatingPointValues = true
|
||||
useArrayPolymorphism = true
|
||||
encodeDefaults = true
|
||||
}
|
||||
|
||||
fun <T: Any> T.toJsonWithoutNulls(serializer: SerializationStrategy<T>): JsonObject = toJson(serializer).withoutNulls()
|
||||
|
||||
@@ -13,6 +13,7 @@ private val nonstrictJsonFormat = Json {
|
||||
ignoreUnknownKeys = true
|
||||
allowSpecialFloatingPointValues = true
|
||||
useArrayPolymorphism = true
|
||||
encodeDefaults = true
|
||||
}
|
||||
|
||||
class SimpleInputFilesTest {
|
||||
|
||||
@@ -2,4 +2,6 @@ package com.github.insanusmokrassar.TelegramBotAPI
|
||||
|
||||
import kotlinx.serialization.json.Json
|
||||
|
||||
val TestsJsonFormat = Json {}
|
||||
val TestsJsonFormat = Json {
|
||||
encodeDefaults = true
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
{"bintrayConfig":{"repo":"StandardRepository","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/TelegramBotAPI"},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API Extensions for API","description":"API extensions which provide work with RequestsExecutor of TelegramBotAPI almost like it is described in original Telegram Bot API reference","url":"https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-extensions-api","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]},"type":"Multiplatform"}
|
||||
1
TelegramBotAPI-extensions-api/mpp_publish_template.kpsb
Normal file
1
TelegramBotAPI-extensions-api/mpp_publish_template.kpsb
Normal file
@@ -0,0 +1 @@
|
||||
{"bintrayConfig":{"repo":"StandardRepository","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/TelegramBotAPI","autoPublish":true},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API Extensions for API","description":"API extensions which provide work with RequestsExecutor of TelegramBotAPI almost like it is described in original Telegram Bot API reference","url":"https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-extensions-api","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]},"type":"Multiplatform"}
|
||||
@@ -25,6 +25,9 @@ bintray {
|
||||
}
|
||||
into "${project.group}".replace(".", "/")
|
||||
}
|
||||
|
||||
publish = true
|
||||
|
||||
pkg {
|
||||
repo = "StandardRepository"
|
||||
name = "${project.name}"
|
||||
|
||||
@@ -8,4 +8,5 @@ internal val nonstrictJsonFormat = Json {
|
||||
ignoreUnknownKeys = true
|
||||
allowSpecialFloatingPointValues = true
|
||||
useArrayPolymorphism = true
|
||||
encodeDefaults = true
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
{"bintrayConfig":{"repo":"StandardRepository","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/TelegramBotAPI"},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API Utility Extensions","description":"Util extensions for more useful work with updates and other things","url":"https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-extensions-utils","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]},"type":"Multiplatform"}
|
||||
@@ -0,0 +1 @@
|
||||
{"bintrayConfig":{"repo":"StandardRepository","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/TelegramBotAPI","autoPublish":true},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API Utility Extensions","description":"Util extensions for more useful work with updates and other things","url":"https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI-extensions-utils","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]},"type":"Multiplatform"}
|
||||
@@ -25,6 +25,9 @@ bintray {
|
||||
}
|
||||
into "${project.group}".replace(".", "/")
|
||||
}
|
||||
|
||||
publish = true
|
||||
|
||||
pkg {
|
||||
repo = "StandardRepository"
|
||||
name = "${project.name}"
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.CommonMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.PossiblySentViaBotCommonMessage
|
||||
import kotlinx.coroutines.flow.*
|
||||
@@ -11,17 +10,21 @@ import kotlinx.coroutines.flow.*
|
||||
*/
|
||||
fun <C: MessageContent, T : ContentMessage<C>> Flow<T>.onlyCommonMessages() = filterIsInstance<CommonMessage<C>>()
|
||||
|
||||
/**
|
||||
* Shortcut for [onlyCommonMessages]
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun <C: MessageContent, T : ContentMessage<C>> Flow<T>.commonMessages() = onlyCommonMessages()
|
||||
|
||||
/**
|
||||
* Filter the messages and checking that incoming [CommonMessage] is [PossiblySentViaBotCommonMessage] and its
|
||||
* [PossiblySentViaBotCommonMessage.senderBot] is not null
|
||||
*/
|
||||
fun <T : MessageContent> Flow<CommonMessage<T>>.onlySentViaBot() = mapNotNull {
|
||||
(it as? PossiblySentViaBotCommonMessage) ?.let { possiblySentViaBot ->
|
||||
if (possiblySentViaBot.senderBot != null) {
|
||||
possiblySentViaBot
|
||||
} else {
|
||||
null
|
||||
}
|
||||
fun <MC : MessageContent, M : ContentMessage<MC>> Flow<M>.onlySentViaBot() = mapNotNull {
|
||||
if (it is PossiblySentViaBot && it.senderBot != null) {
|
||||
it
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +32,6 @@ fun <T : MessageContent> Flow<CommonMessage<T>>.onlySentViaBot() = mapNotNull {
|
||||
* Filter the messages and checking that incoming [CommonMessage] not is [PossiblySentViaBotCommonMessage] or its
|
||||
* [PossiblySentViaBotCommonMessage.senderBot] is null
|
||||
*/
|
||||
fun <T : MessageContent> Flow<CommonMessage<T>>.withoutSentViaBot() = filter {
|
||||
it !is PossiblySentViaBotCommonMessage || it.senderBot == null
|
||||
fun <MC : MessageContent, M : ContentMessage<MC>> Flow<M>.withoutSentViaBot() = filter {
|
||||
it !is PossiblySentViaBot || it.senderBot == null
|
||||
}
|
||||
|
||||
@@ -8,4 +8,5 @@ internal val nonstrictJsonFormat = Json {
|
||||
ignoreUnknownKeys = true
|
||||
allowSpecialFloatingPointValues = true
|
||||
useArrayPolymorphism = true
|
||||
encodeDefaults = true
|
||||
}
|
||||
|
||||
@@ -17,5 +17,5 @@ fun <T : ChatEventMessage> Flow<ChatEventMessage>.divideBySource(contentType: KC
|
||||
}
|
||||
|
||||
fun Flow<ChatEventMessage>.onlyChannelEvents() = divideBySource(ChannelEventMessage::class)
|
||||
fun Flow<ChatEventMessage>.onlyGroupEvents() = divideBySource(GroupEventMessage::class)
|
||||
fun Flow<ChatEventMessage>.onlySupergroupEvents() = divideBySource(SupergroupEventMessage::class)
|
||||
fun Flow<ChatEventMessage>.onlyGroupEvents() = divideBySource(CommonGroupEventMessage::class)
|
||||
fun Flow<ChatEventMessage>.onlySupergroupEvents() = divideBySource(CommonSupergroupEventMessage::class)
|
||||
|
||||
@@ -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,94 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.shortcuts
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.onlyTextContentMessages
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.updates.asContentMessagesFlow
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources.BotCommandTextSource
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources.RegularTextSource
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.fullEntitiesList
|
||||
import kotlinx.coroutines.flow.*
|
||||
|
||||
/**
|
||||
* Convert incoming [com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage.content] of
|
||||
* messages with [fullEntitiesList] and check that incoming message contains ONLY ONE [TextSource] and that is
|
||||
* [BotCommandTextSource]. Besides, it is checking that [BotCommandTextSource.command] [Regex.matches] with incoming
|
||||
* [commandRegex]
|
||||
*
|
||||
* @return The same message in case if it contains only [BotCommandTextSource] with [Regex.matches]
|
||||
* [BotCommandTextSource.command]
|
||||
*
|
||||
* @see fullEntitiesList
|
||||
* @see asContentMessagesFlow
|
||||
* @see onlyTextContentMessages
|
||||
* @see textMessages
|
||||
*/
|
||||
fun <T : ContentMessage<TextContent>> Flow<T>.filterExactCommands(
|
||||
commandRegex: Regex
|
||||
) = filter { contentMessage ->
|
||||
(contentMessage.content.fullEntitiesList().singleOrNull() as? BotCommandTextSource) ?.let { commandRegex.matches(it.command) } == true
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert incoming [com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage.content] of
|
||||
* messages with [fullEntitiesList] and check that incoming message contains [BotCommandTextSource]. Besides, it is
|
||||
* checking that [BotCommandTextSource.command] [Regex.matches] with incoming [commandRegex]
|
||||
*
|
||||
* @return The same message in case if it contains somewhere in text [BotCommandTextSource] with [Regex.matches]
|
||||
* [BotCommandTextSource.command]
|
||||
*
|
||||
* @see fullEntitiesList
|
||||
* @see asContentMessagesFlow
|
||||
* @see onlyTextContentMessages
|
||||
* @see textMessages
|
||||
*/
|
||||
fun <T : ContentMessage<TextContent>> Flow<T>.filterCommandsInsideTextMessages(
|
||||
commandRegex: Regex
|
||||
) = filter { contentMessage ->
|
||||
contentMessage.content.fullEntitiesList().any {
|
||||
(it as? BotCommandTextSource) ?.let { commandRegex.matches(it.command) } == true
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert incoming [com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage.content] of
|
||||
* messages with [fullEntitiesList] and check that incoming message contains first [TextSource] as
|
||||
* [BotCommandTextSource]. Besides, it is checking that [BotCommandTextSource.command] [Regex.matches] with incoming
|
||||
* [commandRegex] and for other [TextSource] objects used next rules: all incoming text sources will be passed as is,
|
||||
* [RegularTextSource] will be split by " " for several [RegularTextSource] which will contains not empty args without
|
||||
* spaces.
|
||||
*
|
||||
* @return Paired original message and converted list with first entity [BotCommandTextSource] and than all others
|
||||
* according to rules in description
|
||||
*
|
||||
* @see fullEntitiesList
|
||||
* @see asContentMessagesFlow
|
||||
* @see onlyTextContentMessages
|
||||
* @see textMessages
|
||||
*/
|
||||
fun <T : ContentMessage<TextContent>> Flow<T>.filterCommandsWithArgs(
|
||||
commandRegex: Regex
|
||||
) = mapNotNull { contentMessage ->
|
||||
val allEntities = contentMessage.content.fullEntitiesList()
|
||||
(allEntities.firstOrNull() as? BotCommandTextSource) ?.let {
|
||||
if (commandRegex.matches(it.command)) {
|
||||
contentMessage to allEntities.flatMap {
|
||||
when (it) {
|
||||
is RegularTextSource -> it.source.split(" ").mapNotNull { regularTextSourcePart ->
|
||||
if (regularTextSourcePart.isNotBlank()) {
|
||||
RegularTextSource(regularTextSourcePart)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
else -> listOf(it)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
@@ -2,8 +2,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.updates
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.onlyTextContentMessages
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.shortcuts.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources.BotCommandTextSource
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources.RegularTextSource
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.fullEntitiesList
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseSentMessageUpdate
|
||||
import kotlinx.coroutines.flow.*
|
||||
@@ -23,9 +26,7 @@ import kotlinx.coroutines.flow.*
|
||||
*/
|
||||
fun <T : BaseSentMessageUpdate> Flow<T>.filterExactCommands(
|
||||
commandRegex: Regex
|
||||
) = asContentMessagesFlow().onlyTextContentMessages().filter { contentMessage ->
|
||||
(contentMessage.content.fullEntitiesList().singleOrNull() as? BotCommandTextSource) ?.let { commandRegex.matches(it.command) } == true
|
||||
}
|
||||
) = textMessages().filterExactCommands(commandRegex)
|
||||
|
||||
/**
|
||||
* Convert incoming [com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage.content] of
|
||||
@@ -41,11 +42,7 @@ fun <T : BaseSentMessageUpdate> Flow<T>.filterExactCommands(
|
||||
*/
|
||||
fun <T : BaseSentMessageUpdate> Flow<T>.filterCommandsInsideTextMessages(
|
||||
commandRegex: Regex
|
||||
) = asContentMessagesFlow().onlyTextContentMessages().filter { contentMessage ->
|
||||
contentMessage.content.fullEntitiesList().any {
|
||||
(it as? BotCommandTextSource) ?.let { commandRegex.matches(it.command) } == true
|
||||
}
|
||||
}
|
||||
) = textMessages().filterCommandsInsideTextMessages(commandRegex)
|
||||
|
||||
/**
|
||||
* Convert incoming [com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage.content] of
|
||||
@@ -55,7 +52,8 @@ fun <T : BaseSentMessageUpdate> Flow<T>.filterCommandsInsideTextMessages(
|
||||
* [RegularTextSource] will be split by " " for several [RegularTextSource] which will contains not empty args without
|
||||
* spaces.
|
||||
*
|
||||
* @return Converted list with first entity [BotCommandTextSource] and than all others according to rules in description
|
||||
* @return Paired original message and converted list with first entity [BotCommandTextSource] and than all others
|
||||
* according to rules in description
|
||||
*
|
||||
* @see fullEntitiesList
|
||||
* @see asContentMessagesFlow
|
||||
@@ -63,24 +61,4 @@ fun <T : BaseSentMessageUpdate> Flow<T>.filterCommandsInsideTextMessages(
|
||||
*/
|
||||
fun <T : BaseSentMessageUpdate> Flow<T>.filterCommandsWithArgs(
|
||||
commandRegex: Regex
|
||||
): Flow<List<TextSource>> = asContentMessagesFlow().onlyTextContentMessages().mapNotNull { contentMessage ->
|
||||
val allEntities = contentMessage.content.fullEntitiesList()
|
||||
(allEntities.firstOrNull() as? BotCommandTextSource) ?.let {
|
||||
if (commandRegex.matches(it.command)) {
|
||||
allEntities.flatMap {
|
||||
when (it) {
|
||||
is RegularTextSource -> it.source.split(" ").mapNotNull { regularTextSourcePart ->
|
||||
if (regularTextSourcePart.isNotBlank()) {
|
||||
RegularTextSource(regularTextSourcePart)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
else -> listOf(it)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
): Flow<Pair<ContentMessage<TextContent>, List<TextSource>>> = textMessages().filterCommandsWithArgs(commandRegex)
|
||||
|
||||
@@ -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()
|
||||
@@ -1 +1 @@
|
||||
{"bintrayConfig":{"repo":"StandardRepository","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/TelegramBotAPI"},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API","description":"This project just include all subproject of TelegramBotAPI","url":"https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]},"type":"Multiplatform"}
|
||||
{"bintrayConfig":{"repo":"StandardRepository","packageName":"${project.name}","packageVcs":"https://github.com/InsanusMokrassar/TelegramBotAPI","autoPublish":true},"licenses":[{"id":"Apache-2.0","title":"Apache Software License 2.0","url":"https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/LICENSE"}],"mavenConfig":{"name":"Telegram Bot API","description":"This project just include all subproject of TelegramBotAPI","url":"https://insanusmokrassar.github.io/TelegramBotAPI/TelegramBotAPI","vcsUrl":"https://github.com/insanusmokrassar/TelegramBotAPI.git","developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]},"type":"Multiplatform"}
|
||||
@@ -25,6 +25,9 @@ bintray {
|
||||
}
|
||||
into "${project.group}".replace(".", "/")
|
||||
}
|
||||
|
||||
publish = true
|
||||
|
||||
pkg {
|
||||
repo = "StandardRepository"
|
||||
name = "${project.name}"
|
||||
|
||||
30
build.gradle
30
build.gradle
@@ -3,12 +3,14 @@ buildscript {
|
||||
mavenLocal()
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
maven { url "https://plugins.gradle.org/m2/" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
|
||||
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version"
|
||||
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.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_coroutines_version=1.3.9
|
||||
kotlin_serialisation_runtime_version=1.0.0-RC
|
||||
klock_version=1.12.0
|
||||
kotlin_serialisation_runtime_version=1.0.0-RC2
|
||||
klock_version=1.12.1
|
||||
uuid_version=0.2.2
|
||||
ktor_version=1.4.0
|
||||
ktor_version=1.4.1
|
||||
|
||||
javax_activation_version=1.1.1
|
||||
|
||||
library_group=com.github.insanusmokrassar
|
||||
library_version=0.28.1
|
||||
library_version=0.28.4
|
||||
|
||||
gradle_bintray_plugin_version=1.8.5
|
||||
github_release_plugin_version=2.2.12
|
||||
|
||||
Reference in New Issue
Block a user