新增NicePT签到
新增https工具
This commit is contained in:
66
src/main/java/com/yutou/qqbot/models/WebSign/NicePT.java
Normal file
66
src/main/java/com/yutou/qqbot/models/WebSign/NicePT.java
Normal file
@@ -0,0 +1,66 @@
|
||||
package com.yutou.qqbot.models.WebSign;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.yutou.qqbot.QQBotManager;
|
||||
import com.yutou.qqbot.models.Model;
|
||||
import com.yutou.qqbot.utlis.*;
|
||||
import org.openqa.selenium.Cookie;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class NicePT extends Model {
|
||||
@Override
|
||||
public boolean isUserPublic() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getUsePowers() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTime(String time) {
|
||||
super.onTime(time);
|
||||
if ("08:01:00".equals(time)) {
|
||||
Log.i("开始天使动漫签到");
|
||||
try {
|
||||
sign();
|
||||
QQBotManager.getInstance().sendMessage(QQBotManager.defGroup, "已完成NicePT的签到");
|
||||
} catch (Exception e) {
|
||||
QQBotManager.getInstance().sendMessage(QQBotManager.defGroup, "NicePT签到失败:" + AppTools.getExceptionString(e));
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void 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;
|
||||
}
|
||||
WebDriver driver = WebClient.getInstance().getWebDriver();
|
||||
driver.manage().timeouts().implicitlyWait(10000, TimeUnit.SECONDS);
|
||||
driver.get(url);
|
||||
for (Cookie _cookie : WebClient.loadCookie(array)) {
|
||||
driver.manage().addCookie(_cookie);
|
||||
}
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
driver.get(url);
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
driver.close();
|
||||
driver.quit();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user