mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-01-27 06:04:54 +00:00
[AB-xxx] minor logging updates
This commit is contained in:
@@ -13,6 +13,7 @@ import dev.sheldan.abstracto.entertainment.config.EntertainmentFeatureDefinition
|
||||
import dev.sheldan.abstracto.entertainment.config.EntertainmentModuleDefinition;
|
||||
import dev.sheldan.abstracto.entertainment.exception.ReactTooManyReactionsException;
|
||||
import dev.sheldan.abstracto.entertainment.service.EntertainmentService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -21,6 +22,7 @@ import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class React extends AbstractConditionableCommand {
|
||||
|
||||
@Autowired
|
||||
@@ -38,6 +40,7 @@ public class React extends AbstractConditionableCommand {
|
||||
List<String> reactionChars = entertainmentService.convertTextToEmojis(text);
|
||||
int existingReactions = message.getReactions().size();
|
||||
if(reactionChars.size() + existingReactions > Message.MAX_REACTIONS) {
|
||||
log.error("Message has already {} reactions, {} would be added.", existingReactions, reactionChars.size());
|
||||
throw new ReactTooManyReactionsException();
|
||||
}
|
||||
List<CompletableFuture<Void>> futures = new ArrayList<>();
|
||||
|
||||
@@ -128,6 +128,7 @@ public class EntertainmentServiceBean implements EntertainmentService {
|
||||
}
|
||||
}
|
||||
}
|
||||
log.debug("Replaced {} combos.", replacedCombos.size());
|
||||
Set<String> usedReplacements = new HashSet<>();
|
||||
char[] split = text.toCharArray();
|
||||
|
||||
@@ -152,6 +153,7 @@ public class EntertainmentServiceBean implements EntertainmentService {
|
||||
}
|
||||
// reject any other character, as the ones we can deal with
|
||||
if (!this.reactMapping.getSingle().containsKey(charAsString)) {
|
||||
log.info("Cannot find mapping. Not replacing with emote.");
|
||||
continue;
|
||||
}
|
||||
List<String> listToUse = this.reactMapping.getSingle().get(charAsString);
|
||||
@@ -168,6 +170,7 @@ public class EntertainmentServiceBean implements EntertainmentService {
|
||||
throw new ReactDuplicateCharacterException();
|
||||
}
|
||||
}
|
||||
log.debug("We used {} replacements for a string of length {}.", usedReplacements.size(), text.length());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -182,6 +185,8 @@ public class EntertainmentServiceBean implements EntertainmentService {
|
||||
JsonReader reader = new JsonReader(new InputStreamReader(reactMappingSource.getInputStream()));
|
||||
this.reactMapping = gson.fromJson(reader, ReactMapping.class);
|
||||
this.reactMapping.populateKeys();
|
||||
log.info("Loaded {} single replacement mappings.", this.reactMapping.getSingle().size());
|
||||
log.info("Loaded {} combo replacements.", this.reactMapping.getCombination().size());
|
||||
} catch (IOException e) {
|
||||
log.error("Failed to load react bindings.", e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user