mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-25 08:45:50 +00:00
Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 37a23c7e79 | |||
| b053c29ea3 | |||
| 23a1fed7dd | |||
| 87d2537bda | |||
| 6d782f28c3 | |||
| d8dbbdf549 | |||
| f317e144e6 | |||
| 4f9cb531c0 | |||
| 09bbb1945c | |||
| 6a73aa1525 | |||
| e85e7d02f7 | |||
| 37ad279ab4 | |||
| 3b41dc1fbf | |||
| 5747383ed1 | |||
| 18a6efabb8 | |||
| dcb837b155 | |||
| 03755e9eef | |||
|
|
b9db2d544d | ||
| 800d14561e | |||
| 2378237fc5 | |||
| 48c6f103b5 | |||
| e326d289cb | |||
| 7fd9c4c897 | |||
| 347a6212d4 |
2
.github/pull_request_template.md
vendored
Normal file
2
.github/pull_request_template.md
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
* Please, be sure that you have read [Contributing](https://github.com/InsanusMokrassar/TelegramBotAPI/blob/master/CONTRIBUTING.md) file. Of course, this line must be removed during PR preparation :)
|
||||
* Describe your changes, shortly. As example (or format) you can look at the body of any [Project releases](https://github.com/InsanusMokrassar/TelegramBotAPI/releases)
|
||||
@@ -11,3 +11,5 @@ jobs:
|
||||
script: ./gradlew build -s -x jvmTest -x jsIrTest -x jsIrBrowserTest -x jsIrNodeTest -x jsLegacyTest -x jsLegacyBrowserTest -x jsLegacyNodeTest
|
||||
- state: test
|
||||
script: ./gradlew allTests
|
||||
- state: dokka
|
||||
script: ./gradlew dokkaHtml
|
||||
|
||||
1131
CHANGELOG.md
1131
CHANGELOG.md
File diff suppressed because it is too large
Load Diff
10
CONTRIBUTING.md
Normal file
10
CONTRIBUTING.md
Normal file
@@ -0,0 +1,10 @@
|
||||
# Contributing
|
||||
|
||||
In case you wish to contribute this project, there are several small things you must remember:
|
||||
|
||||
* Give maintainers opportunity to manage your Pull request. It is required for two reasons
|
||||
* For more efficient Pull Requests handling (it is much easier for me to fix something small directly in your pull request than ask to fix some small things after each review)
|
||||
* Usually, you will set as a target `master` branch, but I prefer to include code into separated version branch firstly. So, if you will give me opporunity to change Pull Request, I will be available to change base branch
|
||||
* Currently in Pull Requests there are several bots. The most important is Travis bot and it must always successfuly build code from your Pull Request
|
||||
|
||||
This project was built on the idea of strongly-typed declaration of TelegramBotAPI. So, do not worry if maintaners will change your pull requests: you are already cool because you have contributed this project:)
|
||||
@@ -1,6 +1,6 @@
|
||||
# TelegramBotAPI
|
||||
|
||||
| Common info | [](https://github.com/KotlinBy/awesome-kotlin) [](https://travis-ci.com/InsanusMokrassar/TelegramBotAPI) [Small survey](https://forms.gle/tnjuExdSKEr32ygKA)|
|
||||
| Common info | [](https://github.com/KotlinBy/awesome-kotlin) [](https://travis-ci.com/InsanusMokrassar/TelegramBotAPI) [Small survey](https://forms.gle/2Hex2ynbHWHhi1KY7)|
|
||||
| -------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| Useful links | [](https://t.me/InMoTelegramBotAPI) [](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) |
|
||||
| TelegramBotAPI Core status | [](https://bintray.com/insanusmokrassar/TelegramBotAPI/tgbotapi.core/_latestVersion) [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.core) |
|
||||
@@ -74,7 +74,7 @@ kotlin {
|
||||
|
||||

|
||||
|
||||
In most cases, the most simple way will be to implement [TelegramBotAPI](TelegramBotAPI/README.md) - it contains
|
||||
In most cases, the most simple way will be to implement [TelegramBotAPI](tgbotapi/README.md) - it contains
|
||||
all necessary tools for comfort usage of this library. If you want to exclude some libraries, you can implement just
|
||||
[TelegramBotAPI API Extensions](tgbotapi.extensions.api/README.md),
|
||||
[TelegramBotAPI Util Extensions](tgbotapi.extensions.utils/README.md) or even
|
||||
|
||||
@@ -6,8 +6,8 @@ kotlin.incremental=true
|
||||
kotlin.incremental.js=true
|
||||
|
||||
kotlin_version=1.4.10
|
||||
kotlin_coroutines_version=1.3.9
|
||||
kotlin_serialisation_runtime_version=1.0.0-RC2
|
||||
kotlin_coroutines_version=1.4.0
|
||||
kotlin_serialisation_runtime_version=1.0.0
|
||||
klock_version=1.12.1
|
||||
uuid_version=0.2.2
|
||||
ktor_version=1.4.1
|
||||
@@ -15,7 +15,7 @@ ktor_version=1.4.1
|
||||
javax_activation_version=1.1.1
|
||||
|
||||
library_group=dev.inmo
|
||||
library_version=0.29.0
|
||||
library_version=0.29.2
|
||||
|
||||
gradle_bintray_plugin_version=1.8.5
|
||||
github_release_plugin_version=2.2.12
|
||||
|
||||
@@ -23,5 +23,4 @@ internal object ChatMemberDeserializationStrategy : DeserializationStrategy<Chat
|
||||
override val descriptor: SerialDescriptor = RawChatMember.serializer().descriptor
|
||||
|
||||
override fun deserialize(decoder: Decoder): ChatMember = RawChatMember.serializer().deserialize(decoder).asChatMember
|
||||
override fun patch(decoder: Decoder, old: ChatMember): ChatMember = error("ChatMember can't be patched")
|
||||
}
|
||||
|
||||
@@ -24,3 +24,5 @@ data class AudioFile(
|
||||
override val fileSize: Long? = null,
|
||||
override val thumb: PhotoSize? = null
|
||||
) : TelegramMediaFile, MimedMediaFile, ThumbedMediaFile, PlayableMediaFile, TitledMediaFile, Performerable
|
||||
|
||||
fun AudioFile.asVoiceFile() = VoiceFile(fileId, fileUniqueId, duration, mimeType, fileSize)
|
||||
|
||||
@@ -20,3 +20,8 @@ data class VoiceFile(
|
||||
@SerialName(fileSizeField)
|
||||
override val fileSize: Long? = null
|
||||
) : TelegramMediaFile, MimedMediaFile, PlayableMediaFile
|
||||
|
||||
fun VoiceFile.asAudioFile(
|
||||
performer: String? = null,
|
||||
title: String? = null
|
||||
) = AudioFile(fileId, fileUniqueId, duration, performer, title, mimeType, fileSize)
|
||||
|
||||
@@ -26,8 +26,6 @@ internal class TelegramBotAPIMessageDeserializationStrategyClass<T> : Deserializ
|
||||
@InternalSerializationApi
|
||||
override val descriptor: SerialDescriptor = buildSerialDescriptor("TelegramBotAPIMessageSerializer", PolymorphicKind.OPEN)
|
||||
|
||||
override fun patch(decoder: Decoder, old: T): T = error("TelegramBotAPIMessageSerializer")
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun deserialize(decoder: Decoder): T {
|
||||
return RawMessage.serializer().deserialize(decoder).asMessage as T
|
||||
|
||||
@@ -47,6 +47,4 @@ object UpdateDeserializationStrategy : DeserializationStrategy<Update> {
|
||||
asJson
|
||||
)
|
||||
}
|
||||
|
||||
override fun patch(decoder: Decoder, old: Update): Update = error("Unsupported operation")
|
||||
}
|
||||
|
||||
@@ -5,21 +5,20 @@ import dev.inmo.tgbotapi.types.update.*
|
||||
import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.*
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.UnknownUpdate
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
import kotlinx.coroutines.channels.BroadcastChannel
|
||||
import kotlinx.coroutines.flow.*
|
||||
|
||||
@Suppress("EXPERIMENTAL_API_USAGE", "unused")
|
||||
class FlowsUpdatesFilter(
|
||||
broadcastChannelsSize: Int = 100
|
||||
): UpdatesFilter {
|
||||
private val updatesReceivingChannel = BroadcastChannel<Update>(broadcastChannelsSize)
|
||||
private val updatesSharedFlow = MutableSharedFlow<Update>(extraBufferCapacity = broadcastChannelsSize)
|
||||
@Suppress("MemberVisibilityCanBePrivate")
|
||||
val allUpdatesFlow: Flow<Update> = updatesReceivingChannel.asFlow()
|
||||
val allUpdatesFlow: Flow<Update> = updatesSharedFlow.asSharedFlow()
|
||||
|
||||
override val allowedUpdates: List<String>
|
||||
get() = ALL_UPDATES_LIST
|
||||
override val asUpdateReceiver: UpdateReceiver<Update> = {
|
||||
updatesReceivingChannel.send(it)
|
||||
updatesSharedFlow.emit(it)
|
||||
}
|
||||
|
||||
val messageFlow: Flow<MessageUpdate> = allUpdatesFlow.filterIsInstance()
|
||||
|
||||
@@ -11,6 +11,7 @@ private sealed class DebounceAction<T> {
|
||||
private data class AddValue<T>(override val value: T) : DebounceAction<T>()
|
||||
private data class RemoveJob<T>(override val value: T, val job: Job) : DebounceAction<T>()
|
||||
|
||||
@Deprecated("Unused and will be removed in next major release")
|
||||
fun <T> ReceiveChannel<T>.debounceByValue(
|
||||
delayMillis: Long,
|
||||
scope: CoroutineScope = CoroutineScope(Dispatchers.Default),
|
||||
|
||||
@@ -2,7 +2,6 @@ package dev.inmo.tgbotapi.extensions.utils
|
||||
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.channels.BroadcastChannel
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.flow.*
|
||||
|
||||
/**
|
||||
@@ -11,15 +10,15 @@ import kotlinx.coroutines.flow.*
|
||||
fun <T> aggregateFlows(
|
||||
withScope: CoroutineScope,
|
||||
vararg flows: Flow<T>,
|
||||
internalBufferSize: Int = Channel.BUFFERED
|
||||
internalBufferSize: Int = 64
|
||||
): Flow<T> {
|
||||
val bc = BroadcastChannel<T>(internalBufferSize)
|
||||
val sharedFlow = MutableSharedFlow<T>(extraBufferCapacity = internalBufferSize)
|
||||
flows.forEach {
|
||||
it.onEach {
|
||||
safely { bc.send(it) }
|
||||
safely { sharedFlow.emit(it) }
|
||||
}.launchIn(withScope)
|
||||
}
|
||||
return bc.asFlow()
|
||||
return sharedFlow
|
||||
}
|
||||
|
||||
fun <T> Flow<Iterable<T>>.flatMap(): Flow<T> = flow {
|
||||
|
||||
Reference in New Issue
Block a user