mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 08:13:47 +00:00
add support of ChatBoostAdded
This commit is contained in:
parent
9177e01910
commit
468c54a30f
@ -214,3 +214,8 @@ suspend fun BehaviourContext.waitChatShared(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<ChatShared>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitChatBoostAdded(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<ChatBoostAdded>(initRequest, errorFactory)
|
||||
|
@ -208,3 +208,8 @@ suspend fun BehaviourContext.waitChatSharedEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<ChatShared>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitChatBoostAddedEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<ChatBoostAdded>(initRequest, errorFactory)
|
||||
|
@ -823,3 +823,24 @@ suspend fun <BC : BehaviourContext> BC.onChatShared(
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<ChatShared>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PrivateEventMessage<ChatShared>>
|
||||
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, 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 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
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onChatBoostAdded(
|
||||
initialFilter: SimpleFilter<ChatEventMessage<ChatBoostAdded>>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatEventMessage<ChatBoostAdded>, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<ChatBoostAdded>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatEventMessage<ChatBoostAdded>>
|
||||
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
|
@ -656,6 +656,7 @@ const val menuButtonField = "menu_button"
|
||||
|
||||
const val boostIdField = "boost_id"
|
||||
const val boostField = "boost"
|
||||
const val boostCountField = "boost_count"
|
||||
const val addDateField = "add_date"
|
||||
const val expirationDateField = "expiration_date"
|
||||
const val removeDateField = "remove_date"
|
||||
|
@ -0,0 +1,12 @@
|
||||
package dev.inmo.tgbotapi.types.message.ChatEvents
|
||||
|
||||
import dev.inmo.tgbotapi.types.boostCountField
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class ChatBoostAdded(
|
||||
@SerialName(boostCountField)
|
||||
val count: Int
|
||||
) : PublicChatEvent
|
@ -117,6 +117,9 @@ internal data class RawMessage(
|
||||
private val general_forum_topic_unhidden: GeneralForumTopicUnhidden? = null,
|
||||
private val write_access_allowed: WriteAccessAllowed? = null,
|
||||
|
||||
// Boost added to groups
|
||||
private val boost_added: ChatBoostAdded? = null,
|
||||
|
||||
// AutoDelete Message time changed
|
||||
private val message_auto_delete_timer_changed: MessageAutoDeleteTimerChanged? = null,
|
||||
|
||||
@ -247,6 +250,7 @@ internal data class RawMessage(
|
||||
giveaway_created != null -> giveaway_created
|
||||
giveaway_winners is GiveawayPrivateResults -> giveaway_winners
|
||||
giveaway_completed != null -> giveaway_completed
|
||||
boost_added != null -> boost_added
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
@ -222,6 +222,7 @@ import dev.inmo.tgbotapi.types.media.TitledTelegramMedia
|
||||
import dev.inmo.tgbotapi.types.media.VisualMediaGroupMemberTelegramMedia
|
||||
import dev.inmo.tgbotapi.types.message.ChannelEventMessage
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.ChannelChatCreated
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.ChatBoostAdded
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.DeleteChatPhoto
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.GroupChatCreated
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.LeftChatMemberEvent
|
||||
@ -2882,6 +2883,15 @@ public inline fun ChatEvent.channelChatCreatedOrThrow(): ChannelChatCreated = th
|
||||
public inline fun <T> ChatEvent.ifChannelChatCreated(block: (ChannelChatCreated) -> T): T? =
|
||||
channelChatCreatedOrNull() ?.let(block)
|
||||
|
||||
public inline fun ChatEvent.chatBoostAddedOrNull(): ChatBoostAdded? = this as?
|
||||
dev.inmo.tgbotapi.types.message.ChatEvents.ChatBoostAdded
|
||||
|
||||
public inline fun ChatEvent.chatBoostAddedOrThrow(): ChatBoostAdded = this as
|
||||
dev.inmo.tgbotapi.types.message.ChatEvents.ChatBoostAdded
|
||||
|
||||
public inline fun <T> ChatEvent.ifChatBoostAdded(block: (ChatBoostAdded) -> T): T? =
|
||||
chatBoostAddedOrNull() ?.let(block)
|
||||
|
||||
public inline fun ChatEvent.deleteChatPhotoOrNull(): DeleteChatPhoto? = this as?
|
||||
dev.inmo.tgbotapi.types.message.ChatEvents.DeleteChatPhoto
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user