mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 08:13:47 +00:00
commit
95ae25a3fb
19
CHANGELOG.md
19
CHANGELOG.md
@ -1,5 +1,24 @@
|
|||||||
# TelegramBotAPI changelog
|
# TelegramBotAPI changelog
|
||||||
|
|
||||||
|
## 0.13.0 Telegram Polls
|
||||||
|
|
||||||
|
* Type `PollOption` and `AnonymousPollOption` added
|
||||||
|
* Type `Poll` added
|
||||||
|
* Type `PollUpdate` added and implemented in `RawUpdate`. Now `PollUpdate` can be retrieved from `RawUpdate`
|
||||||
|
* Type `PollContent` added - now it can be a value of `ContentMessage#content`
|
||||||
|
* Request `SendPoll` added and `PollContent#createResend` now use it
|
||||||
|
* `ByInlineMessageId` is deprecated (use `InlineMessageAction` instead)
|
||||||
|
* `ByMessageId` is deprecated (use `MessageAction` instead)
|
||||||
|
* Most part of requests which are working with identifiers of messages now implement `MessageAction` directly or
|
||||||
|
by their parents
|
||||||
|
* `StopPoll` implemented
|
||||||
|
* All current `Chat` abstractions are deprecated and rewritten as typealiases. Use `Chat` abstractions from
|
||||||
|
`com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts` package
|
||||||
|
* Common Groups now may have pinned message
|
||||||
|
* `is_member` field added into `RestrictedChatMember`
|
||||||
|
* **BREAK CHANGES** Now `ForwardedMessages` can be `AnonymousForwardedMessage` and `PublicForwardedMessage`. Old
|
||||||
|
implementations now extend `PublicForwardedMessage`
|
||||||
|
|
||||||
## 0.12.0 Webhooks
|
## 0.12.0 Webhooks
|
||||||
|
|
||||||
* Added `DataRequest` interface which replace `Data` interface
|
* Added `DataRequest` interface which replace `Data` interface
|
||||||
|
@ -10,9 +10,7 @@ solves or unuseful moments are describing by official [Telegram Bot API](https:/
|
|||||||
|
|
||||||
## Compatibility
|
## Compatibility
|
||||||
|
|
||||||
This version compatible with [July 2018 update of TelegramBotAPI](https://core.telegram.org/bots/api#july-26-2018). That means that
|
This version compatible with [14th of April 2019 update of TelegramBotAPI](https://core.telegram.org/bots/api#april-14-2019). There is one exception of implemented functionality. It is Telegram Passport API, which was presented in [August 2018 update of TelegramBotAPI](https://core.telegram.org/bots/api#august-27-2018) update. It will be implemented as soon as possible. All included and supported API
|
||||||
most part of API has been implemented (according to last [August 2018 update of TelegramBotAPI](https://core.telegram.org/bots/api#august-27-2018))
|
|
||||||
except the Passport API which will be included as soon as possible. All included and supported API
|
|
||||||
can be found on [wiki](https://github.com/InsanusMokrassar/TelegramBotAPI/wiki/Included-API).
|
can be found on [wiki](https://github.com/InsanusMokrassar/TelegramBotAPI/wiki/Included-API).
|
||||||
|
|
||||||
## How to implement library?
|
## How to implement library?
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
project.version = "0.12.7"
|
project.version = "0.13.0"
|
||||||
project.group = "com.github.insanusmokrassar"
|
project.group = "com.github.insanusmokrassar"
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types
|
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineMessageIdentifier
|
@Deprecated(
|
||||||
|
"Deprecated for the reason of creating of more obvious type interface",
|
||||||
interface ByInlineMessageId {
|
ReplaceWith("InlineMessageAction", "com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.InlineMessageAction")
|
||||||
val inlineMessageId: InlineMessageIdentifier
|
)
|
||||||
}
|
typealias ByInlineMessageId = InlineMessageAction
|
@ -1,7 +1,8 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types
|
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
@Deprecated(
|
||||||
|
"Deprecated for the reason of creating of more obvious type interface",
|
||||||
|
ReplaceWith("MessageAction", "com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction")
|
||||||
|
|
||||||
interface ByMessageId : ChatRequest {
|
)
|
||||||
val messageId: MessageIdentifier
|
typealias ByMessageId = MessageAction
|
||||||
}
|
|
@ -0,0 +1,7 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineMessageIdentifier
|
||||||
|
|
||||||
|
interface InlineMessageAction {
|
||||||
|
val inlineMessageId: InlineMessageIdentifier
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
|
|
||||||
|
interface MessageAction: ChatRequest {
|
||||||
|
val messageId: MessageIdentifier
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests
|
package com.github.insanusmokrassar.TelegramBotAPI.requests
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
@ -8,10 +9,10 @@ import kotlinx.serialization.internal.BooleanSerializer
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class DeleteMessage(
|
data class DeleteMessage(
|
||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
val chatId: ChatIdentifier,
|
override val chatId: ChatIdentifier,
|
||||||
@SerialName(messageIdField)
|
@SerialName(messageIdField)
|
||||||
val messageId: MessageIdentifier
|
override val messageId: MessageIdentifier
|
||||||
) : SimpleRequest<Boolean> {
|
) : SimpleRequest<Boolean>, MessageAction {
|
||||||
override fun method(): String = "deleteMessage"
|
override fun method(): String = "deleteMessage"
|
||||||
|
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests
|
package com.github.insanusmokrassar.TelegramBotAPI.requests
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||||
@ -12,10 +13,14 @@ data class ForwardMessage(
|
|||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
val toChatId: ChatIdentifier,
|
val toChatId: ChatIdentifier,
|
||||||
@SerialName(messageIdField)
|
@SerialName(messageIdField)
|
||||||
val messageId: MessageIdentifier,
|
override val messageId: MessageIdentifier,
|
||||||
@SerialName(disableNotificationField)
|
@SerialName(disableNotificationField)
|
||||||
val disableNotification: Boolean = false
|
val disableNotification: Boolean = false
|
||||||
): SimpleRequest<RawMessage> {
|
): SimpleRequest<RawMessage>, MessageAction {
|
||||||
|
@Transient
|
||||||
|
override val chatId: ChatIdentifier
|
||||||
|
get() = fromChatId
|
||||||
|
|
||||||
override fun method(): String = "forwardMessage"
|
override fun method(): String = "forwardMessage"
|
||||||
|
|
||||||
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.requests
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ReplyMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class StopPoll(
|
||||||
|
@SerialName(chatIdField)
|
||||||
|
override val chatId: ChatIdentifier,
|
||||||
|
@SerialName(messageIdField)
|
||||||
|
override val messageId: MessageIdentifier,
|
||||||
|
@SerialName(replyMarkupField)
|
||||||
|
override val replyMarkup: InlineKeyboardMarkup?
|
||||||
|
) : MessageAction, SimpleRequest<Poll>, ReplyMarkup {
|
||||||
|
override fun method(): String = "stopPoll"
|
||||||
|
override fun resultSerializer(): KSerializer<Poll> = Poll.serializer()
|
||||||
|
}
|
@ -1,7 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.chat.modify
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ChatRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.DisableNotification
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
@ -12,10 +11,10 @@ data class PinChatMessage (
|
|||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
override val chatId: ChatIdentifier,
|
override val chatId: ChatIdentifier,
|
||||||
@SerialName(messageIdField)
|
@SerialName(messageIdField)
|
||||||
val messageId: MessageIdentifier,
|
override val messageId: MessageIdentifier,
|
||||||
@SerialName(disableNotificationField)
|
@SerialName(disableNotificationField)
|
||||||
override val disableNotification: Boolean = false
|
override val disableNotification: Boolean = false
|
||||||
): ChatRequest, SimpleRequest<Boolean>, DisableNotification {
|
): ChatRequest, SimpleRequest<Boolean>, MessageAction, DisableNotification {
|
||||||
override fun method(): String = "pinChatMessage"
|
override fun method(): String = "pinChatMessage"
|
||||||
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
override fun resultSerializer(): KSerializer<Boolean> = BooleanSerializer
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.edit.abstracts
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||||
|
|
||||||
interface EditChatMessage : SimpleRequest<RawMessage> {
|
interface EditChatMessage : SimpleRequest<RawMessage>, MessageAction
|
||||||
val chatId: ChatIdentifier
|
|
||||||
val messageId: MessageIdentifier
|
|
||||||
}
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.games
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.games
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ByMessageId
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.GetGameHighScores
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.GetGameHighScores
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
@ -14,4 +14,4 @@ data class GetGameHighScoresByChat (
|
|||||||
override val chatId: ChatId,
|
override val chatId: ChatId,
|
||||||
@SerialName(messageIdField)
|
@SerialName(messageIdField)
|
||||||
override val messageId: MessageIdentifier
|
override val messageId: MessageIdentifier
|
||||||
) : GetGameHighScores, ByMessageId
|
) : GetGameHighScores, MessageAction
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.games
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.games
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ByInlineMessageId
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.InlineMessageAction
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.GetGameHighScores
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.GetGameHighScores
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
@ -12,4 +12,4 @@ data class GetGameHighScoresByInlineMessageId (
|
|||||||
override val userId: UserId,
|
override val userId: UserId,
|
||||||
@SerialName(inlineMessageIdField)
|
@SerialName(inlineMessageIdField)
|
||||||
override val inlineMessageId: InlineMessageIdentifier
|
override val inlineMessageId: InlineMessageIdentifier
|
||||||
) : GetGameHighScores, ByInlineMessageId
|
) : GetGameHighScores, InlineMessageAction
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.games
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.games
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ByMessageId
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.MessageAction
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.SetGameScore
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.SetGameScore
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
@ -20,4 +20,4 @@ data class SetGameScoreByChatId (
|
|||||||
override val force: Boolean = false,
|
override val force: Boolean = false,
|
||||||
@SerialName(disableEditMessageField)
|
@SerialName(disableEditMessageField)
|
||||||
override val disableEditMessage: Boolean = false
|
override val disableEditMessage: Boolean = false
|
||||||
) : SetGameScore, ByMessageId
|
) : SetGameScore, MessageAction
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.games
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.games
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.ByInlineMessageId
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.types.InlineMessageAction
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.SetGameScore
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.games.abstracts.SetGameScore
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
@ -18,4 +18,4 @@ data class SetGameScoreByInlineMessageId (
|
|||||||
override val force: Boolean = false,
|
override val force: Boolean = false,
|
||||||
@SerialName(disableEditMessageField)
|
@SerialName(disableEditMessageField)
|
||||||
override val disableEditMessage: Boolean = false
|
override val disableEditMessage: Boolean = false
|
||||||
) : SetGameScore, ByInlineMessageId
|
) : SetGameScore, InlineMessageAction
|
||||||
|
@ -0,0 +1,45 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.send
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.ReplyingMarkupSendMessageRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||||
|
import kotlinx.serialization.KSerializer
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class SendPoll(
|
||||||
|
@SerialName(chatIdField)
|
||||||
|
override val chatId: ChatIdentifier,
|
||||||
|
@SerialName(questionField)
|
||||||
|
val question: String,
|
||||||
|
@SerialName(optionsField)
|
||||||
|
val options: List<String>,
|
||||||
|
@SerialName(disableNotificationField)
|
||||||
|
override val disableNotification: Boolean = false,
|
||||||
|
@SerialName(replyToMessageIdField)
|
||||||
|
override val replyToMessageId: MessageIdentifier? = null,
|
||||||
|
@SerialName(replyMarkupField)
|
||||||
|
override val replyMarkup: KeyboardMarkup? = null
|
||||||
|
) : SendMessageRequest<RawMessage>,
|
||||||
|
ReplyingMarkupSendMessageRequest<RawMessage> {
|
||||||
|
|
||||||
|
init {
|
||||||
|
if (question.length !in pollQuestionTextLength) {
|
||||||
|
throw IllegalArgumentException("The length of questions for polls must be in $pollQuestionTextLength range, but was ${question.length}")
|
||||||
|
}
|
||||||
|
options.forEach {
|
||||||
|
if (it.length !in pollOptionTextLength) {
|
||||||
|
throw IllegalArgumentException("The length of question option text for polls must be in $pollOptionTextLength range, but was ${it.length}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (options.size !in pollOptionsLimit) {
|
||||||
|
throw IllegalArgumentException("The amount of question options for polls must be in $pollOptionsLimit range, but was ${options.size}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun method(): String = "sendPoll"
|
||||||
|
override fun resultSerializer(): KSerializer<RawMessage> = RawMessage.serializer()
|
||||||
|
}
|
@ -26,6 +26,8 @@ data class RawChatMember(
|
|||||||
private val canPinMessages: Boolean = false,
|
private val canPinMessages: Boolean = false,
|
||||||
@SerialName(canPromoteMembersField)
|
@SerialName(canPromoteMembersField)
|
||||||
private val canPromoteMembers: Boolean = false,
|
private val canPromoteMembers: Boolean = false,
|
||||||
|
@SerialName(isMemberField)
|
||||||
|
private val isMember: Boolean = false,
|
||||||
@SerialName(canSendMessagesField)
|
@SerialName(canSendMessagesField)
|
||||||
private val canSendMessages: Boolean = false,
|
private val canSendMessages: Boolean = false,
|
||||||
@SerialName(canSendMediaMessagesField)
|
@SerialName(canSendMediaMessagesField)
|
||||||
@ -55,6 +57,7 @@ data class RawChatMember(
|
|||||||
"restricted" -> RestrictedChatMember(
|
"restricted" -> RestrictedChatMember(
|
||||||
user,
|
user,
|
||||||
until_date,
|
until_date,
|
||||||
|
isMember,
|
||||||
canSendMessages,
|
canSendMessages,
|
||||||
canSendMediaMessages,
|
canSendMediaMessages,
|
||||||
canSendOtherMessages,
|
canSendOtherMessages,
|
||||||
|
@ -6,6 +6,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.User
|
|||||||
data class RestrictedChatMember(
|
data class RestrictedChatMember(
|
||||||
override val user: User,
|
override val user: User,
|
||||||
override val untilDate: TelegramDate?,
|
override val untilDate: TelegramDate?,
|
||||||
|
val isMember: Boolean,
|
||||||
val canSendMessages: Boolean,
|
val canSendMessages: Boolean,
|
||||||
val canSendMediaMessages: Boolean,
|
val canSendMediaMessages: Boolean,
|
||||||
val canSendOtherMessages: Boolean,
|
val canSendOtherMessages: Boolean,
|
||||||
|
@ -6,6 +6,7 @@ typealias InlineQueryIdentifier = String
|
|||||||
typealias UpdateIdentifier = Long
|
typealias UpdateIdentifier = Long
|
||||||
typealias MediaGroupIdentifier = String
|
typealias MediaGroupIdentifier = String
|
||||||
typealias ForwardSignature = String
|
typealias ForwardSignature = String
|
||||||
|
typealias ForwardSenderName = String
|
||||||
typealias AuthorSignature = ForwardSignature
|
typealias AuthorSignature = ForwardSignature
|
||||||
typealias CallbackQueryIdentifier = String
|
typealias CallbackQueryIdentifier = String
|
||||||
typealias PaymentQueryIdentifier = String
|
typealias PaymentQueryIdentifier = String
|
||||||
@ -15,6 +16,7 @@ typealias InvoicePayload = String
|
|||||||
typealias ShippingOptionIdentifier = String
|
typealias ShippingOptionIdentifier = String
|
||||||
typealias StartParameter = String
|
typealias StartParameter = String
|
||||||
typealias InlineMessageIdentifier = String
|
typealias InlineMessageIdentifier = String
|
||||||
|
typealias PollIdentifier = String
|
||||||
|
|
||||||
val callbackQueryAnswerLength = 0 until 200
|
val callbackQueryAnswerLength = 0 until 200
|
||||||
val captionLength = 0 until 1024
|
val captionLength = 0 until 1024
|
||||||
@ -29,6 +31,10 @@ val invoiceTitleLimit = 1 until 32
|
|||||||
val invoiceDescriptionLimit = 1 until 256
|
val invoiceDescriptionLimit = 1 until 256
|
||||||
val invoicePayloadBytesLimit = 1 until 128
|
val invoicePayloadBytesLimit = 1 until 128
|
||||||
|
|
||||||
|
val pollOptionTextLength = 1 .. 100
|
||||||
|
val pollQuestionTextLength = 1 until 256
|
||||||
|
val pollOptionsLimit = 2 .. 10
|
||||||
|
|
||||||
val livePeriodLimit = 60 .. 86400
|
val livePeriodLimit = 60 .. 86400
|
||||||
|
|
||||||
val inlineQueryAnswerResultsLimit = 0 .. 50
|
val inlineQueryAnswerResultsLimit = 0 .. 50
|
||||||
@ -75,6 +81,8 @@ const val hasCustomCertificateField = "has_custom_certificate"
|
|||||||
const val pendingUpdateCountField = "pending_update_count"
|
const val pendingUpdateCountField = "pending_update_count"
|
||||||
const val lastErrorDateField = "last_error_date"
|
const val lastErrorDateField = "last_error_date"
|
||||||
const val lastErrorMessageField = "last_error_message"
|
const val lastErrorMessageField = "last_error_message"
|
||||||
|
const val votesCountField = "voter_count"
|
||||||
|
const val isClosedField = "is_closed"
|
||||||
|
|
||||||
|
|
||||||
const val photoUrlField = "photo_url"
|
const val photoUrlField = "photo_url"
|
||||||
@ -124,6 +132,7 @@ const val inputMessageContentField = "input_message_content"
|
|||||||
const val hideUrlField = "hide_url"
|
const val hideUrlField = "hide_url"
|
||||||
|
|
||||||
|
|
||||||
|
const val isMemberField = "is_member"
|
||||||
const val canSendMessagesField = "can_send_messages"
|
const val canSendMessagesField = "can_send_messages"
|
||||||
const val canSendMediaMessagesField = "can_send_media_messages"
|
const val canSendMediaMessagesField = "can_send_media_messages"
|
||||||
const val canSendOtherMessagesField = "can_send_other_messages"
|
const val canSendOtherMessagesField = "can_send_other_messages"
|
||||||
@ -180,6 +189,8 @@ const val payloadField = "payload"
|
|||||||
const val vcardField = "vcard"
|
const val vcardField = "vcard"
|
||||||
const val resultsField = "results"
|
const val resultsField = "results"
|
||||||
const val certificateField = "certificate"
|
const val certificateField = "certificate"
|
||||||
|
const val questionField = "question"
|
||||||
|
const val optionsField = "options"
|
||||||
|
|
||||||
const val pointField = "point"
|
const val pointField = "point"
|
||||||
const val xShiftField = "x_shift"
|
const val xShiftField = "x_shift"
|
||||||
|
@ -4,7 +4,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.mediaField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.mediaField
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class InputMediaAnimation(
|
data class InputMediaAnimation(
|
||||||
|
@ -4,7 +4,8 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.parseModeField
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.mediaField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.mediaField
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class InputMediaDocument(
|
data class InputMediaDocument(
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.chat
|
package com.github.insanusmokrassar.TelegramBotAPI.types.chat
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||||
|
|
||||||
data class ChannelChat(
|
data class ChannelChat(
|
||||||
override val id: ChatId,
|
override val id: ChatId,
|
||||||
override val title: String? = null,
|
override val title: String? = null,
|
||||||
val username: Username? = null,
|
override val username: Username? = null,
|
||||||
val description: String? = null,
|
override val description: String? = null,
|
||||||
override val inviteLink: String? = null,
|
override val inviteLink: String? = null,
|
||||||
override val chatPhoto: ChatPhoto? = null,
|
override val chatPhoto: ChatPhoto? = null,
|
||||||
val pinnedMessage: RawMessage?
|
override val pinnedMessage: RawMessage?
|
||||||
) : PublicChat
|
) : PublicChat, UsernameChat, DescriptionChat
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.chat
|
package com.github.insanusmokrassar.TelegramBotAPI.types.chat
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatId
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatPhoto
|
|
||||||
|
|
||||||
interface Chat {
|
@Deprecated(
|
||||||
val id: ChatId
|
"Replaced into another package",
|
||||||
val chatPhoto: ChatPhoto?
|
ReplaceWith("Chat", "com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat")
|
||||||
}
|
)
|
||||||
|
typealias Chat = Chat
|
@ -1,15 +1,9 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.chat
|
package com.github.insanusmokrassar.TelegramBotAPI.types.chat
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatId
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.GroupChat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatPhoto
|
|
||||||
|
|
||||||
interface GroupChat : PublicChat {
|
@Deprecated(
|
||||||
val allMembersAreAdmins: Boolean
|
"Replaced into another package",
|
||||||
}
|
ReplaceWith("GroupChat", "com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.GroupChat")
|
||||||
|
)
|
||||||
data class GroupChatImpl(
|
typealias GroupChat = GroupChat
|
||||||
override val id: ChatId,
|
|
||||||
override val title: String? = null,
|
|
||||||
override val allMembersAreAdmins: Boolean,
|
|
||||||
override val inviteLink: String? = null,
|
|
||||||
override val chatPhoto: ChatPhoto? = null) : GroupChat
|
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.chat
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatId
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatPhoto
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.GroupChat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||||
|
|
||||||
|
data class GroupChatImpl(
|
||||||
|
override val id: ChatId,
|
||||||
|
override val title: String? = null,
|
||||||
|
override val allMembersAreAdmins: Boolean,
|
||||||
|
override val inviteLink: String? = null,
|
||||||
|
override val chatPhoto: ChatPhoto? = null,
|
||||||
|
override val pinnedMessage: RawMessage? = null
|
||||||
|
) : GroupChat
|
@ -1,11 +1,13 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.chat
|
package com.github.insanusmokrassar.TelegramBotAPI.types.chat
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.UsernameChat
|
||||||
|
|
||||||
data class PrivateChat(
|
data class PrivateChat(
|
||||||
override val id: ChatId,
|
override val id: ChatId,
|
||||||
val username: Username? = null,
|
override val username: Username? = null,
|
||||||
val firstName: String? = null,
|
val firstName: String? = null,
|
||||||
val lastName: String? = null,
|
val lastName: String? = null,
|
||||||
override val chatPhoto: ChatPhoto? = null
|
override val chatPhoto: ChatPhoto? = null
|
||||||
) : Chat
|
) : Chat, UsernameChat
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.chat
|
package com.github.insanusmokrassar.TelegramBotAPI.types.chat
|
||||||
|
|
||||||
interface PublicChat : Chat {
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat
|
||||||
val title: String?
|
|
||||||
val inviteLink: String?
|
@Deprecated(
|
||||||
}
|
"Replaced into another package",
|
||||||
|
ReplaceWith("PublicChat", "com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PublicChat")
|
||||||
|
)
|
||||||
|
typealias PublicChat = PublicChat
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.chat
|
package com.github.insanusmokrassar.TelegramBotAPI.types.chat
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
@ -1,17 +1,19 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.chat
|
package com.github.insanusmokrassar.TelegramBotAPI.types.chat
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.GroupChat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||||
|
|
||||||
data class SupergroupChat(
|
data class SupergroupChat(
|
||||||
override val id: ChatId,
|
override val id: ChatId,
|
||||||
override val title: String? = null,
|
override val title: String? = null,
|
||||||
val username: Username? = null,
|
override val username: Username? = null,
|
||||||
val description: String? = null,
|
override val description: String? = null,
|
||||||
override val allMembersAreAdmins: Boolean,
|
override val allMembersAreAdmins: Boolean,
|
||||||
override val inviteLink: String? = null,
|
override val inviteLink: String? = null,
|
||||||
override val chatPhoto: ChatPhoto? = null,
|
override val chatPhoto: ChatPhoto? = null,
|
||||||
val pinnedMessage: RawMessage? = null,
|
override val pinnedMessage: RawMessage? = null,
|
||||||
val stickerSetName: String? = null,
|
val stickerSetName: String? = null,
|
||||||
val canSetStickerSet: Boolean
|
val canSetStickerSet: Boolean
|
||||||
) : GroupChat
|
) : GroupChat, UsernameChat, DescriptionChat
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatId
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatPhoto
|
||||||
|
|
||||||
|
interface Chat {
|
||||||
|
val id: ChatId
|
||||||
|
val chatPhoto: ChatPhoto?
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts
|
||||||
|
|
||||||
|
interface DescriptionChat : PublicChat {
|
||||||
|
val description: String?
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts
|
||||||
|
|
||||||
|
interface GroupChat : PublicChat {
|
||||||
|
val allMembersAreAdmins: Boolean
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||||
|
|
||||||
|
interface PublicChat : Chat {
|
||||||
|
val title: String?
|
||||||
|
val inviteLink: String?
|
||||||
|
val pinnedMessage: RawMessage?
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.Username
|
||||||
|
|
||||||
|
interface UsernameChat : Chat {
|
||||||
|
val username: Username?
|
||||||
|
}
|
@ -2,7 +2,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message
|
|||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MediaGroupIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MediaGroupIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.Chat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaGroupMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaGroupMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaGroupContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaGroupContent
|
||||||
|
@ -2,7 +2,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message
|
|||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.AuthorSignature
|
import com.github.insanusmokrassar.TelegramBotAPI.types.AuthorSignature
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.Chat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.CommonMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.CommonMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.message
|
package com.github.insanusmokrassar.TelegramBotAPI.types.message
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.Chat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaGroupContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaGroupContent
|
||||||
import org.joda.time.DateTime
|
import org.joda.time.DateTime
|
||||||
|
@ -2,7 +2,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message
|
|||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.User
|
import com.github.insanusmokrassar.TelegramBotAPI.types.User
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.Chat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.abstracts.PaymentInfo
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.abstracts.PaymentInfo
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.message
|
package com.github.insanusmokrassar.TelegramBotAPI.types.message
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.Chat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
|
|
||||||
sealed class ForwardedMessage {
|
sealed class ForwardedMessage {
|
||||||
abstract val messageId: MessageIdentifier
|
|
||||||
abstract val dateOfOriginal: TelegramDate
|
abstract val dateOfOriginal: TelegramDate
|
||||||
|
}
|
||||||
|
|
||||||
|
data class AnonymousForwardedMessage(
|
||||||
|
override val dateOfOriginal: TelegramDate,
|
||||||
|
val senderName: String
|
||||||
|
) : ForwardedMessage()
|
||||||
|
|
||||||
|
sealed class PublicForwardedMessage : ForwardedMessage() {
|
||||||
|
abstract val messageId: MessageIdentifier
|
||||||
abstract val from: User?
|
abstract val from: User?
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -13,7 +21,7 @@ data class CommonForwardedMessage(
|
|||||||
override val messageId: MessageIdentifier,
|
override val messageId: MessageIdentifier,
|
||||||
override val dateOfOriginal: TelegramDate,
|
override val dateOfOriginal: TelegramDate,
|
||||||
override val from: User
|
override val from: User
|
||||||
) : ForwardedMessage()
|
) : PublicForwardedMessage()
|
||||||
|
|
||||||
data class ForwardedFromChannelMessage(
|
data class ForwardedFromChannelMessage(
|
||||||
override val messageId: MessageIdentifier,
|
override val messageId: MessageIdentifier,
|
||||||
@ -21,4 +29,4 @@ data class ForwardedFromChannelMessage(
|
|||||||
override val from: User?,
|
override val from: User?,
|
||||||
val channelChat: Chat,
|
val channelChat: Chat,
|
||||||
val signature: String? = null
|
val signature: String? = null
|
||||||
) : ForwardedMessage()
|
) : PublicForwardedMessage()
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.message
|
package com.github.insanusmokrassar.TelegramBotAPI.types.message
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.GroupChat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.GroupChat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.ChatEvents.abstracts.GroupEvent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.ChatEvents.abstracts.GroupEvent
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ChatEventMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ChatEventMessage
|
||||||
import org.joda.time.DateTime
|
import org.joda.time.DateTime
|
||||||
|
@ -4,6 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.RawMessageEntities
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.RawMessageEntities
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.RawMessageEntitiesSerializer
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.RawMessageEntitiesSerializer
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.GroupChat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.games.Game
|
import com.github.insanusmokrassar.TelegramBotAPI.types.games.Game
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.ChatEvents.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.ChatEvents.*
|
||||||
@ -17,6 +18,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.Success
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.abstracts.PaymentInfo
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.abstracts.PaymentInfo
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.Invoice
|
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.Invoice
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.SuccessfulPayment
|
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.SuccessfulPayment
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
@ -35,6 +37,7 @@ data class RawMessage(
|
|||||||
private val forward_from_chat: RawChat? = null,
|
private val forward_from_chat: RawChat? = null,
|
||||||
private val forward_from_message_id: MessageIdentifier? = null,
|
private val forward_from_message_id: MessageIdentifier? = null,
|
||||||
private val forward_signature: ForwardSignature? = null,
|
private val forward_signature: ForwardSignature? = null,
|
||||||
|
private val forward_sender_name: ForwardSenderName? = null,
|
||||||
private val forward_date: TelegramDate? = null,
|
private val forward_date: TelegramDate? = null,
|
||||||
private val reply_to_message: RawMessage? = null,
|
private val reply_to_message: RawMessage? = null,
|
||||||
private val edit_date: TelegramDate? = null,
|
private val edit_date: TelegramDate? = null,
|
||||||
@ -59,6 +62,7 @@ data class RawMessage(
|
|||||||
private val contact: Contact? = null,
|
private val contact: Contact? = null,
|
||||||
private val location: Location? = null,
|
private val location: Location? = null,
|
||||||
private val venue: Venue? = null,
|
private val venue: Venue? = null,
|
||||||
|
private val poll: Poll? = null,
|
||||||
private val new_chat_members: List<User>? = null,
|
private val new_chat_members: List<User>? = null,
|
||||||
private val left_chat_member: User? = null,
|
private val left_chat_member: User? = null,
|
||||||
private val new_chat_title: String? = null,
|
private val new_chat_title: String? = null,
|
||||||
@ -122,14 +126,16 @@ data class RawMessage(
|
|||||||
contact != null -> ContactContent(contact)
|
contact != null -> ContactContent(contact)
|
||||||
location != null -> LocationContent(location)
|
location != null -> LocationContent(location)
|
||||||
venue != null -> VenueContent(venue)
|
venue != null -> VenueContent(venue)
|
||||||
|
poll != null -> PollContent(poll)
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
private val forwarded: ForwardedMessage? by lazy {
|
private val forwarded: ForwardedMessage? by lazy {
|
||||||
|
forward_date ?: return@lazy null // According to the documentation, now any forwarded message contains this field
|
||||||
forward_from_message_id ?.let {
|
forward_from_message_id ?.let {
|
||||||
forward_date ?: throw IllegalStateException("For forwarded messages date of original message declared as set up required")
|
forward_from ?: throw IllegalStateException("For common forwarded messages author of original message declared as set up required")
|
||||||
forward_from_chat ?.let {
|
forward_from_chat ?.let {
|
||||||
ForwardedFromChannelMessage(
|
ForwardedFromChannelMessage(
|
||||||
forward_from_message_id,
|
forward_from_message_id,
|
||||||
@ -142,7 +148,11 @@ data class RawMessage(
|
|||||||
forward_from_message_id,
|
forward_from_message_id,
|
||||||
forward_date,
|
forward_date,
|
||||||
forward_from
|
forward_from
|
||||||
?: throw IllegalStateException("For common forwarded messages author of original message declared as set up required")
|
)
|
||||||
|
} ?: forward_sender_name ?.let {
|
||||||
|
AnonymousForwardedMessage(
|
||||||
|
forward_date,
|
||||||
|
forward_sender_name
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts
|
package com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.Chat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
import org.joda.time.DateTime
|
import org.joda.time.DateTime
|
||||||
|
|
||||||
interface Message {
|
interface Message {
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.message.content
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendPoll
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll
|
||||||
|
|
||||||
|
data class PollContent(
|
||||||
|
val poll: Poll
|
||||||
|
) : MessageContent {
|
||||||
|
override fun createResend(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
disableNotification: Boolean,
|
||||||
|
replyToMessageId: MessageIdentifier?,
|
||||||
|
replyMarkup: KeyboardMarkup?
|
||||||
|
): Request<RawMessage> = SendPoll(
|
||||||
|
chatId,
|
||||||
|
poll.question,
|
||||||
|
poll.options.map { it.text },
|
||||||
|
disableNotification,
|
||||||
|
replyToMessageId,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.polls
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Poll(
|
||||||
|
@SerialName(idField)
|
||||||
|
val id: PollIdentifier,
|
||||||
|
@SerialName(questionField)
|
||||||
|
val question: String,
|
||||||
|
@SerialName(optionsField)
|
||||||
|
val options: List<PollOption>,
|
||||||
|
@SerialName(isClosedField)
|
||||||
|
val closed: Boolean = false
|
||||||
|
)
|
@ -0,0 +1,37 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.polls
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.textField
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.votesCountField
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
import kotlinx.serialization.internal.StringDescriptor
|
||||||
|
|
||||||
|
@Serializable(PollOptionSerializer::class)
|
||||||
|
sealed class PollOption {
|
||||||
|
abstract val text: String
|
||||||
|
abstract val votes: Int
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class AnonymousPollOption (
|
||||||
|
@SerialName(textField)
|
||||||
|
override val text: String,
|
||||||
|
@SerialName(votesCountField)
|
||||||
|
override val votes: Int
|
||||||
|
) : PollOption()
|
||||||
|
|
||||||
|
object PollOptionSerializer : KSerializer<PollOption> {
|
||||||
|
override val descriptor: SerialDescriptor = StringDescriptor.withName(PollOption::class.simpleName ?: "PollOption")
|
||||||
|
|
||||||
|
override fun deserialize(decoder: Decoder): PollOption = AnonymousPollOption.serializer().deserialize(
|
||||||
|
decoder
|
||||||
|
)
|
||||||
|
|
||||||
|
override fun serialize(encoder: Encoder, obj: PollOption) {
|
||||||
|
when (obj) {
|
||||||
|
is AnonymousPollOption -> AnonymousPollOption.serializer().serialize(
|
||||||
|
encoder,
|
||||||
|
obj
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.update
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
|
||||||
|
|
||||||
|
data class PollUpdate(
|
||||||
|
override val updateId: UpdateIdentifier,
|
||||||
|
override val data: Poll
|
||||||
|
) : Update
|
@ -7,6 +7,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.PreCheckoutQuery
|
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.PreCheckoutQuery
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.ShippingQuery
|
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.ShippingQuery
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.Poll
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.updateIdField
|
import com.github.insanusmokrassar.TelegramBotAPI.types.updateIdField
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
@ -25,7 +26,8 @@ data class RawUpdate constructor(
|
|||||||
private val chosen_inline_result: RawChosenInlineResult? = null,
|
private val chosen_inline_result: RawChosenInlineResult? = null,
|
||||||
private val callback_query: RawCallbackQuery? = null,
|
private val callback_query: RawCallbackQuery? = null,
|
||||||
private val shipping_query: ShippingQuery? = null,
|
private val shipping_query: ShippingQuery? = null,
|
||||||
private val pre_checkout_query: PreCheckoutQuery? = null
|
private val pre_checkout_query: PreCheckoutQuery? = null,
|
||||||
|
private val poll: Poll? = null
|
||||||
) {
|
) {
|
||||||
@Transient
|
@Transient
|
||||||
val asUpdate: Update by lazy {
|
val asUpdate: Update by lazy {
|
||||||
@ -40,6 +42,7 @@ data class RawUpdate constructor(
|
|||||||
callback_query != null -> CallbackQueryUpdate(updateId, callback_query.asCallbackQuery)
|
callback_query != null -> CallbackQueryUpdate(updateId, callback_query.asCallbackQuery)
|
||||||
shipping_query != null -> ShippingQueryUpdate(updateId, shipping_query)
|
shipping_query != null -> ShippingQueryUpdate(updateId, shipping_query)
|
||||||
pre_checkout_query != null -> PreCheckoutQueryUpdate(updateId, pre_checkout_query)
|
pre_checkout_query != null -> PreCheckoutQueryUpdate(updateId, pre_checkout_query)
|
||||||
|
poll != null -> PollUpdate(updateId, poll)
|
||||||
else -> throw IllegalArgumentException("Unsupported type of update")
|
else -> throw IllegalArgumentException("Unsupported type of update")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.utils
|
package com.github.insanusmokrassar.TelegramBotAPI.utils
|
||||||
|
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MediaGroupIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MediaGroupIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.Chat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.ForwardedMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.ForwardedMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate
|
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate
|
||||||
|
Loading…
Reference in New Issue
Block a user