All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.insanusmokrassar.AutoPostTelegramBot.utils.CallbackQueryReceivers.SafeCallbackQueryReceiver.kt Maven / Gradle / Ivy

Go to download

It is base library for creating smart bot for simple management of channels posts

There is a newer version: 1.7.0
Show newest version
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)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy