mirror of
https://github.com/LamGC/ContentGrabbingJi.git
synced 2025-04-29 22:27:33 +00:00
[Update] BotCommandProcess 更新帮助信息, 补充Javadoc, 调整命令名;
[Change] RandomIntervalSendTimer 将下一执行时间从分钟调整为具体时间; [Change] MessageEvent toString方法调整为输出具体实现类名而不是"MessageEvent";
This commit is contained in:
parent
5a52dd9208
commit
5f796f7da0
@ -113,13 +113,31 @@ public class BotCommandProcess {
|
||||
public static String help() {
|
||||
StringBuilder helpStrBuilder = new StringBuilder();
|
||||
helpStrBuilder.append("CGJ Bot使用指南").append("\n");
|
||||
helpStrBuilder.append("使用方法:.cgj <命令> [参数...]").append("\n");
|
||||
helpStrBuilder.append("例如查询作品信息功能:").append("\n");
|
||||
helpStrBuilder.append(".cgj artwork -id 80846159").append("\n");
|
||||
helpStrBuilder.append("目前可用的命令:").append("\n");
|
||||
helpStrBuilder.append("\t").append("ranking - 获取今天或指定日期排行榜的前10名作品").append("\n");
|
||||
helpStrBuilder.append("\t\t").append("-date - 指定查询日期(年-月-日)").append("\n");
|
||||
helpStrBuilder.append("\t\t").append("-type - 排行榜类型(illust/插画, ugoira/动图, manga/漫画)").append("\n");
|
||||
|
||||
helpStrBuilder.append("\t").append("search - 搜索指定关键词并显示前10个作品").append("\n");
|
||||
helpStrBuilder.append("\t\t").append("-content - 搜索内容").append("\n");
|
||||
helpStrBuilder.append("\t").append("artworks - 获取作品的Pixiv页面").append("\n");
|
||||
|
||||
helpStrBuilder.append("\t").append("link - 获取作品的Pixiv页面").append("\n");
|
||||
helpStrBuilder.append("\t\t").append("-id - 作品id").append("\n");
|
||||
|
||||
helpStrBuilder.append("\t").append("info - 获取Pixiv作品信息").append("\n");
|
||||
helpStrBuilder.append("\t\t").append("-id - 作品id").append("\n");
|
||||
|
||||
helpStrBuilder.append("\t").append("image - 获取指定作品的图片").append("\n");
|
||||
helpStrBuilder.append("\t\t").append("-id - 作品id").append("\n");
|
||||
helpStrBuilder.append("\t\t").append("-quality - 图片质量(original/原图 regular/预览图)").append("\n");
|
||||
helpStrBuilder.append("\t\t").append("-page - 页数").append("\n");
|
||||
|
||||
helpStrBuilder.append("\t").append("report - 报告不当作品").append("\n");
|
||||
helpStrBuilder.append("\t\t").append("-id - 作品Id").append("\n");
|
||||
helpStrBuilder.append("\t\t").append("-msg - 报告原因").append("\n");
|
||||
return helpStrBuilder.toString();
|
||||
}
|
||||
|
||||
@ -259,6 +277,18 @@ public class BotCommandProcess {
|
||||
return "功能未完成";
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索命令
|
||||
* @param content 搜索内容
|
||||
* @param type 搜索类型
|
||||
* @param area 搜索区域
|
||||
* @param includeKeywords 包括关键字
|
||||
* @param excludeKeywords 排除关键字
|
||||
* @param contentOption 搜索选项
|
||||
* @param pagesIndex 搜索页索引
|
||||
* @return 返回搜索内容消息
|
||||
* @throws IOException 当搜索发生异常时抛出
|
||||
*/
|
||||
@Command
|
||||
public static String search(@Argument(name = "content") String content,
|
||||
@Argument(name = "type", force = false) String type,
|
||||
@ -438,7 +468,7 @@ public class BotCommandProcess {
|
||||
}
|
||||
}
|
||||
|
||||
@Command(commandName = "artwork")
|
||||
@Command(commandName = "link")
|
||||
public static String artworksLink(@Argument(name = "id") int illustId) {
|
||||
try {
|
||||
if (isNoSafe(illustId, globalProp, false)) {
|
||||
|
@ -4,6 +4,8 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@ -89,6 +91,8 @@ public class RandomIntervalSendTimer extends TimerTask {
|
||||
start(this.loop.get());
|
||||
}
|
||||
|
||||
private final static DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-ss HH:mm:ss");
|
||||
|
||||
/**
|
||||
* 启动定时器
|
||||
* @param loop 是否循环, 如果为true, 则任务完成后会自动调用start方法继续循环, 直到被调用{@code #}或总定时器被销毁;
|
||||
@ -96,7 +100,9 @@ public class RandomIntervalSendTimer extends TimerTask {
|
||||
public void start(boolean loop) {
|
||||
this.loop.set(loop);
|
||||
long nextDelay = time + timeRandom.nextInt(floatTime);
|
||||
log.info("定时器 {} 下一延迟: {}ms ({}min)", Integer.toHexString(this.hashCode()), nextDelay, nextDelay / 1000F / 60F);
|
||||
Date nextDate = new Date();
|
||||
nextDate.setTime(nextDate.getTime() + nextDelay);
|
||||
log.info("定时器 {} 下一延迟: {}ms ({})", Integer.toHexString(this.hashCode()), nextDelay, dateFormat.format(nextDate));
|
||||
if(start.get()) {
|
||||
try {
|
||||
Field state = this.getClass().getSuperclass().getDeclaredField("state");
|
||||
|
@ -56,7 +56,7 @@ public abstract class MessageEvent implements EventObject, MessageSender {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MessageEvent{" +
|
||||
return this.getClass().getSimpleName() + "{" +
|
||||
"fromGroup=" + getFromGroup() +
|
||||
", fromQQ=" + getFromQQ() +
|
||||
", message='" + getMessage() + '\'' +
|
||||
|
Loading…
Reference in New Issue
Block a user