Compare commits
No commits in common. "4b46d34f45d7685b3e201fd5df029b5a270764f3" and "c65e4031d9556841d8f14725b780c4a91aaca34b" have entirely different histories.
4b46d34f45
...
c65e4031d9
8 changed files with 16 additions and 25 deletions
|
@ -29,7 +29,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
//lilJudd version 2
|
//lilJudd version 2
|
||||||
val creatorID = 372703841151614976L
|
val ownerID = 372703841151614976L
|
||||||
group = "net.moonleay.liljudd"
|
group = "net.moonleay.liljudd"
|
||||||
version = System.getenv("CI_COMMIT_TAG")?.let { "$it-${System.getenv("CI_COMMIT_SHORT_SHA")}-prod" }
|
version = System.getenv("CI_COMMIT_TAG")?.let { "$it-${System.getenv("CI_COMMIT_SHORT_SHA")}-prod" }
|
||||||
?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" }
|
?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" }
|
||||||
|
@ -120,7 +120,7 @@ val templateSrc = project.rootDir.resolve("src/main/templates")
|
||||||
val templateDest = project.projectDir.resolve("build/generated/templates")
|
val templateDest = project.projectDir.resolve("build/generated/templates")
|
||||||
val templateProps = mapOf(
|
val templateProps = mapOf(
|
||||||
"version" to project.version as String,
|
"version" to project.version as String,
|
||||||
"creatorID" to creatorID,
|
"ownerID" to ownerID,
|
||||||
"kordversion" to kordver,
|
"kordversion" to kordver,
|
||||||
"coroutinesversion" to coroutinesver,
|
"coroutinesversion" to coroutinesver,
|
||||||
"ktorversion" to ktorver,
|
"ktorversion" to ktorver,
|
||||||
|
|
|
@ -133,7 +133,7 @@ object Bot {
|
||||||
this.embed {
|
this.embed {
|
||||||
this.title = "Oops. Something went wrong."
|
this.title = "Oops. Something went wrong."
|
||||||
this.description = "The bot encountered an error during execution.\n" +
|
this.description = "The bot encountered an error during execution.\n" +
|
||||||
"Please report this to <@${BuildConstants.creatorID}>.\n" +
|
"Please report this to <@${BuildConstants.ownerID}>.\n" +
|
||||||
"The errorid is \"$stamp.stk\""
|
"The errorid is \"$stamp.stk\""
|
||||||
this.field {
|
this.field {
|
||||||
this.name = "Error message:"
|
this.name = "Error message:"
|
||||||
|
|
|
@ -31,7 +31,7 @@ suspend fun main() {
|
||||||
"v.${BuildConstants.version}\n"
|
"v.${BuildConstants.version}\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
Logger.out("li'l Judd made by moonleay (https://moonleay.net). Web UI made by aronmal (https://mal-noh.de).")
|
Logger.out("li'l Judd made by moonleay (https://moonleay.net). Web UI made by IchLiebeZuege (https://mal-noh.de).")
|
||||||
Logger.out("For more information check out https://liljudd.ink and https://git.moonleay.net/DiscordBots/lilJudd")
|
Logger.out("For more information check out https://liljudd.ink and https://git.moonleay.net/DiscordBots/lilJudd")
|
||||||
|
|
||||||
Bot.start()
|
Bot.start()
|
||||||
|
|
|
@ -44,7 +44,7 @@ object AvailabilityManager : IFeature {
|
||||||
|
|
||||||
// This runs during the cronjob.
|
// This runs during the cronjob.
|
||||||
suspend fun runThread() {
|
suspend fun runThread() {
|
||||||
Logger.out("Updating match roles")
|
Logger.out("Starting to update roles...")
|
||||||
|
|
||||||
// ChannelID, Data
|
// ChannelID, Data
|
||||||
val messages = TimePlanningMessagesRepository.getWeek(TimeUtil.getWeekStamp().toEpochSecond())
|
val messages = TimePlanningMessagesRepository.getWeek(TimeUtil.getWeekStamp().toEpochSecond())
|
||||||
|
@ -70,7 +70,7 @@ object AvailabilityManager : IFeature {
|
||||||
}
|
}
|
||||||
this.updateInChannel(snf, data, roleData)
|
this.updateInChannel(snf, data, roleData)
|
||||||
}
|
}
|
||||||
Logger.out("Finished updating roles")
|
Logger.out("Done! Until tomorrow! <3 ")
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun updateInChannel(snf: Snowflake) {
|
suspend fun updateInChannel(snf: Snowflake) {
|
||||||
|
@ -162,7 +162,7 @@ object AvailabilityManager : IFeature {
|
||||||
|
|
||||||
// Register the cronjob to run at 1AM UTC every day
|
// Register the cronjob to run at 1AM UTC every day
|
||||||
override suspend fun registerThread() {
|
override suspend fun registerThread() {
|
||||||
Logger.out("Registering daily planning message role update coroutine")
|
Logger.out("Adding availability scheduler...")
|
||||||
val scheduler = buildSchedule("0 0 2 * * *") // 0 0 4 * * * 0o 1w // 0o is UTC
|
val scheduler = buildSchedule("0 0 2 * * *") // 0 0 4 * * * 0o 1w // 0o is UTC
|
||||||
scheduler.doInfinity {
|
scheduler.doInfinity {
|
||||||
this.runThread()
|
this.runThread()
|
||||||
|
@ -176,7 +176,7 @@ object AvailabilityManager : IFeature {
|
||||||
ch: Channel,
|
ch: Channel,
|
||||||
args: FeatureManageExtension.FeatureManagerArgs
|
args: FeatureManageExtension.FeatureManagerArgs
|
||||||
): EmbedBuilder {
|
): EmbedBuilder {
|
||||||
val alreadyExists = PlanningNotifierRolesRepository.existsInChannel(cID)
|
var alreadyExists = PlanningNotifierRolesRepository.existsInChannel(cID)
|
||||||
// Check if the channel and guild already exist in the db
|
// Check if the channel and guild already exist in the db
|
||||||
if (!alreadyExists) {
|
if (!alreadyExists) {
|
||||||
// Create the roles in Discord
|
// Create the roles in Discord
|
||||||
|
|
|
@ -28,7 +28,7 @@ import net.moonleay.liljudd.util.Logger
|
||||||
|
|
||||||
object MatchManager {
|
object MatchManager {
|
||||||
suspend fun update() {
|
suspend fun update() {
|
||||||
Logger.out("Updating matches")
|
Logger.out("Updating match roles...")
|
||||||
val dataList = MatchPlanningDataRepository.getAll()
|
val dataList = MatchPlanningDataRepository.getAll()
|
||||||
|
|
||||||
for (data in dataList) {
|
for (data in dataList) {
|
||||||
|
@ -41,7 +41,7 @@ object MatchManager {
|
||||||
}
|
}
|
||||||
this.registerJob(data)
|
this.registerJob(data)
|
||||||
}
|
}
|
||||||
Logger.out("Finished updating matches")
|
Logger.out("Done. Until next time! <3 ")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun registerJob(data: MatchPlanningDataData) {
|
private fun registerJob(data: MatchPlanningDataData) {
|
||||||
|
|
|
@ -52,7 +52,7 @@ object TimeManager : IFeature {
|
||||||
|
|
||||||
// Register the cronjob to run at 0:01 AM UTC every Monday
|
// Register the cronjob to run at 0:01 AM UTC every Monday
|
||||||
override suspend fun registerThread() {
|
override suspend fun registerThread() {
|
||||||
Logger.out("Registering weekly planning message posting coroutine")
|
Logger.out("Adding message scheduler...")
|
||||||
val scheduler = buildSchedule("0 0 1 * * * 0o 1w") // 0 0 4 * * * 0o 1w // 0o is UTC
|
val scheduler = buildSchedule("0 0 1 * * * 0o 1w") // 0 0 4 * * * 0o 1w // 0o is UTC
|
||||||
scheduler.doInfinity {
|
scheduler.doInfinity {
|
||||||
this.runThread()
|
this.runThread()
|
||||||
|
@ -60,7 +60,7 @@ object TimeManager : IFeature {
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun runThread() {
|
private suspend fun runThread() {
|
||||||
Logger.out("Starting to send out weekly planning messages")
|
Logger.out("Starting to notify...")
|
||||||
|
|
||||||
// ChannelID -> Data
|
// ChannelID -> Data
|
||||||
val targetedChannels = TimePlanningChannelsRepository.getAll().associateBy { it.channelID }
|
val targetedChannels = TimePlanningChannelsRepository.getAll().associateBy { it.channelID }
|
||||||
|
@ -72,7 +72,7 @@ object TimeManager : IFeature {
|
||||||
for (ch2 in targetedChannels.keys) {
|
for (ch2 in targetedChannels.keys) {
|
||||||
val ch = Snowflake(ch2)
|
val ch = Snowflake(ch2)
|
||||||
if (Bot.bot.kordRef.getChannel(ch) == null)
|
if (Bot.bot.kordRef.getChannel(ch) == null)
|
||||||
continue
|
continue // TODO: Check if the channel is valid in another shard
|
||||||
val c = Bot.bot.kordRef.getChannelOf<MessageChannel>(ch)!!
|
val c = Bot.bot.kordRef.getChannelOf<MessageChannel>(ch)!!
|
||||||
msgStr = ""
|
msgStr = ""
|
||||||
if (targetedRoles != null && targetedRoles.keys.contains(ch2) && targetedRoles[ch2] != null) {
|
if (targetedRoles != null && targetedRoles.keys.contains(ch2) && targetedRoles[ch2] != null) {
|
||||||
|
@ -133,7 +133,7 @@ object TimeManager : IFeature {
|
||||||
}
|
}
|
||||||
msgStr += "${it}:${msg.id.value};"
|
msgStr += "${it}:${msg.id.value};"
|
||||||
then = then.plusDays(1).withHour(4).withMinute(0).withSecond(0)
|
then = then.plusDays(1).withHour(4).withMinute(0).withSecond(0)
|
||||||
Logger.out("Finished sending day $it in $ch")
|
Logger.out("Finished sending day $it")
|
||||||
|
|
||||||
delay(1000)
|
delay(1000)
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ object TimeManager : IFeature {
|
||||||
): EmbedBuilder {
|
): EmbedBuilder {
|
||||||
// Check if entry exists in db
|
// Check if entry exists in db
|
||||||
if (TimePlanningChannelsRepository.exists(cID, gID)) {
|
if (TimePlanningChannelsRepository.exists(cID, gID)) {
|
||||||
// delete all entries for this channel
|
// delete all entrys for this channel
|
||||||
TimePlanningChannelsRepository.deleteFromChannelInServer(cID, gID)
|
TimePlanningChannelsRepository.deleteFromChannelInServer(cID, gID)
|
||||||
return MessageUtil.getEmbed(
|
return MessageUtil.getEmbed(
|
||||||
EmbedColor.SUCCESS,
|
EmbedColor.SUCCESS,
|
||||||
|
|
|
@ -37,11 +37,6 @@ object MessageUtil {
|
||||||
val ebb = EmbedBuilder()
|
val ebb = EmbedBuilder()
|
||||||
ebb.color = e.color
|
ebb.color = e.color
|
||||||
ebb.title = e.title
|
ebb.title = e.title
|
||||||
ebb.author {
|
|
||||||
this.icon = e.author?.url
|
|
||||||
this.name = e.author?.name.toString()
|
|
||||||
this.url = e.author?.url
|
|
||||||
}
|
|
||||||
e.fields.forEach {
|
e.fields.forEach {
|
||||||
val fb = EmbedBuilder.Field()
|
val fb = EmbedBuilder.Field()
|
||||||
fb.name = it.name
|
fb.name = it.name
|
||||||
|
@ -49,10 +44,6 @@ object MessageUtil {
|
||||||
fb.inline = it.inline
|
fb.inline = it.inline
|
||||||
ebb.fields.add(fb)
|
ebb.fields.add(fb)
|
||||||
}
|
}
|
||||||
ebb.footer {
|
|
||||||
this.icon = e.footer?.iconUrl
|
|
||||||
this.text = e.footer?.text.toString()
|
|
||||||
}
|
|
||||||
ebb.description = e.description
|
ebb.description = e.description
|
||||||
return ebb
|
return ebb
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ package net.moonleay.liljudd.build
|
||||||
|
|
||||||
internal object BuildConstants {
|
internal object BuildConstants {
|
||||||
const val version = "${version}"
|
const val version = "${version}"
|
||||||
const val creatorID = "${creatorID}"
|
const val ownerID = "${ownerID}"
|
||||||
const val kordVersion = "${kordversion}"
|
const val kordVersion = "${kordversion}"
|
||||||
const val coroutinesVersion = "${coroutinesversion}"
|
const val coroutinesVersion = "${coroutinesversion}"
|
||||||
const val ktorVersion = "${ktorversion}"
|
const val ktorVersion = "${ktorversion}"
|
||||||
|
|
Loading…
Reference in a new issue