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

editForumtTopic optional fields

This commit is contained in:
InsanusMokrassar 2022-12-30 20:32:05 +06:00
parent 8b5da90e28
commit 463d5252bd
2 changed files with 7 additions and 11 deletions

View File

@ -11,8 +11,8 @@ import dev.inmo.tgbotapi.types.chat.Chat
suspend fun TelegramBot.editForumTopic(
chatId: ChatIdentifier,
messageThreadId: MessageThreadId,
name: String,
iconEmojiId: CustomEmojiId
name: String? = null,
iconEmojiId: CustomEmojiId? = null
) = execute(
EditForumTopic(
chatId,
@ -25,12 +25,12 @@ suspend fun TelegramBot.editForumTopic(
suspend fun TelegramBot.editForumTopic(
chat: Chat,
messageThreadId: MessageThreadId,
name: String,
iconEmojiId: CustomEmojiId
name: String? = null,
iconEmojiId: CustomEmojiId? = null
) = editForumTopic(chat.id, messageThreadId, name, iconEmojiId)
suspend fun TelegramBot.editForumTopic(
chatIdentifier: ChatIdentifier,
forumTopic: ForumTopic,
iconEmojiId: CustomEmojiId = forumTopic.iconEmojiId ?: error("Icon emoji id in forum topic should be presented when edit forum topic basing on other forum topic object")
iconEmojiId: CustomEmojiId? = forumTopic.iconEmojiId
) = editForumTopic(chatIdentifier, forumTopic.messageThreadId, forumTopic.name, iconEmojiId)

View File

@ -1,11 +1,7 @@
package dev.inmo.tgbotapi.requests.chat.forum
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.utils.RGBColor
import kotlinx.serialization.*
import kotlinx.serialization.builtins.serializer
@Serializable
data class EditForumTopic (
@ -14,9 +10,9 @@ data class EditForumTopic (
@SerialName(messageThreadIdField)
val messageThreadId: MessageThreadId,
@SerialName(nameField)
val name: String,
val name: String? = null,
@SerialName(iconCustomEmojiIdField)
val iconEmojiId: CustomEmojiId,
val iconEmojiId: CustomEmojiId? = null,
): ModifyForumRequest {
init {
if (name.length !in threadNameLength) {