1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-12-23 00:57:13 +00:00

CommonGroupEvent -> PublicChatEvent

This commit is contained in:
InsanusMokrassar 2021-10-03 18:44:29 +06:00
parent e51a4b7702
commit 3919359f79
13 changed files with 36 additions and 27 deletions

View File

@ -14,7 +14,7 @@
* `RowBuilder` and `MatrixBuilder` now are open and available for extending
* `MatrixBuilder#matrix` will return read-only new list instead of original internal `mutMatrix`
* Introduced new type of events `SuccessfulPaymentEvent` instead of putting of payment inside of message
* New type of events union: `CommonGroupEvent`
* New type of events union: `PublicChatEvent`
* `Utils`:
* Two new dsl:
* `inlineKeyboard` for creating `InlineKeyboardMarkup`

View File

@ -1,5 +1,5 @@
package dev.inmo.tgbotapi.types.message.ChatEvents
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonGroupEvent
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent
class DeleteChatPhoto: CommonGroupEvent
class DeleteChatPhoto: PublicChatEvent

View File

@ -1,8 +1,8 @@
package dev.inmo.tgbotapi.types.message.ChatEvents
import dev.inmo.tgbotapi.types.User
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonGroupEvent
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent
data class LeftChatMember(
val user: User
) : CommonGroupEvent
) : PublicChatEvent

View File

@ -1,8 +1,8 @@
package dev.inmo.tgbotapi.types.message.ChatEvents
import dev.inmo.tgbotapi.types.files.Photo
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonGroupEvent
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent
data class NewChatPhoto(
val photo: Photo
): CommonGroupEvent
): PublicChatEvent

View File

@ -1,7 +1,7 @@
package dev.inmo.tgbotapi.types.message.ChatEvents
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonGroupEvent
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent
data class NewChatTitle(
val title: String
): CommonGroupEvent
): PublicChatEvent

View File

@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.types.message.ChatEvents
import dev.inmo.tgbotapi.types.Meters
import dev.inmo.tgbotapi.types.User
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonGroupEvent
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent
import kotlinx.serialization.Serializable
/**
@ -14,4 +14,4 @@ data class ProximityAlertTriggered(
val traveler: User,
val watcher: User,
val distance: Meters
) : CommonGroupEvent
) : PublicChatEvent

View File

@ -1,3 +1,3 @@
package dev.inmo.tgbotapi.types.message.ChatEvents.abstracts
interface CommonEvent : CommonGroupEvent, PrivateEvent
interface CommonEvent : PublicChatEvent, PrivateEvent

View File

@ -1,3 +0,0 @@
package dev.inmo.tgbotapi.types.message.ChatEvents.abstracts
interface CommonGroupEvent : ChannelEvent, GroupEvent, SupergroupEvent

View File

@ -0,0 +1,3 @@
package dev.inmo.tgbotapi.types.message.ChatEvents.abstracts
interface PublicChatEvent : ChannelEvent, GroupEvent, SupergroupEvent

View File

@ -1,3 +1,3 @@
package dev.inmo.tgbotapi.types.message.ChatEvents.abstracts
interface VoiceChatEvent : CommonGroupEvent
interface VoiceChatEvent : PublicChatEvent

View File

@ -127,12 +127,12 @@ suspend fun BehaviourContext.waitMessageAutoDeleteTimerChangedEvents(
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
suspend fun BehaviourContext.waitCommonGroupEvents(
suspend fun BehaviourContext.waitPublicChatEvents(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },
count: Int = 1,
filter: SimpleFilter<ChatEventMessage<CommonGroupEvent>>? = null,
mapper: EventMessageToEventMapper<CommonGroupEvent>? = null
filter: SimpleFilter<ChatEventMessage<PublicChatEvent>>? = null,
mapper: EventMessageToEventMapper<PublicChatEvent>? = null
) = waitEvents(count, initRequest, errorFactory, filter, mapper)
suspend fun BehaviourContext.waitCommonEvents(
initRequest: Request<*>? = null,

View File

@ -189,11 +189,11 @@ suspend fun BehaviourContext.onMessageAutoDeleteTimerChangedEvent(
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
* data
*/
suspend fun BehaviourContext.onCommonGroupEvent(
initialFilter: SimpleFilter<ChatEventMessage<CommonGroupEvent>>? = null,
subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver<Boolean, ChatEventMessage<CommonGroupEvent>, Update>? = MessageFilterByChat,
markerFactory: MarkerFactory<in ChatEventMessage<CommonGroupEvent>, Any> = ByChatMessageMarkerFactory,
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatEventMessage<CommonGroupEvent>>
suspend fun BehaviourContext.onPublicChatEvent(
initialFilter: SimpleFilter<ChatEventMessage<PublicChatEvent>>? = null,
subcontextUpdatesFilter: BehaviourContextAndTwoTypesReceiver<Boolean, ChatEventMessage<PublicChatEvent>, Update>? = MessageFilterByChat,
markerFactory: MarkerFactory<in ChatEventMessage<PublicChatEvent>, Any> = ByChatMessageMarkerFactory,
scenarioReceiver: BehaviourContextAndTypeReceiver<Unit, ChatEventMessage<PublicChatEvent>>
) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
/**

View File

@ -3043,13 +3043,22 @@ inline fun ChatEvent.asChannelEvent(): ChannelEvent? = this as? ChannelEvent
inline fun ChatEvent.requireChannelEvent(): ChannelEvent = this as ChannelEvent
@PreviewFeature
inline fun <T> ChatEvent.whenCommonEvent(block: (CommonGroupEvent) -> T) = asCommonEvent() ?.let(block)
inline fun <T> ChatEvent.whenPublicChatEvent(block: (PublicChatEvent) -> T) = asPublicChatEvent() ?.let(block)
@PreviewFeature
inline fun ChatEvent.asCommonEvent(): CommonGroupEvent? = this as? CommonGroupEvent
inline fun ChatEvent.asPublicChatEvent(): PublicChatEvent? = this as? PublicChatEvent
@PreviewFeature
inline fun ChatEvent.requireCommonEvent(): CommonGroupEvent = this as CommonGroupEvent
inline fun ChatEvent.requirePublicChatEvent(): PublicChatEvent = this as PublicChatEvent
@PreviewFeature
inline fun <T> ChatEvent.whenCommonEvent(block: (CommonEvent) -> T) = asCommonEvent() ?.let(block)
@PreviewFeature
inline fun ChatEvent.asCommonEvent(): CommonEvent? = this as? CommonEvent
@PreviewFeature
inline fun ChatEvent.requireCommonEvent(): CommonEvent = this as CommonEvent
@PreviewFeature
inline fun <T> ChatEvent.whenGroupEvent(block: (GroupEvent) -> T) = asGroupEvent() ?.let(block)