mirror of
https://github.com/LamGC/ContentGrabbingJi.git
synced 2025-04-30 06:37:36 +00:00
[Update] Main, AutoArtworksSender, ImageCacheStore, PixivAccessProxyServer, PagesQualityParser 整理代码问题, 删除无用类;
This commit is contained in:
parent
1f402fbbac
commit
f040f130d7
@ -86,7 +86,7 @@ public class Main {
|
|||||||
File cookieStoreFile = new File(System.getProperty("cgj.botDataDir"), "cookies.store");
|
File cookieStoreFile = new File(System.getProperty("cgj.botDataDir"), "cookies.store");
|
||||||
if(!cookieStoreFile.exists()) {
|
if(!cookieStoreFile.exists()) {
|
||||||
log.warn("未找到cookies.store文件, 是否启动PixivLoginProxyServer? (yes/no)");
|
log.warn("未找到cookies.store文件, 是否启动PixivLoginProxyServer? (yes/no)");
|
||||||
Scanner scanner = new Scanner(System.in);
|
try(Scanner scanner = new Scanner(System.in)) {
|
||||||
if(scanner.nextLine().trim().equalsIgnoreCase("yes")) {
|
if(scanner.nextLine().trim().equalsIgnoreCase("yes")) {
|
||||||
startPixivLoginProxyServer();
|
startPixivLoginProxyServer();
|
||||||
} else {
|
} else {
|
||||||
@ -94,6 +94,8 @@ public class Main {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(cookieStoreFile));
|
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(cookieStoreFile));
|
||||||
cookieStore = (CookieStore) ois.readObject();
|
cookieStore = (CookieStore) ois.readObject();
|
||||||
ois.close();
|
ois.close();
|
||||||
@ -137,7 +139,9 @@ public class Main {
|
|||||||
|
|
||||||
@Command
|
@Command
|
||||||
public static void botMode(@Argument(name = "args", force = false) String argsStr) {
|
public static void botMode(@Argument(name = "args", force = false) String argsStr) {
|
||||||
new MiraiMain().init();
|
MiraiMain main = new MiraiMain();
|
||||||
|
main.init();
|
||||||
|
main.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command
|
@Command
|
||||||
@ -423,8 +427,9 @@ public class Main {
|
|||||||
proxyServerStartThread.setName("LoginProxyServerThread");
|
proxyServerStartThread.setName("LoginProxyServerThread");
|
||||||
proxyServerStartThread.start();
|
proxyServerStartThread.start();
|
||||||
//System.console().readLine();
|
//System.console().readLine();
|
||||||
Scanner scanner = new Scanner(System.in);
|
|
||||||
log.info("登录完成后, 使用\"done\"命令结束登录过程.");
|
log.info("登录完成后, 使用\"done\"命令结束登录过程.");
|
||||||
|
try(Scanner scanner = new Scanner(System.in)) {
|
||||||
while(true) {
|
while(true) {
|
||||||
if (scanner.nextLine().equalsIgnoreCase("done")) {
|
if (scanner.nextLine().equalsIgnoreCase("done")) {
|
||||||
log.info("关闭PLPS服务器...");
|
log.info("关闭PLPS服务器...");
|
||||||
@ -443,5 +448,6 @@ public class Main {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,57 +0,0 @@
|
|||||||
package net.lamgc.cgj.bot;
|
|
||||||
|
|
||||||
import net.lz1998.cq.robot.CoolQ;
|
|
||||||
import org.apache.http.client.methods.HttpGet;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
import java.util.Timer;
|
|
||||||
import java.util.TimerTask;
|
|
||||||
|
|
||||||
public class AutoArtworksSender {
|
|
||||||
|
|
||||||
private final CoolQ CQ;
|
|
||||||
private final ReceiveType receiveType;
|
|
||||||
private final long targetReceiveId;
|
|
||||||
private Timer timer = new Timer();
|
|
||||||
private TimerTask task = new TimerTask() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
HttpGet request = new HttpGet();
|
|
||||||
|
|
||||||
// https://api.imjad.cn/pixiv/v2/?type=tags
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public AutoArtworksSender(CoolQ cq, ReceiveType receiveType, long receiveId) {
|
|
||||||
this.CQ = cq;
|
|
||||||
this.receiveType = receiveType;
|
|
||||||
this.targetReceiveId = receiveId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reset(long time) {
|
|
||||||
if(time <= 0) {
|
|
||||||
timer.schedule(task, new Random().nextInt(10 * 60 * 60 * 1000) + 7200000L); //2H ~ 12H
|
|
||||||
} else {
|
|
||||||
timer.schedule(task, time);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendMessage(String message, boolean auto_escape) {
|
|
||||||
switch (receiveType) {
|
|
||||||
case GROUP:
|
|
||||||
CQ.sendGroupMsg(targetReceiveId, message, auto_escape);
|
|
||||||
break;
|
|
||||||
case Discuss:
|
|
||||||
CQ.sendDiscussMsg(targetReceiveId, message, auto_escape);
|
|
||||||
break;
|
|
||||||
case PRIVATE:
|
|
||||||
CQ.sendPrivateMsg(targetReceiveId, message, auto_escape);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum ReceiveType {
|
|
||||||
PRIVATE, GROUP, Discuss
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -8,7 +8,6 @@ import java.util.Hashtable;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import java.util.concurrent.locks.Condition;
|
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
public final class ImageCacheStore {
|
public final class ImageCacheStore {
|
||||||
@ -102,8 +101,6 @@ public final class ImageCacheStore {
|
|||||||
|
|
||||||
public final AtomicReference<TaskState> taskState = new AtomicReference<>(TaskState.READY);
|
public final AtomicReference<TaskState> taskState = new AtomicReference<>(TaskState.READY);
|
||||||
|
|
||||||
public final Condition condition = lock.newCondition();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ public class PixivAccessProxyServer {
|
|||||||
}*/
|
}*/
|
||||||
log.info("Response Cookie: " + value);
|
log.info("Response Cookie: " + value);
|
||||||
BasicClientCookie cookie = parseRawCookie(value);
|
BasicClientCookie cookie = parseRawCookie(value);
|
||||||
cookieStore.addCookie(null);
|
cookieStore.addCookie(cookie);
|
||||||
});
|
});
|
||||||
httpResponse.headers().remove(HttpHeaderNames.SET_COOKIE);
|
httpResponse.headers().remove(HttpHeaderNames.SET_COOKIE);
|
||||||
super.afterResponse(clientChannel, proxyChannel, httpResponse, pipeline);
|
super.afterResponse(clientChannel, proxyChannel, httpResponse, pipeline);
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package net.lamgc.cgj.util;
|
package net.lamgc.cgj.util;
|
||||||
|
|
||||||
import net.lamgc.cgj.pixiv.PixivDownload;
|
import net.lamgc.cgj.pixiv.PixivDownload;
|
||||||
import net.lamgc.cgj.pixiv.PixivURL;
|
|
||||||
import net.lamgc.utils.base.runner.StringParameterParser;
|
import net.lamgc.utils.base.runner.StringParameterParser;
|
||||||
|
|
||||||
public class PagesQualityParser implements StringParameterParser<PixivDownload.PageQuality> {
|
public class PagesQualityParser implements StringParameterParser<PixivDownload.PageQuality> {
|
||||||
|
Loading…
Reference in New Issue
Block a user