mirror of https://github.com/bvn13/JIrcBot.git
fixed duplicated corrections
parent
dff99f91f1
commit
40fd72f305
|
@ -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("" +
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue