1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2026-04-10 03:52:33 +00:00

add support of PollOptionAdded and PolloptionDeleted

This commit is contained in:
2026-04-08 18:10:39 +06:00
parent 277c329ab9
commit 243a3ca626
11 changed files with 2634 additions and 2334 deletions

View File

@@ -688,6 +688,10 @@ public final class dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/W
public static synthetic fun waitPaidMessagePriceChanged$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow;
public static final fun waitPinnedMessageEvents (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;)Lkotlinx/coroutines/flow/Flow;
public static synthetic fun waitPinnedMessageEvents$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow;
public static final fun waitPollOptionAddedEvents (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;)Lkotlinx/coroutines/flow/Flow;
public static synthetic fun waitPollOptionAddedEvents$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow;
public static final fun waitPollOptionDeletedEvents (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;)Lkotlinx/coroutines/flow/Flow;
public static synthetic fun waitPollOptionDeletedEvents$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow;
public static final fun waitPrivateEvents (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;)Lkotlinx/coroutines/flow/Flow;
public static synthetic fun waitPrivateEvents$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow;
public static final fun waitProximityAlertTriggeredEvents (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;)Lkotlinx/coroutines/flow/Flow;
@@ -1432,6 +1436,10 @@ public final class dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handl
public static synthetic fun onPaidMessagePriceChanged$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Lkotlinx/coroutines/Job;
public static final fun onPinnedMessage (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;)Lkotlinx/coroutines/Job;
public static synthetic fun onPinnedMessage$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Lkotlinx/coroutines/Job;
public static final fun onPollOptionAdded (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;)Lkotlinx/coroutines/Job;
public static synthetic fun onPollOptionAdded$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Lkotlinx/coroutines/Job;
public static final fun onPollOptionDeleted (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;)Lkotlinx/coroutines/Job;
public static synthetic fun onPollOptionDeleted$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Lkotlinx/coroutines/Job;
public static final fun onPrivateEvent (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;)Lkotlinx/coroutines/Job;
public static synthetic fun onPrivateEvent$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;ILjava/lang/Object;)Lkotlinx/coroutines/Job;
public static final fun onPrivateForumTopicCreated (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;)Lkotlinx/coroutines/Job;

View File

@@ -15,6 +15,8 @@ import dev.inmo.tgbotapi.types.giveaway.GiveawayCreated
import dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults
import dev.inmo.tgbotapi.types.managed_bots.ManagedBotCreated
import dev.inmo.tgbotapi.types.managed_bots.ManagedBotUpdated
import dev.inmo.tgbotapi.types.polls.PollOptionAdded
import dev.inmo.tgbotapi.types.polls.PollOptionDeleted
import dev.inmo.tgbotapi.types.message.ChatEvents.*
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicClosed
@@ -255,6 +257,16 @@ fun BehaviourContext.waitManagedBotCreatedEvents(
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEvents<ManagedBotCreated>(initRequest, errorFactory)
fun BehaviourContext.waitPollOptionAddedEvents(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEvents<PollOptionAdded>(initRequest, errorFactory)
fun BehaviourContext.waitPollOptionDeletedEvents(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEvents<PollOptionDeleted>(initRequest, errorFactory)
fun BehaviourContext.waitManagedBotUpdatedEvents(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }

View File

@@ -20,6 +20,8 @@ import dev.inmo.tgbotapi.types.giveaway.GiveawayCreated
import dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults
import dev.inmo.tgbotapi.types.managed_bots.ManagedBotCreated
import dev.inmo.tgbotapi.types.managed_bots.ManagedBotUpdated
import dev.inmo.tgbotapi.types.polls.PollOptionAdded
import dev.inmo.tgbotapi.types.polls.PollOptionDeleted
import dev.inmo.tgbotapi.types.message.ChannelEventMessage
import dev.inmo.tgbotapi.types.message.ChatEvents.*
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
@@ -1077,6 +1079,48 @@ fun <BC : BehaviourContext> BC.onManagedBotCreated(
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatEventMessage<ManagedBotCreated>>
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, additionalSubcontextInitialAction, scenarioReceiver)
/**
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
* to combinate several filters
* @param [markerFactory] **Pass null to handle requests fully parallel**. Will be used to identify different "stream".
* [scenarioReceiver] will be called synchronously in one "stream". Output of [markerFactory] will be used as a key for
* "stream"
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
* data
*/
fun <BC : BehaviourContext> BC.onPollOptionAdded(
initialFilter: SimpleFilter<ChatEventMessage<PollOptionAdded>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatEventMessage<PollOptionAdded>, Update>? = MessageFilterByChat,
markerFactory: MarkerFactory<in ChatEventMessage<PollOptionAdded>, Any>? = ByChatMessageMarkerFactory,
additionalSubcontextInitialAction: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, Update, ChatEventMessage<PollOptionAdded>>? = null,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatEventMessage<PollOptionAdded>>
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, additionalSubcontextInitialAction, scenarioReceiver)
/**
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
* to combinate several filters
* @param [markerFactory] **Pass null to handle requests fully parallel**. Will be used to identify different "stream".
* [scenarioReceiver] will be called synchronously in one "stream". Output of [markerFactory] will be used as a key for
* "stream"
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
* data
*/
fun <BC : BehaviourContext> BC.onPollOptionDeleted(
initialFilter: SimpleFilter<ChatEventMessage<PollOptionDeleted>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatEventMessage<PollOptionDeleted>, Update>? = MessageFilterByChat,
markerFactory: MarkerFactory<in ChatEventMessage<PollOptionDeleted>, Any>? = ByChatMessageMarkerFactory,
additionalSubcontextInitialAction: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, Update, ChatEventMessage<PollOptionDeleted>>? = null,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatEventMessage<PollOptionDeleted>>
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, additionalSubcontextInitialAction, scenarioReceiver)
/**
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call

View File

@@ -10899,7 +10899,10 @@ public final class dev/inmo/tgbotapi/types/CommonKt {
public static final field openingHoursField Ljava/lang/String;
public static final field openingMinuteField Ljava/lang/String;
public static final field optionIdsField Ljava/lang/String;
public static final field optionPersistentIdField Ljava/lang/String;
public static final field optionPersistentIdsField Ljava/lang/String;
public static final field optionTextEntitiesField Ljava/lang/String;
public static final field optionTextField Ljava/lang/String;
public static final field optionsField Ljava/lang/String;
public static final field orderInfoField Ljava/lang/String;
public static final field originField Ljava/lang/String;
@@ -10936,6 +10939,7 @@ public final class dev/inmo/tgbotapi/types/CommonKt {
public static final field pngStickerField Ljava/lang/String;
public static final field pointField Ljava/lang/String;
public static final field pollIdField Ljava/lang/String;
public static final field pollMessageField Ljava/lang/String;
public static final field positionField Ljava/lang/String;
public static final field postCodeField Ljava/lang/String;
public static final field postToChatPageField Ljava/lang/String;
@@ -31998,6 +32002,62 @@ public final class dev/inmo/tgbotapi/types/polls/PollOption$Simple$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}
public final class dev/inmo/tgbotapi/types/polls/PollOptionAdded : dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/CommonEvent {
public static final field Companion Ldev/inmo/tgbotapi/types/polls/PollOptionAdded$Companion;
public synthetic fun <init> (Ldev/inmo/tgbotapi/types/message/abstracts/Message;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Ldev/inmo/tgbotapi/types/message/abstracts/Message;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Ldev/inmo/tgbotapi/types/message/abstracts/Message;
public final fun component2--sSIB8c ()Ljava/lang/String;
public final fun component3 ()Ljava/lang/String;
public final fun component4 ()Ljava/util/List;
public final fun copy-W9ZM0iI (Ldev/inmo/tgbotapi/types/message/abstracts/Message;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;)Ldev/inmo/tgbotapi/types/polls/PollOptionAdded;
public static synthetic fun copy-W9ZM0iI$default (Ldev/inmo/tgbotapi/types/polls/PollOptionAdded;Ldev/inmo/tgbotapi/types/message/abstracts/Message;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/polls/PollOptionAdded;
public fun equals (Ljava/lang/Object;)Z
public final fun getOptionPersistentId--sSIB8c ()Ljava/lang/String;
public final fun getOptionText ()Ljava/lang/String;
public final fun getOptionTextSources ()Ljava/util/List;
public final fun getPollMessage ()Ldev/inmo/tgbotapi/types/message/abstracts/Message;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}
public final class dev/inmo/tgbotapi/types/polls/PollOptionAdded$Companion : kotlinx/serialization/KSerializer {
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/inmo/tgbotapi/types/polls/PollOptionAdded;
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/inmo/tgbotapi/types/polls/PollOptionAdded;)V
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}
public final class dev/inmo/tgbotapi/types/polls/PollOptionDeleted : dev/inmo/tgbotapi/types/message/ChatEvents/abstracts/CommonEvent {
public static final field Companion Ldev/inmo/tgbotapi/types/polls/PollOptionDeleted$Companion;
public synthetic fun <init> (Ldev/inmo/tgbotapi/types/message/abstracts/Message;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Ldev/inmo/tgbotapi/types/message/abstracts/Message;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Ldev/inmo/tgbotapi/types/message/abstracts/Message;
public final fun component2--sSIB8c ()Ljava/lang/String;
public final fun component3 ()Ljava/lang/String;
public final fun component4 ()Ljava/util/List;
public final fun copy-W9ZM0iI (Ldev/inmo/tgbotapi/types/message/abstracts/Message;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;)Ldev/inmo/tgbotapi/types/polls/PollOptionDeleted;
public static synthetic fun copy-W9ZM0iI$default (Ldev/inmo/tgbotapi/types/polls/PollOptionDeleted;Ldev/inmo/tgbotapi/types/message/abstracts/Message;Ljava/lang/String;Ljava/lang/String;Ljava/util/List;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/polls/PollOptionDeleted;
public fun equals (Ljava/lang/Object;)Z
public final fun getOptionPersistentId--sSIB8c ()Ljava/lang/String;
public final fun getOptionText ()Ljava/lang/String;
public final fun getOptionTextSources ()Ljava/util/List;
public final fun getPollMessage ()Ldev/inmo/tgbotapi/types/message/abstracts/Message;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}
public final class dev/inmo/tgbotapi/types/polls/PollOptionDeleted$Companion : kotlinx/serialization/KSerializer {
public fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/inmo/tgbotapi/types/polls/PollOptionDeleted;
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
public fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
public fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/inmo/tgbotapi/types/polls/PollOptionDeleted;)V
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}
public final class dev/inmo/tgbotapi/types/polls/PollOptionPersistentId {
public static final field Companion Ldev/inmo/tgbotapi/types/polls/PollOptionPersistentId$Companion;
public static final synthetic fun box-impl (Ljava/lang/String;)Ldev/inmo/tgbotapi/types/polls/PollOptionPersistentId;

View File

@@ -323,6 +323,10 @@ const val activeUsernamesField = "active_usernames"
const val customTitleField = "custom_title"
const val optionIdsField = "option_ids"
const val optionPersistentIdsField = "option_persistent_ids"
const val optionPersistentIdField = "option_persistent_id"
const val optionTextField = "option_text"
const val optionTextEntitiesField = "option_text_entities"
const val pollMessageField = "poll_message"
const val parentChatField = "parent_chat"
const val voterChatField = "voter_chat"
const val ipAddressField = "ip_address"

View File

@@ -20,6 +20,8 @@ import dev.inmo.tgbotapi.types.message.content.GiveawayContent
import dev.inmo.tgbotapi.types.location.Location
import dev.inmo.tgbotapi.types.managed_bots.ManagedBotCreated
import dev.inmo.tgbotapi.types.managed_bots.ManagedBotUpdated
import dev.inmo.tgbotapi.types.polls.PollOptionAdded
import dev.inmo.tgbotapi.types.polls.PollOptionDeleted
import dev.inmo.tgbotapi.types.message.ChatEvents.*
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicClosed
@@ -207,7 +209,9 @@ internal data class RawMessage(
private val gift_upgrade_sent: GiftSentOrReceivedEvent.RegularGift? = null,
private val chat_owner_left: ChatOwnerLeft? = null,
private val chat_owner_changed: ChatOwnerChanged? = null,
private val managed_bot_created: ManagedBotCreated? = null
private val managed_bot_created: ManagedBotCreated? = null,
private val poll_option_added: PollOptionAdded? = null,
private val poll_option_deleted: PollOptionDeleted? = null,
) {
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
private val checkedFrom = from ?.takeIf { !it.isFakeTelegramUser() }
@@ -347,6 +351,8 @@ internal data class RawMessage(
suggested_post_paid != null -> suggested_post_paid
suggested_post_refunded != null -> suggested_post_refunded
managed_bot_created != null -> managed_bot_created
poll_option_added != null -> poll_option_added
poll_option_deleted != null -> poll_option_deleted
else -> null
}
}

View File

@@ -60,7 +60,7 @@ sealed interface PollOption : TextedInput {
@Serializable(PollOption.LatelyAdded.Companion::class)
sealed interface LatelyAdded : PollOption {
val additionDate: TelegramDate?
val additionDate: TelegramDate
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
@Serializable(PollOption.LatelyAdded.Companion::class)
@@ -77,7 +77,7 @@ sealed interface PollOption : TextedInput {
val addedByUser: User,
@Serializable(TelegramDateSerializer::class)
@SerialName(additionDateField)
override val additionDate: TelegramDate? = null
override val additionDate: TelegramDate
) : LatelyAdded {
override fun asInput(): InputPollOption = InputPollOption(text, null, textSources)
}
@@ -97,7 +97,7 @@ sealed interface PollOption : TextedInput {
val addedByChat: Chat,
@Serializable(TelegramDateSerializer::class)
@SerialName(additionDateField)
override val additionDate: TelegramDate? = null
override val additionDate: TelegramDate
) : LatelyAdded {
override fun asInput(): InputPollOption = InputPollOption(text, null, textSources)
}
@@ -110,13 +110,21 @@ sealed interface PollOption : TextedInput {
val surrogate = PollOptionSurrogate.serializer().deserialize(decoder)
val textSources = surrogate.textEntities.asTextSources(surrogate.text)
return when {
surrogate.addedByUser != null -> AddedByUser(
surrogate.id, surrogate.text, textSources, surrogate.votes,
surrogate.addedByUser, surrogate.additionDate
surrogate.addedByUser != null && surrogate.additionDate != null -> AddedByUser(
id = surrogate.id,
text = surrogate.text,
textSources = textSources,
votes = surrogate.votes,
addedByUser = surrogate.addedByUser,
additionDate = surrogate.additionDate
)
surrogate.addedByChat != null -> AddedByChat(
surrogate.id, surrogate.text, textSources, surrogate.votes,
surrogate.addedByChat, surrogate.additionDate
surrogate.addedByChat != null && surrogate.additionDate != null -> AddedByChat(
id = surrogate.id,
text = surrogate.text,
textSources = textSources,
votes = surrogate.votes,
addedByChat = surrogate.addedByChat,
additionDate = surrogate.additionDate
)
else -> error("LatelyAdded poll option must have either added_by_user or added_by_chat")
}
@@ -177,7 +185,7 @@ sealed interface PollOption : TextedInput {
val surrogate = PollOptionSurrogate.serializer().deserialize(decoder)
val textSources = surrogate.textEntities.asTextSources(surrogate.text)
return when {
surrogate.addedByUser != null -> LatelyAdded.AddedByUser(
surrogate.addedByUser != null && surrogate.additionDate != null -> LatelyAdded.AddedByUser(
id = surrogate.id,
text = surrogate.text,
textSources = textSources,
@@ -185,7 +193,7 @@ sealed interface PollOption : TextedInput {
addedByUser = surrogate.addedByUser,
additionDate = surrogate.additionDate
)
surrogate.addedByChat != null -> LatelyAdded.AddedByChat(
surrogate.addedByChat != null && surrogate.additionDate != null -> LatelyAdded.AddedByChat(
id = surrogate.id,
text = surrogate.text,
textSources = textSources,

View File

@@ -0,0 +1,69 @@
package dev.inmo.tgbotapi.types.polls
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonEvent
import dev.inmo.tgbotapi.types.message.RawMessageEntity
import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializerClass
import dev.inmo.tgbotapi.types.message.asTextSources
import dev.inmo.tgbotapi.types.message.textsources.TextSource
import dev.inmo.tgbotapi.types.message.toRawMessageEntities
import kotlinx.serialization.KSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
@Serializable(PollOptionAdded.Companion::class)
data class PollOptionAdded(
@SerialName(pollMessageField)
val pollMessage: Message? = null,
@SerialName(optionPersistentIdField)
val optionPersistentId: PollOptionPersistentId,
@SerialName(optionTextField)
val optionText: String,
@SerialName(optionTextEntitiesField)
val optionTextSources: List<TextSource> = emptyList(),
) : CommonEvent {
companion object : KSerializer<PollOptionAdded> {
@Serializable
private data class Surrogate(
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
@SerialName(pollMessageField)
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializerClass::class)
val pollMessage: Message? = null,
@SerialName(optionPersistentIdField)
val optionPersistentId: PollOptionPersistentId,
@SerialName(optionTextField)
val optionText: String,
@SerialName(optionTextEntitiesField)
val optionTextEntities: List<RawMessageEntity> = emptyList(),
)
override val descriptor: SerialDescriptor
get() = Surrogate.serializer().descriptor
override fun deserialize(decoder: Decoder): PollOptionAdded {
val surrogate = Surrogate.serializer().deserialize(decoder)
return PollOptionAdded(
pollMessage = surrogate.pollMessage,
optionPersistentId = surrogate.optionPersistentId,
optionText = surrogate.optionText,
optionTextSources = surrogate.optionTextEntities.asTextSources(surrogate.optionText),
)
}
override fun serialize(encoder: Encoder, value: PollOptionAdded) {
Surrogate.serializer().serialize(
encoder,
Surrogate(
pollMessage = value.pollMessage,
optionPersistentId = value.optionPersistentId,
optionText = value.optionText,
optionTextEntities = value.optionTextSources.toRawMessageEntities(),
)
)
}
}
}

View File

@@ -0,0 +1,69 @@
package dev.inmo.tgbotapi.types.polls
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonEvent
import dev.inmo.tgbotapi.types.message.RawMessageEntity
import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializerClass
import dev.inmo.tgbotapi.types.message.asTextSources
import dev.inmo.tgbotapi.types.message.textsources.TextSource
import dev.inmo.tgbotapi.types.message.toRawMessageEntities
import kotlinx.serialization.KSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
@Serializable(PollOptionDeleted.Companion::class)
data class PollOptionDeleted(
@SerialName(pollMessageField)
val pollMessage: Message? = null,
@SerialName(optionPersistentIdField)
val optionPersistentId: PollOptionPersistentId,
@SerialName(optionTextField)
val optionText: String,
@SerialName(optionTextEntitiesField)
val optionTextSources: List<TextSource> = emptyList(),
) : CommonEvent {
companion object : KSerializer<PollOptionDeleted> {
@Serializable
private data class Surrogate(
@Suppress("SERIALIZER_TYPE_INCOMPATIBLE")
@SerialName(pollMessageField)
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializerClass::class)
val pollMessage: Message? = null,
@SerialName(optionPersistentIdField)
val optionPersistentId: PollOptionPersistentId,
@SerialName(optionTextField)
val optionText: String,
@SerialName(optionTextEntitiesField)
val optionTextEntities: List<RawMessageEntity> = emptyList(),
)
override val descriptor: SerialDescriptor
get() = Surrogate.serializer().descriptor
override fun deserialize(decoder: Decoder): PollOptionDeleted {
val surrogate = Surrogate.serializer().deserialize(decoder)
return PollOptionDeleted(
pollMessage = surrogate.pollMessage,
optionPersistentId = surrogate.optionPersistentId,
optionText = surrogate.optionText,
optionTextSources = surrogate.optionTextEntities.asTextSources(surrogate.optionText),
)
}
override fun serialize(encoder: Encoder, value: PollOptionDeleted) {
Surrogate.serializer().serialize(
encoder,
Surrogate(
pollMessage = value.pollMessage,
optionPersistentId = value.optionPersistentId,
optionText = value.optionText,
optionTextEntities = value.optionTextSources.toRawMessageEntities(),
)
)
}
}
}

View File

@@ -1978,6 +1978,8 @@ public final class dev/inmo/tgbotapi/extensions/utils/ClassCastsNewKt {
public static final fun ifPollAnswerPublic (Ldev/inmo/tgbotapi/abstracts/OptionallyWithUser;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun ifPollAnswerUpdate (Ldev/inmo/tgbotapi/types/update/abstracts/Update;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun ifPollContent (Ldev/inmo/tgbotapi/types/message/content/ResendableContent;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun ifPollOptionAdded (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun ifPollOptionDeleted (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun ifPollUpdate (Ldev/inmo/tgbotapi/types/update/abstracts/Update;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun ifPossiblyEditedMessage (Ldev/inmo/tgbotapi/types/message/abstracts/Message;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun ifPossiblyForwardedMessage (Ldev/inmo/tgbotapi/types/message/abstracts/Message;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
@@ -2474,6 +2476,10 @@ public final class dev/inmo/tgbotapi/extensions/utils/ClassCastsNewKt {
public static final fun pollAnswerUpdateOrThrow (Ldev/inmo/tgbotapi/types/update/abstracts/Update;)Ldev/inmo/tgbotapi/types/update/PollAnswerUpdate;
public static final fun pollContentOrNull (Ldev/inmo/tgbotapi/types/message/content/ResendableContent;)Ldev/inmo/tgbotapi/types/message/content/PollContent;
public static final fun pollContentOrThrow (Ldev/inmo/tgbotapi/types/message/content/ResendableContent;)Ldev/inmo/tgbotapi/types/message/content/PollContent;
public static final fun pollOptionAddedOrNull (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;)Ldev/inmo/tgbotapi/types/polls/PollOptionAdded;
public static final fun pollOptionAddedOrThrow (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;)Ldev/inmo/tgbotapi/types/polls/PollOptionAdded;
public static final fun pollOptionDeletedOrNull (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;)Ldev/inmo/tgbotapi/types/polls/PollOptionDeleted;
public static final fun pollOptionDeletedOrThrow (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;)Ldev/inmo/tgbotapi/types/polls/PollOptionDeleted;
public static final fun pollUpdateOrNull (Ldev/inmo/tgbotapi/types/update/abstracts/Update;)Ldev/inmo/tgbotapi/types/update/PollUpdate;
public static final fun pollUpdateOrThrow (Ldev/inmo/tgbotapi/types/update/abstracts/Update;)Ldev/inmo/tgbotapi/types/update/PollUpdate;
public static final fun possiblyEditedMessageOrNull (Ldev/inmo/tgbotapi/types/message/abstracts/Message;)Ldev/inmo/tgbotapi/types/message/abstracts/PossiblyEditedMessage;