mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2024-12-22 00:27:19 +00:00
improve boosts info bot
This commit is contained in:
parent
673424b234
commit
06459ebc0a
@ -52,14 +52,21 @@ suspend fun main(args: Array<String>) {
|
||||
}
|
||||
|
||||
onChatShared(initialFilter = { it.chatEvent.requestId == requestChatId }) {
|
||||
val boosts = getUserChatBoosts(it.chatEvent.chatId, it.chat.id)
|
||||
reply(
|
||||
it
|
||||
) {
|
||||
boosts.boosts.forEach {
|
||||
val boostsInfoContrainer = runCatching {
|
||||
getUserChatBoosts(it.chatEvent.chatId, it.chat.id)
|
||||
}.getOrNull()
|
||||
|
||||
reply(it) {
|
||||
when {
|
||||
boostsInfoContrainer == null -> +"Unable to take info about boosts in shared chat"
|
||||
boostsInfoContrainer.boosts.isEmpty() -> +"There is no any boosts in passed chat"
|
||||
else -> {
|
||||
boostsInfoContrainer.boosts.forEach {
|
||||
regular("Boost added: ${DateFormat.FORMAT1.format(it.addDate.asDate)}; Boost expire: ${DateFormat.FORMAT1.format(it.expirationDate.asDate)}; Unformatted: $it") + "\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.join()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user