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

fixes in status info

This commit is contained in:
InsanusMokrassar 2024-12-08 10:40:09 +06:00
parent adcaffe115
commit a034fa18d7
4 changed files with 10 additions and 7 deletions

View File

@ -218,7 +218,7 @@ external class WebApp {
@JsName("onEvent") @JsName("onEvent")
internal fun onContactRequested(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgStatusObject) -> Unit) internal fun onContactRequested(type: String, callback: (dev.inmo.tgbotapi.webapps.args.ArgStatusObject) -> Unit)
@JsName("onEvent") @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") @JsName("onEvent")
internal fun onGyroscopeStarted(type: String, callback: () -> Unit) internal fun onGyroscopeStarted(type: String, callback: () -> Unit)
@JsName("onEvent") @JsName("onEvent")

View File

@ -41,7 +41,7 @@
}, },
{ {
"event_name": "invoiceClosed", "event_name": "invoiceClosed",
"callback_args": "String, dev.inmo.tgbotapi.webapps.invoice.InvoiceStatus" "callback_args": "String, String"
}, },
{ {
"event_name": "popupClosed", "event_name": "popupClosed",

View File

@ -885,14 +885,14 @@ fun WebApp.onEvent(type: EventType.ContactRequested, eventHandler: ContactReques
fun WebApp.onContactRequested(eventHandler: ContactRequestedEventHandler) = onEvent(EventType.ContactRequested, eventHandler) fun WebApp.onContactRequested(eventHandler: ContactRequestedEventHandler) = onEvent(EventType.ContactRequested, eventHandler)
// Part for callback typealias // 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 // Part for outside of WebApp
/** /**
* @return The callback which should be used in case you want to turn off events handling * @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) eventHandler(js("this").unsafeCast<WebApp>(), p0, p1)
}.also { }.also {
onInvoiceClosed( onInvoiceClosed(

View File

@ -5,12 +5,15 @@ external interface InvoiceClosedInfo {
val status: String val status: String
} }
val InvoiceClosedInfo.statusTyped val String.statusTyped
get() = when (status) { get() = when (this) {
InvoiceStatus.Paid.name -> InvoiceStatus.Paid InvoiceStatus.Paid.name -> InvoiceStatus.Paid
InvoiceStatus.Cancelled.name -> InvoiceStatus.Cancelled InvoiceStatus.Cancelled.name -> InvoiceStatus.Cancelled
InvoiceStatus.Failed.name -> InvoiceStatus.Failed InvoiceStatus.Failed.name -> InvoiceStatus.Failed
InvoiceStatus.Pending.name -> InvoiceStatus.Pending InvoiceStatus.Pending.name -> InvoiceStatus.Pending
else -> InvoiceStatus.Unknown(status) else -> InvoiceStatus.Unknown(this)
} }
val InvoiceClosedInfo.statusTyped
get() = status.statusTyped