add TimerType.STREAM_OFF status.

- if connected on stream off status, TimerType.STREAM_OFF message sent.
- if stream on, default type is TimerType.UPTIME
This commit is contained in:
dalbodeule
2024-08-02 14:52:28 +09:00
parent 65d491cc8e
commit 8e9382cb3a
5 changed files with 48 additions and 14 deletions

View File

@@ -3,7 +3,9 @@ package space.mori.chzzk_bot.common.events
enum class TimerType(var value: Int) {
UPTIME(0),
TIMER(1),
REMOVE(2)
REMOVE(2),
STREAM_OFF(50)
}
class TimerEvent(

View File

@@ -0,0 +1,14 @@
package space.mori.chzzk_bot.common.utils
import java.time.LocalDateTime
import java.time.temporal.ChronoUnit
fun getUptime(streamOnTime: LocalDateTime): String {
val currentTime = LocalDateTime.now()
val hours = ChronoUnit.HOURS.between(streamOnTime, currentTime)
val minutes = ChronoUnit.MINUTES.between(streamOnTime?.plusHours(hours), currentTime)
val seconds = ChronoUnit.SECONDS.between(streamOnTime?.plusHours(hours)?.plusMinutes(minutes), currentTime)
return String.format("%02d:%02d:%02d", hours, minutes, seconds)
}