From b2610a02b286f8d7a27d26c6a90aeeabc2246f42 Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Sat, 16 Jul 2022 12:35:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EHiRes=E7=8C=AA=E7=8C=AA?= =?UTF-8?q?=E8=AE=BA=E5=9D=9B=E7=AD=BE=E5=88=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../qqbot/MessageEvent/AdminMessage.java | 15 +++- .../yutou/qqbot/models/WebSign/ZhuZhu.java | 77 +++++++++++++++++++ 2 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/yutou/qqbot/models/WebSign/ZhuZhu.java diff --git a/src/main/java/com/yutou/qqbot/MessageEvent/AdminMessage.java b/src/main/java/com/yutou/qqbot/MessageEvent/AdminMessage.java index 83a684b..a140ec6 100644 --- a/src/main/java/com/yutou/qqbot/MessageEvent/AdminMessage.java +++ b/src/main/java/com/yutou/qqbot/MessageEvent/AdminMessage.java @@ -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()); } } diff --git a/src/main/java/com/yutou/qqbot/models/WebSign/ZhuZhu.java b/src/main/java/com/yutou/qqbot/models/WebSign/ZhuZhu.java new file mode 100644 index 0000000..de5c121 --- /dev/null +++ b/src/main/java/com/yutou/qqbot/models/WebSign/ZhuZhu.java @@ -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(); + } +}