mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2026-06-12 14:26:47 +00:00
Compare commits
11 Commits
v26.0.0
...
71ccfc88cc
| Author | SHA1 | Date | |
|---|---|---|---|
| 71ccfc88cc | |||
| dd2923f92d | |||
| ff78153591 | |||
| e2ce9cfebf | |||
| 0a01d2567e | |||
| e4fb45c09b | |||
| db0df975c7 | |||
| 2003b314a3 | |||
| 55a78375be | |||
|
|
256607e336 | ||
| 92f2a5afdb |
@@ -1,5 +1,7 @@
|
||||
# TelegramBotAPI changelog
|
||||
|
||||
## 26.1.0
|
||||
|
||||
## 26.0.0
|
||||
|
||||
**THIS UPDATE CONTAINS BREAKING CHANGES IN BEHAVIOUR BUILDER AND CORE. BE CAREFUL ON UPDATE**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# TelegramBotAPI [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#april-11-2025)
|
||||
# TelegramBotAPI [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#april-11-2025)
|
||||
|
||||
| Docs | [](https://tgbotapi.inmo.dev/index.html) [](https://docs.inmo.dev/tgbotapi/index.html) |
|
||||
|:----------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|
||||
|
||||
@@ -6,4 +6,4 @@ kotlin.incremental=true
|
||||
kotlin.incremental.js=true
|
||||
|
||||
library_group=dev.inmo
|
||||
library_version=26.0.0
|
||||
library_version=26.1.0
|
||||
|
||||
@@ -27,3 +27,12 @@ interface TextedOutput : ParsableOutput, EntitiesOutput
|
||||
interface TextedInput : TextedWithTextSources {
|
||||
override val textSources: List<TextSource>
|
||||
}
|
||||
|
||||
interface TitledInput : TextedInput {
|
||||
val title: String
|
||||
val titleTextSources: List<TextSource>
|
||||
override val text: String
|
||||
get() = title
|
||||
override val textSources: List<TextSource>
|
||||
get() = titleTextSources
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package dev.inmo.tgbotapi.requests.send
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.types.AllowPaidBroadcast
|
||||
import dev.inmo.tgbotapi.abstracts.types.DisableNotification
|
||||
import dev.inmo.tgbotapi.abstracts.types.OptionallyWithEffectId
|
||||
import dev.inmo.tgbotapi.abstracts.types.ProtectContent
|
||||
import dev.inmo.tgbotapi.abstracts.types.WithBusinessConnectionId
|
||||
import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup
|
||||
import dev.inmo.tgbotapi.abstracts.types.WithReplyParameters
|
||||
import dev.inmo.tgbotapi.requests.send.abstracts.OptionallyMessageThreadRequest
|
||||
import dev.inmo.tgbotapi.requests.send.abstracts.SendChatMessageRequest
|
||||
import dev.inmo.tgbotapi.requests.send.abstracts.SendContentMessageRequest
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.checklists.Checklist
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||
import dev.inmo.tgbotapi.types.message.content.ChecklistContent
|
||||
import dev.inmo.tgbotapi.types.message.content.GameContent
|
||||
import kotlinx.serialization.*
|
||||
|
||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<ChecklistContent>>
|
||||
= TelegramBotAPIMessageDeserializationStrategyClass()
|
||||
|
||||
@Serializable
|
||||
data class SendChecklist (
|
||||
@SerialName(chatIdField)
|
||||
override val chatId: ChatIdentifier,
|
||||
@SerialName(checklistField)
|
||||
val checklist: Checklist.Input,
|
||||
@SerialName(businessConnectionIdField)
|
||||
override val businessConnectionId: BusinessConnectionId,
|
||||
@SerialName(disableNotificationField)
|
||||
override val disableNotification: Boolean = false,
|
||||
@SerialName(protectContentField)
|
||||
override val protectContent: Boolean = false,
|
||||
@SerialName(messageEffectIdField)
|
||||
override val effectId: EffectId? = null,
|
||||
@SerialName(replyParametersField)
|
||||
override val replyParameters: ReplyParameters? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: KeyboardMarkup? = null
|
||||
) : SendChatMessageRequest<ContentMessage<ChecklistContent>>,
|
||||
WithReplyParameters,
|
||||
DisableNotification,
|
||||
ProtectContent,
|
||||
OptionallyWithEffectId,
|
||||
WithBusinessConnectionId,
|
||||
WithReplyMarkup {
|
||||
constructor(
|
||||
chatId: BusinessChatId,
|
||||
checklist: Checklist.Input,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
effectId: EffectId? = null,
|
||||
replyParameters: ReplyParameters? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) : this(
|
||||
chatId = chatId,
|
||||
checklist = checklist,
|
||||
businessConnectionId = chatId.businessConnectionId,
|
||||
disableNotification = disableNotification,
|
||||
protectContent = protectContent,
|
||||
effectId = effectId,
|
||||
replyParameters = replyParameters,
|
||||
replyMarkup = replyMarkup
|
||||
)
|
||||
|
||||
override fun method(): String = "sendChecklist"
|
||||
override val resultDeserializer: DeserializationStrategy<ContentMessage<ChecklistContent>>
|
||||
get() = commonResultDeserializer
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
@@ -308,6 +308,13 @@ const val pendingJoinRequestCountField = "pending_join_request_count"
|
||||
const val memberLimitField = "member_limit"
|
||||
const val iconColorField = "icon_color"
|
||||
const val emojiListField = "emoji_list"
|
||||
const val completedByUserField = "completed_by_user"
|
||||
const val completionDateField = "completion_date"
|
||||
const val titleEntitiesField = "title_entities"
|
||||
const val tasksField = "tasks"
|
||||
const val othersCanAddTasksField = "others_can_add_tasks"
|
||||
const val othersCanMarkTasksAsDoneField = "others_can_mark_tasks_as_done"
|
||||
const val checklistField = "checklist"
|
||||
|
||||
const val requestContactField = "request_contact"
|
||||
const val requestLocationField = "request_location"
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
package dev.inmo.tgbotapi.types.checklists
|
||||
|
||||
import dev.inmo.micro_utils.common.Warning
|
||||
import dev.inmo.tgbotapi.abstracts.TitledInput
|
||||
import dev.inmo.tgbotapi.types.checklists.ChecklistTask.Input
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
import dev.inmo.tgbotapi.types.message.RawMessageEntity
|
||||
import dev.inmo.tgbotapi.types.message.asTextSources
|
||||
import dev.inmo.tgbotapi.types.message.parseModeField
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSource
|
||||
import dev.inmo.tgbotapi.types.message.toRawMessageEntities
|
||||
import dev.inmo.tgbotapi.types.othersCanAddTasksField
|
||||
import dev.inmo.tgbotapi.types.othersCanMarkTasksAsDoneField
|
||||
import dev.inmo.tgbotapi.types.tasksField
|
||||
import dev.inmo.tgbotapi.types.titleEntitiesField
|
||||
import dev.inmo.tgbotapi.types.titleField
|
||||
import dev.inmo.tgbotapi.utils.EntitiesBuilder
|
||||
import dev.inmo.tgbotapi.utils.EntitiesBuilderBody
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeSourceString
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
@Serializable
|
||||
sealed interface Checklist : TitledInput {
|
||||
val tasks: List<ChecklistTask>
|
||||
val othersCanAddTasks: Boolean
|
||||
val othersCanCompleteTasks: Boolean
|
||||
@Serializable
|
||||
data class Input @Warning("It is low level API. Do not use it without need") constructor(
|
||||
@SerialName(titleField)
|
||||
override val title: String,
|
||||
@SerialName(tasksField)
|
||||
override val tasks: List<ChecklistTask.Input>,
|
||||
@SerialName(parseModeField)
|
||||
val parseMode: ParseMode? = null,
|
||||
@SerialName(titleEntitiesField)
|
||||
override val titleTextSources: List<TextSource> = emptyList(),
|
||||
@SerialName(othersCanAddTasksField)
|
||||
override val othersCanAddTasks: Boolean = false,
|
||||
@SerialName(othersCanMarkTasksAsDoneField)
|
||||
override val othersCanCompleteTasks: Boolean = false,
|
||||
) : Checklist {
|
||||
constructor(
|
||||
text: String,
|
||||
tasks: List<ChecklistTask.Input>,
|
||||
parseMode: ParseMode? = null,
|
||||
othersCanAddTasks: Boolean = false,
|
||||
othersCanCompleteTasks: Boolean = false,
|
||||
) : this(
|
||||
title = text,
|
||||
parseMode = parseMode,
|
||||
titleTextSources = emptyList(),
|
||||
tasks = tasks,
|
||||
othersCanAddTasks = othersCanAddTasks,
|
||||
othersCanCompleteTasks = othersCanCompleteTasks
|
||||
)
|
||||
constructor(
|
||||
titleTextSources: List<TextSource>,
|
||||
tasks: List<ChecklistTask.Input>,
|
||||
othersCanAddTasks: Boolean = false,
|
||||
othersCanCompleteTasks: Boolean = false,
|
||||
) : this(
|
||||
title = titleTextSources.makeSourceString(),
|
||||
parseMode = null,
|
||||
titleTextSources = titleTextSources,
|
||||
tasks = tasks,
|
||||
othersCanAddTasks = othersCanAddTasks,
|
||||
othersCanCompleteTasks = othersCanCompleteTasks
|
||||
)
|
||||
constructor(
|
||||
tasks: List<ChecklistTask.Input>,
|
||||
othersCanAddTasks: Boolean = false,
|
||||
othersCanCompleteTasks: Boolean = false,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) : this(
|
||||
titleTextSources = EntitiesBuilder().apply(builderBody).build(),
|
||||
tasks = tasks,
|
||||
othersCanAddTasks = othersCanAddTasks,
|
||||
othersCanCompleteTasks = othersCanCompleteTasks
|
||||
)
|
||||
|
||||
companion object : KSerializer<Input> {
|
||||
@Serializable
|
||||
private class RawChecklist(
|
||||
val title: String,
|
||||
val parseMode: ParseMode? = null,
|
||||
val title_entities: List<RawMessageEntity> = emptyList(),
|
||||
val tasks: List<ChecklistTask.Input>,
|
||||
val others_can_add_tasks: Boolean = false,
|
||||
val others_can_mark_tasks_as_done: Boolean = false,
|
||||
)
|
||||
override val descriptor: SerialDescriptor = RawChecklist.serializer().descriptor
|
||||
|
||||
override fun serialize(
|
||||
encoder: Encoder,
|
||||
value: Input
|
||||
) {
|
||||
RawChecklist.serializer().serialize(
|
||||
encoder,
|
||||
RawChecklist(
|
||||
title = value.title,
|
||||
title_entities = value.titleTextSources.toRawMessageEntities(),
|
||||
tasks = value.tasks,
|
||||
parseMode = value.parseMode,
|
||||
others_can_add_tasks = value.othersCanAddTasks,
|
||||
others_can_mark_tasks_as_done = value.othersCanCompleteTasks,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun deserialize(decoder: Decoder): Input {
|
||||
val raw = RawChecklist.serializer().deserialize(decoder)
|
||||
return Input(
|
||||
title = raw.title,
|
||||
titleTextSources = raw.title_entities.asTextSources(raw.title),
|
||||
tasks = raw.tasks,
|
||||
parseMode = raw.parseMode,
|
||||
othersCanAddTasks = raw.others_can_add_tasks,
|
||||
othersCanCompleteTasks = raw.others_can_mark_tasks_as_done
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable(Created.Companion::class)
|
||||
data class Created(
|
||||
override val titleTextSources: List<TextSource>,
|
||||
@SerialName(tasksField)
|
||||
override val tasks: List<ChecklistTask.Created>,
|
||||
@SerialName(othersCanAddTasksField)
|
||||
override val othersCanAddTasks: Boolean = false,
|
||||
@SerialName(othersCanMarkTasksAsDoneField)
|
||||
override val othersCanCompleteTasks: Boolean = false,
|
||||
): Checklist {
|
||||
override val title: String by lazy {
|
||||
titleTextSources.makeSourceString()
|
||||
}
|
||||
|
||||
companion object : KSerializer<Created> {
|
||||
@Serializable
|
||||
private class RawChecklist(
|
||||
val title: String,
|
||||
val title_entities: List<RawMessageEntity> = emptyList(),
|
||||
val tasks: List<ChecklistTask.Created>,
|
||||
val others_can_add_tasks: Boolean = false,
|
||||
val others_can_mark_tasks_as_done: Boolean = false,
|
||||
)
|
||||
override val descriptor: SerialDescriptor = RawChecklist.serializer().descriptor
|
||||
|
||||
override fun serialize(
|
||||
encoder: Encoder,
|
||||
value: Created
|
||||
) {
|
||||
RawChecklist.serializer().serialize(
|
||||
encoder,
|
||||
RawChecklist(
|
||||
title = value.title,
|
||||
title_entities = value.titleTextSources.toRawMessageEntities(),
|
||||
tasks = value.tasks,
|
||||
others_can_add_tasks = value.othersCanAddTasks,
|
||||
others_can_mark_tasks_as_done = value.othersCanCompleteTasks,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun deserialize(decoder: Decoder): Created {
|
||||
val raw = RawChecklist.serializer().deserialize(decoder)
|
||||
return Created(
|
||||
titleTextSources = raw.title_entities.asTextSources(raw.title),
|
||||
tasks = raw.tasks,
|
||||
othersCanAddTasks = raw.others_can_add_tasks,
|
||||
othersCanCompleteTasks = raw.others_can_mark_tasks_as_done
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
package dev.inmo.tgbotapi.types.checklists
|
||||
|
||||
import dev.inmo.micro_utils.common.Warning
|
||||
import dev.inmo.tgbotapi.abstracts.TextedInput
|
||||
import dev.inmo.tgbotapi.abstracts.TitledInput
|
||||
import dev.inmo.tgbotapi.types.TelegramDate
|
||||
import dev.inmo.tgbotapi.types.chat.PreviewUser
|
||||
import dev.inmo.tgbotapi.types.completedByUserField
|
||||
import dev.inmo.tgbotapi.types.completionDateField
|
||||
import dev.inmo.tgbotapi.types.idField
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
import dev.inmo.tgbotapi.types.message.RawMessageEntity
|
||||
import dev.inmo.tgbotapi.types.message.asTextSources
|
||||
import dev.inmo.tgbotapi.types.message.parseModeField
|
||||
import dev.inmo.tgbotapi.types.message.textsources.RegularTextSource
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSource
|
||||
import dev.inmo.tgbotapi.types.message.toRawMessageEntities
|
||||
import dev.inmo.tgbotapi.types.tasksField
|
||||
import dev.inmo.tgbotapi.types.textEntitiesField
|
||||
import dev.inmo.tgbotapi.types.textField
|
||||
import dev.inmo.tgbotapi.types.textParseModeField
|
||||
import dev.inmo.tgbotapi.types.titleEntitiesField
|
||||
import dev.inmo.tgbotapi.types.titleField
|
||||
import dev.inmo.tgbotapi.utils.EntitiesBuilder
|
||||
import dev.inmo.tgbotapi.utils.EntitiesBuilderBody
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeSourceString
|
||||
import kotlinx.serialization.EncodeDefault
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
@Serializable
|
||||
sealed interface ChecklistTask : TextedInput {
|
||||
val id: ChecklistTaskId
|
||||
override val text: String
|
||||
|
||||
@Serializable(Input.Companion::class)
|
||||
data class Input @Warning("It is low level API. Do not use it without need") constructor(
|
||||
@SerialName(idField)
|
||||
override val id: ChecklistTaskId,
|
||||
@SerialName(textField)
|
||||
override val text: String,
|
||||
@SerialName(textParseModeField)
|
||||
val parseMode: ParseMode? = null,
|
||||
@SerialName(textEntitiesField)
|
||||
override val textSources: List<TextSource> = emptyList(),
|
||||
) : ChecklistTask {
|
||||
constructor(id: ChecklistTaskId, text: String, parseMode: ParseMode? = null) : this(
|
||||
id = id,
|
||||
text = text,
|
||||
parseMode = parseMode,
|
||||
textSources = emptyList()
|
||||
)
|
||||
constructor(id: ChecklistTaskId, textSources: List<TextSource>) : this(
|
||||
id = id,
|
||||
text = textSources.makeSourceString(),
|
||||
parseMode = null,
|
||||
textSources = textSources
|
||||
)
|
||||
constructor(id: ChecklistTaskId, builderBody: EntitiesBuilderBody) : this(
|
||||
id = id,
|
||||
textSources = EntitiesBuilder().apply(builderBody).build()
|
||||
)
|
||||
|
||||
companion object : KSerializer<Input> {
|
||||
@Serializable
|
||||
private data class RawInput(
|
||||
@SerialName(idField)
|
||||
val id: ChecklistTaskId,
|
||||
@SerialName(textField)
|
||||
val text: String,
|
||||
@SerialName(textParseModeField)
|
||||
val parseMode: ParseMode? = null,
|
||||
@SerialName(textEntitiesField)
|
||||
val textSources: List<RawMessageEntity> = emptyList(),
|
||||
)
|
||||
override val descriptor: SerialDescriptor
|
||||
get() = RawInput.serializer().descriptor
|
||||
|
||||
override fun deserialize(decoder: Decoder): Input {
|
||||
val raw = RawInput.serializer().deserialize(decoder)
|
||||
return Input(
|
||||
raw.id,
|
||||
raw.text,
|
||||
raw.parseMode,
|
||||
raw.textSources.asTextSources(raw.text)
|
||||
)
|
||||
}
|
||||
|
||||
override fun serialize(encoder: Encoder, value: Input) {
|
||||
RawInput.serializer().serialize(
|
||||
encoder,
|
||||
RawInput(
|
||||
value.id,
|
||||
value.text,
|
||||
value.parseMode,
|
||||
value.textSources.toRawMessageEntities()
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable(Created.Serializer::class)
|
||||
data class Undone(
|
||||
@SerialName(idField)
|
||||
override val id: ChecklistTaskId,
|
||||
@SerialName(textEntitiesField)
|
||||
override val textSources: List<TextSource> = emptyList(),
|
||||
) : ChecklistTask.Created {
|
||||
@OptIn(ExperimentalSerializationApi::class)
|
||||
@EncodeDefault
|
||||
@Serializable
|
||||
@SerialName(textField)
|
||||
override val text: String = textSources.makeSourceString()
|
||||
|
||||
constructor(id: ChecklistTaskId, text: String): this(
|
||||
id,
|
||||
listOf(
|
||||
RegularTextSource(text)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Serializable(Created.Serializer::class)
|
||||
data class Done(
|
||||
@SerialName(idField)
|
||||
override val id: ChecklistTaskId,
|
||||
@SerialName(completedByUserField)
|
||||
override val completedByUser: PreviewUser,
|
||||
@SerialName(completionDateField)
|
||||
override val completionDate: TelegramDate,
|
||||
@SerialName(textEntitiesField)
|
||||
override val textSources: List<TextSource> = emptyList()
|
||||
) : ChecklistTask.Created {
|
||||
@OptIn(ExperimentalSerializationApi::class)
|
||||
@EncodeDefault
|
||||
@Serializable
|
||||
@SerialName(textField)
|
||||
override val text: String = textSources.makeSourceString()
|
||||
|
||||
constructor(
|
||||
id: ChecklistTaskId,
|
||||
text: String,
|
||||
completedByUser: PreviewUser,
|
||||
completionDate: TelegramDate,
|
||||
): this(
|
||||
id,
|
||||
completedByUser,
|
||||
completionDate,
|
||||
listOf(
|
||||
RegularTextSource(text)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Serializable(Created.Serializer::class)
|
||||
sealed interface Created : ChecklistTask {
|
||||
val completedByUser: PreviewUser?
|
||||
get() = null
|
||||
val completionDate: TelegramDate?
|
||||
get() = null
|
||||
|
||||
@RiskFeature
|
||||
object Serializer : KSerializer<Created> {
|
||||
@Serializable
|
||||
private data class RawCreatedChecklistTask(
|
||||
@SerialName(idField)
|
||||
val id: ChecklistTaskId,
|
||||
@SerialName(textField)
|
||||
val text: String,
|
||||
@SerialName(textEntitiesField)
|
||||
val textSources: List<RawMessageEntity> = emptyList(),
|
||||
@SerialName(completedByUserField)
|
||||
val completedByUser: PreviewUser? = null,
|
||||
@SerialName(completionDateField)
|
||||
val completionDate: TelegramDate = TelegramDate(0), // TelegramDate(0) is the default according to https://core.telegram.org/bots/api#checklisttask
|
||||
)
|
||||
override val descriptor: SerialDescriptor = RawCreatedChecklistTask.serializer().descriptor
|
||||
|
||||
override fun deserialize(decoder: Decoder): Created {
|
||||
val raw = RawCreatedChecklistTask.serializer().deserialize(
|
||||
decoder
|
||||
)
|
||||
|
||||
return when {
|
||||
raw.completedByUser != null -> Done(
|
||||
id = raw.id,
|
||||
completedByUser = raw.completedByUser,
|
||||
completionDate = raw.completionDate,
|
||||
textSources = raw.textSources.asTextSources(raw.text),
|
||||
)
|
||||
else -> Undone(
|
||||
id = raw.id,
|
||||
textSources = raw.textSources.asTextSources(raw.text),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun serialize(encoder: Encoder, value: Created) {
|
||||
RawCreatedChecklistTask.serializer().serialize(
|
||||
encoder,
|
||||
RawCreatedChecklistTask(
|
||||
id = value.id,
|
||||
text = value.text,
|
||||
completedByUser = value.completedByUser,
|
||||
completionDate = value.completionDate ?: TelegramDate(0),
|
||||
textSources = value.textSources.toRawMessageEntities()
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package dev.inmo.tgbotapi.types.checklists
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlin.jvm.JvmInline
|
||||
|
||||
@Serializable
|
||||
@JvmInline
|
||||
value class ChecklistTaskId(
|
||||
val int: UInt
|
||||
)
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.inmo.tgbotapi.types.checklists
|
||||
|
||||
import dev.inmo.micro_utils.common.Warning
|
||||
import dev.inmo.tgbotapi.abstracts.TextedInput
|
||||
import dev.inmo.tgbotapi.abstracts.TitledInput
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
import dev.inmo.tgbotapi.types.message.parseModeField
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSource
|
||||
import dev.inmo.tgbotapi.types.tasksField
|
||||
import dev.inmo.tgbotapi.types.titleEntitiesField
|
||||
import dev.inmo.tgbotapi.types.titleField
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@@ -165,6 +165,10 @@ internal data class RawMessage(
|
||||
private val giveaway_winners: GiveawayPublicResults? = null,
|
||||
private val giveaway_completed: GiveawayPrivateResults? = null,
|
||||
|
||||
// Checklists
|
||||
private val checklist_tasks_done: Nothing,
|
||||
private val checklist_tasks_added: Nothing,
|
||||
|
||||
// Gifts
|
||||
private val gift: GiftSentOrReceived.Regular? = null,
|
||||
private val unique_gift: GiftSentOrReceived.Unique? = null,
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package dev.inmo.tgbotapi.types.message.content
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.EffectId
|
||||
import dev.inmo.tgbotapi.types.MessageThreadId
|
||||
import dev.inmo.tgbotapi.types.ReplyParameters
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.checklists.Checklist
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class ChecklistContent(
|
||||
val checklist: Checklist
|
||||
) : MessageContent {
|
||||
override fun createResend(
|
||||
chatId: ChatIdentifier,
|
||||
messageThreadId: MessageThreadId?,
|
||||
businessConnectionId: BusinessConnectionId?,
|
||||
disableNotification: Boolean,
|
||||
protectContent: Boolean,
|
||||
allowPaidBroadcast: Boolean,
|
||||
effectId: EffectId?,
|
||||
replyParameters: ReplyParameters?,
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): Request<CommonMessage<ChecklistContent>> {
|
||||
return SendChecklist
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,56 @@ import dev.inmo.tgbotapi.types.message.textsources.*
|
||||
typealias EntitiesBuilderBody = EntitiesBuilder.() -> Unit
|
||||
val newLine = regularTextSource("\n")
|
||||
|
||||
/**
|
||||
* Documentation: [DSL text](https://docs.inmo.dev/tgbotapi/dsls/text.html)
|
||||
*
|
||||
* Example: [PollsBot](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/blob/master/PollsBot/src/main/kotlin/PollsBot.kt)
|
||||
*
|
||||
* @see dev.inmo.tgbotapi.utils.bold
|
||||
* @see dev.inmo.tgbotapi.utils.blockquote
|
||||
* @see dev.inmo.tgbotapi.utils.expandableBlockquote
|
||||
* @see dev.inmo.tgbotapi.utils.spoiler
|
||||
* @see dev.inmo.tgbotapi.utils.botCommand
|
||||
* @see dev.inmo.tgbotapi.utils.cashTag
|
||||
* @see dev.inmo.tgbotapi.utils.code
|
||||
* @see dev.inmo.tgbotapi.utils.email
|
||||
* @see dev.inmo.tgbotapi.utils.hashtag
|
||||
* @see dev.inmo.tgbotapi.utils.italic
|
||||
* @see dev.inmo.tgbotapi.utils.mention
|
||||
* @see dev.inmo.tgbotapi.utils.phone
|
||||
* @see dev.inmo.tgbotapi.utils.pre
|
||||
* @see dev.inmo.tgbotapi.utils.regular
|
||||
* @see dev.inmo.tgbotapi.utils.strikethrough
|
||||
* @see dev.inmo.tgbotapi.utils.link
|
||||
* @see dev.inmo.tgbotapi.utils.underline
|
||||
* @see dev.inmo.tgbotapi.utils.customEmoji
|
||||
*/
|
||||
inline fun buildEntities(separator: TextSource? = null, init: EntitiesBuilderBody): TextSourcesList = EntitiesBuilder(separator).apply(init).build()
|
||||
|
||||
/**
|
||||
* Documentation: [DSL text](https://docs.inmo.dev/tgbotapi/dsls/text.html)
|
||||
*
|
||||
* Example: [PollsBot](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/blob/master/PollsBot/src/main/kotlin/PollsBot.kt)
|
||||
*
|
||||
* @see dev.inmo.tgbotapi.utils.bold
|
||||
* @see dev.inmo.tgbotapi.utils.blockquote
|
||||
* @see dev.inmo.tgbotapi.utils.expandableBlockquote
|
||||
* @see dev.inmo.tgbotapi.utils.spoiler
|
||||
* @see dev.inmo.tgbotapi.utils.botCommand
|
||||
* @see dev.inmo.tgbotapi.utils.cashTag
|
||||
* @see dev.inmo.tgbotapi.utils.code
|
||||
* @see dev.inmo.tgbotapi.utils.email
|
||||
* @see dev.inmo.tgbotapi.utils.hashtag
|
||||
* @see dev.inmo.tgbotapi.utils.italic
|
||||
* @see dev.inmo.tgbotapi.utils.mention
|
||||
* @see dev.inmo.tgbotapi.utils.phone
|
||||
* @see dev.inmo.tgbotapi.utils.pre
|
||||
* @see dev.inmo.tgbotapi.utils.regular
|
||||
* @see dev.inmo.tgbotapi.utils.strikethrough
|
||||
* @see dev.inmo.tgbotapi.utils.link
|
||||
* @see dev.inmo.tgbotapi.utils.underline
|
||||
* @see dev.inmo.tgbotapi.utils.customEmoji
|
||||
*/
|
||||
inline fun buildEntities(separator: String, init: EntitiesBuilderBody) = buildEntities(regularTextSource(separator), init)
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user