mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-09-14 12:52:50 +00:00
refactor and fixes
This commit is contained in:
@@ -0,0 +1 @@
|
||||
data object {{$event_name_uppercase}} : EventType("{{$event_name}}")
|
@@ -0,0 +1,2 @@
|
||||
@JsName("onEvent")
|
||||
internal fun on{{$event_name_uppercase}}(type: String, callback: ({{$callback_args}}) -> Unit)
|
@@ -0,0 +1,22 @@
|
||||
// Part for callback typealias
|
||||
|
||||
typealias {{$callback_typealias_name}} = WebApp.({{$callback_args}}) -> 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.{{$event_name_uppercase}}, eventHandler: {{$callback_typealias_name}}) = { it: {{$callback_typealias_name}} ->
|
||||
eventHandler(js("this").unsafeCast<WebApp>(), it)
|
||||
}.also {
|
||||
on{{$event_name_uppercase}}(
|
||||
type.typeName,
|
||||
callback = it
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The callback which should be used in case you want to turn off events handling
|
||||
*/
|
||||
fun WebApp.on{{$event_name_uppercase}}(eventHandler: {{$callback_typealias_name}}) = onEvent(EventType.{{$event_name_uppercase}}, eventHandler)
|
Reference in New Issue
Block a user