Skip to content

Release v4.14 #1184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions application/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
dependencies {
classpath 'org.xerial:sqlite-jdbc:3.45.0.0'
classpath 'org.xerial:sqlite-jdbc:3.46.1.0'
}
}

Expand Down Expand Up @@ -46,7 +46,7 @@ dependencies {
implementation project(':utils')
implementation project(':formatter')

implementation 'net.dv8tion:JDA:5.0.0-beta.21'
implementation 'net.dv8tion:JDA:5.1.0'

implementation 'org.apache.logging.log4j:log4j-core:2.23.0'
runtimeOnly 'org.apache.logging.log4j:log4j-slf4j18-impl:2.18.0'
Expand All @@ -57,7 +57,7 @@ dependencies {

implementation 'io.mikael:urlbuilder:2.0.9'

implementation 'org.jsoup:jsoup:1.17.1'
implementation 'org.jsoup:jsoup:1.18.1'

implementation 'org.scilab.forge:jlatexmath:1.0.7'
implementation 'org.scilab.forge:jlatexmath-font-greek:1.0.7'
Expand All @@ -75,16 +75,16 @@ dependencies {

implementation 'com.github.ben-manes.caffeine:caffeine:3.1.1'

implementation 'org.kohsuke:github-api:1.321'
implementation 'org.kohsuke:github-api:1.324'

implementation 'org.apache.commons:commons-text:1.12.0'
implementation 'com.apptasticsoftware:rssreader:3.6.0'
implementation 'com.apptasticsoftware:rssreader:3.8.1'

testImplementation 'org.mockito:mockito-core:5.12.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.0'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.10.0'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.11.0'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.11.1'

implementation "com.theokanning.openai-gpt3-java:api:$chatGPTVersion"
implementation "com.theokanning.openai-gpt3-java:service:$chatGPTVersion"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private RestAction<Message> createAIResponse(ThreadChannel threadChannel, Messag
}

private static boolean isContextSufficient(Message message) {
return !MessageUtils.containsImage(message)
return !MessageUtils.containsAttachments(message)
&& !LinkDetection.containsLink(message.getContentRaw());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.togetherjava.tjbot.features.help;

import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel;
import net.dv8tion.jda.api.entities.channel.forums.ForumTag;
import net.dv8tion.jda.api.events.channel.update.ChannelUpdateAppliedTagsEvent;
Expand Down Expand Up @@ -75,14 +76,25 @@ private void handleThreadStatus(ThreadChannel threadChannel) {
boolean isArchived = threadChannel.isArchived();

if (isArchived) {
handleArchiveStatus(closedAt, threadChannel);
handleArchiveStatus(closedAt, threadId, threadChannel.getJDA());
return;
}

updateThreadStatusToActive(threadId);
}

void handleArchiveStatus(Instant closedAt, ThreadChannel threadChannel) {
void handleArchiveStatus(Instant closedAt, long id, JDA jda) {
ThreadChannel threadChannel = jda.getThreadChannelById(id);
if (threadChannel == null) {
logger.info("thread with id: {} no longer exists, marking archived in records", id);
database.write(context -> context.update(HELP_THREADS)
.set(HELP_THREADS.CLOSED_AT, closedAt)
.set(HELP_THREADS.TICKET_STATUS, HelpSystemHelper.TicketStatus.ARCHIVED.val)
.where(HELP_THREADS.CHANNEL_ID.eq(id))
.execute());
return;
}

long threadId = threadChannel.getIdLong();
int messageCount = threadChannel.getMessageCount();
int participantsExceptAuthor = threadChannel.getMemberCount() - 1;
Expand All @@ -96,6 +108,7 @@ void handleArchiveStatus(Instant closedAt, ThreadChannel threadChannel) {
.execute());

logger.info("Thread with id: {}, updated to archived status in database", threadId);

}

private void updateThreadStatusToActive(long threadId) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.togetherjava.tjbot.features.help;

import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -59,13 +58,12 @@ private void updateTicketStatus(JDA jda) {
.map(HelpThreadsRecord::getChannelId)
.toList());


threadIdsToClose.forEach(id -> {
try {
ThreadChannel threadChannel = jda.getThreadChannelById(id);
helpThreadLifecycleListener.handleArchiveStatus(now, threadChannel);
helpThreadLifecycleListener.handleArchiveStatus(now, id, jda);
} catch (Exception exception) {
logger.warn("unable to mark thread as close with id :{}", id, exception);
logger.warn("Failed to update status of thread with id: {} to archived", id,
exception);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,11 @@ public void onModalSubmitted(ModalInteractionEvent event, List<String> args) {

private void handleVersionCommand(SlashCommandInteractionEvent event) {
String code = """
System.out.println("```");
System.out.println("Version: " + Runtime.version());
System.out.println("Vendor: " + System.getProperty("java.vendor"));
System.out.println("OS: " + System.getProperty("os.name"));
System.out.println("Arch: " + System.getProperty("os.arch"));
System.out.println("```");""";
""";
handleEval(event, null, false, code, false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,16 +221,16 @@ public static Optional<CodeFence> extractCode(String fullMessage) {
}

/**
* Checks if a given message contains any image attachments.
*
* Checks if a given message contains any attachments.
*
* @param message the message to be checked
* @return {@code true} if the message contains at least one image attachment
* @return {@code true} if the message contains at least one attachment
*
* @see Message
* @see Message.Attachment
*/
public static boolean containsImage(Message message) {
return message.getAttachments().stream().anyMatch(Message.Attachment::isImage);
public static boolean containsAttachments(Message message) {
return !message.getAttachments().isEmpty();
}

}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id 'java'
id "com.diffplug.spotless" version "6.25.0"
id "org.sonarqube" version "5.0.0.4638"
id "org.sonarqube" version "5.1.0.4882"
id "name.remal.sonarlint" version "4.2.2"
}

Expand Down
4 changes: 2 additions & 2 deletions database/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ plugins {
id 'java'
}

var sqliteVersion = "3.45.0.0"
var sqliteVersion = "3.46.1.0"

dependencies {
implementation 'com.google.code.findbugs:jsr305:3.0.2'
implementation "org.xerial:sqlite-jdbc:${sqliteVersion}"
implementation 'org.flywaydb:flyway-core:10.13.0'
implementation 'org.flywaydb:flyway-core:10.17.2'
implementation "org.jooq:jooq:$jooqVersion"

implementation project(':utils')
Expand Down
4 changes: 2 additions & 2 deletions formatter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependencies {
implementation project(':utils')

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.0'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.10.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.0'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.11.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.11.1'
}

Loading