Compare commits
4 commits
c65e4031d9
...
4b46d34f45
Author | SHA1 | Date | |
---|---|---|---|
4b46d34f45 | |||
0cd3e4d6a8 | |||
a7e656bcbe | |||
404e043da1 |
8 changed files with 25 additions and 16 deletions
|
@ -29,7 +29,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
//lilJudd version 2
|
//lilJudd version 2
|
||||||
val ownerID = 372703841151614976L
|
val creatorID = 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,
|
||||||
"ownerID" to ownerID,
|
"creatorID" to creatorID,
|
||||||
"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.ownerID}>.\n" +
|
"Please report this to <@${BuildConstants.creatorID}>.\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 IchLiebeZuege (https://mal-noh.de).")
|
Logger.out("li'l Judd made by moonleay (https://moonleay.net). Web UI made by aronmal (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("Starting to update roles...")
|
Logger.out("Updating match 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("Done! Until tomorrow! <3 ")
|
Logger.out("Finished updating roles")
|
||||||
}
|
}
|
||||||
|
|
||||||
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("Adding availability scheduler...")
|
Logger.out("Registering daily planning message role update coroutine")
|
||||||
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 {
|
||||||
var alreadyExists = PlanningNotifierRolesRepository.existsInChannel(cID)
|
val 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 match roles...")
|
Logger.out("Updating matches")
|
||||||
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("Done. Until next time! <3 ")
|
Logger.out("Finished updating matches")
|
||||||
}
|
}
|
||||||
|
|
||||||
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("Adding message scheduler...")
|
Logger.out("Registering weekly planning message posting coroutine")
|
||||||
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 notify...")
|
Logger.out("Starting to send out weekly planning messages")
|
||||||
|
|
||||||
// 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 // TODO: Check if the channel is valid in another shard
|
continue
|
||||||
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")
|
Logger.out("Finished sending day $it in $ch")
|
||||||
|
|
||||||
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 entrys for this channel
|
// delete all entries for this channel
|
||||||
TimePlanningChannelsRepository.deleteFromChannelInServer(cID, gID)
|
TimePlanningChannelsRepository.deleteFromChannelInServer(cID, gID)
|
||||||
return MessageUtil.getEmbed(
|
return MessageUtil.getEmbed(
|
||||||
EmbedColor.SUCCESS,
|
EmbedColor.SUCCESS,
|
||||||
|
|
|
@ -37,6 +37,11 @@ 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
|
||||||
|
@ -44,6 +49,10 @@ 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 ownerID = "${ownerID}"
|
const val creatorID = "${creatorID}"
|
||||||
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