1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-26 12:08:43 +00:00

complete answers extensions

This commit is contained in:
InsanusMokrassar 2020-02-06 12:54:55 +06:00
parent 9c25254937
commit 2eb2d25662
4 changed files with 45 additions and 7 deletions

View File

@ -34,7 +34,7 @@ fun CallbackQuery.createAnswer(
cachedTimeSeconds: Int? = null cachedTimeSeconds: Int? = null
): AnswerCallbackQuery = AnswerCallbackQuery(id, text, showAlert, url, cachedTimeSeconds) ): AnswerCallbackQuery = AnswerCallbackQuery(id, text, showAlert, url, cachedTimeSeconds)
suspend fun RequestsExecutor.sendCallbackQueryAnswer( suspend fun RequestsExecutor.answerCallbackQuery(
callbackQueryId: CallbackQueryIdentifier, callbackQueryId: CallbackQueryIdentifier,
text: String? = null, text: String? = null,
showAlert: Boolean? = null, showAlert: Boolean? = null,
@ -42,10 +42,10 @@ suspend fun RequestsExecutor.sendCallbackQueryAnswer(
cachedTimeSeconds: Int? = null cachedTimeSeconds: Int? = null
) = execute(AnswerCallbackQuery(callbackQueryId, text, showAlert, url, cachedTimeSeconds)) ) = execute(AnswerCallbackQuery(callbackQueryId, text, showAlert, url, cachedTimeSeconds))
suspend fun RequestsExecutor.sendCallbackQueryAnswer( suspend fun RequestsExecutor.answerCallbackQuery(
callbackQuery: CallbackQuery, callbackQuery: CallbackQuery,
text: String? = null, text: String? = null,
showAlert: Boolean? = null, showAlert: Boolean? = null,
url: String? = null, url: String? = null,
cachedTimeSeconds: Int? = null cachedTimeSeconds: Int? = null
) = sendCallbackQueryAnswer(callbackQuery.id, text, showAlert, url, cachedTimeSeconds) ) = answerCallbackQuery(callbackQuery.id, text, showAlert, url, cachedTimeSeconds)

View File

@ -52,7 +52,7 @@ fun InlineQuery.createAnswer(
switchPmParameter switchPmParameter
) )
suspend fun RequestsExecutor.sendInlineQueryAnswer( suspend fun RequestsExecutor.answerInlineQuery(
inlineQueryID: InlineQueryIdentifier, inlineQueryID: InlineQueryIdentifier,
results: List<InlineQueryResult> = emptyList(), results: List<InlineQueryResult> = emptyList(),
cachedTime: Int? = null, cachedTime: Int? = null,
@ -64,7 +64,7 @@ suspend fun RequestsExecutor.sendInlineQueryAnswer(
AnswerInlineQuery(inlineQueryID, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter) AnswerInlineQuery(inlineQueryID, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)
) )
suspend fun RequestsExecutor.sendInlineQueryAnswer( suspend fun RequestsExecutor.answerInlineQuery(
inlineQuery: InlineQuery, inlineQuery: InlineQuery,
results: List<InlineQueryResult> = emptyList(), results: List<InlineQueryResult> = emptyList(),
cachedTime: Int? = null, cachedTime: Int? = null,
@ -72,7 +72,7 @@ suspend fun RequestsExecutor.sendInlineQueryAnswer(
nextOffset: String? = null, nextOffset: String? = null,
switchPmText: String? = null, switchPmText: String? = null,
switchPmParameter: String? = null switchPmParameter: String? = null
) = sendInlineQueryAnswer(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter) ) = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)
internal object InlineQueryAnswersResultsSerializer: KSerializer<List<InlineQueryResult>> by ArrayListSerializer( internal object InlineQueryAnswersResultsSerializer: KSerializer<List<InlineQueryResult>> by ArrayListSerializer(
InlineQueryResultSerializer InlineQueryResultSerializer

View File

@ -1,8 +1,9 @@
package com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments package com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.abstracts.AnswerPreCheckoutQuery import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.abstracts.AnswerPreCheckoutQuery
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.PreCheckoutQuery import com.github.insanusmokrassar.TelegramBotAPI.types.payments.*
import kotlinx.serialization.* import kotlinx.serialization.*
@Serializable @Serializable
@ -40,3 +41,19 @@ fun PreCheckoutQuery.createAnswerError(
id, id,
error error
) )
suspend fun RequestsExecutor.answerPreCheckoutQueryOk(
id: PreCheckoutQueryId
) = execute(AnswerPreCheckoutQueryOk(id))
suspend fun RequestsExecutor.answerPreCheckoutQueryOk(
preCheckoutQuery: PreCheckoutQuery
) = answerPreCheckoutQueryOk(preCheckoutQuery.id)
suspend fun RequestsExecutor.answerPreCheckoutQueryError(
id: PreCheckoutQueryId,
error: String
) = execute(AnswerPreCheckoutQueryError(id, error))
suspend fun RequestsExecutor.answerPreCheckoutQueryError(
preCheckoutQuery: PreCheckoutQuery,
error: String
) = answerPreCheckoutQueryError(preCheckoutQuery.id, error)

View File

@ -1,5 +1,6 @@
package com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments package com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.abstracts.AnswerShippingQuery import com.github.insanusmokrassar.TelegramBotAPI.requests.answers.payments.abstracts.AnswerShippingQuery
import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.*
import com.github.insanusmokrassar.TelegramBotAPI.types.payments.ShippingOption import com.github.insanusmokrassar.TelegramBotAPI.types.payments.ShippingOption
@ -51,3 +52,23 @@ fun ShippingQuery.createAnswerError(
id, id,
error error
) )
suspend fun RequestsExecutor.answerShippingQueryOk(
id: ShippingQueryIdentifier,
shippingOptions: List<ShippingOption>
) = execute(AnswerShippingQueryOk(id, shippingOptions))
suspend fun RequestsExecutor.answerShippingQueryOk(
shippingQuery: ShippingQuery,
shippingOptions: List<ShippingOption>
) = answerShippingQueryOk(shippingQuery.id, shippingOptions)
suspend fun RequestsExecutor.answerShippingQueryError(
id: ShippingQueryIdentifier,
error: String
) = execute(AnswerShippingQueryError(id, error))
suspend fun RequestsExecutor.answerShippingQueryError(
shippingQuery: ShippingQuery,
error: String
) = answerShippingQueryError(shippingQuery.id, error)