1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-12-25 10:07:14 +00:00

update microutils and add banChatSenderChat and unbanChatSenderChat support

This commit is contained in:
InsanusMokrassar 2021-12-10 12:49:13 +06:00
parent 6c3425d5f9
commit 23f93075a4
8 changed files with 106 additions and 2 deletions

View File

@ -4,7 +4,7 @@
* `Common`:
* `Version`:
* `MicroUtils`: `0.8.2` -> `0.8.5`
* `MicroUtils`: `0.8.2` -> `0.8.6`
* `Utils`:
* Fix of `EntitiesBuilder#linkln`

View File

@ -12,7 +12,7 @@ klock_version=2.4.8
uuid_version=0.3.1
ktor_version=1.6.5
micro_utils_version=0.8.5
micro_utils_version=0.8.6
javax_activation_version=1.1.1

View File

@ -0,0 +1,27 @@
package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.BanChatMember
import dev.inmo.tgbotapi.requests.chat.members.BanChatSenderChat
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
suspend fun TelegramBot.banChatSenderChat(
chatId: ChatIdentifier,
senderChatId: ChatId
) = execute(BanChatSenderChat(chatId, senderChatId))
suspend fun TelegramBot.banChatSenderChat(
chat: PublicChat,
senderChatId: ChatId
) = banChatSenderChat(chat.id, senderChatId)
suspend fun TelegramBot.banChatSenderChat(
chatId: ChatId,
senderChat: PublicChat
) = banChatSenderChat(chatId, senderChat.id)
suspend fun TelegramBot.banChatSenderChat(
chat: PublicChat,
senderChat: PublicChat,
) = banChatSenderChat(chat.id, senderChat)

View File

@ -0,0 +1,26 @@
package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.*
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
suspend fun TelegramBot.unbanChatSenderChat(
chatId: ChatIdentifier,
senderChatId: ChatId
) = execute(UnbanChatSenderChat(chatId, senderChatId))
suspend fun TelegramBot.unbanChatSenderChat(
chat: PublicChat,
senderChatId: ChatId
) = unbanChatSenderChat(chat.id, senderChatId)
suspend fun TelegramBot.unbanChatSenderChat(
chatId: ChatId,
senderChat: PublicChat
) = unbanChatSenderChat(chatId, senderChat.id)
suspend fun TelegramBot.unbanChatSenderChat(
chat: PublicChat,
senderChat: PublicChat,
) = unbanChatSenderChat(chat.id, senderChat)

View File

@ -0,0 +1,10 @@
package dev.inmo.tgbotapi.requests.chat.abstracts
import dev.inmo.tgbotapi.CommonAbstracts.types.ChatRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.ChatId
import dev.inmo.tgbotapi.types.UserId
interface ChatSenderRequest : ChatRequest, SimpleRequest<Boolean> {
val senderChatId: ChatId
}

View File

@ -0,0 +1,20 @@
package dev.inmo.tgbotapi.requests.chat.members
import dev.inmo.tgbotapi.requests.chat.abstracts.ChatSenderRequest
import dev.inmo.tgbotapi.types.*
import kotlinx.serialization.*
import kotlinx.serialization.builtins.serializer
@Serializable
data class BanChatSenderChat(
@SerialName(chatIdField)
override val chatId: ChatIdentifier,
@SerialName(senderChatIdField)
override val senderChatId: ChatId
) : ChatSenderRequest {
override fun method(): String = "banChatSenderChat"
override val resultDeserializer: DeserializationStrategy<Boolean>
get() = Boolean.serializer()
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@ -0,0 +1,20 @@
package dev.inmo.tgbotapi.requests.chat.members
import dev.inmo.tgbotapi.requests.chat.abstracts.ChatSenderRequest
import dev.inmo.tgbotapi.types.*
import kotlinx.serialization.*
import kotlinx.serialization.builtins.serializer
@Serializable
data class UnbanChatSenderChat(
@SerialName(chatIdField)
override val chatId: ChatIdentifier,
@SerialName(senderChatIdField)
override val senderChatId: ChatId
) : ChatSenderRequest {
override fun method(): String = "unbanChatSenderChat"
override val resultDeserializer: DeserializationStrategy<Boolean>
get() = Boolean.serializer()
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@ -96,6 +96,7 @@ val telegramInlineModeGifPermittedMimeTypes by lazy {
}
const val chatIdField = "chat_id"
const val senderChatIdField = "sender_chat_id"
const val messageIdField = "message_id"
const val updateIdField = "update_id"
const val fromChatIdField = "from_chat_id"