fixed duplicated corrections

pull/2/head
Vyacheslav N. Boyko 2018-02-05 22:17:40 +03:00
parent dff99f91f1
commit 40fd72f305
2 changed files with 5 additions and 3 deletions

View File

@ -9,6 +9,7 @@ import ru.bvn13.jircbot.database.repositories.GrammarCorrectionRepository;
import javax.sql.DataSource;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
@ -24,10 +25,10 @@ public class GrammarCorrectionService {
@Autowired
private GrammarCorrectionRepository grammarCorrectionRepository;
public List<String> getCorrectionsForMessage(String message) {
public HashSet<String> getCorrectionsForMessage(String message) {
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
List<String> result = new ArrayList<>();
HashSet<String> result = new HashSet<>();
try {
jdbcTemplate.query("" +

View File

@ -9,6 +9,7 @@ import ru.bvn13.jircbot.database.services.ChannelSettingsService;
import ru.bvn13.jircbot.database.services.GrammarCorrectionService;
import java.text.SimpleDateFormat;
import java.util.HashSet;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import java.util.regex.Matcher;
@ -53,7 +54,7 @@ public class GrammarCorrectorListener extends ImprovedListenerAdapter {
private void checkForCorrection(final GenericMessageEvent event) throws Exception {
String message = event.getMessage().replace(COMMAND, "").trim();
List<String> corrections = grammarCorrectionService.getCorrectionsForMessage(message);
HashSet<String> corrections = grammarCorrectionService.getCorrectionsForMessage(message);
corrections.forEach(correct -> {
this.sendNotice(event,"*"+correct);
});