Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ public void onMessageContext(MessageContextInteractionEvent event) {
.formatted(originalMessage);
Optional<String> chatGptTitle = chatGptService.ask(chatGptTitleRequest, null);
String title = chatGptTitle.orElse(createTitle(originalMessage));
title = title.replaceAll("^[\"']|[\"']$", "");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please chain it instead.

Suggested change
title = title.replaceAll("^[\"']|[\"']$", "");
String title = chatGptTitle.orElse(createTitle(originalMessage))
.replaceAll("^[\"']|[\"']$", "");

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im not a fan of your regex for two reasons:

  • currently it also triggers when just one condition is met, for example Need help with "foo" or "Foo" is weird, it shouldnt trigger here. Only for "Foo bar".
  • if we do the first part then regex is overkill for this

so i propose to instead add if (title.startsWith("\"") && title.endsWith("\"")) { title = title.substring(1, title.length() - 1); } or something like that.

that said, i dont have a strong opinion on avoiding regex here specifically, so whatever. but please fix the first part.


if (title.length() > TITLE_MAX_LENGTH) {
title = title.substring(0, TITLE_MAX_LENGTH);
}
Expand Down Expand Up @@ -137,6 +139,25 @@ public void onMessageContext(MessageContextInteractionEvent event) {
event.replyModal(transferModal).queue();
}


String generateTitle(String originalMessage) {
String chatGptTitleRequest =
"Summarize the following question into a concise title or heading not more than 5 words, remove quotations if any: %s"
.formatted(originalMessage);
Optional<String> chatGptTitle = chatGptService.ask(chatGptTitleRequest, null);
String title = chatGptTitle.orElse(createTitle(originalMessage));

// 🔧 FIX: Remove surrounding quotes
title = title.replaceAll("^\"|\"$", "");

if (title.length() > TITLE_MAX_LENGTH) {
title = title.substring(0, TITLE_MAX_LENGTH);
}

return title;
}


Comment on lines +142 to +160
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a leftover or something? that new method isnt used anywhere. remove it or use it

@Override
public void onModalSubmitted(ModalInteractionEvent event, List<String> args) {
event.deferReply(true).queue();
Expand Down Expand Up @@ -175,8 +196,7 @@ private void transferFlow(ModalInteractionEvent event, String channelId, String
.retrieveUserById(authorId)
.flatMap(fetchedUser -> createForumPost(event, fetchedUser))
.flatMap(createdForumPost -> dmUser(event.getChannel(), createdForumPost,
event.getGuild())
.and(sendMessageToTransferrer.apply(createdForumPost)))
event.getGuild()).and(sendMessageToTransferrer.apply(createdForumPost)))
Comment on lines -178 to +199
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you didnt change anything here. i wouldnt be surprised if this will be auto-reverted the second you run spotless

.flatMap(dmSent -> deleteOriginalMessage(event.getJDA(), channelId, messageId))
.queue();
}
Expand Down
Loading