-
-
Notifications
You must be signed in to change notification settings - Fork 101
Fixes quotation marks in titles on /transfer #1332
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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("^[\"']|[\"']$", ""); | ||
|
||
if (title.length() > TITLE_MAX_LENGTH) { | ||
title = title.substring(0, TITLE_MAX_LENGTH); | ||
} | ||
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(); | ||
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please chain it instead.
There was a problem hiding this comment.
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:
Need help with "foo"
or"Foo" is weird
, it shouldnt trigger here. Only for"Foo bar"
.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.