mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-25 11:38:45 +00:00
add support of forum requests
This commit is contained in:
parent
ad75aef64f
commit
aca4d90608
@ -0,0 +1,20 @@
|
|||||||
|
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 CloseForumTopic (
|
||||||
|
@SerialName(chatIdField)
|
||||||
|
override val chatId: ChatIdentifier,
|
||||||
|
@SerialName(messageThreadIdField)
|
||||||
|
val messageThreadId: MessageThreadId
|
||||||
|
): ModifyForumRequest {
|
||||||
|
override fun method(): String = "closeForumTopic"
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
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 CreateForumTopic (
|
||||||
|
@SerialName(chatIdField)
|
||||||
|
override val chatId: ChatIdentifier,
|
||||||
|
@SerialName(nameField)
|
||||||
|
val name: String,
|
||||||
|
@SerialName(iconColorField)
|
||||||
|
val color: RGBColor,
|
||||||
|
@SerialName(iconCustomEmojiIdField)
|
||||||
|
val iconEmojiId: CustomEmojiId? = null,
|
||||||
|
): ForumRequest<ForumTopic> {
|
||||||
|
init {
|
||||||
|
if (name.length !in threadNameLength) {
|
||||||
|
throw IllegalArgumentException("Thread name must be in $threadNameLength range")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun method(): String = "createForumTopic"
|
||||||
|
override val resultDeserializer: DeserializationStrategy<ForumTopic>
|
||||||
|
get() = ForumTopic.serializer()
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
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 DeleteForumTopic (
|
||||||
|
@SerialName(chatIdField)
|
||||||
|
override val chatId: ChatIdentifier,
|
||||||
|
@SerialName(messageThreadIdField)
|
||||||
|
val messageThreadId: MessageThreadId
|
||||||
|
): ModifyForumRequest {
|
||||||
|
override fun method(): String = "deleteForumTopic"
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
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 (
|
||||||
|
@SerialName(chatIdField)
|
||||||
|
override val chatId: ChatIdentifier,
|
||||||
|
@SerialName(messageThreadIdField)
|
||||||
|
val messageThreadId: MessageThreadId,
|
||||||
|
@SerialName(nameField)
|
||||||
|
val name: String,
|
||||||
|
@SerialName(iconCustomEmojiIdField)
|
||||||
|
val iconEmojiId: CustomEmojiId,
|
||||||
|
): ModifyForumRequest {
|
||||||
|
init {
|
||||||
|
if (name.length !in threadNameLength) {
|
||||||
|
throw IllegalArgumentException("Thread name must be in $threadNameLength range")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun method(): String = "editForumTopic"
|
||||||
|
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 ForumRequest<T : Any> : SimpleRequest<T>, ChatRequest
|
@ -0,0 +1,10 @@
|
|||||||
|
package dev.inmo.tgbotapi.requests.chat.forum
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
|
import kotlinx.serialization.DeserializationStrategy
|
||||||
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
|
sealed interface ModifyForumRequest : ForumRequest<Boolean> {
|
||||||
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
get() = Boolean.serializer()
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
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 ReopenForumTopic (
|
||||||
|
@SerialName(chatIdField)
|
||||||
|
override val chatId: ChatIdentifier,
|
||||||
|
@SerialName(messageThreadIdField)
|
||||||
|
val messageThreadId: MessageThreadId
|
||||||
|
): ModifyForumRequest {
|
||||||
|
override fun method(): String = "reopenForumTopic"
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
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 UnpinAllForumTopicMessages (
|
||||||
|
@SerialName(chatIdField)
|
||||||
|
override val chatId: ChatIdentifier,
|
||||||
|
@SerialName(messageThreadIdField)
|
||||||
|
val messageThreadId: MessageThreadId
|
||||||
|
): ModifyForumRequest {
|
||||||
|
override fun method(): String = "unpinAllForumTopicMessages"
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package dev.inmo.tgbotapi.requests.chat.get
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
|
||||||
|
import dev.inmo.tgbotapi.abstracts.types.OptionalChatRequest
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import dev.inmo.tgbotapi.types.files.Sticker
|
||||||
|
import dev.inmo.tgbotapi.types.files.StickerSerializer
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
import kotlinx.serialization.builtins.ListSerializer
|
||||||
|
import kotlinx.serialization.builtins.serializer
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
object GetForumTopicIconStickers : SimpleRequest<List<Sticker>> {
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
private val deserializer = ListSerializer(StickerSerializer)
|
||||||
|
|
||||||
|
override fun method(): String = "getForumTopicIconStickers"
|
||||||
|
|
||||||
|
override val resultDeserializer: DeserializationStrategy<List<Sticker>>
|
||||||
|
get() = deserializer
|
||||||
|
}
|
@ -94,6 +94,7 @@ val captionLength = 0 .. 1024
|
|||||||
val textLength = 1 .. 4096
|
val textLength = 1 .. 4096
|
||||||
val userProfilePhotosRequestLimit = 0 .. 100
|
val userProfilePhotosRequestLimit = 0 .. 100
|
||||||
val chatTitleLength = 1 until 255
|
val chatTitleLength = 1 until 255
|
||||||
|
val threadNameLength = 1 until 128
|
||||||
val chatDescriptionLength = 0 until 256
|
val chatDescriptionLength = 0 until 256
|
||||||
val inlineResultQueryIdLingth = 1 until 64
|
val inlineResultQueryIdLingth = 1 until 64
|
||||||
val allowedConnectionsLength = 1 .. 100
|
val allowedConnectionsLength = 1 .. 100
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
package dev.inmo.tgbotapi.types
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.utils.RGBColor
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class ForumTopic(
|
||||||
|
@SerialName(messageThreadIdField)
|
||||||
|
val messageThreadId: MessageThreadId,
|
||||||
|
@SerialName(nameField)
|
||||||
|
val name: String,
|
||||||
|
@SerialName(iconColorField)
|
||||||
|
val color: RGBColor,
|
||||||
|
@SerialName(iconCustomEmojiIdField)
|
||||||
|
val iconEmojiId: CustomEmojiId? = null
|
||||||
|
) {
|
||||||
|
companion object {
|
||||||
|
val CYAN = RGBColor(0x6FB9F0)
|
||||||
|
val YELLOW = RGBColor(0xffd67e)
|
||||||
|
val PURPLE = RGBColor(0xCB86DB)
|
||||||
|
val GREEN = RGBColor(0x8EEE98)
|
||||||
|
val PINK = RGBColor(0xFF93B2)
|
||||||
|
val RED = RGBColor(0xFB6F5F)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user