mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 08:13:47 +00:00
add full support of editGeneralForumTopic, closeGeneralForumTopic, reopenGeneralForumTopic, hideGeneralForumTopic, unhideGeneralForumTopic
This commit is contained in:
parent
9a33451f88
commit
bea056bba3
@ -0,0 +1,19 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.chat.forum
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.chat.forum.CloseForumTopic
|
||||||
|
import dev.inmo.tgbotapi.requests.chat.forum.CloseGeneralForumTopic
|
||||||
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.ForumTopic
|
||||||
|
import dev.inmo.tgbotapi.types.MessageThreadId
|
||||||
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
|
|
||||||
|
suspend fun TelegramBot.closeGeneralForumTopic(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = execute(
|
||||||
|
CloseGeneralForumTopic(chatId)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.closeGeneralForumTopic(
|
||||||
|
chat: Chat
|
||||||
|
) = closeGeneralForumTopic(chat.id)
|
@ -0,0 +1,30 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.chat.forum
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.chat.forum.EditForumTopic
|
||||||
|
import dev.inmo.tgbotapi.requests.chat.forum.EditGeneralForumTopic
|
||||||
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.CustomEmojiId
|
||||||
|
import dev.inmo.tgbotapi.types.ForumTopic
|
||||||
|
import dev.inmo.tgbotapi.types.MessageThreadId
|
||||||
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
|
|
||||||
|
suspend fun TelegramBot.editGeneralForumTopic(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
name: String
|
||||||
|
) = execute(
|
||||||
|
EditGeneralForumTopic(
|
||||||
|
chatId,
|
||||||
|
name
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.editGeneralForumTopic(
|
||||||
|
chat: Chat,
|
||||||
|
name: String
|
||||||
|
) = editGeneralForumTopic(chat.id, name)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.editGeneralForumTopic(
|
||||||
|
chatIdentifier: ChatIdentifier,
|
||||||
|
forumTopic: ForumTopic,
|
||||||
|
) = editGeneralForumTopic(chatIdentifier, forumTopic.name)
|
@ -0,0 +1,20 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.chat.forum
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.chat.forum.CloseForumTopic
|
||||||
|
import dev.inmo.tgbotapi.requests.chat.forum.CloseGeneralForumTopic
|
||||||
|
import dev.inmo.tgbotapi.requests.chat.forum.HideGeneralForumTopic
|
||||||
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.ForumTopic
|
||||||
|
import dev.inmo.tgbotapi.types.MessageThreadId
|
||||||
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
|
|
||||||
|
suspend fun TelegramBot.hideGeneralForumTopic(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = execute(
|
||||||
|
HideGeneralForumTopic(chatId)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.hideGeneralForumTopic(
|
||||||
|
chat: Chat
|
||||||
|
) = hideGeneralForumTopic(chat.id)
|
@ -0,0 +1,19 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.chat.forum
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.chat.forum.ReopenForumTopic
|
||||||
|
import dev.inmo.tgbotapi.requests.chat.forum.ReopenGeneralForumTopic
|
||||||
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.ForumTopic
|
||||||
|
import dev.inmo.tgbotapi.types.MessageThreadId
|
||||||
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
|
|
||||||
|
suspend fun TelegramBot.reopenGeneralForumTopic(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = execute(
|
||||||
|
ReopenGeneralForumTopic(chatId)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.reopenGeneralForumTopic(
|
||||||
|
chat: Chat
|
||||||
|
) = reopenGeneralForumTopic(chat.id)
|
@ -0,0 +1,21 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.chat.forum
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.chat.forum.CloseForumTopic
|
||||||
|
import dev.inmo.tgbotapi.requests.chat.forum.CloseGeneralForumTopic
|
||||||
|
import dev.inmo.tgbotapi.requests.chat.forum.HideGeneralForumTopic
|
||||||
|
import dev.inmo.tgbotapi.requests.chat.forum.UnhideGeneralForumTopic
|
||||||
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.ForumTopic
|
||||||
|
import dev.inmo.tgbotapi.types.MessageThreadId
|
||||||
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
|
|
||||||
|
suspend fun TelegramBot.unhideGeneralForumTopic(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = execute(
|
||||||
|
UnhideGeneralForumTopic(chatId)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.unhideGeneralForumTopic(
|
||||||
|
chat: Chat
|
||||||
|
) = unhideGeneralForumTopic(chat.id)
|
@ -0,0 +1,18 @@
|
|||||||
|
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 CloseGeneralForumTopic (
|
||||||
|
@SerialName(chatIdField)
|
||||||
|
override val chatId: ChatIdentifier
|
||||||
|
): ModifyForumRequest, GeneralForumRequest<Boolean> {
|
||||||
|
override fun method(): String = "closeGeneralForumTopic"
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
}
|
@ -15,7 +15,7 @@ data class EditForumTopic (
|
|||||||
val iconEmojiId: CustomEmojiId? = null,
|
val iconEmojiId: CustomEmojiId? = null,
|
||||||
): ModifyForumRequest {
|
): ModifyForumRequest {
|
||||||
init {
|
init {
|
||||||
if (name.length !in threadNameLength) {
|
if (name != null && name.length !in threadNameLength) {
|
||||||
throw IllegalArgumentException("Thread name must be in $threadNameLength range")
|
throw IllegalArgumentException("Thread name must be in $threadNameLength range")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
package dev.inmo.tgbotapi.requests.chat.forum
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class EditGeneralForumTopic (
|
||||||
|
@SerialName(chatIdField)
|
||||||
|
override val chatId: ChatIdentifier,
|
||||||
|
@SerialName(nameField)
|
||||||
|
val name: String
|
||||||
|
): ModifyForumRequest, GeneralForumRequest<Boolean> {
|
||||||
|
init {
|
||||||
|
if (name.length !in threadNameLength) {
|
||||||
|
throw IllegalArgumentException("Thread name must be in $threadNameLength range")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun method(): String = "editGeneralForumTopic"
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
package dev.inmo.tgbotapi.requests.chat.forum
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
|
|
||||||
|
sealed interface GeneralForumRequest<T : Any> : ForumRequest<T>, ChatRequest
|
@ -0,0 +1,18 @@
|
|||||||
|
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 HideGeneralForumTopic (
|
||||||
|
@SerialName(chatIdField)
|
||||||
|
override val chatId: ChatIdentifier
|
||||||
|
): ModifyForumRequest, GeneralForumRequest<Boolean> {
|
||||||
|
override fun method(): String = "hideGeneralForumTopic"
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
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 ReopenGeneralForumTopic (
|
||||||
|
@SerialName(chatIdField)
|
||||||
|
override val chatId: ChatIdentifier,
|
||||||
|
): ModifyForumRequest, GeneralForumRequest<Boolean> {
|
||||||
|
override fun method(): String = "reopenGeneralForumTopic"
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
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 UnhideGeneralForumTopic (
|
||||||
|
@SerialName(chatIdField)
|
||||||
|
override val chatId: ChatIdentifier
|
||||||
|
): ModifyForumRequest, GeneralForumRequest<Boolean> {
|
||||||
|
override fun method(): String = "unhideGeneralForumTopic"
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user