Skip to content
This repository has been archived by the owner on Apr 18, 2021. It is now read-only.

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ShrBox committed Jan 10, 2021
1 parent 2ca5b42 commit 5579494
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ AutoRecall: 0 //自动撤回时间,0为禁用
# Usage

在群内发送`acg [关键词] [数量(1-20)]`
关键词中可以用`_`来表示空格
可以不加关键词和数量
控制台/群内输入`/acgreload`指令可以重载配置文件
9 changes: 8 additions & 1 deletion src/main/java/shrbox/github/acgpro/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Main extends PluginBase {
public static Config config;
public static boolean isPulling = false;
short count = 0;
public boolean limitMode;
public static boolean flashImageMode;
public static int autoRecall;

Expand All @@ -33,9 +34,12 @@ public void load_Config() { //配置文件加载
r18Groups.clear();
flashImageMode = config.getBoolean("FlashImageMode");
autoRecall = config.getInt("AutoRecall");
limitMode = config.getBoolean("limit-mode");
}

public void onEnable() {
load_Config();

JCommandManager.getInstance().register(this, new BlockingCommand( //注册命令
"acgreload", new ArrayList<>(), "重载ACGPro配置文件", "/acghreload"
) {
Expand All @@ -46,16 +50,19 @@ public boolean onCommandBlocking(@NotNull CommandSender commandSender, @NotNull
return true;
}
});

new Timer().schedule(new TimerTask() {
@Override
public void run() {
count = 0;
}
}, 60 * 1000, 60 * 1000); //一分钟自动重置变量count

System.setProperty("http.agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; QQBrowser/7.0.3698.400)");

getEventListener().subscribeAlways(GroupMessageEvent.class, (GroupMessageEvent e) -> {//监听群消息
if (e.getMessage().contentToString().toLowerCase().contains("acg")) {
if (config.getBoolean("limit-mode") && Main.isPulling) {//如果limit-mode为true,则同时只能存在一个图片下载任务
if (limitMode && Main.isPulling) {//如果limit-mode为true,则同时只能存在一个图片下载任务
e.getGroup().sendMessage("[ACGPro] 正在下载图片,请稍后再试");
return;
}
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/shrbox/github/acgpro/Thread.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ public void run() {
short pigNum = 1;
if (msgContent.contains(" ")) {
String[] str = msgContent.split(" ", 2);
msgContent = str[0];
msgContent = str[0].replace("_", " ");
if (str[1] == null) return;
char[] pigNum_ = str[1].toCharArray();
if (!Character.isDigit(pigNum_[0])) return;
pigNum = Short.parseShort(str[1]);
}

List<Long> r18Groups = Main.config.getLongList("r18-groups");
boolean isR18 = false;
if (Main.config.getBoolean("r18") && r18Groups.contains(e.getGroup().getId())) isR18 = true;
Expand Down Expand Up @@ -76,7 +77,7 @@ public void run() {
};
new Timer().schedule(timerTask, 80 * 1000);
*/
if (pigNum == 1) {
if (pigNum == 1) { //单张图片处理
Random random = new Random();
short index = (short) random.nextInt(json.data.size());
Data data = json.data.get(index);
Expand Down Expand Up @@ -116,7 +117,7 @@ public void run() {
}
}, Main.autoRecall * 1000);
}
} else {
} else { //多张图片处理
if (pigNum > json.data.size()) pigNum = (short) json.data.size();
e.getGroup().sendMessage("[ACGPro] 正在从服务器下载" + pigNum + "张图片...");
for (short a = 0; a < pigNum; a++) {
Expand Down

0 comments on commit 5579494

Please sign in to comment.