File tree Expand file tree Collapse file tree
BusinessConnectionsBot/src/main/kotlin
CustomBot/src/main/kotlin Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ import dev.inmo.tgbotapi.extensions.utils.ifBusinessContentMessage
3434import dev.inmo.tgbotapi.extensions.utils.textContentOrNull
3535import dev.inmo.tgbotapi.extensions.utils.types.buttons.dataButton
3636import dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard
37+ import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.flushAccumulatedUpdates
3738import dev.inmo.tgbotapi.extensions.utils.withContentOrNull
3839import dev.inmo.tgbotapi.requests.abstracts.multipartFile
3940import dev.inmo.tgbotapi.requests.business_connection.InputProfilePhoto
@@ -84,6 +85,7 @@ suspend fun main(args: Array<String>) {
8485 telegramBotWithBehaviourAndLongPolling(botToken, CoroutineScope (Dispatchers .IO )) {
8586 val me = getMe()
8687 println (me)
88+ flushAccumulatedUpdates()
8789
8890 onBusinessConnectionEnabled {
8991 businessConnectionsChatsMutex.withLock {
@@ -471,5 +473,15 @@ suspend fun main(args: Array<String>) {
471473 }
472474 }
473475 }
476+
477+ // Will work when some premium user sending to some other user checklist
478+ onChecklistContent {
479+ execute(
480+ it.content.createResend(
481+ it.chat.id,
482+ businessConnectionId = it.chat.id.businessConnectionId ? : chatsBusinessConnections[it.chat.id] ? : return @onChecklistContent
483+ )
484+ )
485+ }
474486 }.second.join()
475487}
Original file line number Diff line number Diff line change @@ -4,10 +4,13 @@ import dev.inmo.kslog.common.defaultMessageFormatter
44import dev.inmo.kslog.common.setDefaultKSLog
55import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
66import dev.inmo.tgbotapi.extensions.api.bot.getMe
7+ import dev.inmo.tgbotapi.extensions.api.bot.getMyStarBalance
78import dev.inmo.tgbotapi.extensions.api.chat.get.getChat
9+ import dev.inmo.tgbotapi.extensions.api.send.reply
810import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextData
911import dev.inmo.tgbotapi.extensions.behaviour_builder.buildSubcontextInitialAction
1012import dev.inmo.tgbotapi.extensions.behaviour_builder.telegramBotWithBehaviourAndLongPolling
13+ import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onChannelDirectMessagesConfigurationChanged
1114import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onCommand
1215import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
1316import dev.inmo.tgbotapi.types.update.abstracts.Update
@@ -79,6 +82,17 @@ suspend fun main(vararg args: String) {
7982 println (data.commonMessage)
8083 }
8184
85+ onCommand(" getMyStarBalance" ) {
86+ reply(
87+ to = it,
88+ text = getMyStarBalance().toString()
89+ )
90+ }
91+
92+ onChannelDirectMessagesConfigurationChanged {
93+ println (it.chatEvent)
94+ }
95+
8296 allUpdatesFlow.subscribeSafelyWithoutExceptions(this ) {
8397 println (it)
8498 }
Original file line number Diff line number Diff line change @@ -163,6 +163,34 @@ fun main() {
163163 Text (" Answer in chat button" )
164164 }
165165
166+ H3 { Text (" Hide keyboard" ) }
167+ val hideCountdown = remember { mutableStateOf<Int ?>(null ) }
168+ Button ({
169+ onClick {
170+ hideCountdown.value = 5
171+ }
172+ }) {
173+ if (hideCountdown.value == null ) {
174+ Text (" Hide" )
175+ } else {
176+ Text (" Hide in ${hideCountdown.value} seconds" )
177+ }
178+ }
179+ LaunchedEffect (hideCountdown.value) {
180+ val value = hideCountdown.value
181+ when {
182+ value == null -> return @LaunchedEffect
183+ value > 0 -> {
184+ delay(1000 )
185+ hideCountdown.value = hideCountdown.value ?.minus(1 )
186+ }
187+ else -> {
188+ webApp.hideKeyboard()
189+ hideCountdown.value = null
190+ }
191+ }
192+ }
193+
166194 P ()
167195 H3 { Text (" User info" ) }
168196 Text (" Allow to write in private messages: ${webApp.initDataUnsafe.user ?.allowsWriteToPM ? : " User unavailable" } " )
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ kotlin.daemon.jvmargs=-Xmx3g -Xms500m
66
77
88kotlin_version =2.1.20
9- telegram_bot_api_version =26.0 .0
9+ telegram_bot_api_version =26.1 .0
1010micro_utils_version =0.25.7
1111serialization_version =1.8.1
1212ktor_version =3.1.3
You can’t perform that action at this time.
0 commit comments