Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class SlackAIService {

private static final Pattern AI_PREFIX_PATTERN = Pattern.compile("^[Aa][Ii]\\)\\s*(.+)$");
private static final Pattern MENTION_PATTERN = Pattern.compile("^<@[^>]+>\\s*");
private static final Pattern MARKDOWN_BOLD_PATTERN =
Pattern.compile("\\*\\*(.+?)\\*\\*", Pattern.DOTALL);
private static final String AI_RESPONSE_PREFIX = ":robot_face: *AI 응답*\n";
private static final int MAX_HISTORY_MESSAGES = 10;
private static final String EMPTY_QUERY_MESSAGE =
Expand Down Expand Up @@ -169,7 +171,14 @@ private List<Map<String, Object>> mergeConsecutiveRoles(List<Map<String, Object>
return merged;
}

private String convertMarkdownToSlack(String text) {
if (text == null) {
return null;
}
return MARKDOWN_BOLD_PATTERN.matcher(text).replaceAll("*$1*");
}

private String formatSlackResponse(String response) {
return String.format(":robot_face: *AI 응답*\n%s", response);
return AI_RESPONSE_PREFIX + convertMarkdownToSlack(response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,21 @@ private void handleEvent(Map<String, Object> event) {
if (slackAIService.isAIQuery(text)) {
log.debug("AI 질문 감지");
slackAIService.processAIQuery(text, channelId, effectiveThreadTs, null);
} else if (threadTs != null && slackAIService.isAppMention(text)) {
List<Map<String, Object>> aiReplies =
slackAIService.fetchAIThreadReplies(channelId, threadTs);
if (!aiReplies.isEmpty()) {
log.debug("AI 스레드 내 후속 질문 감지");
slackAIService.processAIQuery(
text, channelId, effectiveThreadTs, aiReplies);
}
}
}

if ("app_mention".equals(eventType) && text != null) {
String normalizedText = slackAIService.normalizeAppMentionText(text);
log.debug("앱 멘션 감지");
slackAIService.processAIQuery(normalizedText, channelId, effectiveThreadTs, null);
if (threadTs != null) {
List<Map<String, Object>> aiReplies =
slackAIService.fetchAIThreadReplies(channelId, threadTs);
slackAIService.processAIQuery(
normalizedText, channelId, effectiveThreadTs,
aiReplies.isEmpty() ? null : aiReplies);
} else {
slackAIService.processAIQuery(normalizedText, channelId, effectiveThreadTs, null);
}
}
}
}
Loading