Skip to content

Commit

Permalink
Merge pull request #271 from HyacinthBots/develop
Browse files Browse the repository at this point in the history
4.1.1
  • Loading branch information
tempest15 committed Oct 1, 2022
2 parents b535f40 + e1079b1 commit eb440a7
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 51 deletions.
4 changes: 1 addition & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugins {
}

group = "org.hyacinthbots.lilybot"
version = "4.1.0"
version = "4.1.1"

repositories {
mavenCentral()
Expand Down Expand Up @@ -53,14 +53,12 @@ dependencies {

implementation(libs.kord.extensions)
implementation(libs.kord.extensions.phishing)
implementation(libs.kord.extensions.mappings)
implementation(libs.kord.extensions.pluralkit)
implementation(libs.kord.extensions.unsafe)

implementation(libs.kotlin.stdlib)

// Logging dependencies
implementation(libs.groovy)
implementation(libs.logback)
implementation(libs.logging)

Expand Down
19 changes: 19 additions & 0 deletions docs/changelogs/4.1.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# LilyBot 4.1.1

This release cleans up quite a few errors and small missing features from the 4.1.0 release.
It also temporarily removes reminders as they are completely broken and need to be re-written.
Lastly, it removes the KordEx Mappings extension as Lily is no longer a Minecraft-focused bot.

Change:
* remove reminders
* remove mappings extension
* switch to xml for logback
* add a jump button to edit logging
* no longer log edited messages from bots

Fix:
* message edits going to member log
* Lily's online embed in production
* message attachments on message edit and delete logs

You can find a list of all the commits in this update [here](https://github.com/hyacinthbots/LilyBot/compare/v4.1.0...v4.1.1)
7 changes: 2 additions & 5 deletions libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
[versions]
kotlin = "1.7.10" # Note: Plugin versions must be updated in the settings.gradle.kts too

groovy = "3.0.13"
kord-extensions = "1.5.5-20220925.092000-32"
logging = "2.1.23" # Cannot be updated to 3.0.0 because we need newer logback, which requires an XML file, which throws errors I cannot fix
logback = "1.2.8"
logging = "3.0.0"
logback = "1.4.1"
github-api = "1.313"
kmongo = "4.7.1"
detekt = "1.21.0"
koma = "1.1.0"

[libraries]
groovy = { module = "org.codehaus.groovy:groovy", version.ref = "groovy" }
kord-extensions = { module = "com.kotlindiscord.kord.extensions:kord-extensions", version.ref = "kord-extensions" }
kord-extensions-phishing = { module = "com.kotlindiscord.kord.extensions:extra-phishing", version.ref = "kord-extensions" }
kord-extensions-mappings = { module = "com.kotlindiscord.kord.extensions:extra-mappings", version.ref = "kord-extensions"}
kord-extensions-pluralkit = { module = "com.kotlindiscord.kord.extensions:extra-pluralkit", version.ref = "kord-extensions"}
kord-extensions-unsafe = { module = "com.kotlindiscord.kord.extensions:unsafe", version.ref = "kord-extensions"}
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8" }
Expand Down
3 changes: 0 additions & 3 deletions src/main/kotlin/org/hyacinthbots/lilybot/LilyBot.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package org.hyacinthbots.lilybot
import cc.ekblad.toml.decode
import cc.ekblad.toml.tomlMapper
import com.kotlindiscord.kord.extensions.ExtensibleBot
import com.kotlindiscord.kord.extensions.modules.extra.mappings.extMappings
import com.kotlindiscord.kord.extensions.modules.extra.phishing.DetectionAction
import com.kotlindiscord.kord.extensions.modules.extra.phishing.extPhishing
import com.kotlindiscord.kord.extensions.modules.extra.pluralkit.extPluralKit
Expand Down Expand Up @@ -107,8 +106,6 @@ suspend fun main() {
requiredCommandPermission = null
}

extMappings { } // Enable the mappings extension

extPluralKit()

sentry {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@ package org.hyacinthbots.lilybot.extensions.events

import com.kotlindiscord.kord.extensions.DISCORD_YELLOW
import com.kotlindiscord.kord.extensions.checks.anyGuild
import com.kotlindiscord.kord.extensions.components.components
import com.kotlindiscord.kord.extensions.components.linkButton
import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.extensions.event
import com.kotlindiscord.kord.extensions.modules.extra.pluralkit.api.PKMessage
import com.kotlindiscord.kord.extensions.modules.extra.pluralkit.events.ProxiedMessageUpdateEvent
import com.kotlindiscord.kord.extensions.modules.extra.pluralkit.events.UnProxiedMessageUpdateEvent
import com.kotlindiscord.kord.extensions.utils.getJumpUrl
import dev.kord.core.behavior.channel.asChannelOf
import dev.kord.core.behavior.channel.createEmbed
import dev.kord.core.behavior.channel.createMessage
import dev.kord.core.entity.Message
import dev.kord.core.entity.channel.GuildMessageChannel
import dev.kord.rest.builder.message.create.embed
import kotlinx.datetime.Clock
import org.hyacinthbots.lilybot.extensions.config.ConfigOptions
import org.hyacinthbots.lilybot.utils.attachmentsAndProxiedMessageInfo
Expand All @@ -37,7 +41,8 @@ class MessageEdit : Extension() {
anyGuild()
requiredConfigs(ConfigOptions.MESSAGE_EDIT_LOGGING_ENABLED, ConfigOptions.MESSAGE_LOG)
failIf {
event.message.asMessage().author?.id == kord.selfId
val message = event.message.asMessage()
message.author?.isBot == true || event.old?.content == message.content
}
}
action {
Expand All @@ -55,7 +60,7 @@ class MessageEdit : Extension() {
anyGuild()
requiredConfigs(ConfigOptions.MESSAGE_EDIT_LOGGING_ENABLED, ConfigOptions.MESSAGE_LOG)
failIf {
event.message.asMessage().author?.id == kord.selfId
event.old?.content == event.message.asMessage().content
}
}
action {
Expand All @@ -77,28 +82,36 @@ class MessageEdit : Extension() {

val messageLog = getLoggingChannelWithPerms(ConfigOptions.MESSAGE_LOG, guild) ?: return

messageLog.createEmbed {
color = DISCORD_YELLOW
author {
name = "Message Edited"
icon = proxiedMessage?.member?.avatarUrl ?: message.author?.avatar?.url
}
description =
"Location: ${message.channel.mention} " +
"(${message.channel.asChannelOf<GuildMessageChannel>().name})"
timestamp = Clock.System.now()
messageLog.createMessage {
embed {
color = DISCORD_YELLOW
author {
name = "Message Edited"
icon = proxiedMessage?.member?.avatarUrl ?: message.author?.avatar?.url
}
description =
"Location: ${message.channel.mention} " +
"(${message.channel.asChannelOf<GuildMessageChannel>().name})"
timestamp = Clock.System.now()

field {
name = "Previous contents"
value = old?.trimmedContents().ifNullOrEmpty { "Failed to retrieve previous message contents" }
inline = false
field {
name = "Previous contents"
value = old?.trimmedContents().ifNullOrEmpty { "Failed to retrieve previous message contents" }
inline = false
}
field {
name = "New contents"
value = message.trimmedContents().ifNullOrEmpty { "Failed to retrieve new message contents" }
inline = false
}
attachmentsAndProxiedMessageInfo(guild, message, proxiedMessage)
}
field {
name = "New contents"
value = message.trimmedContents().ifNullOrEmpty { "Failed to retrieve new message contents" }
inline = false
components {
linkButton {
label = "Jump"
url = message.getJumpUrl()
}
}
attachmentsAndProxiedMessageInfo(guild, message, proxiedMessage)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import com.kotlindiscord.kord.extensions.extensions.event
import com.kotlindiscord.kord.extensions.types.respond
import com.kotlindiscord.kord.extensions.utils.delete
import com.kotlindiscord.kord.extensions.utils.respond
import com.soywiz.klock.seconds
import dev.kord.common.entity.MessageType
import dev.kord.common.entity.Permission
import dev.kord.common.entity.Permissions
Expand All @@ -25,6 +24,7 @@ import org.hyacinthbots.lilybot.database.collections.GalleryChannelCollection
import org.hyacinthbots.lilybot.extensions.config.ConfigOptions
import org.hyacinthbots.lilybot.utils.botHasChannelPerms
import org.hyacinthbots.lilybot.utils.getLoggingChannelWithPerms
import kotlin.time.Duration.Companion.seconds

/**
* The class the holds the systems that allow a guild to set a channel as a gallery channel.
Expand Down Expand Up @@ -187,7 +187,7 @@ class GalleryChannel : Extension() {
// If there are no attachments to the message and the channel we're in is an image channel
if (event.message.channelId == it.channelId && event.message.attachments.isEmpty()) {
// We delay to give the message a chance to populate with an embed, if it is a link to imgur etc.
delay(0.25.seconds.millisecondsLong)
delay(0.25.seconds.inWholeMilliseconds)
if (event.message.embeds.isEmpty()) { // If there is still no embed, we delete the message
// and explain why
if (event.message.type != MessageType.Default && event.message.type != MessageType.Reply) {
Expand All @@ -204,7 +204,7 @@ class GalleryChannel : Extension() {
try {
// Delete the explanation after 3 seconds. If an exception is thrown, the
// message has already been deleted
response.delete(2.5.seconds.millisecondsLong)
response.delete(2.5.seconds.inWholeMilliseconds)
} catch (e: EntityNotFoundException) {
// The message that we're attempting to delete has already been deleted.
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/org/hyacinthbots/lilybot/utils/_Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ suspend fun EmbedBuilder.attachmentsAndProxiedMessageInfo(
if (message.attachments.isNotEmpty()) {
field {
name = "Attachments"
value = message.attachments.map { it.url }.joinToString { "\n" }
value = message.attachments.joinToString(separator = "\n") { it.url }
inline = false
}
}
Expand Down
14 changes: 0 additions & 14 deletions src/main/resources/logback.groovy

This file was deleted.

15 changes: 15 additions & 0 deletions src/main/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- Disable warning "NativePRNGNonBlocking is not found, fallback to SHA1PRNG" -->
<logger name="io.ktor.util.random" level="ERROR"/>

<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%boldMagenta(%d{dd-MM-yyyy HH:mm:ss}) %gray(|) %boldCyan(%-30.-30thread) %gray(|) %highlight(%-5level) %gray(|) %boldGreen(%-40.40logger{40}) %gray(|) %msg%n</pattern>
</encoder>
</appender>

<root level="INFO">
<appender-ref ref="CONSOLE" />
</root>
</configuration>

0 comments on commit eb440a7

Please sign in to comment.