com.github.insanusmokrassar.AutoPostTelegramBot.utils.CallbackQueryReceivers.SafeCallbackQueryReceiver.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of AutoPostTelegramBot Show documentation
Show all versions of AutoPostTelegramBot Show documentation
It is base library for creating smart bot for simple management of channels posts
package com.github.insanusmokrassar.AutoPostTelegramBot.utils.CallbackQueryReceivers
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
import com.github.insanusmokrassar.TelegramBotAPI.types.CallbackQuery.MessageDataCallbackQuery
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
import com.github.insanusmokrassar.TelegramBotAPI.types.update.CallbackQueryUpdate
abstract class SafeCallbackQueryReceiver(
executor: RequestsExecutor,
private val checkChatId: ChatIdentifier
) : CallbackQueryReceiver(
executor
) {
override suspend fun invoke(update: CallbackQueryUpdate) {
val query = update.data as? MessageDataCallbackQuery ?: return
if (query.message.chat.id == checkChatId) {
invoke(query)
}
}
abstract suspend fun invoke(query: MessageDataCallbackQuery)
}