join/left消息堆叠时检测是否已经跨分钟
This commit is contained in:
parent
c178415969
commit
49a5dd76e7
1 changed files with 8 additions and 1 deletions
|
@ -40,6 +40,7 @@ import java.util.function.BiConsumer;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
public class TGBridge {
|
||||
private static final long MINUTE = 60_000;
|
||||
private final VTools plugin;
|
||||
private final ProxyServer server;
|
||||
@SuppressWarnings("java:S3008")
|
||||
|
@ -505,13 +506,16 @@ public class TGBridge {
|
|||
private class JoinLeftAnnounceMessage {
|
||||
private int messageId;
|
||||
private long time;
|
||||
private long timeMinute;
|
||||
|
||||
private StringBuilder text;
|
||||
private boolean abort = false;
|
||||
|
||||
boolean isValid() {
|
||||
if (abort || messageId < 1) return false;
|
||||
long dt = System.currentTimeMillis() - time;
|
||||
long current = System.currentTimeMillis();
|
||||
if (current / MINUTE != timeMinute) return false;
|
||||
long dt = current - time;
|
||||
return dt <= 30_000 && dt >= 0;
|
||||
}
|
||||
|
||||
|
@ -522,6 +526,7 @@ public class TGBridge {
|
|||
protected JoinLeftAnnounceMessage(String firstMessage) {
|
||||
text = new StringBuilder(firstMessage);
|
||||
time = System.currentTimeMillis();
|
||||
timeMinute = time/MINUTE;
|
||||
sendAnnounceMessage();
|
||||
}
|
||||
|
||||
|
@ -548,7 +553,9 @@ public class TGBridge {
|
|||
protected JoinLeftAnnounceMessage() {
|
||||
messageId = 0;
|
||||
time = 0;
|
||||
timeMinute = 0;
|
||||
text = new StringBuilder();
|
||||
abort = false;
|
||||
} //dummy
|
||||
|
||||
private void addLines(List<String> messages) {
|
||||
|
|
Loading…
Reference in a new issue