mirror of
https://github.com/dalbodeule/chibot-chzzk-bot.git
synced 2025-06-09 07:18:22 +00:00
add /user/{uid} call on web module.
- fix some bug with use Pair
This commit is contained in:
parent
b77a3d02c5
commit
4025cbceec
@ -30,7 +30,6 @@ object Connector {
|
|||||||
private val dispatcher: CoroutinesEventBus by inject(CoroutinesEventBus::class.java)
|
private val dispatcher: CoroutinesEventBus by inject(CoroutinesEventBus::class.java)
|
||||||
|
|
||||||
fun getChannel(channelId: String): ChzzkChannel? = chzzk.getChannel(channelId)
|
fun getChannel(channelId: String): ChzzkChannel? = chzzk.getChannel(channelId)
|
||||||
fun getChannelAndUser(channelId: String): Pair<ChzzkChannel, User?>? = pair(chzzk.getChannel(channelId), UserService.getUser(channelId))
|
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@ -38,17 +37,22 @@ object Connector {
|
|||||||
dispatcher.subscribe(GetUserEvents::class) {
|
dispatcher.subscribe(GetUserEvents::class) {
|
||||||
if (it.type == GetUserType.REQUEST) {
|
if (it.type == GetUserType.REQUEST) {
|
||||||
CoroutineScope(Dispatchers.Default).launch {
|
CoroutineScope(Dispatchers.Default).launch {
|
||||||
val channel = getChannelAndUser(it.uid ?: "")
|
val channel = getChannel(it.uid ?: "")
|
||||||
if(channel == null) dispatcher.post(GetUserEvents(
|
if(channel == null) dispatcher.post(GetUserEvents(
|
||||||
GetUserType.NOTFOUND, null, null, null, null
|
GetUserType.NOTFOUND, null, null, null, null
|
||||||
))
|
))
|
||||||
else dispatcher.post(GetUserEvents(
|
else {
|
||||||
|
val user = UserService.getUser(channel.channelId)
|
||||||
|
dispatcher.post(
|
||||||
|
GetUserEvents(
|
||||||
GetUserType.RESPONSE,
|
GetUserType.RESPONSE,
|
||||||
channel.first.channelId,
|
channel.channelId,
|
||||||
channel.first.channelName,
|
channel.channelName,
|
||||||
LiveStatusService.getLiveStatus(channel.second!!)?.status ?: false,
|
LiveStatusService.getLiveStatus(user!!)?.status ?: false,
|
||||||
channel.first.channelImageUrl
|
channel.channelImageUrl
|
||||||
))
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user