This commit is contained in:
parent
0be5976be2
commit
56e66c52ef
1
.github/workflows/root.yml
vendored
1
.github/workflows/root.yml
vendored
@ -2,6 +2,7 @@ name: Build & Publish
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package dev.jansel.aglaea.utils
|
package dev.jansel.aglaea.utils
|
||||||
|
|
||||||
import com.github.philippheuer.events4j.reactor.ReactorEventHandler
|
|
||||||
import com.github.twitch4j.TwitchClientBuilder
|
import com.github.twitch4j.TwitchClientBuilder
|
||||||
|
import com.github.twitch4j.chat.events.channel.ChannelMessageEvent
|
||||||
|
import dev.jansel.aglaea.logger
|
||||||
import dev.jansel.aglaea.twitchClient
|
import dev.jansel.aglaea.twitchClient
|
||||||
import dev.kordex.core.koin.KordExKoinComponent
|
import dev.kordex.core.koin.KordExKoinComponent
|
||||||
|
|
||||||
@ -10,9 +11,14 @@ class Twitch : KordExKoinComponent {
|
|||||||
twitchClient = TwitchClientBuilder.builder()
|
twitchClient = TwitchClientBuilder.builder()
|
||||||
.withEnableHelix(true)
|
.withEnableHelix(true)
|
||||||
.withEnablePubSub(true)
|
.withEnablePubSub(true)
|
||||||
.withDefaultEventHandler(ReactorEventHandler::class.java)
|
|
||||||
.withClientId(twitchcid)
|
.withClientId(twitchcid)
|
||||||
.withClientSecret(twitchcs)
|
.withClientSecret(twitchcs)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
|
twitchClient!!.chat.joinChannel(getTwitchNameById("120275141"))
|
||||||
|
|
||||||
|
twitchClient!!.eventManager.onEvent(com.github.twitch4j.chat.events.channel.ChannelMessageEvent::class.java) { event ->
|
||||||
|
logger.info { "Message from Twitch: ${event.user.name}: ${event.message}" }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package dev.jansel.aglaea.utils
|
package dev.jansel.aglaea.utils
|
||||||
|
|
||||||
|
import dev.jansel.aglaea.twitchClient
|
||||||
import dev.kordex.core.builders.ExtensibleBotBuilder
|
import dev.kordex.core.builders.ExtensibleBotBuilder
|
||||||
import dev.kordex.core.utils.env
|
import dev.kordex.core.utils.env
|
||||||
import dev.kordex.core.utils.loadModule
|
import dev.kordex.core.utils.loadModule
|
||||||
@ -21,3 +22,13 @@ suspend inline fun ExtensibleBotBuilder.twitch(active: Boolean) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getTwitchNameById(id: String): String? {
|
||||||
|
val resultList = twitchClient!!.helix?.getUsers(null, listOf(id), null)?.execute()
|
||||||
|
resultList?.users?.forEach { user ->
|
||||||
|
if (user.id == id) {
|
||||||
|
return user.displayName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user