1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 00:03:48 +00:00

add support for businessConnectionId in stopPoll

This commit is contained in:
InsanusMokrassar 2024-06-23 15:23:58 +06:00
parent 02a404b805
commit af79e26855
2 changed files with 14 additions and 5 deletions

View File

@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.extensions.api
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.StopPoll
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
@ -14,9 +15,10 @@ import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
suspend fun TelegramBot.stopPoll(
chatId: ChatIdentifier,
messageId: MessageId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(
StopPoll(chatId, messageId, replyMarkup)
StopPoll(chatId, messageId, businessConnectionId, replyMarkup)
)
/**
@ -26,8 +28,9 @@ suspend fun TelegramBot.stopPoll(
suspend fun TelegramBot.stopPoll(
chat: Chat,
messageId: MessageId,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
replyMarkup: InlineKeyboardMarkup? = null
) = stopPoll(chat.id, messageId, replyMarkup)
) = stopPoll(chat.id, messageId, businessConnectionId, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
@ -36,8 +39,9 @@ suspend fun TelegramBot.stopPoll(
suspend fun TelegramBot.stopPoll(
chatId: IdChatIdentifier,
message: AccessibleMessage,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
replyMarkup: InlineKeyboardMarkup? = null
) = stopPoll(chatId, message.messageId, replyMarkup)
) = stopPoll(chatId, message.messageId, businessConnectionId, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
@ -46,5 +50,6 @@ suspend fun TelegramBot.stopPoll(
suspend fun TelegramBot.stopPoll(
chat: Chat,
message: AccessibleMessage,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
replyMarkup: InlineKeyboardMarkup? = null
) = stopPoll(chat.id, message.messageId, replyMarkup)
) = stopPoll(chat.id, message.messageId, businessConnectionId, replyMarkup)

View File

@ -1,9 +1,11 @@
package dev.inmo.tgbotapi.requests
import dev.inmo.tgbotapi.abstracts.types.MessageAction
import dev.inmo.tgbotapi.abstracts.types.OptionallyBusinessConnectionRequest
import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.polls.Poll
import dev.inmo.tgbotapi.types.polls.PollSerializer
@ -15,9 +17,11 @@ data class StopPoll(
override val chatId: ChatIdentifier,
@SerialName(messageIdField)
override val messageId: MessageId,
@SerialName(businessConnectionIdField)
override val businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
@SerialName(replyMarkupField)
override val replyMarkup: InlineKeyboardMarkup? = null
) : MessageAction, SimpleRequest<Poll>, WithReplyMarkup {
) : MessageAction, SimpleRequest<Poll>, WithReplyMarkup, OptionallyBusinessConnectionRequest {
override fun method(): String = "stopPoll"
override val resultDeserializer: DeserializationStrategy<Poll>
get() = PollSerializer