mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-27 20:48:44 +00:00
voice chats functionality included
This commit is contained in:
parent
8cd3f91e9e
commit
80200d78ef
@ -31,7 +31,9 @@ data class PromoteChatMember(
|
|||||||
@SerialName(canPinMessagesField)
|
@SerialName(canPinMessagesField)
|
||||||
private val canPinMessages: Boolean? = null,
|
private val canPinMessages: Boolean? = null,
|
||||||
@SerialName(canPromoteMembersField)
|
@SerialName(canPromoteMembersField)
|
||||||
private val canPromoteMembers: Boolean? = null
|
private val canPromoteMembers: Boolean? = null,
|
||||||
|
@SerialName(canManageVoiceChatsField)
|
||||||
|
private val canManageVoiceChats: Boolean? = null
|
||||||
) : ChatMemberRequest<Boolean>, UntilDate {
|
) : ChatMemberRequest<Boolean>, UntilDate {
|
||||||
override fun method(): String = "promoteChatMember"
|
override fun method(): String = "promoteChatMember"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
|
@ -26,6 +26,8 @@ data class AdministratorChatMemberImpl(
|
|||||||
override val canPinMessages: Boolean = false,
|
override val canPinMessages: Boolean = false,
|
||||||
@SerialName(canPromoteMembersField)
|
@SerialName(canPromoteMembersField)
|
||||||
override val canPromoteMembers: Boolean = false,
|
override val canPromoteMembers: Boolean = false,
|
||||||
|
@SerialName(canManageVoiceChatsField)
|
||||||
|
override val canManageVoiceChats: Boolean = false,
|
||||||
@SerialName(isAnonymousField)
|
@SerialName(isAnonymousField)
|
||||||
override val isAnonymous: Boolean = false,
|
override val isAnonymous: Boolean = false,
|
||||||
@SerialName(customTitleField)
|
@SerialName(customTitleField)
|
||||||
|
@ -30,6 +30,8 @@ data class CreatorChatMember(
|
|||||||
override val canPinMessages: Boolean = true
|
override val canPinMessages: Boolean = true
|
||||||
@Transient
|
@Transient
|
||||||
override val canPromoteMembers: Boolean = true
|
override val canPromoteMembers: Boolean = true
|
||||||
|
@Transient
|
||||||
|
override val canManageVoiceChats: Boolean = true
|
||||||
@SerialName(statusField)
|
@SerialName(statusField)
|
||||||
@Required
|
@Required
|
||||||
private val type: String = "creator"
|
private val type: String = "creator"
|
||||||
|
@ -13,6 +13,7 @@ interface AdministratorChatMember : SpecialRightsChatMember {
|
|||||||
val canRemoveMessages: Boolean
|
val canRemoveMessages: Boolean
|
||||||
val canRestrictMembers: Boolean
|
val canRestrictMembers: Boolean
|
||||||
val canPromoteMembers: Boolean
|
val canPromoteMembers: Boolean
|
||||||
|
val canManageVoiceChats: Boolean
|
||||||
val isAnonymous: Boolean
|
val isAnonymous: Boolean
|
||||||
val customTitle: String?
|
val customTitle: String?
|
||||||
}
|
}
|
||||||
|
@ -239,6 +239,7 @@ const val canInviteUsersField = "can_invite_users"
|
|||||||
const val canRestrictMembersField = "can_restrict_members"
|
const val canRestrictMembersField = "can_restrict_members"
|
||||||
const val canPinMessagesField = "can_pin_messages"
|
const val canPinMessagesField = "can_pin_messages"
|
||||||
const val canPromoteMembersField = "can_promote_members"
|
const val canPromoteMembersField = "can_promote_members"
|
||||||
|
const val canManageVoiceChatsField = "can_manage_voice_chats"
|
||||||
const val pngStickerField = "png_sticker"
|
const val pngStickerField = "png_sticker"
|
||||||
const val tgsStickerField = "tgs_sticker"
|
const val tgsStickerField = "tgs_sticker"
|
||||||
|
|
||||||
@ -331,6 +332,7 @@ const val telegramPaymentChargeIdField = "telegram_payment_charge_id"
|
|||||||
const val providerPaymentChargeIdField = "provider_payment_charge_id"
|
const val providerPaymentChargeIdField = "provider_payment_charge_id"
|
||||||
const val providerTokenField = "provider_token"
|
const val providerTokenField = "provider_token"
|
||||||
const val providerDataField = "provider_data"
|
const val providerDataField = "provider_data"
|
||||||
|
const val usersField = "users"
|
||||||
|
|
||||||
const val requireNameField = "need_name"
|
const val requireNameField = "need_name"
|
||||||
const val requirePhoneNumberField = "need_phone_number"
|
const val requirePhoneNumberField = "need_phone_number"
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
package dev.inmo.tgbotapi.types.message.ChatEvents.abstracts
|
||||||
|
|
||||||
|
interface VoiceChatEvent : SupergroupEvent
|
@ -0,0 +1,18 @@
|
|||||||
|
package dev.inmo.tgbotapi.types.message.ChatEvents.voice
|
||||||
|
|
||||||
|
import com.soywiz.klock.TimeSpan
|
||||||
|
import com.soywiz.klock.seconds
|
||||||
|
import dev.inmo.tgbotapi.types.Seconds
|
||||||
|
import dev.inmo.tgbotapi.types.durationField
|
||||||
|
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.VoiceChatEvent
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class VoiceChatEnded(
|
||||||
|
@SerialName(durationField)
|
||||||
|
val duration: Seconds
|
||||||
|
) : VoiceChatEvent {
|
||||||
|
val timeSpan: TimeSpan
|
||||||
|
get() = TimeSpan(duration.seconds.milliseconds)
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package dev.inmo.tgbotapi.types.message.ChatEvents.voice
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.User
|
||||||
|
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.VoiceChatEvent
|
||||||
|
import dev.inmo.tgbotapi.types.usersField
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
class VoiceChatParticipantsInvited(
|
||||||
|
@SerialName(usersField)
|
||||||
|
val users: List<User> = emptyList()
|
||||||
|
) : VoiceChatEvent
|
@ -0,0 +1,7 @@
|
|||||||
|
package dev.inmo.tgbotapi.types.message.ChatEvents.voice
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.VoiceChatEvent
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
object VoiceChatStarted : VoiceChatEvent
|
@ -11,6 +11,7 @@ import dev.inmo.tgbotapi.types.games.RawGame
|
|||||||
import dev.inmo.tgbotapi.types.location.Location
|
import dev.inmo.tgbotapi.types.location.Location
|
||||||
import dev.inmo.tgbotapi.types.message.ChatEvents.*
|
import dev.inmo.tgbotapi.types.message.ChatEvents.*
|
||||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
|
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
|
||||||
|
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.*
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.UnknownMessageType
|
import dev.inmo.tgbotapi.types.message.abstracts.UnknownMessageType
|
||||||
import dev.inmo.tgbotapi.types.message.content.*
|
import dev.inmo.tgbotapi.types.message.content.*
|
||||||
@ -81,6 +82,11 @@ internal data class RawMessage(
|
|||||||
private val dice: Dice? = null,
|
private val dice: Dice? = null,
|
||||||
private val successful_payment: SuccessfulPayment? = null,
|
private val successful_payment: SuccessfulPayment? = null,
|
||||||
|
|
||||||
|
// Voice Chat Service Messages
|
||||||
|
private val voice_chat_started: VoiceChatStarted? = null,
|
||||||
|
private val voice_chat_ended: VoiceChatEnded? = null,
|
||||||
|
private val voice_chat_participants_invited: VoiceChatParticipantsInvited? = null,
|
||||||
|
|
||||||
// login property
|
// login property
|
||||||
private val connected_website: String? = null,
|
private val connected_website: String? = null,
|
||||||
|
|
||||||
@ -172,6 +178,9 @@ internal data class RawMessage(
|
|||||||
left_chat_member != null -> LeftChatMember(left_chat_member)
|
left_chat_member != null -> LeftChatMember(left_chat_member)
|
||||||
new_chat_title != null -> NewChatTitle(new_chat_title)
|
new_chat_title != null -> NewChatTitle(new_chat_title)
|
||||||
new_chat_photo != null -> NewChatPhoto(new_chat_photo.toList())
|
new_chat_photo != null -> NewChatPhoto(new_chat_photo.toList())
|
||||||
|
voice_chat_started != null -> voice_chat_started
|
||||||
|
voice_chat_ended != null -> voice_chat_ended
|
||||||
|
voice_chat_participants_invited != null -> voice_chat_participants_invited
|
||||||
delete_chat_photo -> DeleteChatPhoto()
|
delete_chat_photo -> DeleteChatPhoto()
|
||||||
group_chat_created -> GroupChatCreated(
|
group_chat_created -> GroupChatCreated(
|
||||||
migrate_to_chat_id
|
migrate_to_chat_id
|
||||||
|
@ -17,7 +17,8 @@ suspend fun TelegramBot.promoteChatMember(
|
|||||||
canInviteUsers: Boolean? = null,
|
canInviteUsers: Boolean? = null,
|
||||||
canRestrictMembers: Boolean? = null,
|
canRestrictMembers: Boolean? = null,
|
||||||
canPinMessages: Boolean? = null,
|
canPinMessages: Boolean? = null,
|
||||||
canPromoteMembers: Boolean? = null
|
canPromoteMembers: Boolean? = null,
|
||||||
|
canManageVoiceChats: Boolean? = null
|
||||||
) = execute(
|
) = execute(
|
||||||
PromoteChatMember(
|
PromoteChatMember(
|
||||||
chatId,
|
chatId,
|
||||||
@ -31,7 +32,8 @@ suspend fun TelegramBot.promoteChatMember(
|
|||||||
canInviteUsers,
|
canInviteUsers,
|
||||||
canRestrictMembers,
|
canRestrictMembers,
|
||||||
canPinMessages,
|
canPinMessages,
|
||||||
canPromoteMembers
|
canPromoteMembers,
|
||||||
|
canManageVoiceChats
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -47,7 +49,8 @@ suspend fun TelegramBot.promoteChatMember(
|
|||||||
canInviteUsers: Boolean? = null,
|
canInviteUsers: Boolean? = null,
|
||||||
canRestrictMembers: Boolean? = null,
|
canRestrictMembers: Boolean? = null,
|
||||||
canPinMessages: Boolean? = null,
|
canPinMessages: Boolean? = null,
|
||||||
canPromoteMembers: Boolean? = null
|
canPromoteMembers: Boolean? = null,
|
||||||
|
canManageVoiceChats: Boolean?
|
||||||
) = promoteChatMember(
|
) = promoteChatMember(
|
||||||
chat.id,
|
chat.id,
|
||||||
userId,
|
userId,
|
||||||
@ -60,7 +63,8 @@ suspend fun TelegramBot.promoteChatMember(
|
|||||||
canInviteUsers,
|
canInviteUsers,
|
||||||
canRestrictMembers,
|
canRestrictMembers,
|
||||||
canPinMessages,
|
canPinMessages,
|
||||||
canPromoteMembers
|
canPromoteMembers,
|
||||||
|
canManageVoiceChats
|
||||||
)
|
)
|
||||||
|
|
||||||
suspend fun TelegramBot.promoteChatMember(
|
suspend fun TelegramBot.promoteChatMember(
|
||||||
@ -75,7 +79,8 @@ suspend fun TelegramBot.promoteChatMember(
|
|||||||
canInviteUsers: Boolean? = null,
|
canInviteUsers: Boolean? = null,
|
||||||
canRestrictMembers: Boolean? = null,
|
canRestrictMembers: Boolean? = null,
|
||||||
canPinMessages: Boolean? = null,
|
canPinMessages: Boolean? = null,
|
||||||
canPromoteMembers: Boolean? = null
|
canPromoteMembers: Boolean? = null,
|
||||||
|
canManageVoiceChats: Boolean?
|
||||||
) = promoteChatMember(
|
) = promoteChatMember(
|
||||||
chatId,
|
chatId,
|
||||||
user.id,
|
user.id,
|
||||||
@ -88,7 +93,8 @@ suspend fun TelegramBot.promoteChatMember(
|
|||||||
canInviteUsers,
|
canInviteUsers,
|
||||||
canRestrictMembers,
|
canRestrictMembers,
|
||||||
canPinMessages,
|
canPinMessages,
|
||||||
canPromoteMembers
|
canPromoteMembers,
|
||||||
|
canManageVoiceChats
|
||||||
)
|
)
|
||||||
|
|
||||||
suspend fun TelegramBot.promoteChatMember(
|
suspend fun TelegramBot.promoteChatMember(
|
||||||
@ -103,7 +109,8 @@ suspend fun TelegramBot.promoteChatMember(
|
|||||||
canInviteUsers: Boolean? = null,
|
canInviteUsers: Boolean? = null,
|
||||||
canRestrictMembers: Boolean? = null,
|
canRestrictMembers: Boolean? = null,
|
||||||
canPinMessages: Boolean? = null,
|
canPinMessages: Boolean? = null,
|
||||||
canPromoteMembers: Boolean? = null
|
canPromoteMembers: Boolean? = null,
|
||||||
|
canManageVoiceChats: Boolean?
|
||||||
) = promoteChatMember(
|
) = promoteChatMember(
|
||||||
chat.id,
|
chat.id,
|
||||||
user.id,
|
user.id,
|
||||||
@ -116,5 +123,6 @@ suspend fun TelegramBot.promoteChatMember(
|
|||||||
canInviteUsers,
|
canInviteUsers,
|
||||||
canRestrictMembers,
|
canRestrictMembers,
|
||||||
canPinMessages,
|
canPinMessages,
|
||||||
canPromoteMembers
|
canPromoteMembers,
|
||||||
|
canManageVoiceChats
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user