1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-11-18 13:00:18 +00:00

Compare commits

...

21 Commits

Author SHA1 Message Date
c773736fb8 Update CHANGELOG.md 2025-03-26 10:12:19 +06:00
8a3a05ef12 fix of cancelling absence for subchains which become out of FSM 2025-03-26 09:45:30 +06:00
0afbe8ef2d update dependencies 2025-03-25 18:56:59 +06:00
3f4018f969 update KSLog part of library 2025-03-03 09:25:19 +06:00
097d82b4b4 start 24.0.2 2025-03-03 08:59:16 +06:00
7c2a379161 Merge pull request #956 from InsanusMokrassar/24.0.1
24.0.1
2025-03-01 15:05:23 +07:00
ba5f76e8cd fix of EditChatMessageMedia 2025-03-01 14:04:08 +06:00
8aec920a15 start 24.0.1 2025-03-01 12:57:35 +06:00
c92bd33ba1 Merge pull request #952 from InsanusMokrassar/24.0.0
24.0.0
2025-02-20 22:34:35 +06:00
51927974f5 ForumContentMessage.threadCreatingInfo 2025-02-20 11:54:41 +06:00
9350f87e19 update dependencies 2025-02-20 09:00:01 +06:00
6cb9950b36 fix of subcontextUpdatesFilter 2025-02-18 23:09:28 +06:00
974c2e883f start 24.0.0 2025-02-18 23:04:47 +06:00
af6f98fd56 Update FUNDING.yml 2025-02-18 09:15:13 +06:00
75a2b2c282 Merge pull request #951 from InsanusMokrassar/23.2.1
23.2.1
2025-02-17 21:16:15 +06:00
d66d4b4209 jvmApiDump 2025-02-17 13:18:55 +06:00
9d54820fd7 fill changelog 2025-02-17 13:17:26 +06:00
1876df2c2d fix of year in Birthdate 2025-02-17 13:16:10 +06:00
d818592cd3 start 23.2.1 2025-02-17 13:14:03 +06:00
c29737b6b3 update changelog and readme 2025-02-15 20:53:28 +06:00
46243a21eb Merge pull request #949 from InsanusMokrassar/23.2.0
23.2.0
2025-02-15 14:28:08 +06:00
16 changed files with 185 additions and 37 deletions

2
.github/FUNDING.yml vendored
View File

@@ -1,3 +1,3 @@
# These are supported funding model platforms # These are supported funding model platforms
custom: ['https://www.tinkoff.ru/rm/ovsyannikov.aleksey113/ObMJ712472', 'https://boosty.to/insanusmokrassar'] custom: ['https://tonscan.org/address/UQAtuSLJ76Zehc3qP-eRYMR98fPIu_oOp_atcpVX55zxHwTU']

View File

@@ -1,7 +1,42 @@
# TelegramBotAPI changelog # TelegramBotAPI changelog
## 24.0.2
* `Version`:
* `Kotlin`: `2.1.10` -> `2.1.20`
* `Ktor`: `3.1.0` -> `3.1.1`
* `MicroUtils`: `0.24.7` -> `0.25.3`
* `DefaultKTgBotAPIKSLog` will drop `CancellationException`s by default
* You may configure `DefaultKTgBotAPIKSLog` in simple way with `SetDefaultKTgBotAPIKSLog`
* `BehaviourBuilder`:
* `FSM`:
* Fix chains cancelling on their ends
## 24.0.1
* `Core`:
* Now you may upload photos with `EditChatMessageMedia`
## 24.0.0
**THIS UPDATE CONTAINS BREAKING CHANGES IN `subcontextUpdatesFilter` WORK. TAKE CARE IN MIGRATION**
* `Version`:
* `MicroUtils`: `0.24.6` -> `0.24.7`
* `Core`:
* `ForumContentMessage` got property `threadCreatingInfo` which represents information about topic where message has been sent
* `BehaviourBuilder`:
* Fix of overall `subcontextUpdatesFilter` behaviour. In fact, this update will fix its affection on scenaries
## 23.2.1
* `Core`:
* Fix of `year` field in `Birthdate`
## 23.2.0 ## 23.2.0
**THIS UPDATE CONTAINS ADDING SUPPORT OF [Telegram Bots API 8.3](https://core.telegram.org/bots/api-changelog#february-12-2025)**
* `Version`: * `Version`:
* `MicroUtils`: `0.24.5` -> `0.24.6` * `MicroUtils`: `0.24.5` -> `0.24.6`
* `Ktor`: `3.0.3` -> `3.1.0` * `Ktor`: `3.0.3` -> `3.1.0`

View File

@@ -1,4 +1,4 @@
# TelegramBotAPI [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [![Supported version](https://img.shields.io/badge/Telegram%20Bot%20API-8.2-blue)](https://core.telegram.org/bots/api-changelog#january-1-2025) # TelegramBotAPI [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [![Supported version](https://img.shields.io/badge/Telegram%20Bot%20API-8.3-blue)](https://core.telegram.org/bots/api-changelog#february-12-2025)
| Docs | [![KDocs](https://img.shields.io/static/v1?label=Dokka&message=KDocs&color=blue&logo=kotlin)](https://tgbotapi.inmo.dev/index.html) [![Mini tutorial](https://img.shields.io/static/v1?label=Mk&message=Docs&color=blue&logo=mkdocs)](https://docs.inmo.dev/tgbotapi/index.html) | | Docs | [![KDocs](https://img.shields.io/static/v1?label=Dokka&message=KDocs&color=blue&logo=kotlin)](https://tgbotapi.inmo.dev/index.html) [![Mini tutorial](https://img.shields.io/static/v1?label=Mk&message=Docs&color=blue&logo=mkdocs)](https://docs.inmo.dev/tgbotapi/index.html) |
|:----------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| |:----------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|

View File

@@ -6,4 +6,4 @@ kotlin.incremental=true
kotlin.incremental.js=true kotlin.incremental.js=true
library_group=dev.inmo library_group=dev.inmo
library_version=23.2.0 library_version=24.0.2

View File

@@ -1,6 +1,6 @@
[versions] [versions]
kotlin = "2.1.10" kotlin = "2.1.20"
kotlin-serialization = "1.8.0" kotlin-serialization = "1.8.0"
kotlin-coroutines = "1.10.1" kotlin-coroutines = "1.10.1"
@@ -8,12 +8,12 @@ javax-activation = "1.1.1"
korlibs = "5.4.0" korlibs = "5.4.0"
uuid = "0.8.4" uuid = "0.8.4"
ktor = "3.1.0" ktor = "3.1.1"
ksp = "2.1.10-1.0.29" ksp = "2.1.20-1.0.31"
kotlin-poet = "1.18.1" kotlin-poet = "1.18.1"
microutils = "0.24.6" microutils = "0.25.3"
kslog = "1.4.1" kslog = "1.4.1"
versions = "0.51.0" versions = "0.51.0"

View File

@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip

View File

@@ -144,10 +144,12 @@ class DefaultBehaviourContextWithFSM<T : State>(
state.context state.context
).apply { ).apply {
stateInitialAction(state) stateInitialAction(state)
}.launchStateHandling( }.run {
state, launchStateHandling(
actualHandlersList state,
) actualHandlersList
)
}
} }
override fun <I : T> add(kClass: KClass<I>, strict: Boolean, handler: BehaviourWithFSMStateHandler<I, T>) { override fun <I : T> add(kClass: KClass<I>, strict: Boolean, handler: BehaviourWithFSMStateHandler<I, T>) {
@@ -188,7 +190,7 @@ class DefaultBehaviourContextWithFSM<T : State>(
statesJobsMutex.withLock { statesJobsMutex.withLock {
runCatchingSafely { statesJobs.remove(it) ?.cancel() } runCatchingSafely { statesJobs.remove(it) ?.cancel() }
} }
updatesFlows.remove(it.context) updatesFlows.remove(it.context) ?.cancel()
} }
statesManager.onChainStateUpdated.subscribeSafelyWithoutExceptions(this) { (old, new) -> statesManager.onChainStateUpdated.subscribeSafelyWithoutExceptions(this) { (old, new) ->
statesJobsMutex.withLock { statesJobsMutex.withLock {
@@ -197,7 +199,7 @@ class DefaultBehaviourContextWithFSM<T : State>(
statesJobs[new] = launch { statePerformer(new) }.apply { enableRemoveOnCompletion(new) } statesJobs[new] = launch { statePerformer(new) }.apply { enableRemoveOnCompletion(new) }
} }
if (old.context != new.context) { if (old.context != new.context) {
updatesFlows.remove(old.context) updatesFlows.remove(old.context) ?.cancel()
} }
} }

View File

@@ -1,13 +1,20 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
import dev.inmo.micro_utils.coroutines.SpecialMutableStateFlow
import dev.inmo.micro_utils.coroutines.launchLoggingDropExceptions
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
import dev.inmo.micro_utils.coroutines.subscribeLoggingDropExceptions
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptionsAsync import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptionsAsync
import dev.inmo.tgbotapi.extensions.behaviour_builder.* import dev.inmo.tgbotapi.extensions.behaviour_builder.*
import dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.expectFlow import dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.expectFlow
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
import dev.inmo.tgbotapi.extensions.utils.flatMap
import dev.inmo.tgbotapi.types.update.abstracts.Update import dev.inmo.tgbotapi.types.update.abstracts.Update
import kotlinx.coroutines.flow.emptyFlow
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.flatMapLatest
internal suspend fun <BC : BehaviourContext, T> BC.on( internal suspend fun <BC : BehaviourContext, T> BC.on(
markerFactory: MarkerFactory<in T, Any>?, markerFactory: MarkerFactory<in T, Any>?,
@@ -40,11 +47,21 @@ internal suspend fun <BC : BehaviourContext, T> BC.on(
} }
val handler: suspend (Pair<Update, T>) -> Unit = subcontextUpdatesFilter ?.let { val handler: suspend (Pair<Update, T>) -> Unit = subcontextUpdatesFilter ?.let {
{ (update, triggerData) -> { (update, triggerData) ->
createSubContextAndDoSynchronouslyWithUpdatesFilter { val contextStateFlow = SpecialMutableStateFlow<BC?>(null)
if (subcontextUpdatesFilter(this, triggerData, update)) { createSubContextAndDoSynchronouslyWithUpdatesFilter(
localSubcontextInitialAction(update, triggerData) updatesUpstreamFlow = contextStateFlow.flatMapLatest { context ->
scenarioReceiver(triggerData) if (context == null) {
emptyFlow()
} else {
allUpdatesFlow.filter {
context.subcontextUpdatesFilter(triggerData, it)
}
}
} }
) {
contextStateFlow.value = this
localSubcontextInitialAction(update, triggerData)
scenarioReceiver(triggerData)
} }
} }
} ?: { (update, triggerData) -> } ?: { (update, triggerData) ->
@@ -57,8 +74,8 @@ internal suspend fun <BC : BehaviourContext, T> BC.on(
{ markerFactory(it.second) }, { markerFactory(it.second) },
block = handler block = handler
) )
} ?: subscribeSafelyWithoutExceptions(scope) { } ?: subscribeLoggingDropExceptions(scope) {
scope.launchSafelyWithoutExceptions { scope.launchLoggingDropExceptions {
handler(it) handler(it)
} }
} }

View File

@@ -432,6 +432,7 @@ public final class dev/inmo/tgbotapi/bot/ktor/base/MultipartRequestCallFactory :
public fun <init> ()V public fun <init> ()V
public fun <init> (Ldev/inmo/kslog/common/KSLog;)V public fun <init> (Ldev/inmo/kslog/common/KSLog;)V
public synthetic fun <init> (Ldev/inmo/kslog/common/KSLog;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public synthetic fun <init> (Ldev/inmo/kslog/common/KSLog;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun makeCall (Lio/ktor/client/HttpClient;Ldev/inmo/tgbotapi/utils/TelegramAPIUrlsKeeper;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlinx/serialization/json/Json;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
} }
public final class dev/inmo/tgbotapi/bot/ktor/base/MultipleClientKtorRequestsExecutor : dev/inmo/tgbotapi/bot/BaseRequestsExecutor { public final class dev/inmo/tgbotapi/bot/ktor/base/MultipleClientKtorRequestsExecutor : dev/inmo/tgbotapi/bot/BaseRequestsExecutor {
@@ -3895,7 +3896,7 @@ public final class dev/inmo/tgbotapi/requests/edit/location/live/StopInlineMessa
public final fun serializer ()Lkotlinx/serialization/KSerializer; public final fun serializer ()Lkotlinx/serialization/KSerializer;
} }
public final class dev/inmo/tgbotapi/requests/edit/media/EditChatMessageMedia : dev/inmo/tgbotapi/requests/edit/abstracts/EditChatMessage, dev/inmo/tgbotapi/requests/edit/abstracts/EditMediaMessage, dev/inmo/tgbotapi/requests/edit/abstracts/EditReplyMessage { public final class dev/inmo/tgbotapi/requests/edit/media/EditChatMessageMedia : dev/inmo/tgbotapi/requests/abstracts/MultipartRequest$Common, dev/inmo/tgbotapi/requests/edit/abstracts/EditChatMessage, dev/inmo/tgbotapi/requests/edit/abstracts/EditMediaMessage, dev/inmo/tgbotapi/requests/edit/abstracts/EditReplyMessage {
public static final field Companion Ldev/inmo/tgbotapi/requests/edit/media/EditChatMessageMedia$Companion; public static final field Companion Ldev/inmo/tgbotapi/requests/edit/media/EditChatMessageMedia$Companion;
public synthetic fun <init> (Ldev/inmo/tgbotapi/types/ChatIdentifier;JLdev/inmo/tgbotapi/types/media/TelegramFreeMedia;Ljava/lang/String;Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public synthetic fun <init> (Ldev/inmo/tgbotapi/types/ChatIdentifier;JLdev/inmo/tgbotapi/types/media/TelegramFreeMedia;Ljava/lang/String;Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Ldev/inmo/tgbotapi/types/ChatIdentifier;JLdev/inmo/tgbotapi/types/media/TelegramFreeMedia;Ljava/lang/String;Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup;Lkotlin/jvm/internal/DefaultConstructorMarker;)V public synthetic fun <init> (Ldev/inmo/tgbotapi/types/ChatIdentifier;JLdev/inmo/tgbotapi/types/media/TelegramFreeMedia;Ljava/lang/String;Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
@@ -3909,8 +3910,11 @@ public final class dev/inmo/tgbotapi/requests/edit/media/EditChatMessageMedia :
public fun equals (Ljava/lang/Object;)Z public fun equals (Ljava/lang/Object;)Z
public fun getBusinessConnectionId-nXr5wdE ()Ljava/lang/String; public fun getBusinessConnectionId-nXr5wdE ()Ljava/lang/String;
public fun getChatId ()Ldev/inmo/tgbotapi/types/ChatIdentifier; public fun getChatId ()Ldev/inmo/tgbotapi/types/ChatIdentifier;
public fun getData ()Ldev/inmo/tgbotapi/requests/abstracts/SimpleRequest;
public fun getMedia ()Ldev/inmo/tgbotapi/types/media/TelegramFreeMedia; public fun getMedia ()Ldev/inmo/tgbotapi/types/media/TelegramFreeMedia;
public fun getMediaMap ()Ljava/util/Map;
public fun getMessageId-APLFQys ()J public fun getMessageId-APLFQys ()J
public fun getParamsJson ()Lkotlinx/serialization/json/JsonObject;
public fun getReplyMarkup ()Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup; public fun getReplyMarkup ()Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup;
public synthetic fun getReplyMarkup ()Ldev/inmo/tgbotapi/types/buttons/KeyboardMarkup; public synthetic fun getReplyMarkup ()Ldev/inmo/tgbotapi/types/buttons/KeyboardMarkup;
public fun getRequestSerializer ()Lkotlinx/serialization/SerializationStrategy; public fun getRequestSerializer ()Lkotlinx/serialization/SerializationStrategy;
@@ -8307,17 +8311,18 @@ public abstract interface class dev/inmo/tgbotapi/types/BackgroundType$WithDocum
public final class dev/inmo/tgbotapi/types/Birthdate { public final class dev/inmo/tgbotapi/types/Birthdate {
public static final field Companion Ldev/inmo/tgbotapi/types/Birthdate$Companion; public static final field Companion Ldev/inmo/tgbotapi/types/Birthdate$Companion;
public fun <init> (III)V public fun <init> (IILjava/lang/Integer;)V
public synthetic fun <init> (IILjava/lang/Integer;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()I public final fun component1 ()I
public final fun component2 ()I public final fun component2 ()I
public final fun component3 ()I public final fun component3 ()Ljava/lang/Integer;
public final fun copy (III)Ldev/inmo/tgbotapi/types/Birthdate; public final fun copy (IILjava/lang/Integer;)Ldev/inmo/tgbotapi/types/Birthdate;
public static synthetic fun copy$default (Ldev/inmo/tgbotapi/types/Birthdate;IIIILjava/lang/Object;)Ldev/inmo/tgbotapi/types/Birthdate; public static synthetic fun copy$default (Ldev/inmo/tgbotapi/types/Birthdate;IILjava/lang/Integer;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/Birthdate;
public fun equals (Ljava/lang/Object;)Z public fun equals (Ljava/lang/Object;)Z
public final fun getDate-1iQqF6g ()I public final fun getDate-1iQqF6g ()I
public final fun getDay ()I public final fun getDay ()I
public final fun getMonth ()I public final fun getMonth ()I
public final fun getYear ()I public final fun getYear ()Ljava/lang/Integer;
public fun hashCode ()I public fun hashCode ()I
public fun toString ()Ljava/lang/String; public fun toString ()Ljava/lang/String;
} }
@@ -19164,6 +19169,7 @@ public final class dev/inmo/tgbotapi/types/message/AnonymousForumContentMessageI
public fun getSenderBot ()Ldev/inmo/tgbotapi/types/chat/CommonBot; public fun getSenderBot ()Ldev/inmo/tgbotapi/types/chat/CommonBot;
public synthetic fun getSenderChat ()Ldev/inmo/tgbotapi/types/chat/PreviewChat; public synthetic fun getSenderChat ()Ldev/inmo/tgbotapi/types/chat/PreviewChat;
public fun getSenderChat ()Ldev/inmo/tgbotapi/types/chat/PreviewGroupChat; public fun getSenderChat ()Ldev/inmo/tgbotapi/types/chat/PreviewGroupChat;
public fun getThreadCreatingInfo ()Ldev/inmo/tgbotapi/types/message/ChatEvents/forum/ForumTopicCreated;
public synthetic fun getThreadId-S3HF-10 ()Ldev/inmo/tgbotapi/types/MessageThreadId; public synthetic fun getThreadId-S3HF-10 ()Ldev/inmo/tgbotapi/types/MessageThreadId;
public fun getThreadId-hDmiKeI ()J public fun getThreadId-hDmiKeI ()J
public fun hashCode ()I public fun hashCode ()I
@@ -19852,6 +19858,7 @@ public final class dev/inmo/tgbotapi/types/message/CommonForumContentMessageImpl
public fun getReplyTo ()Ldev/inmo/tgbotapi/types/message/abstracts/Message; public fun getReplyTo ()Ldev/inmo/tgbotapi/types/message/abstracts/Message;
public fun getSenderBoostsCount ()Ljava/lang/Integer; public fun getSenderBoostsCount ()Ljava/lang/Integer;
public fun getSenderBot ()Ldev/inmo/tgbotapi/types/chat/CommonBot; public fun getSenderBot ()Ldev/inmo/tgbotapi/types/chat/CommonBot;
public fun getThreadCreatingInfo ()Ldev/inmo/tgbotapi/types/message/ChatEvents/forum/ForumTopicCreated;
public synthetic fun getThreadId-S3HF-10 ()Ldev/inmo/tgbotapi/types/MessageThreadId; public synthetic fun getThreadId-S3HF-10 ()Ldev/inmo/tgbotapi/types/MessageThreadId;
public fun getThreadId-hDmiKeI ()J public fun getThreadId-hDmiKeI ()J
public fun getUser ()Ldev/inmo/tgbotapi/types/chat/User; public fun getUser ()Ldev/inmo/tgbotapi/types/chat/User;
@@ -20136,6 +20143,7 @@ public final class dev/inmo/tgbotapi/types/message/FromChannelForumContentMessag
public fun getSenderBot ()Ldev/inmo/tgbotapi/types/chat/CommonBot; public fun getSenderBot ()Ldev/inmo/tgbotapi/types/chat/CommonBot;
public fun getSenderChat ()Ldev/inmo/tgbotapi/types/chat/PreviewChannelChat; public fun getSenderChat ()Ldev/inmo/tgbotapi/types/chat/PreviewChannelChat;
public synthetic fun getSenderChat ()Ldev/inmo/tgbotapi/types/chat/PreviewChat; public synthetic fun getSenderChat ()Ldev/inmo/tgbotapi/types/chat/PreviewChat;
public fun getThreadCreatingInfo ()Ldev/inmo/tgbotapi/types/message/ChatEvents/forum/ForumTopicCreated;
public synthetic fun getThreadId-S3HF-10 ()Ldev/inmo/tgbotapi/types/MessageThreadId; public synthetic fun getThreadId-S3HF-10 ()Ldev/inmo/tgbotapi/types/MessageThreadId;
public fun getThreadId-hDmiKeI ()J public fun getThreadId-hDmiKeI ()J
public fun hashCode ()I public fun hashCode ()I
@@ -20571,6 +20579,7 @@ public final class dev/inmo/tgbotapi/types/message/abstracts/AnonymousForumConte
public static fun getMetaInfo-fV8YnZ8 (Ldev/inmo/tgbotapi/types/message/abstracts/AnonymousForumContentMessage;)Lkotlin/Triple; public static fun getMetaInfo-fV8YnZ8 (Ldev/inmo/tgbotapi/types/message/abstracts/AnonymousForumContentMessage;)Lkotlin/Triple;
public static fun getReplyTo (Ldev/inmo/tgbotapi/types/message/abstracts/AnonymousForumContentMessage;)Ldev/inmo/tgbotapi/types/message/abstracts/Message; public static fun getReplyTo (Ldev/inmo/tgbotapi/types/message/abstracts/AnonymousForumContentMessage;)Ldev/inmo/tgbotapi/types/message/abstracts/Message;
public static fun getSenderChat (Ldev/inmo/tgbotapi/types/message/abstracts/AnonymousForumContentMessage;)Ldev/inmo/tgbotapi/types/chat/PreviewGroupChat; public static fun getSenderChat (Ldev/inmo/tgbotapi/types/message/abstracts/AnonymousForumContentMessage;)Ldev/inmo/tgbotapi/types/chat/PreviewGroupChat;
public static fun getThreadCreatingInfo (Ldev/inmo/tgbotapi/types/message/abstracts/AnonymousForumContentMessage;)Ldev/inmo/tgbotapi/types/message/ChatEvents/forum/ForumTopicCreated;
} }
public abstract interface class dev/inmo/tgbotapi/types/message/abstracts/AnonymousGroupContentMessage : dev/inmo/tgbotapi/types/message/abstracts/GroupContentMessage, dev/inmo/tgbotapi/types/message/abstracts/SignedMessage, dev/inmo/tgbotapi/types/message/abstracts/WithSenderChatMessage { public abstract interface class dev/inmo/tgbotapi/types/message/abstracts/AnonymousGroupContentMessage : dev/inmo/tgbotapi/types/message/abstracts/GroupContentMessage, dev/inmo/tgbotapi/types/message/abstracts/SignedMessage, dev/inmo/tgbotapi/types/message/abstracts/WithSenderChatMessage {
@@ -20635,6 +20644,7 @@ public final class dev/inmo/tgbotapi/types/message/abstracts/CommonForumContentM
public static fun getForwardable (Ldev/inmo/tgbotapi/types/message/abstracts/CommonForumContentMessage;)Z public static fun getForwardable (Ldev/inmo/tgbotapi/types/message/abstracts/CommonForumContentMessage;)Z
public static fun getMetaInfo-fV8YnZ8 (Ldev/inmo/tgbotapi/types/message/abstracts/CommonForumContentMessage;)Lkotlin/Triple; public static fun getMetaInfo-fV8YnZ8 (Ldev/inmo/tgbotapi/types/message/abstracts/CommonForumContentMessage;)Lkotlin/Triple;
public static fun getReplyTo (Ldev/inmo/tgbotapi/types/message/abstracts/CommonForumContentMessage;)Ldev/inmo/tgbotapi/types/message/abstracts/Message; public static fun getReplyTo (Ldev/inmo/tgbotapi/types/message/abstracts/CommonForumContentMessage;)Ldev/inmo/tgbotapi/types/message/abstracts/Message;
public static fun getThreadCreatingInfo (Ldev/inmo/tgbotapi/types/message/abstracts/CommonForumContentMessage;)Ldev/inmo/tgbotapi/types/message/ChatEvents/forum/ForumTopicCreated;
public static fun getUser (Ldev/inmo/tgbotapi/types/message/abstracts/CommonForumContentMessage;)Ldev/inmo/tgbotapi/types/chat/User; public static fun getUser (Ldev/inmo/tgbotapi/types/message/abstracts/CommonForumContentMessage;)Ldev/inmo/tgbotapi/types/chat/User;
} }
@@ -20687,6 +20697,7 @@ public final class dev/inmo/tgbotapi/types/message/abstracts/ContentMessage$Defa
public abstract interface class dev/inmo/tgbotapi/types/message/abstracts/ForumContentMessage : dev/inmo/tgbotapi/types/message/abstracts/GroupContentMessage, dev/inmo/tgbotapi/types/message/abstracts/PossiblyTopicMessage { public abstract interface class dev/inmo/tgbotapi/types/message/abstracts/ForumContentMessage : dev/inmo/tgbotapi/types/message/abstracts/GroupContentMessage, dev/inmo/tgbotapi/types/message/abstracts/PossiblyTopicMessage {
public abstract fun getChat ()Ldev/inmo/tgbotapi/types/chat/PreviewForumChat; public abstract fun getChat ()Ldev/inmo/tgbotapi/types/chat/PreviewForumChat;
public abstract fun getThreadCreatingInfo ()Ldev/inmo/tgbotapi/types/message/ChatEvents/forum/ForumTopicCreated;
public abstract fun getThreadId-hDmiKeI ()J public abstract fun getThreadId-hDmiKeI ()J
} }
@@ -20696,6 +20707,7 @@ public final class dev/inmo/tgbotapi/types/message/abstracts/ForumContentMessage
public static fun getForwardable (Ldev/inmo/tgbotapi/types/message/abstracts/ForumContentMessage;)Z public static fun getForwardable (Ldev/inmo/tgbotapi/types/message/abstracts/ForumContentMessage;)Z
public static fun getMetaInfo-fV8YnZ8 (Ldev/inmo/tgbotapi/types/message/abstracts/ForumContentMessage;)Lkotlin/Triple; public static fun getMetaInfo-fV8YnZ8 (Ldev/inmo/tgbotapi/types/message/abstracts/ForumContentMessage;)Lkotlin/Triple;
public static fun getReplyTo (Ldev/inmo/tgbotapi/types/message/abstracts/ForumContentMessage;)Ldev/inmo/tgbotapi/types/message/abstracts/Message; public static fun getReplyTo (Ldev/inmo/tgbotapi/types/message/abstracts/ForumContentMessage;)Ldev/inmo/tgbotapi/types/message/abstracts/Message;
public static fun getThreadCreatingInfo (Ldev/inmo/tgbotapi/types/message/abstracts/ForumContentMessage;)Ldev/inmo/tgbotapi/types/message/ChatEvents/forum/ForumTopicCreated;
} }
public abstract interface class dev/inmo/tgbotapi/types/message/abstracts/FromChannelForumContentMessage : dev/inmo/tgbotapi/types/message/abstracts/ForumContentMessage, dev/inmo/tgbotapi/types/message/abstracts/FromChannelGroupContentMessage { public abstract interface class dev/inmo/tgbotapi/types/message/abstracts/FromChannelForumContentMessage : dev/inmo/tgbotapi/types/message/abstracts/ForumContentMessage, dev/inmo/tgbotapi/types/message/abstracts/FromChannelGroupContentMessage {
@@ -20708,6 +20720,7 @@ public final class dev/inmo/tgbotapi/types/message/abstracts/FromChannelForumCon
public static fun getMetaInfo-fV8YnZ8 (Ldev/inmo/tgbotapi/types/message/abstracts/FromChannelForumContentMessage;)Lkotlin/Triple; public static fun getMetaInfo-fV8YnZ8 (Ldev/inmo/tgbotapi/types/message/abstracts/FromChannelForumContentMessage;)Lkotlin/Triple;
public static fun getReplyTo (Ldev/inmo/tgbotapi/types/message/abstracts/FromChannelForumContentMessage;)Ldev/inmo/tgbotapi/types/message/abstracts/Message; public static fun getReplyTo (Ldev/inmo/tgbotapi/types/message/abstracts/FromChannelForumContentMessage;)Ldev/inmo/tgbotapi/types/message/abstracts/Message;
public static fun getSenderChat (Ldev/inmo/tgbotapi/types/message/abstracts/FromChannelForumContentMessage;)Ldev/inmo/tgbotapi/types/chat/PreviewChannelChat; public static fun getSenderChat (Ldev/inmo/tgbotapi/types/message/abstracts/FromChannelForumContentMessage;)Ldev/inmo/tgbotapi/types/chat/PreviewChannelChat;
public static fun getThreadCreatingInfo (Ldev/inmo/tgbotapi/types/message/abstracts/FromChannelForumContentMessage;)Ldev/inmo/tgbotapi/types/message/ChatEvents/forum/ForumTopicCreated;
} }
public abstract interface class dev/inmo/tgbotapi/types/message/abstracts/FromChannelGroupContentMessage : dev/inmo/tgbotapi/types/message/abstracts/GroupContentMessage, dev/inmo/tgbotapi/types/message/abstracts/SignedMessage, dev/inmo/tgbotapi/types/message/abstracts/WithSenderChatMessage { public abstract interface class dev/inmo/tgbotapi/types/message/abstracts/FromChannelGroupContentMessage : dev/inmo/tgbotapi/types/message/abstracts/GroupContentMessage, dev/inmo/tgbotapi/types/message/abstracts/SignedMessage, dev/inmo/tgbotapi/types/message/abstracts/WithSenderChatMessage {
@@ -20929,6 +20942,7 @@ public final class dev/inmo/tgbotapi/types/message/abstracts/PossiblySentViaBotC
} }
public abstract interface class dev/inmo/tgbotapi/types/message/abstracts/PossiblyTopicMessage : dev/inmo/tgbotapi/types/message/abstracts/AccessibleMessage { public abstract interface class dev/inmo/tgbotapi/types/message/abstracts/PossiblyTopicMessage : dev/inmo/tgbotapi/types/message/abstracts/AccessibleMessage {
public abstract fun getThreadCreatingInfo ()Ldev/inmo/tgbotapi/types/message/ChatEvents/forum/ForumTopicCreated;
public abstract fun getThreadId-S3HF-10 ()Ldev/inmo/tgbotapi/types/MessageThreadId; public abstract fun getThreadId-S3HF-10 ()Ldev/inmo/tgbotapi/types/MessageThreadId;
} }
@@ -27133,6 +27147,8 @@ public final class dev/inmo/tgbotapi/utils/ByteReadChannelAllocatorDeserializati
} }
public final class dev/inmo/tgbotapi/utils/DefaultKSLogKt { public final class dev/inmo/tgbotapi/utils/DefaultKSLogKt {
public static final fun SetDefaultKTgBotAPIKSLog (ZLkotlin/jvm/functions/Function1;)V
public static synthetic fun SetDefaultKTgBotAPIKSLog$default (ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)V
public static final fun getDefaultKTgBotAPIKSLog ()Ldev/inmo/kslog/common/KSLog; public static final fun getDefaultKTgBotAPIKSLog ()Ldev/inmo/kslog/common/KSLog;
public static final fun getDefaultKTgBotAPIKSLogSystemTag ()Ljava/lang/String; public static final fun getDefaultKTgBotAPIKSLogSystemTag ()Ljava/lang/String;
public static final fun setDefaultKTgBotAPIKSLog (Ldev/inmo/kslog/common/KSLog;)V public static final fun setDefaultKTgBotAPIKSLog (Ldev/inmo/kslog/common/KSLog;)V

View File

@@ -12,8 +12,8 @@ import kotlinx.serialization.json.Json
@RiskFeature @RiskFeature
fun createTelegramBotDefaultKtorCallRequestsFactories(logger: KSLog? = null) = listOf( fun createTelegramBotDefaultKtorCallRequestsFactories(logger: KSLog? = null) = listOf(
SimpleRequestCallFactory(logger),
MultipartRequestCallFactory(logger), MultipartRequestCallFactory(logger),
SimpleRequestCallFactory(logger),
DownloadFileRequestCallFactory, DownloadFileRequestCallFactory,
DownloadFileChannelRequestCallFactory DownloadFileChannelRequestCallFactory
) )

View File

@@ -9,8 +9,23 @@ import io.ktor.client.HttpClient
import io.ktor.client.request.forms.* import io.ktor.client.request.forms.*
import io.ktor.http.Headers import io.ktor.http.Headers
import io.ktor.http.HttpHeaders import io.ktor.http.HttpHeaders
import kotlinx.serialization.json.Json
class MultipartRequestCallFactory(logger: KSLog? = null) : AbstractRequestCallFactory(logger ?: DefaultKTgBotAPIKSLog) { class MultipartRequestCallFactory(logger: KSLog? = null) : AbstractRequestCallFactory(logger ?: DefaultKTgBotAPIKSLog) {
private val localSimpleRequestCallFactory = SimpleRequestCallFactory(logger)
override suspend fun <T : Any> makeCall(
client: HttpClient,
urlsKeeper: TelegramAPIUrlsKeeper,
request: Request<T>,
jsonFormatter: Json
): T? {
return when (request) {
!is MultipartRequest -> null
is MultipartRequest.Common -> localSimpleRequestCallFactory.makeCall(client, urlsKeeper, request.data, jsonFormatter)
else -> super.makeCall(client, urlsKeeper, request, jsonFormatter)
}
}
override fun <T : Any> prepareCallBody( override fun <T : Any> prepareCallBody(
client: HttpClient, client: HttpClient,
urlsKeeper: TelegramAPIUrlsKeeper, urlsKeeper: TelegramAPIUrlsKeeper,

View File

@@ -1,6 +1,8 @@
package dev.inmo.tgbotapi.requests.edit.media package dev.inmo.tgbotapi.requests.edit.media
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
import dev.inmo.tgbotapi.requests.abstracts.MultipartRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.requests.edit.abstracts.* import dev.inmo.tgbotapi.requests.edit.abstracts.*
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
@@ -27,14 +29,21 @@ data class EditChatMessageMedia(
override val businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId, override val businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
@SerialName(replyMarkupField) @SerialName(replyMarkupField)
override val replyMarkup: InlineKeyboardMarkup? = null override val replyMarkup: InlineKeyboardMarkup? = null
) : EditChatMessage<MediaContent>, EditReplyMessage, EditMediaMessage { ) : EditChatMessage<MediaContent>, EditReplyMessage, EditMediaMessage, MultipartRequest.Common<ContentMessage<MediaContent>> {
override val data: SimpleRequest<ContentMessage<MediaContent>>
init { get() = this
if (media.file is MultipartFile) { override val mediaMap: Map<String, MultipartFile> by lazy {
throw IllegalArgumentException("For editing of media messages you MUST use file id (according to documentation)") (media.file as? MultipartFile) ?.let {
} mapOf(it.fileId to it)
} ?: emptyMap()
} }
// init {
// if (media.file is MultipartFile) {
// throw IllegalArgumentException("For editing of media messages you MUST use file id (according to documentation)")
// }
// }
override fun method(): String = editMessageMediaMethod override fun method(): String = editMessageMediaMethod
override val resultDeserializer: DeserializationStrategy<ContentMessage<MediaContent>> override val resultDeserializer: DeserializationStrategy<ContentMessage<MediaContent>>
get() = MediaContentMessageResultDeserializer get() = MediaContentMessageResultDeserializer

View File

@@ -1,6 +1,8 @@
package dev.inmo.tgbotapi.types package dev.inmo.tgbotapi.types
import korlibs.time.Date import korlibs.time.Date
import korlibs.time.DateTime
import korlibs.time.Year
import kotlinx.serialization.SerialName import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
@@ -11,9 +13,12 @@ data class Birthdate(
@SerialName(monthField) @SerialName(monthField)
val month: Int, val month: Int,
@SerialName(yearField) @SerialName(yearField)
val year: Int val year: Int? = null
) { ) {
/**
* Represents this birthday as korlibs [Date]. Will use this year in case if [year] has not been retrieved
*/
val date: Date by lazy { val date: Date by lazy {
Date(year, month, day) Date(year ?: DateTime.now().year.year, month, day)
} }
} }

View File

@@ -1,7 +1,9 @@
package dev.inmo.tgbotapi.types.message.abstracts package dev.inmo.tgbotapi.types.message.abstracts
import dev.inmo.tgbotapi.requests.chat.forum.CreateForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.* import dev.inmo.tgbotapi.types.chat.*
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicCreated
import dev.inmo.tgbotapi.types.message.content.MessageContent import dev.inmo.tgbotapi.types.message.content.MessageContent
sealed interface GroupContentMessage<T : MessageContent> : PublicContentMessage<T> { sealed interface GroupContentMessage<T : MessageContent> : PublicContentMessage<T> {
@@ -15,6 +17,9 @@ sealed interface PotentiallyFromUserGroupContentMessage<T : MessageContent> : Gr
sealed interface ForumContentMessage<T : MessageContent> : GroupContentMessage<T>, PossiblyTopicMessage { sealed interface ForumContentMessage<T : MessageContent> : GroupContentMessage<T>, PossiblyTopicMessage {
override val chat: PreviewForumChat override val chat: PreviewForumChat
override val threadId: MessageThreadId override val threadId: MessageThreadId
override val threadCreatingInfo: ForumTopicCreated?
get() = (replyTo as? ChatEventMessage<*>) ?.chatEvent as? ForumTopicCreated
} }

View File

@@ -1,7 +1,10 @@
package dev.inmo.tgbotapi.types.message.abstracts package dev.inmo.tgbotapi.types.message.abstracts
import dev.inmo.tgbotapi.requests.chat.forum.CreateForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicCreated
interface PossiblyTopicMessage : AccessibleMessage { interface PossiblyTopicMessage : AccessibleMessage {
val threadId: MessageThreadId? val threadId: MessageThreadId?
val threadCreatingInfo: ForumTopicCreated?
} }

View File

@@ -2,18 +2,59 @@ package dev.inmo.tgbotapi.utils
import dev.inmo.kslog.common.KSLog import dev.inmo.kslog.common.KSLog
import dev.inmo.kslog.common.LogLevel import dev.inmo.kslog.common.LogLevel
import dev.inmo.kslog.common.MessageFilter
import dev.inmo.kslog.common.TagLogger import dev.inmo.kslog.common.TagLogger
import dev.inmo.kslog.common.filter.filtered
import kotlinx.coroutines.CancellationException
/** /**
* Default tag for [DefaultKTgBotAPIKSLog]. You may change it and tag will be changed since the near logging * Default tag for [DefaultKTgBotAPIKSLog]. You may change it and tag will be changed since the near logging
*/ */
var DefaultKTgBotAPIKSLogSystemTag: String = "KTgBot" var DefaultKTgBotAPIKSLogSystemTag: String = "KTgBot"
private inline fun CreateDefaultKSLogger(
crossinline loggerTagGetter: () -> String,
dropCancellationExceptions: Boolean = true,
noinline additionalLoggerMapper: (KSLog.() -> KSLog)? = null
): KSLog {
val filter: MessageFilter? = if (dropCancellationExceptions) {
{ ll, message, e ->
e !is CancellationException
}
} else {
null
}
return KSLog { level: LogLevel, tag: String?, message: Any, throwable: Throwable? ->
TagLogger(loggerTagGetter()).performLog(level, tag, message, throwable)
}.let {
if (filter == null) {
additionalLoggerMapper ?.invoke(it) ?: it
} else {
val base = it.filtered(filter)
additionalLoggerMapper ?.invoke(base) ?: base
}
}
}
/** /**
* Default realization of [KSLog] which will be used everywhere where there is no some custom variant of [KSLog] * Default realization of [KSLog] which will be used everywhere where there is no some custom variant of [KSLog]
* *
* By default, uses [KSLog] factory with lambda and tag [DefaultKTgBotAPIKSLogSystemTag] (which in fact falling back to * By default, uses [KSLog] factory with lambda and tag [DefaultKTgBotAPIKSLogSystemTag] (which in fact falling back to
* [KSLog.default] with `KTgBot` default tag) * [KSLog.default] with `KTgBot` default tag)
*
* @see SetDefaultKTgBotAPIKSLog
*/ */
var DefaultKTgBotAPIKSLog: KSLog = KSLog { level: LogLevel, tag: String?, message: Any, throwable: Throwable? -> var DefaultKTgBotAPIKSLog: KSLog = CreateDefaultKSLogger({ DefaultKTgBotAPIKSLogSystemTag } )
TagLogger(DefaultKTgBotAPIKSLogSystemTag).performLog(level, tag, message, throwable)
/**
* Setting [DefaultKTgBotAPIKSLog] with applying of [dropCancellationExceptions] and [additionalFilter] to it
*
* @param dropCancellationExceptions Will drap coroutines job [CancellationException]s
* @param additionalLoggerMapper Receives [KSLog] to allow you to use extensions like [filtered]. Returned
* [KSLog] will be used as the result [KSLog] in [DefaultKTgBotAPIKSLog]
*/
fun SetDefaultKTgBotAPIKSLog(
dropCancellationExceptions: Boolean = true,
additionalLoggerMapper: (KSLog.() -> KSLog)? = null
) {
DefaultKTgBotAPIKSLog = CreateDefaultKSLogger({ DefaultKTgBotAPIKSLogSystemTag }, dropCancellationExceptions, additionalLoggerMapper)
} }