ConfigurableInlineTelegramBot/src/main/kotlin/dev/inmo/configurable_inline_telegram_bot/config/Restrictions.kt

15 lines
456 B
Kotlin
Raw Normal View History

2021-02-02 13:15:42 +00:00
package dev.inmo.configurable_inline_telegram_bot.config
import dev.inmo.tgbotapi.types.*
2022-04-10 16:14:56 +00:00
import dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery
2021-02-02 13:15:42 +00:00
import kotlinx.serialization.Serializable
@Serializable
data class Restrictions(
val allowedUsers: List<ChatIdentifier> = emptyList()
) {
fun check(query: InlineQuery): Boolean {
return query.from.id in allowedUsers || query.from.username ?.let { it in allowedUsers } ?: false
}
2022-04-10 16:14:56 +00:00
}