新增HiRes猪猪论坛签到

This commit is contained in:
Yutousama 2022-07-16 12:35:15 +08:00
parent 05e8814b91
commit b2610a02b2
2 changed files with 91 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import com.yutou.qqbot.models.Model;
import com.yutou.qqbot.models.WebSign.BaiHeHui;
import com.yutou.qqbot.models.WebSign.NicePT;
import com.yutou.qqbot.models.WebSign.Tsdm;
import com.yutou.qqbot.models.WebSign.ZhuZhu;
import com.yutou.qqbot.utlis.AppTools;
import com.yutou.qqbot.utlis.Log;
import com.yutou.qqbot.utlis.StringUtils;
@ -178,7 +179,7 @@ public class AdminMessage extends Message {
case QQCommands.SIGN -> {
boolean sign = true;
boolean tsdmSign = false, baiheSign = false, nicePtSign = false;
boolean tsdmSign = false, baiheSign = false, nicePtSign = false, zhuzhuSign=false;
Log.i("开始签到");
try {
if (new Tsdm().tsdmSign()) {
@ -207,6 +208,15 @@ public class AdminMessage extends Message {
QQBotManager.getInstance().sendMessage(qq, "NicePT签到失败:" + AppTools.getExceptionString(e));
e.printStackTrace();
}
try {
if (new ZhuZhu().sign()) {
zhuzhuSign = true;
}
} catch (Exception e) {
sign = false;
QQBotManager.getInstance().sendMessage(qq, "HiRes花园签到失败:" + AppTools.getExceptionString(e));
e.printStackTrace();
}
if (sign && tsdmSign && baiheSign && nicePtSign) {
QQBotManager.getInstance().sendMessage(qq, "签到任务完成");
}else{
@ -220,6 +230,9 @@ public class AdminMessage extends Message {
if(!nicePtSign){
builder.append("NicePT签到失败\n");
}
if(!zhuzhuSign){
builder.append("HiRes花园签到失败\n");
}
QQBotManager.getInstance().sendMessage(qq,builder.toString());
}
}

View File

@ -0,0 +1,77 @@
package com.yutou.qqbot.models.WebSign;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.yutou.qqbot.Annotations.UseModel;
import com.yutou.qqbot.models.Model;
import com.yutou.qqbot.utlis.ConfigTools;
import com.yutou.qqbot.utlis.StringUtils;
import com.yutou.qqbot.utlis.WebClient;
import org.openqa.selenium.*;
import java.io.File;
@UseModel
public class ZhuZhu extends Model {
@Override
public boolean isUserPublic() {
return false;
}
@Override
public String[] getUsePowers() {
return new String[0];
}
@Override
public String getModelName() {
return "HiRes猪猪论坛签到模块";
}
@Override
public synchronized void onTime(Long qq, String time) {
super.onTime(qq, time);
if ("09:01:00".equals(time)) {
sign();
}
}
public boolean sign() {
String url = "https://magpapa.online/";
String cookie = ConfigTools.readFile(new File("zhuzhu.cookie"));
if (StringUtils.isEmpty(cookie)) {
return false;
}
JSONArray array = JSON.parseArray(cookie);
WebDriver driver = WebClient.getInstance().getWebDriver();
try {
driver.get(url);
driver.manage().deleteAllCookies();
for (Cookie _cookie : WebClient.loadCookie(array)) {
driver.manage().addCookie(_cookie);
Thread.sleep(100);
}
driver.navigate().refresh();
driver.get("https://magpapa.online/plugin.php?id=dc_signin");
for (WebElement element : driver.findElements(By.xpath("//a"))) {
if ("签到".equals(element.getText())) {
element.click();
Thread.sleep(1000);
click(driver);
Thread.sleep(1000);
break;
}
}
} catch (Exception e) {
return false;
}finally {
driver.close();
driver.quit();
}
return true;
}
private void click(WebDriver driver){
driver.findElement(By.className("dcsignin_list")).findElement(By.id("emot_9")).click();
driver.findElement(By.id("fwin_content_sign")).findElement(By.name("signpn")).click();
}
}