chromedrive新增代理支持
This commit is contained in:
parent
ec6fce9a8d
commit
694b5fb2ae
@ -178,30 +178,49 @@ public class AdminMessage extends Message {
|
||||
|
||||
case QQCommands.SIGN -> {
|
||||
boolean sign = true;
|
||||
boolean tsdmSign = false, baiheSign = false, nicePtSign = false;
|
||||
Log.i("开始签到");
|
||||
try {
|
||||
new Tsdm().tsdmSign();
|
||||
if (new Tsdm().tsdmSign()) {
|
||||
tsdmSign = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
sign = false;
|
||||
QQBotManager.getInstance().sendMessage(qq, "tsdm签到失败:" + AppTools.getExceptionString(e));
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
new BaiHeHui().sign();
|
||||
if (new BaiHeHui().sign()) {
|
||||
baiheSign = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
sign = false;
|
||||
QQBotManager.getInstance().sendMessage(qq, "百合会签到失败:" + AppTools.getExceptionString(e));
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
new NicePT().sign();
|
||||
if (new NicePT().sign()) {
|
||||
nicePtSign = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
sign = false;
|
||||
QQBotManager.getInstance().sendMessage(qq, "NicePT签到失败:" + AppTools.getExceptionString(e));
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (sign) {
|
||||
if (sign && tsdmSign && baiheSign && nicePtSign) {
|
||||
QQBotManager.getInstance().sendMessage(qq, "签到任务完成");
|
||||
}else{
|
||||
StringBuilder builder=new StringBuilder();
|
||||
if(!tsdmSign){
|
||||
builder.append("天使动漫签到失败\n");
|
||||
}
|
||||
if(!baiheSign){
|
||||
builder.append("百合会签到失败\n");
|
||||
}
|
||||
if(!nicePtSign){
|
||||
builder.append("NicePT签到失败\n");
|
||||
}
|
||||
QQBotManager.getInstance().sendMessage(qq,builder.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,8 +34,11 @@ public class BaiHeHui extends Model {
|
||||
if ("08:10:00".equals(time)) {
|
||||
Log.i("开始百合会签到");
|
||||
try {
|
||||
sign();
|
||||
if (sign()) {
|
||||
QQBotManager.getInstance().sendMessage(QQBotManager.defGroup, "百合会签到成功");
|
||||
}else{
|
||||
QQBotManager.getInstance().sendMessage(QQBotManager.defGroup, "百合会签到失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
QQBotManager.getInstance().sendMessage(QQBotManager.defGroup, "百合会签到失败:" + AppTools.getExceptionString(e));
|
||||
@ -43,12 +46,13 @@ public class BaiHeHui extends Model {
|
||||
}
|
||||
}
|
||||
|
||||
public void sign() {
|
||||
public boolean sign() {
|
||||
String cookie = ConfigTools.readFile(new File("baihehui.json"));
|
||||
if (StringUtils.isEmpty(cookie)) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
WebDriver driver = WebClient.getInstance().getWebDriver();
|
||||
try {
|
||||
JSONArray array = JSONArray.parseArray(cookie);
|
||||
driver.manage().timeouts().implicitlyWait(10000, TimeUnit.SECONDS);
|
||||
driver.get("https://bbs.yamibo.com/forum.php");
|
||||
@ -68,9 +72,15 @@ public class BaiHeHui extends Model {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
} finally {
|
||||
driver.close();
|
||||
driver.quit();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
|
@ -30,10 +30,13 @@ public class NicePT extends Model {
|
||||
public void onTime(Long qq, String time) {
|
||||
super.onTime(qq, time);
|
||||
if ("08:01:00".equals(time)) {
|
||||
Log.i("开始天使动漫签到");
|
||||
Log.i("开始NicePT签到");
|
||||
try {
|
||||
sign();
|
||||
if(sign()) {
|
||||
QQBotManager.getInstance().sendMessage(QQBotManager.defGroup, "已完成NicePT的签到");
|
||||
}else{
|
||||
QQBotManager.getInstance().sendMessage(QQBotManager.defGroup, "NicePT签到失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
QQBotManager.getInstance().sendMessage(QQBotManager.defGroup, "NicePT签到失败:" + AppTools.getExceptionString(e));
|
||||
e.printStackTrace();
|
||||
@ -41,14 +44,15 @@ public class NicePT extends Model {
|
||||
}
|
||||
}
|
||||
|
||||
public void sign(){
|
||||
public boolean sign() {
|
||||
String url = "https://www.nicept.net/attendance.php";
|
||||
JSONArray array = JSONArray.parseArray(ConfigTools.readFile(new File("nicept.json")));
|
||||
if (array == null) {
|
||||
System.err.println("array is null");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
WebDriver driver = WebClient.getInstance().getWebDriver();
|
||||
try {
|
||||
driver.manage().timeouts().implicitlyWait(10000, TimeUnit.SECONDS);
|
||||
driver.get(url);
|
||||
for (Cookie _cookie : WebClient.loadCookie(array)) {
|
||||
@ -65,7 +69,14 @@ public class NicePT extends Model {
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
} finally {
|
||||
driver.close();
|
||||
driver.quit();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,8 +48,11 @@ public class Tsdm extends Model {
|
||||
if ("08:05:00".equals(time)) {
|
||||
Log.i("开始天使动漫签到");
|
||||
try {
|
||||
tsdmSign();
|
||||
if(tsdmSign()) {
|
||||
QQBotManager.getInstance().sendMessage(QQBotManager.defGroup, "已完成天使动漫的签到");
|
||||
}else{
|
||||
QQBotManager.getInstance().sendMessage(QQBotManager.defGroup, "天使动漫签到失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
QQBotManager.getInstance().sendMessage(QQBotManager.defGroup, "天使动漫签到失败:" + AppTools.getExceptionString(e));
|
||||
e.printStackTrace();
|
||||
@ -57,13 +60,14 @@ public class Tsdm extends Model {
|
||||
}
|
||||
}
|
||||
|
||||
public void tsdmSign() {
|
||||
public boolean tsdmSign() {
|
||||
JSONArray array = JSONArray.parseArray(ConfigTools.readFile(new File("cookie.json")));
|
||||
if (array == null) {
|
||||
System.err.println("array is null");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
WebDriver driver = WebClient.getInstance().getWebDriver();
|
||||
try {
|
||||
driver.get("https://www.tsdm39.net/forum.php");
|
||||
getTsdm(array, driver);
|
||||
boolean isSign = false;
|
||||
@ -76,7 +80,7 @@ public class Tsdm extends Model {
|
||||
if (!isSign) {
|
||||
driver.close();
|
||||
driver.quit();
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
((JavascriptExecutor) driver).executeScript("showWindow('dsu_paulsign', 'plugin.php?id=dsu_paulsign:sign&9b5e8da2')");
|
||||
@ -94,9 +98,15 @@ public class Tsdm extends Model {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
} finally {
|
||||
driver.close();
|
||||
driver.quit();
|
||||
}
|
||||
}
|
||||
|
||||
private void getTsdm(JSONArray array, WebDriver driver) {
|
||||
driver.manage().timeouts().implicitlyWait(10000, TimeUnit.SECONDS);
|
||||
|
Loading…
Reference in New Issue
Block a user