mirror of
https://github.com/dalbodeule/chibot-chzzk-bot.git
synced 2025-06-09 15:28:21 +00:00
Merge pull request #22 from dalbodeule/develop
Chzzk uptime is in status.
This commit is contained in:
commit
39237a35c9
@ -14,6 +14,7 @@ import space.mori.chzzk_bot.common.events.TimerEvent
|
|||||||
import space.mori.chzzk_bot.common.events.TimerType
|
import space.mori.chzzk_bot.common.events.TimerType
|
||||||
import space.mori.chzzk_bot.common.models.User
|
import space.mori.chzzk_bot.common.models.User
|
||||||
import space.mori.chzzk_bot.common.services.UserService
|
import space.mori.chzzk_bot.common.services.UserService
|
||||||
|
import space.mori.chzzk_bot.common.utils.convertChzzkDateToLocalDateTime
|
||||||
import space.mori.chzzk_bot.common.utils.getUptime
|
import space.mori.chzzk_bot.common.utils.getUptime
|
||||||
import xyz.r2turntrue.chzzk4j.chat.ChatEventListener
|
import xyz.r2turntrue.chzzk4j.chat.ChatEventListener
|
||||||
import xyz.r2turntrue.chzzk4j.chat.ChatMessage
|
import xyz.r2turntrue.chzzk4j.chat.ChatMessage
|
||||||
@ -148,7 +149,7 @@ class UserHandler(
|
|||||||
logger.info("ChzzkChat connecting... ${channel.channelName} - ${channel.channelId}")
|
logger.info("ChzzkChat connecting... ${channel.channelName} - ${channel.channelId}")
|
||||||
listener.connectBlocking()
|
listener.connectBlocking()
|
||||||
|
|
||||||
streamStartTime = LocalDateTime.now()
|
streamStartTime = convertChzzkDateToLocalDateTime(status.content.openDate)
|
||||||
|
|
||||||
CoroutineScope(Dispatchers.Default).launch {
|
CoroutineScope(Dispatchers.Default).launch {
|
||||||
dispatcher.post(TimerEvent(
|
dispatcher.post(TimerEvent(
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
package space.mori.chzzk_bot.common.utils
|
||||||
|
|
||||||
|
import org.slf4j.Logger
|
||||||
|
import org.slf4j.LoggerFactory
|
||||||
|
import java.time.LocalDateTime
|
||||||
|
import java.time.format.DateTimeFormatter
|
||||||
|
import java.time.format.DateTimeParseException
|
||||||
|
|
||||||
|
val logger: Logger = LoggerFactory.getLogger("convertChzzkDateToLocalDateTime")
|
||||||
|
|
||||||
|
fun convertChzzkDateToLocalDateTime(chzzkDate: String): LocalDateTime? {
|
||||||
|
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
|
||||||
|
|
||||||
|
return try {
|
||||||
|
LocalDateTime.parse(chzzkDate, formatter)
|
||||||
|
} catch(e: DateTimeParseException) {
|
||||||
|
logger.debug("Error to parsing date", e)
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user