mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-27 20:48:44 +00:00
include ChatMemberUpdated functionality
This commit is contained in:
parent
2be342a769
commit
c027244fbd
@ -17,7 +17,7 @@ private data class RawChatInviteLink(
|
|||||||
@SerialName(isRevokedField)
|
@SerialName(isRevokedField)
|
||||||
val isRevoked: Boolean,
|
val isRevoked: Boolean,
|
||||||
@SerialName(expireDateField)
|
@SerialName(expireDateField)
|
||||||
val expirationDateTime: UnixTimeStamp? = null,
|
val expirationDateTime: TelegramDate? = null,
|
||||||
@SerialName(memberLimitField)
|
@SerialName(memberLimitField)
|
||||||
val membersLimit: MembersLimit ?= null
|
val membersLimit: MembersLimit ?= null
|
||||||
)
|
)
|
||||||
@ -27,7 +27,7 @@ private fun ChatInviteLink.toRawChatInviteLink() = RawChatInviteLink(
|
|||||||
creator,
|
creator,
|
||||||
isPrimary,
|
isPrimary,
|
||||||
isRevoked,
|
isRevoked,
|
||||||
expirationDateTime ?.unixMillis ?.milliseconds ?.seconds ?.toLong(),
|
expirationDateTime ?.toTelegramDate(),
|
||||||
membersLimit
|
membersLimit
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -50,16 +50,14 @@ data class PrimaryInviteLink(
|
|||||||
@SerialName(isRevokedField)
|
@SerialName(isRevokedField)
|
||||||
override val isRevoked: Boolean = false,
|
override val isRevoked: Boolean = false,
|
||||||
@SerialName(expireDateField)
|
@SerialName(expireDateField)
|
||||||
private val expireDate: UnixTimeStamp? = null,
|
private val expireDate: TelegramDate? = null,
|
||||||
@SerialName(memberLimitField)
|
@SerialName(memberLimitField)
|
||||||
override val membersLimit: MembersLimit? = null
|
override val membersLimit: MembersLimit? = null
|
||||||
) : ChatInviteLink() {
|
) : ChatInviteLink() {
|
||||||
override val isPrimary: Boolean
|
override val isPrimary: Boolean
|
||||||
get() = true
|
get() = true
|
||||||
override val expirationDateTime: DateTime?
|
override val expirationDateTime: DateTime?
|
||||||
get() {
|
get() = expireDate ?.asDate
|
||||||
return DateTime(expireDate ?.seconds ?.milliseconds ?: return null)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@ -71,16 +69,14 @@ data class CommonInviteLink(
|
|||||||
@SerialName(isRevokedField)
|
@SerialName(isRevokedField)
|
||||||
override val isRevoked: Boolean = false,
|
override val isRevoked: Boolean = false,
|
||||||
@SerialName(expireDateField)
|
@SerialName(expireDateField)
|
||||||
private val expireDate: UnixTimeStamp? = null,
|
private val expireDate: TelegramDate? = null,
|
||||||
@SerialName(memberLimitField)
|
@SerialName(memberLimitField)
|
||||||
override val membersLimit: MembersLimit? = null
|
override val membersLimit: MembersLimit? = null
|
||||||
) : ChatInviteLink() {
|
) : ChatInviteLink() {
|
||||||
override val isPrimary: Boolean
|
override val isPrimary: Boolean
|
||||||
get() = false
|
get() = false
|
||||||
override val expirationDateTime: DateTime?
|
override val expirationDateTime: DateTime?
|
||||||
get() {
|
get() = expireDate ?.asDate
|
||||||
return DateTime(expireDate ?.seconds ?.milliseconds ?: return null)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializer(ChatInviteLink::class)
|
@Serializer(ChatInviteLink::class)
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
package dev.inmo.tgbotapi.types
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.ChatMember.abstracts.ChatMember
|
||||||
|
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class ChatMemberUpdated(
|
||||||
|
@SerialName(chatField)
|
||||||
|
val chat: Chat,
|
||||||
|
@SerialName(fromField)
|
||||||
|
val user: User,
|
||||||
|
@SerialName(dateField)
|
||||||
|
val date: TelegramDate,
|
||||||
|
@SerialName(oldChatMemberField)
|
||||||
|
val oldChatMemberState: ChatMember,
|
||||||
|
@SerialName(newChatMemberField)
|
||||||
|
val newChatMemberState: ChatMember,
|
||||||
|
@SerialName(inviteLinkField)
|
||||||
|
val inviteLink: ChatInviteLink? = null
|
||||||
|
)
|
@ -253,6 +253,8 @@ const val canManageVoiceChatsField = "can_manage_voice_chats"
|
|||||||
const val canManageChatField = "can_manage_chat"
|
const val canManageChatField = "can_manage_chat"
|
||||||
const val pngStickerField = "png_sticker"
|
const val pngStickerField = "png_sticker"
|
||||||
const val tgsStickerField = "tgs_sticker"
|
const val tgsStickerField = "tgs_sticker"
|
||||||
|
const val oldChatMemberField = "old_chat_member"
|
||||||
|
const val newChatMemberField = "new_chat_member"
|
||||||
|
|
||||||
const val okField = "ok"
|
const val okField = "ok"
|
||||||
const val captionField = "caption"
|
const val captionField = "caption"
|
||||||
|
@ -11,6 +11,8 @@ const val UPDATE_SHIPPING_QUERY = "shipping_query"
|
|||||||
const val UPDATE_PRE_CHECKOUT_QUERY = "pre_checkout_query"
|
const val UPDATE_PRE_CHECKOUT_QUERY = "pre_checkout_query"
|
||||||
const val UPDATE_POLL = "poll"
|
const val UPDATE_POLL = "poll"
|
||||||
const val UPDATE_POLL_ANSWER = "poll_answer"
|
const val UPDATE_POLL_ANSWER = "poll_answer"
|
||||||
|
const val MY_CHAT_MEMBER = "my_chat_member"
|
||||||
|
const val CHAT_MEMBER = "chat_member"
|
||||||
|
|
||||||
val ALL_UPDATES_LIST = listOf(
|
val ALL_UPDATES_LIST = listOf(
|
||||||
UPDATE_MESSAGE,
|
UPDATE_MESSAGE,
|
||||||
@ -23,5 +25,7 @@ val ALL_UPDATES_LIST = listOf(
|
|||||||
UPDATE_SHIPPING_QUERY,
|
UPDATE_SHIPPING_QUERY,
|
||||||
UPDATE_PRE_CHECKOUT_QUERY,
|
UPDATE_PRE_CHECKOUT_QUERY,
|
||||||
UPDATE_POLL,
|
UPDATE_POLL,
|
||||||
UPDATE_POLL_ANSWER
|
UPDATE_POLL_ANSWER,
|
||||||
|
MY_CHAT_MEMBER,
|
||||||
|
CHAT_MEMBER
|
||||||
)
|
)
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
package dev.inmo.tgbotapi.types.update
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.ChatMemberUpdated
|
||||||
|
import dev.inmo.tgbotapi.types.UpdateIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.update.abstracts.ChatMemberUpdatedUpdate
|
||||||
|
|
||||||
|
data class CommonChatMemberUpdatedUpdate(
|
||||||
|
override val updateId: UpdateIdentifier,
|
||||||
|
override val data: ChatMemberUpdated
|
||||||
|
) : ChatMemberUpdatedUpdate
|
@ -0,0 +1,10 @@
|
|||||||
|
package dev.inmo.tgbotapi.types.update
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.ChatMemberUpdated
|
||||||
|
import dev.inmo.tgbotapi.types.UpdateIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.update.abstracts.ChatMemberUpdatedUpdate
|
||||||
|
|
||||||
|
data class MyChatMemberUpdatedUpdate(
|
||||||
|
override val updateId: UpdateIdentifier,
|
||||||
|
override val data: ChatMemberUpdated
|
||||||
|
) : ChatMemberUpdatedUpdate
|
@ -1,9 +1,9 @@
|
|||||||
package dev.inmo.tgbotapi.types.update
|
package dev.inmo.tgbotapi.types.update
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.CallbackQuery.RawCallbackQuery
|
import dev.inmo.tgbotapi.types.CallbackQuery.RawCallbackQuery
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.RawChosenInlineResult
|
import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.RawChosenInlineResult
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.query.RawInlineQuery
|
import dev.inmo.tgbotapi.types.InlineQueries.query.RawInlineQuery
|
||||||
import dev.inmo.tgbotapi.types.UpdateIdentifier
|
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.*
|
import dev.inmo.tgbotapi.types.message.abstracts.*
|
||||||
import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery
|
import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery
|
||||||
import dev.inmo.tgbotapi.types.payments.ShippingQuery
|
import dev.inmo.tgbotapi.types.payments.ShippingQuery
|
||||||
@ -11,7 +11,6 @@ import dev.inmo.tgbotapi.types.polls.Poll
|
|||||||
import dev.inmo.tgbotapi.types.polls.PollAnswer
|
import dev.inmo.tgbotapi.types.polls.PollAnswer
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.UnknownUpdate
|
import dev.inmo.tgbotapi.types.update.abstracts.UnknownUpdate
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
import dev.inmo.tgbotapi.types.updateIdField
|
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.json.JsonElement
|
import kotlinx.serialization.json.JsonElement
|
||||||
import kotlinx.serialization.json.jsonObject
|
import kotlinx.serialization.json.jsonObject
|
||||||
@ -34,7 +33,9 @@ internal data class RawUpdate constructor(
|
|||||||
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,
|
private val poll: Poll? = null,
|
||||||
private val poll_answer: PollAnswer? = null
|
private val poll_answer: PollAnswer? = null,
|
||||||
|
private val my_chat_member: ChatMemberUpdated? = null,
|
||||||
|
private val chat_member: ChatMemberUpdated? = null
|
||||||
) {
|
) {
|
||||||
private var initedUpdate: Update? = null
|
private var initedUpdate: Update? = null
|
||||||
/**
|
/**
|
||||||
@ -58,6 +59,8 @@ internal data class RawUpdate constructor(
|
|||||||
pre_checkout_query != null -> PreCheckoutQueryUpdate(updateId, pre_checkout_query)
|
pre_checkout_query != null -> PreCheckoutQueryUpdate(updateId, pre_checkout_query)
|
||||||
poll != null -> PollUpdate(updateId, poll)
|
poll != null -> PollUpdate(updateId, poll)
|
||||||
poll_answer != null -> PollAnswerUpdate(updateId, poll_answer)
|
poll_answer != null -> PollAnswerUpdate(updateId, poll_answer)
|
||||||
|
my_chat_member != null -> MyChatMemberUpdatedUpdate(updateId, my_chat_member)
|
||||||
|
chat_member != null -> CommonChatMemberUpdatedUpdate(updateId, chat_member)
|
||||||
else -> UnknownUpdate(
|
else -> UnknownUpdate(
|
||||||
updateId,
|
updateId,
|
||||||
raw.toString(),
|
raw.toString(),
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
package dev.inmo.tgbotapi.types.update.abstracts
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.ChatMemberUpdated
|
||||||
|
|
||||||
|
interface ChatMemberUpdatedUpdate : Update {
|
||||||
|
override val data: ChatMemberUpdated
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user