mirror of
https://github.com/dalbodeule/chibot-chzzk-bot.git
synced 2025-06-09 07:18:22 +00:00
fix User.kt
- set "discord", "token" row to nullable.
This commit is contained in:
parent
80fa2d5029
commit
f2a871d664
@ -29,7 +29,7 @@ object ChzzkHandler {
|
||||
private val logger = LoggerFactory.getLogger(this::class.java)
|
||||
lateinit var botUid: String
|
||||
@Volatile private var running: Boolean = false
|
||||
val dispatcher: CoroutinesEventBus by inject(CoroutinesEventBus::class.java)
|
||||
private val dispatcher: CoroutinesEventBus by inject(CoroutinesEventBus::class.java)
|
||||
|
||||
fun addUser(chzzkChannel: ChzzkChannel, user: User) {
|
||||
handlers.add(UserHandler(chzzkChannel, logger, user, streamStartTime = null))
|
||||
|
@ -157,7 +157,7 @@ class MessageHandler(
|
||||
CoroutineScope(Dispatchers.Default).launch {
|
||||
dispatcher.post(
|
||||
TimerEvent(
|
||||
user.token,
|
||||
user.token!!,
|
||||
TimerType.UPTIME,
|
||||
getUptime(handler.streamStartTime!!)
|
||||
)
|
||||
@ -167,7 +167,7 @@ class MessageHandler(
|
||||
"삭제" -> {
|
||||
logger.debug("${user.token} / 삭제")
|
||||
CoroutineScope(Dispatchers.Default).launch {
|
||||
dispatcher.post(TimerEvent(user.token, TimerType.REMOVE, ""))
|
||||
dispatcher.post(TimerEvent(user.token!!, TimerType.REMOVE, ""))
|
||||
}
|
||||
}
|
||||
"설정" -> {
|
||||
@ -191,7 +191,7 @@ class MessageHandler(
|
||||
val timestamp = currentTime.plus(time.toLong(), ChronoUnit.MINUTES)
|
||||
|
||||
CoroutineScope(Dispatchers.Default).launch {
|
||||
dispatcher.post(TimerEvent(user.token, TimerType.TIMER, timestamp.toString()))
|
||||
dispatcher.post(TimerEvent(user.token!!, TimerType.TIMER, timestamp.toString()))
|
||||
}
|
||||
} catch (e: NumberFormatException) {
|
||||
listener.sendChat("!타이머/숫자 형식으로 적어주세요! 단위: 분")
|
||||
@ -254,7 +254,7 @@ class MessageHandler(
|
||||
CoroutineScope(Dispatchers.Default).launch {
|
||||
dispatcher.post(
|
||||
SongEvent(
|
||||
user.token,
|
||||
user.token!!,
|
||||
SongType.ADD,
|
||||
msg.userId,
|
||||
msg.profile?.nickname ?: "",
|
||||
@ -286,10 +286,12 @@ class MessageHandler(
|
||||
val session = "${UUID.randomUUID()}${UUID.randomUUID()}".replace("-", "")
|
||||
|
||||
|
||||
bot.retrieveUserById(user.discord).queue { discordUser ->
|
||||
discordUser?.openPrivateChannel()?.queue { channel ->
|
||||
channel.sendMessage("여기로 접속해주세요! ||https://nabot.mori.space/songlist||.")
|
||||
.queue()
|
||||
user.discord?.let {
|
||||
bot.retrieveUserById(it).queue { discordUser ->
|
||||
discordUser?.openPrivateChannel()?.queue { channel ->
|
||||
channel.sendMessage("여기로 접속해주세요! ||https://nabot.mori.space/songlist||.")
|
||||
.queue()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ object AddCommand : CommandInterface {
|
||||
return
|
||||
}
|
||||
|
||||
val chzzkChannel = Connector.getChannel(user!!.token)
|
||||
val chzzkChannel = user!!.token?.let { Connector.getChannel(it) }
|
||||
|
||||
try {
|
||||
CommandService.saveCommand(user!!, label, content, failContent ?: "")
|
||||
|
@ -43,7 +43,7 @@ object AlertCommand : CommandInterface {
|
||||
return
|
||||
}
|
||||
|
||||
val chzzkChannel = Connector.getChannel(user!!.token)
|
||||
val chzzkChannel = user!!.token?.let { Connector.getChannel(it) }
|
||||
|
||||
try {
|
||||
val newUser = UserService.updateLiveAlert(user!!.id.value, channel?.guild?.idLong ?: 0L, channel?.idLong ?: 0L, content ?: "")
|
||||
|
@ -47,7 +47,7 @@ object RemoveCommand : CommandInterface {
|
||||
return
|
||||
}
|
||||
|
||||
val chzzkChannel = Connector.getChannel(user!!.token)
|
||||
val chzzkChannel = user!!.token?.let { Connector.getChannel(it) }
|
||||
|
||||
try {
|
||||
CommandService.removeCommand(user!!, label)
|
||||
|
@ -51,7 +51,7 @@ object UpdateCommand : CommandInterface {
|
||||
return
|
||||
}
|
||||
|
||||
val chzzkChannel = Connector.getChannel(user!!.token)
|
||||
val chzzkChannel = user!!.token?.let { Connector.getChannel(it) }
|
||||
|
||||
try {
|
||||
CommandService.updateCommand(user!!, label, content, failContent ?: "")
|
||||
|
@ -8,8 +8,8 @@ import org.jetbrains.exposed.dao.id.IntIdTable
|
||||
|
||||
object Users: IntIdTable("users") {
|
||||
val username = varchar("username", 255)
|
||||
val token = varchar("token", 64)
|
||||
val discord = long("discord")
|
||||
val token = varchar("token", 64).nullable()
|
||||
val discord = long("discord").nullable()
|
||||
val naverId = varchar("naver_id", 128)
|
||||
val liveAlertGuild = long("live_alert_guild").nullable()
|
||||
val liveAlertChannel = long("live_alert_channel").nullable()
|
||||
|
@ -103,6 +103,8 @@ val server = embeddedServer(Netty, port = 8080, ) {
|
||||
}
|
||||
get("/logout") {
|
||||
call.sessions.clear<UserSession>()
|
||||
call.response.status(HttpStatusCode.OK)
|
||||
return@get
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ fun Routing.apiRoutes() {
|
||||
user = UserService.saveUser(session.nickname, session.id)
|
||||
}
|
||||
val songConfig = SongConfigService.getConfig(user)
|
||||
val status = getStreamInfo(user.token)
|
||||
val status = getStreamInfo(user.token!!)
|
||||
|
||||
if(status.content == null) {
|
||||
call.respondText(user.naverId, status = HttpStatusCode.NotFound)
|
||||
|
@ -49,13 +49,13 @@ fun Routing.wsSongListRoutes() {
|
||||
|
||||
val uid = user.token
|
||||
|
||||
addSession(uid, this)
|
||||
addSession(uid!!, this)
|
||||
|
||||
if(status[uid] == SongType.STREAM_OFF) {
|
||||
CoroutineScope(Dispatchers.Default).launch {
|
||||
sendSerialized(SongResponse(
|
||||
SongType.STREAM_OFF.value,
|
||||
user.token,
|
||||
uid,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
@ -83,7 +83,7 @@ fun Routing.wsSongListRoutes() {
|
||||
CoroutineScope(Dispatchers.Default).launch {
|
||||
SongListService.saveSong(
|
||||
user,
|
||||
user.token,
|
||||
user.token!!,
|
||||
data.url,
|
||||
youtubeVideo.name,
|
||||
youtubeVideo.author,
|
||||
@ -92,7 +92,7 @@ fun Routing.wsSongListRoutes() {
|
||||
)
|
||||
dispatcher.post(
|
||||
SongEvent(
|
||||
user.token,
|
||||
user.token!!,
|
||||
SongType.ADD,
|
||||
user.token,
|
||||
user.username,
|
||||
@ -110,7 +110,7 @@ fun Routing.wsSongListRoutes() {
|
||||
}
|
||||
else if(data.type == SongType.REMOVE.value && data.url != null) {
|
||||
dispatcher.post(SongEvent(
|
||||
user.token,
|
||||
user.token!!,
|
||||
SongType.REMOVE,
|
||||
null,
|
||||
null,
|
||||
@ -123,7 +123,7 @@ fun Routing.wsSongListRoutes() {
|
||||
val song = SongListService.getSong(user)[0]
|
||||
SongListService.deleteSong(user, song.uid, song.name)
|
||||
dispatcher.post(SongEvent(
|
||||
user.token,
|
||||
user.token!!,
|
||||
SongType.NEXT,
|
||||
null,
|
||||
null,
|
||||
|
Loading…
x
Reference in New Issue
Block a user