From a5a530c9bdf28f2e9e8462fab359fafc63be9493 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 14 Sep 2021 15:51:05 +0600 Subject: [PATCH] TelegramBot#answer --- CHANGELOG.md | 2 ++ .../extensions/api/answers/AnswerCallbackQuery.kt | 8 ++++++++ .../extensions/api/answers/AnswerInlineQuery.kt | 10 ++++++++++ 3 files changed, 20 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c10648adf6..533ac0bbd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ * `Core`: * New `BotAction` implementation - `CustomBotAction` * `LocationContent` has been divided to two different types: `LiveLocationContent` and `StaticLocationContent` +* `API`: + * Two new extensions: `TelegramBot#answer` with `CallbackQuery` and `InlineQuery` * `Behaviour Builder`: * All triggers has been changed to use two filters: filter for in subcontext data and filter for incoming data diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/AnswerCallbackQuery.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/AnswerCallbackQuery.kt index 7ccc4fc3df..ac14d1dff6 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/AnswerCallbackQuery.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/AnswerCallbackQuery.kt @@ -20,3 +20,11 @@ suspend fun TelegramBot.answerCallbackQuery( url: String? = null, cachedTimeSeconds: Int? = null ) = answerCallbackQuery(callbackQuery.id, text, showAlert, url, cachedTimeSeconds) + +suspend fun TelegramBot.answer( + callbackQuery: CallbackQuery, + text: String? = null, + showAlert: Boolean? = null, + url: String? = null, + cachedTimeSeconds: Int? = null +) = answerCallbackQuery(callbackQuery.id, text, showAlert, url, cachedTimeSeconds) diff --git a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/AnswerInlineQuery.kt b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/AnswerInlineQuery.kt index c356576c80..b40ff79f44 100644 --- a/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/AnswerInlineQuery.kt +++ b/tgbotapi.extensions.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/answers/AnswerInlineQuery.kt @@ -27,3 +27,13 @@ suspend fun TelegramBot.answerInlineQuery( switchPmText: String? = null, switchPmParameter: String? = null ) = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter) + +suspend fun TelegramBot.answer( + inlineQuery: InlineQuery, + results: List = emptyList(), + cachedTime: Int? = null, + isPersonal: Boolean? = null, + nextOffset: String? = null, + switchPmText: String? = null, + switchPmParameter: String? = null +) = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)