1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-09-03 23:29:33 +00:00

update api according to new topics api

This commit is contained in:
2022-11-08 00:11:14 +06:00
parent 9df258805d
commit b1bba43f29
55 changed files with 1043 additions and 386 deletions

View File

@@ -239,11 +239,15 @@ import dev.inmo.tgbotapi.types.message.ChatEvents.WebAppData
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChannelEvent
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonEvent
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ForumEvent
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.GroupEvent
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PrivateEvent
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.SupergroupEvent
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.VideoChatEvent
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicClosed
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicCreated
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicReopened
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatEnded
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatParticipantsInvited
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatScheduled
@@ -2826,6 +2830,15 @@ public inline fun ChatEvent.commonEventOrThrow(): CommonEvent = this as
public inline fun <T> ChatEvent.ifCommonEvent(block: (CommonEvent) -> T): T? = commonEventOrNull()
?.let(block)
public inline fun ChatEvent.forumEventOrNull(): ForumEvent? = this as?
dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ForumEvent
public inline fun ChatEvent.forumEventOrThrow(): ForumEvent = this as
dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ForumEvent
public inline fun <T> ChatEvent.ifForumEvent(block: (ForumEvent) -> T): T? = forumEventOrNull()
?.let(block)
public inline fun ChatEvent.groupEventOrNull(): GroupEvent? = this as?
dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.GroupEvent
@@ -2871,6 +2884,33 @@ public inline fun ChatEvent.videoChatEventOrThrow(): VideoChatEvent = this as
public inline fun <T> ChatEvent.ifVideoChatEvent(block: (VideoChatEvent) -> T): T? =
videoChatEventOrNull() ?.let(block)
public inline fun ChatEvent.forumTopicClosedOrNull(): ForumTopicClosed? = this as?
dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicClosed
public inline fun ChatEvent.forumTopicClosedOrThrow(): ForumTopicClosed = this as
dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicClosed
public inline fun <T> ChatEvent.ifForumTopicClosed(block: (ForumTopicClosed) -> T): T? =
forumTopicClosedOrNull() ?.let(block)
public inline fun ChatEvent.forumTopicCreatedOrNull(): ForumTopicCreated? = this as?
dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicCreated
public inline fun ChatEvent.forumTopicCreatedOrThrow(): ForumTopicCreated = this as
dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicCreated
public inline fun <T> ChatEvent.ifForumTopicCreated(block: (ForumTopicCreated) -> T): T? =
forumTopicCreatedOrNull() ?.let(block)
public inline fun ChatEvent.forumTopicReopenedOrNull(): ForumTopicReopened? = this as?
dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicReopened
public inline fun ChatEvent.forumTopicReopenedOrThrow(): ForumTopicReopened = this as
dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicReopened
public inline fun <T> ChatEvent.ifForumTopicReopened(block: (ForumTopicReopened) -> T): T? =
forumTopicReopenedOrNull() ?.let(block)
public inline fun ChatEvent.videoChatEndedOrNull(): VideoChatEnded? = this as?
dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatEnded

View File

@@ -28,12 +28,14 @@ val SentMediaGroupUpdate.mediaGroupId: MediaGroupIdentifier
fun List<CommonMessage<MediaGroupContent>>.createResend(
chatId: ChatId,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyTo: MessageId? = null
) = SendMediaGroup<MediaGroupContent>(
chatId,
map { it.content.toMediaGroupMemberTelegramMedia() },
threadId,
disableNotification,
protectContent,
replyTo
@@ -41,22 +43,26 @@ fun List<CommonMessage<MediaGroupContent>>.createResend(
fun List<CommonMessage<MediaGroupContent>>.createResend(
chat: Chat,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyTo: MessageId? = null
) = createResend(
chat.id,
threadId,
disableNotification,
protectContent,
replyTo
)
fun SentMediaGroupUpdate.createResend(
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyTo: MessageId? = null
) = data.createResend(
chat,
threadId,
disableNotification,
protectContent,
replyTo