1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-11-25 08:45:50 +00:00

Compare commits

..

24 Commits

Author SHA1 Message Date
37a23c7e79 fixes in aggregation of flows 2020-10-27 15:51:48 +06:00
b053c29ea3 update aggregateFlows 2020-10-27 15:26:32 +06:00
23a1fed7dd Revert "update greetings config"
This reverts commit 87d2537bda.
2020-10-27 15:16:04 +06:00
87d2537bda update greetings config 2020-10-27 15:14:45 +06:00
6d782f28c3 updates after coroutines version change 2020-10-27 15:11:57 +06:00
d8dbbdf549 update coroutines 2020-10-27 15:01:30 +06:00
f317e144e6 Revert "add slot machine, but currently it is not working"
This reverts commit 4f9cb531c0.
2020-10-27 14:53:22 +06:00
4f9cb531c0 add slot machine, but currently it is not working 2020-10-19 20:26:36 +06:00
09bbb1945c start 0.29.2 2020-10-19 20:12:18 +06:00
6a73aa1525 add travis dokka step 2020-10-19 19:50:41 +06:00
e85e7d02f7 Merge pull request #149 from InsanusMokrassar/0.29.1
0.29.1
2020-10-13 16:08:19 +06:00
37ad279ab4 Merge pull request #148 from leobia/master
Reformat CHANGELOG.md
2020-10-12 15:27:09 +06:00
3b41dc1fbf Merge remote-tracking branch 'original/0.29.1' 2020-10-12 15:26:11 +06:00
5747383ed1 Update README.md 2020-10-12 01:08:56 +06:00
18a6efabb8 post fixes for serialization update 2020-10-09 11:49:24 +06:00
dcb837b155 update serialization version 2020-10-09 11:41:08 +06:00
03755e9eef start 0.29.1 2020-10-09 11:35:33 +06:00
lbia
b9db2d544d Reformat CHANGELOG.md 2020-10-08 22:11:39 +02:00
800d14561e add conversations between AudioFile and VoiceFile 2020-10-04 20:00:43 +06:00
2378237fc5 Merge pull request #146 from InsanusMokrassar/0.29.0
0.29.0
2020-10-04 19:46:22 +06:00
48c6f103b5 Update README.md 2020-10-02 14:27:07 +06:00
e326d289cb Create pull_request_template.md 2020-10-02 13:26:32 +06:00
7fd9c4c897 Create CONTRIBUTING.md 2020-10-02 13:10:01 +06:00
347a6212d4 Merge pull request #141 from InsanusMokrassar/0.28.4
0.28.4
2020-09-28 13:29:22 +06:00
14 changed files with 608 additions and 576 deletions

2
.github/pull_request_template.md vendored Normal file
View 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)

View File

@@ -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

File diff suppressed because it is too large Load Diff

10
CONTRIBUTING.md Normal file
View 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:)

View File

@@ -1,6 +1,6 @@
# 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) [Small survey](https://forms.gle/tnjuExdSKEr32ygKA)|
| 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) [Small survey](https://forms.gle/2Hex2ynbHWHhi1KY7)|
| -------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Useful links | [![Chat in Telegram](badges/chat.svg)](https://t.me/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) |
| TelegramBotAPI Core status | [![Download](https://api.bintray.com/packages/insanusmokrassar/TelegramBotAPI/tgbotapi.core/images/download.svg)](https://bintray.com/insanusmokrassar/TelegramBotAPI/tgbotapi.core/_latestVersion) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.core/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi.core) |
@@ -74,7 +74,7 @@ kotlin {
![Libraries hierarchy](resources/TelegramBotAPI-libraries-hierarchy.svg)
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

View File

@@ -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

View File

@@ -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")
}

View File

@@ -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)

View File

@@ -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)

View File

@@ -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

View File

@@ -47,6 +47,4 @@ object UpdateDeserializationStrategy : DeserializationStrategy<Update> {
asJson
)
}
override fun patch(decoder: Decoder, old: Update): Update = error("Unsupported operation")
}

View File

@@ -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()

View File

@@ -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),

View File

@@ -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 {