mirror of
https://github.com/LamGC/ContentGrabbingJi.git
synced 2025-04-30 06:37:36 +00:00
[Add] VirtualLoadMessageEvent 增加假负载消息事件, 该事件在消息发送上将没有操作, 纯属执行命令;
[Change] RankingUpdateTimer 调整排行榜更新方式, 利用假负载消息触发一次完全执行;
This commit is contained in:
parent
f02b0e9e98
commit
dbfed874c0
@ -1,10 +1,12 @@
|
|||||||
package net.lamgc.cgj.bot;
|
package net.lamgc.cgj.bot;
|
||||||
|
|
||||||
|
import com.google.common.base.Throwables;
|
||||||
|
import net.lamgc.cgj.bot.event.BotEventHandler;
|
||||||
|
import net.lamgc.cgj.bot.event.VirtualLoadMessageEvent;
|
||||||
import net.lamgc.cgj.pixiv.PixivURL;
|
import net.lamgc.cgj.pixiv.PixivURL;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -65,11 +67,13 @@ public class RankingUpdateTimer {
|
|||||||
}
|
}
|
||||||
log.info("当前排行榜类型: {}.{}, 正在更新...", rankingMode.name(), contentType.name());
|
log.info("当前排行榜类型: {}.{}, 正在更新...", rankingMode.name(), contentType.name());
|
||||||
try {
|
try {
|
||||||
BotCommandProcess.getRankingInfoByCache(contentType, rankingMode, calendar.getTime(), 1, 0, true);
|
//BotCommandProcess.getRankingInfoByCache(contentType, rankingMode, calendar.getTime(), 1, 0, true);
|
||||||
|
BotEventHandler.executor.executorSync(
|
||||||
|
new VirtualLoadMessageEvent(0,0,
|
||||||
|
".cgj ranking -type " + rankingMode.modeParam + " -mode " + rankingMode.modeParam));
|
||||||
log.info("排行榜 {}.{} 更新完成.", rankingMode.name(), contentType.name());
|
log.info("排行榜 {}.{} 更新完成.", rankingMode.name(), contentType.name());
|
||||||
} catch (IOException e) {
|
} catch (InterruptedException e) {
|
||||||
log.error("排行榜 {}.{} 更新时发生异常", rankingMode.name(), contentType.name());
|
log.error("排行榜 {}.{} 更新时发生异常. \n{}", rankingMode.name(), contentType.name(), Throwables.getStackTraceAsString(e));
|
||||||
log.error("异常信息如下", e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
package net.lamgc.cgj.bot.event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 假负载消息事件, 一般用于预处理某个命令使用,可以增强在高峰期来临时的处理速度.
|
||||||
|
*/
|
||||||
|
public class VirtualLoadMessageEvent extends MessageEvent {
|
||||||
|
|
||||||
|
public VirtualLoadMessageEvent(long fromGroup, long fromQQ, String message) {
|
||||||
|
super(fromGroup, fromQQ, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int sendMessage(String message) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getImageUrl(String image) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user