mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-12-22 00:27:14 +00:00
fixes in status info
This commit is contained in:
parent
adcaffe115
commit
a034fa18d7
@ -218,7 +218,7 @@ external class WebApp {
|
||||
@JsName("onEvent")
|
||||
internal fun onContactRequested(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgStatusObject) -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onInvoiceClosed(type: String, callback: (String, dev.inmo.tgbotapi.webapps.invoice.InvoiceStatus) -> Unit)
|
||||
internal fun onInvoiceClosed(type: String, callback: (String, String) -> Unit)
|
||||
@JsName("onEvent")
|
||||
internal fun onGyroscopeStarted(type: String, callback: () -> Unit)
|
||||
@JsName("onEvent")
|
||||
|
@ -41,7 +41,7 @@
|
||||
},
|
||||
{
|
||||
"event_name": "invoiceClosed",
|
||||
"callback_args": "String, dev.inmo.tgbotapi.webapps.invoice.InvoiceStatus"
|
||||
"callback_args": "String, String"
|
||||
},
|
||||
{
|
||||
"event_name": "popupClosed",
|
||||
|
@ -885,14 +885,14 @@ fun WebApp.onEvent(type: EventType.ContactRequested, eventHandler: ContactReques
|
||||
fun WebApp.onContactRequested(eventHandler: ContactRequestedEventHandler) = onEvent(EventType.ContactRequested, eventHandler)
|
||||
// Part for callback typealias
|
||||
|
||||
typealias InvoiceClosedEventHandler = WebApp.(String, dev.inmo.tgbotapi.webapps.invoice.InvoiceStatus) -> Unit
|
||||
typealias InvoiceClosedEventHandler = WebApp.(String, String) -> Unit
|
||||
|
||||
// Part for outside of WebApp
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.onEvent(type: EventType.InvoiceClosed, eventHandler: InvoiceClosedEventHandler) = { p0: String, p1: dev.inmo.tgbotapi.webapps.invoice.InvoiceStatus ->
|
||||
fun WebApp.onEvent(type: EventType.InvoiceClosed, eventHandler: InvoiceClosedEventHandler) = { p0: String, p1: String ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), p0, p1)
|
||||
}.also {
|
||||
onInvoiceClosed(
|
||||
|
@ -5,12 +5,15 @@ external interface InvoiceClosedInfo {
|
||||
val status: String
|
||||
}
|
||||
|
||||
val InvoiceClosedInfo.statusTyped
|
||||
get() = when (status) {
|
||||
val String.statusTyped
|
||||
get() = when (this) {
|
||||
InvoiceStatus.Paid.name -> InvoiceStatus.Paid
|
||||
InvoiceStatus.Cancelled.name -> InvoiceStatus.Cancelled
|
||||
InvoiceStatus.Failed.name -> InvoiceStatus.Failed
|
||||
InvoiceStatus.Pending.name -> InvoiceStatus.Pending
|
||||
else -> InvoiceStatus.Unknown(status)
|
||||
else -> InvoiceStatus.Unknown(this)
|
||||
}
|
||||
|
||||
val InvoiceClosedInfo.statusTyped
|
||||
get() = status.statusTyped
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user