mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 08:13:47 +00:00
add PossiblySentViaBotCommonMessage and fix error in build
This commit is contained in:
parent
ca784e67df
commit
ca4beee95f
@ -53,8 +53,10 @@
|
|||||||
|
|
||||||
* `TelegramBotAPI`:
|
* `TelegramBotAPI`:
|
||||||
* Interface `PossiblySentViaBot` has been added
|
* Interface `PossiblySentViaBot` has been added
|
||||||
* Currently, only `ChannelMessage` and `CommonMessageImpl` are implementing interface `PossiblySentViaBot`. It
|
* Additional interface `PossiblySentViaBotCommonMessage` was added for more explicit typing declaration for
|
||||||
could be changed in future
|
compiler
|
||||||
|
* Currently, only `ChannelMessage` and `CommonMessageImpl` are implementing the interface
|
||||||
|
`PossiblySentViaBotCommonMessage`. It could be changed in future
|
||||||
* Factory `buildMimeType` was added
|
* Factory `buildMimeType` was added
|
||||||
* `BuiltinMimeTypes` was added
|
* `BuiltinMimeTypes` was added
|
||||||
* Abstraction `ThumbedWithMimeTypeInlineQueryResult` with `thumbMimeType` field was added
|
* Abstraction `ThumbedWithMimeTypeInlineQueryResult` with `thumbMimeType` field was added
|
||||||
|
@ -5,6 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMa
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.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.content.abstracts.PossiblySentViaBotCommonMessage
|
||||||
import com.soywiz.klock.DateTime
|
import com.soywiz.klock.DateTime
|
||||||
|
|
||||||
data class ChannelMessage<T: MessageContent>(
|
data class ChannelMessage<T: MessageContent>(
|
||||||
@ -18,4 +19,4 @@ data class ChannelMessage<T: MessageContent>(
|
|||||||
override val replyMarkup: InlineKeyboardMarkup?,
|
override val replyMarkup: InlineKeyboardMarkup?,
|
||||||
override val senderBot: CommonBot?,
|
override val senderBot: CommonBot?,
|
||||||
val authorSignature: AuthorSignature?
|
val authorSignature: AuthorSignature?
|
||||||
) : CommonMessage<T>, PossiblySentViaBot
|
) : PossiblySentViaBotCommonMessage<T>
|
||||||
|
@ -5,6 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMa
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.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.content.abstracts.PossiblySentViaBotCommonMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.SuccessfulPaymentInfo
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.payments.SuccessfulPaymentInfo
|
||||||
import com.soywiz.klock.DateTime
|
import com.soywiz.klock.DateTime
|
||||||
|
|
||||||
@ -20,4 +21,4 @@ data class CommonMessageImpl<T: MessageContent>(
|
|||||||
override val replyMarkup: InlineKeyboardMarkup?,
|
override val replyMarkup: InlineKeyboardMarkup?,
|
||||||
override val senderBot: CommonBot?,
|
override val senderBot: CommonBot?,
|
||||||
val paymentInfo: SuccessfulPaymentInfo?
|
val paymentInfo: SuccessfulPaymentInfo?
|
||||||
) : Message, CommonMessage<T>, PossiblySentViaBot, FromUserMessage
|
) : PossiblySentViaBotCommonMessage<T>, FromUserMessage
|
@ -148,7 +148,7 @@ internal data class RawMessage(
|
|||||||
)
|
)
|
||||||
forward_from_chat is ChannelChat -> ForwardFromChannelInfo(
|
forward_from_chat is ChannelChat -> ForwardFromChannelInfo(
|
||||||
forward_date,
|
forward_date,
|
||||||
forward_from_message_id ?: throw IllegalStateException("Channel forwarded message must contain message id, but was not"),
|
forward_from_message_id ?: error("Channel forwarded message must contain message id, but was not"),
|
||||||
forward_from_chat,
|
forward_from_chat,
|
||||||
forward_signature
|
forward_signature
|
||||||
)
|
)
|
||||||
@ -209,7 +209,7 @@ internal data class RawMessage(
|
|||||||
chatEvent as? ChannelEvent ?: throwWrongChatEvent(ChannelEvent::class, chatEvent),
|
chatEvent as? ChannelEvent ?: throwWrongChatEvent(ChannelEvent::class, chatEvent),
|
||||||
date.asDate
|
date.asDate
|
||||||
)
|
)
|
||||||
else -> throw IllegalStateException("Expected one of the public chats, but was $chat (in extracting of chat event message)")
|
else -> error("Expected one of the public chats, but was $chat (in extracting of chat event message)")
|
||||||
}
|
}
|
||||||
} ?: content?.let { content ->
|
} ?: content?.let { content ->
|
||||||
media_group_id?.let {
|
media_group_id?.let {
|
||||||
@ -222,7 +222,7 @@ internal data class RawMessage(
|
|||||||
when (content) {
|
when (content) {
|
||||||
is PhotoContent -> content
|
is PhotoContent -> content
|
||||||
is VideoContent -> content
|
is VideoContent -> content
|
||||||
else -> throw IllegalStateException("Unsupported content for media group")
|
else -> error("Unsupported content for media group")
|
||||||
},
|
},
|
||||||
edit_date?.asDate,
|
edit_date?.asDate,
|
||||||
forwarded,
|
forwarded,
|
||||||
@ -238,7 +238,7 @@ internal data class RawMessage(
|
|||||||
when (content) {
|
when (content) {
|
||||||
is PhotoContent -> content
|
is PhotoContent -> content
|
||||||
is VideoContent -> content
|
is VideoContent -> content
|
||||||
else -> throw IllegalStateException("Unsupported content for media group")
|
else -> error("Unsupported content for media group")
|
||||||
},
|
},
|
||||||
edit_date?.asDate,
|
edit_date?.asDate,
|
||||||
forwarded,
|
forwarded,
|
||||||
@ -261,8 +261,7 @@ internal data class RawMessage(
|
|||||||
)
|
)
|
||||||
else -> CommonMessageImpl(
|
else -> CommonMessageImpl(
|
||||||
messageId,
|
messageId,
|
||||||
from
|
from ?: error("Was detected common message, but owner (sender) of the message was not found"),
|
||||||
?: throw IllegalStateException("Was detected common message, but owner (sender) of the message was not found"),
|
|
||||||
chat,
|
chat,
|
||||||
content,
|
content,
|
||||||
date.asDate,
|
date.asDate,
|
||||||
@ -274,7 +273,7 @@ internal data class RawMessage(
|
|||||||
paymentInfo
|
paymentInfo
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} ?: throw IllegalStateException("Was not found supported type of data")
|
} ?: error("Was not found supported type of data")
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
UnknownMessageType(
|
UnknownMessageType(
|
||||||
messageId,
|
messageId,
|
||||||
@ -286,6 +285,6 @@ internal data class RawMessage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun throwWrongChatEvent(expected: KClass<*>, but: ChatEvent): CommonEvent {
|
private fun throwWrongChatEvent(expected: KClass<*>, but: ChatEvent): CommonEvent {
|
||||||
throw IllegalStateException("Wrong type of chat event: expected $expected, but was $but")
|
error("Wrong type of chat event: expected $expected, but was $but")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.CommonMessage
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.PossiblySentViaBot
|
||||||
|
|
||||||
|
interface PossiblySentViaBotCommonMessage<T: MessageContent> : CommonMessage<T>, PossiblySentViaBot
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
|
|||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
|
||||||
|
Loading…
Reference in New Issue
Block a user