feature/handle-similar-messages-as-scam by Alathreon · Pull Request #1292 · Together-Java/TJ-Bot
i am not sure if that alreadyFlaggedUsers user thing really works.. the bot has a really long uptime usually, sometimes many months.
the way i read the code is that if a user got flagged once, they will then be immune to this check until the bot is restarted again. u could argue that its probably not an issue in practice but it smells a bit. you would need a time based cleanup for alreadyFlaggedUsers as well.
at which point u have like 30 lines of code dealing with what caffeeine gets done in one line, i guess.
private final Cache<String, Instant> userIdToAskedAtCache = Caffeine.newBuilder() .maximumSize(1_000) .expireAfterWrite(Duration.of(10, ChronoUnit.SECONDS)) .build();
the interface is essentially that of a Map, so you have various get and put variants. internally its a LRU map, so it kicks out the entries that werent touched the longest when it reaches the max limit.