mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-25 19:48:43 +00:00
utils ScheduledCloseInfo shortcuts
This commit is contained in:
parent
830ca8122d
commit
37488e92e6
@ -42,6 +42,11 @@
|
|||||||
* All `RequestsExecutor#sendQuizPoll` extensions now accept additional parameters `caption: String` and
|
* All `RequestsExecutor#sendQuizPoll` extensions now accept additional parameters `caption: String` and
|
||||||
`parseMode: ParseMode` for `explanation` functionality and `closeInfo: ScheduledCloseInfo?` for autoclose poll
|
`parseMode: ParseMode` for `explanation` functionality and `closeInfo: ScheduledCloseInfo?` for autoclose poll
|
||||||
functionality
|
functionality
|
||||||
|
* `TelegramBotAPI-extensions-utils`:
|
||||||
|
* Several shortcuts for `ScheduledCloseInfo` was added:
|
||||||
|
* `closePollExactAt`
|
||||||
|
* `closePollExactAfter`
|
||||||
|
* `closePollAfter`
|
||||||
|
|
||||||
## 0.26.0
|
## 0.26.0
|
||||||
|
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.shortcuts
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.LongSeconds
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.Seconds
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.ApproximateScheduledCloseInfo
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.polls.ExactScheduledCloseInfo
|
||||||
|
import com.soywiz.klock.DateTime
|
||||||
|
import com.soywiz.klock.TimeSpan
|
||||||
|
|
||||||
|
fun closePollExactAt(
|
||||||
|
dateTime: DateTime
|
||||||
|
) = ExactScheduledCloseInfo(
|
||||||
|
dateTime
|
||||||
|
)
|
||||||
|
|
||||||
|
fun closePollExactAfter(
|
||||||
|
seconds: LongSeconds
|
||||||
|
) = closePollExactAt(
|
||||||
|
DateTime.now() + TimeSpan(seconds.toDouble() * 1000L)
|
||||||
|
)
|
||||||
|
fun closePollExactAfter(
|
||||||
|
seconds: Seconds
|
||||||
|
) = closePollExactAfter(
|
||||||
|
seconds.toLong()
|
||||||
|
)
|
||||||
|
|
||||||
|
fun closePollAfter(
|
||||||
|
seconds: LongSeconds
|
||||||
|
) = ApproximateScheduledCloseInfo(
|
||||||
|
TimeSpan(seconds.toDouble() * 1000L)
|
||||||
|
)
|
||||||
|
|
||||||
|
fun closePollAfter(
|
||||||
|
seconds: Seconds
|
||||||
|
) = closePollAfter(seconds.toLong())
|
Loading…
Reference in New Issue
Block a user