mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-16 12:00:18 +00:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 51927974f5 | |||
| 9350f87e19 | |||
| 6cb9950b36 | |||
| 974c2e883f | |||
| af6f98fd56 | |||
| 75a2b2c282 | |||
| d66d4b4209 | |||
| 9d54820fd7 | |||
| 1876df2c2d | |||
| d818592cd3 | |||
| c29737b6b3 | |||
| 46243a21eb |
2
.github/FUNDING.yml
vendored
2
.github/FUNDING.yml
vendored
@@ -1,3 +1,3 @@
|
||||
# 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']
|
||||
|
||||
18
CHANGELOG.md
18
CHANGELOG.md
@@ -1,7 +1,25 @@
|
||||
# TelegramBotAPI changelog
|
||||
|
||||
## 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
|
||||
|
||||
**THIS UPDATE CONTAINS ADDING SUPPORT OF [Telegram Bots API 8.3](https://core.telegram.org/bots/api-changelog#february-12-2025)**
|
||||
|
||||
* `Version`:
|
||||
* `MicroUtils`: `0.24.5` -> `0.24.6`
|
||||
* `Ktor`: `3.0.3` -> `3.1.0`
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# TelegramBotAPI [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#january-1-2025)
|
||||
# TelegramBotAPI [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#february-12-2025)
|
||||
|
||||
| Docs | [](https://tgbotapi.inmo.dev/index.html) [](https://docs.inmo.dev/tgbotapi/index.html) |
|
||||
|:----------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
||||
|
||||
@@ -6,4 +6,4 @@ kotlin.incremental=true
|
||||
kotlin.incremental.js=true
|
||||
|
||||
library_group=dev.inmo
|
||||
library_version=23.2.0
|
||||
library_version=24.0.0
|
||||
|
||||
@@ -10,10 +10,10 @@ korlibs = "5.4.0"
|
||||
uuid = "0.8.4"
|
||||
ktor = "3.1.0"
|
||||
|
||||
ksp = "2.1.10-1.0.29"
|
||||
ksp = "2.1.10-1.0.30"
|
||||
kotlin-poet = "1.18.1"
|
||||
|
||||
microutils = "0.24.6"
|
||||
microutils = "0.24.7"
|
||||
kslog = "1.4.1"
|
||||
|
||||
versions = "0.51.0"
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
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.subscribeLoggingDropExceptions
|
||||
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
|
||||
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptionsAsync
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||
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.marker_factories.MarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.utils.flatMap
|
||||
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(
|
||||
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 {
|
||||
{ (update, triggerData) ->
|
||||
createSubContextAndDoSynchronouslyWithUpdatesFilter {
|
||||
if (subcontextUpdatesFilter(this, triggerData, update)) {
|
||||
localSubcontextInitialAction(update, triggerData)
|
||||
scenarioReceiver(triggerData)
|
||||
val contextStateFlow = SpecialMutableStateFlow<BC?>(null)
|
||||
createSubContextAndDoSynchronouslyWithUpdatesFilter(
|
||||
updatesUpstreamFlow = contextStateFlow.flatMapLatest { context ->
|
||||
if (context == null) {
|
||||
emptyFlow()
|
||||
} else {
|
||||
allUpdatesFlow.filter {
|
||||
context.subcontextUpdatesFilter(triggerData, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
) {
|
||||
contextStateFlow.value = this
|
||||
localSubcontextInitialAction(update, triggerData)
|
||||
scenarioReceiver(triggerData)
|
||||
}
|
||||
}
|
||||
} ?: { (update, triggerData) ->
|
||||
@@ -57,8 +74,8 @@ internal suspend fun <BC : BehaviourContext, T> BC.on(
|
||||
{ markerFactory(it.second) },
|
||||
block = handler
|
||||
)
|
||||
} ?: subscribeSafelyWithoutExceptions(scope) {
|
||||
scope.launchSafelyWithoutExceptions {
|
||||
} ?: subscribeLoggingDropExceptions(scope) {
|
||||
scope.launchLoggingDropExceptions {
|
||||
handler(it)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8307,17 +8307,18 @@ public abstract interface class dev/inmo/tgbotapi/types/BackgroundType$WithDocum
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/Birthdate {
|
||||
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 component2 ()I
|
||||
public final fun component3 ()I
|
||||
public final fun copy (III)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 final fun component3 ()Ljava/lang/Integer;
|
||||
public final fun copy (IILjava/lang/Integer;)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 final fun getDate-1iQqF6g ()I
|
||||
public final fun getDay ()I
|
||||
public final fun getMonth ()I
|
||||
public final fun getYear ()I
|
||||
public final fun getYear ()Ljava/lang/Integer;
|
||||
public fun hashCode ()I
|
||||
public fun toString ()Ljava/lang/String;
|
||||
}
|
||||
@@ -19164,6 +19165,7 @@ public final class dev/inmo/tgbotapi/types/message/AnonymousForumContentMessageI
|
||||
public fun getSenderBot ()Ldev/inmo/tgbotapi/types/chat/CommonBot;
|
||||
public synthetic fun getSenderChat ()Ldev/inmo/tgbotapi/types/chat/PreviewChat;
|
||||
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 fun getThreadId-hDmiKeI ()J
|
||||
public fun hashCode ()I
|
||||
@@ -19852,6 +19854,7 @@ public final class dev/inmo/tgbotapi/types/message/CommonForumContentMessageImpl
|
||||
public fun getReplyTo ()Ldev/inmo/tgbotapi/types/message/abstracts/Message;
|
||||
public fun getSenderBoostsCount ()Ljava/lang/Integer;
|
||||
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 fun getThreadId-hDmiKeI ()J
|
||||
public fun getUser ()Ldev/inmo/tgbotapi/types/chat/User;
|
||||
@@ -20136,6 +20139,7 @@ public final class dev/inmo/tgbotapi/types/message/FromChannelForumContentMessag
|
||||
public fun getSenderBot ()Ldev/inmo/tgbotapi/types/chat/CommonBot;
|
||||
public fun getSenderChat ()Ldev/inmo/tgbotapi/types/chat/PreviewChannelChat;
|
||||
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 fun getThreadId-hDmiKeI ()J
|
||||
public fun hashCode ()I
|
||||
@@ -20571,6 +20575,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 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 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 {
|
||||
@@ -20635,6 +20640,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 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 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;
|
||||
}
|
||||
|
||||
@@ -20687,6 +20693,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 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
|
||||
}
|
||||
|
||||
@@ -20696,6 +20703,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 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 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 {
|
||||
@@ -20708,6 +20716,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 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 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 {
|
||||
@@ -20929,6 +20938,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 fun getThreadCreatingInfo ()Ldev/inmo/tgbotapi/types/message/ChatEvents/forum/ForumTopicCreated;
|
||||
public abstract fun getThreadId-S3HF-10 ()Ldev/inmo/tgbotapi/types/MessageThreadId;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package dev.inmo.tgbotapi.types
|
||||
|
||||
import korlibs.time.Date
|
||||
import korlibs.time.DateTime
|
||||
import korlibs.time.Year
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@@ -11,9 +13,12 @@ data class Birthdate(
|
||||
@SerialName(monthField)
|
||||
val month: Int,
|
||||
@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 {
|
||||
Date(year, month, day)
|
||||
Date(year ?: DateTime.now().year.year, month, day)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
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.chat.*
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicCreated
|
||||
import dev.inmo.tgbotapi.types.message.content.MessageContent
|
||||
|
||||
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 {
|
||||
override val chat: PreviewForumChat
|
||||
override val threadId: MessageThreadId
|
||||
|
||||
override val threadCreatingInfo: ForumTopicCreated?
|
||||
get() = (replyTo as? ChatEventMessage<*>) ?.chatEvent as? ForumTopicCreated
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
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.message.ChatEvents.forum.ForumTopicCreated
|
||||
|
||||
interface PossiblyTopicMessage : AccessibleMessage {
|
||||
val threadId: MessageThreadId?
|
||||
val threadCreatingInfo: ForumTopicCreated?
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user