mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-26 12:08:43 +00:00
Compare commits
No commits in common. "1b5b3af45bb333b10df530b0440886ebc077f5c1" and "bd23d3fbdba575378ed710e53f633c3e619fc32f" have entirely different histories.
1b5b3af45b
...
bd23d3fbdb
@ -4,9 +4,6 @@
|
|||||||
|
|
||||||
* `BehaviourBuilder FSM`:
|
* `BehaviourBuilder FSM`:
|
||||||
* Hotfixes
|
* Hotfixes
|
||||||
* `WebApps`:
|
|
||||||
* New extension `TelegramBot#answerWebAppQuery`
|
|
||||||
* New function `handleResult`
|
|
||||||
|
|
||||||
## 0.38.19
|
## 0.38.19
|
||||||
|
|
||||||
|
@ -6,9 +6,6 @@ import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQ
|
|||||||
import dev.inmo.tgbotapi.types.webapps.query.SentWebAppMessage
|
import dev.inmo.tgbotapi.types.webapps.query.SentWebAppMessage
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
/**
|
|
||||||
* @param webAppQueryId [dev.inmo.tgbotapi.webapps.WebAppInitData.queryId]
|
|
||||||
*/
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class AnswerWebAppQuery(
|
data class AnswerWebAppQuery(
|
||||||
@SerialName(webAppQueryIdField)
|
@SerialName(webAppQueryIdField)
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.webapps
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.answers.AnswerWebAppQuery
|
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
|
|
||||||
|
|
||||||
suspend fun TelegramBot.answerWebAppQuery(
|
|
||||||
result: InlineQueryResult
|
|
||||||
) = webApp.initDataUnsafe.queryId ?.let {
|
|
||||||
execute(AnswerWebAppQuery(it, result))
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.webapps
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.WebAppQueryId
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param onSendData Should return the data which must be used in [WebApp.sendData]. If returns null, data will not be sent
|
|
||||||
* @param onAnswerWebAppQuery In case if [WebAppInitData.queryId] is presented in [WebApp.initDataUnsafe], will be called
|
|
||||||
* that callback. Before and after calling of this callback will not be used any method of answering to the telegram
|
|
||||||
* system, so, you must use something like [answerWebAppQuery] by yourself to send the result
|
|
||||||
*/
|
|
||||||
inline fun handleResult(
|
|
||||||
onSendData: () -> String?,
|
|
||||||
onAnswerWebAppQuery: (WebAppQueryId) -> Unit
|
|
||||||
) {
|
|
||||||
webApp.initDataUnsafe.queryId ?.let {
|
|
||||||
onAnswerWebAppQuery(it)
|
|
||||||
} ?: webApp.sendData(onSendData() ?: return)
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user