From e0751972a33517b996062b6ef47f20535c1443ff Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Mon, 20 Dec 2021 17:52:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B7=AF=E7=94=B1=E5=99=A8?= =?UTF-8?q?=E6=89=AB=E6=8F=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yutou/qqbot/models/XiaoMi/MiRouter.java | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/yutou/qqbot/models/XiaoMi/MiRouter.java b/src/main/java/com/yutou/qqbot/models/XiaoMi/MiRouter.java index a2d368c..bce3741 100644 --- a/src/main/java/com/yutou/qqbot/models/XiaoMi/MiRouter.java +++ b/src/main/java/com/yutou/qqbot/models/XiaoMi/MiRouter.java @@ -31,22 +31,24 @@ public class MiRouter extends Model { @Override public void onMessage(Long qq, MessageEvent event, boolean isGroup) { super.onMessage(qq, event, isGroup); - if(msg.equals(QQFromCommands.ROUTER_ADD)){ - String url="http://192.168.31.88:8002/router/device/add.do?qq="+qq; - QQBotManager.getInstance().sendMessage(qq,"点击该链接完成设备添加:\n"+url); - }else if(msg.equals(QQFromCommands.ROUTER_DEL)){ - String url="http://192.168.31.88:8002/router/device/del.do?qq="+qq; - QQBotManager.getInstance().sendMessage(qq,"点击该删除设备:\n"+url); + if (msg.equals(QQFromCommands.ROUTER_ADD)) { + String url = "http://192.168.31.88:8002/router/device/add.do?qq=" + qq; + QQBotManager.getInstance().sendMessage(qq, "点击该链接完成设备添加:\n" + url); + } else if (msg.equals(QQFromCommands.ROUTER_DEL)) { + String url = "http://192.168.31.88:8002/router/device/del.do?qq=" + qq; + QQBotManager.getInstance().sendMessage(qq, "点击该删除设备:\n" + url); } } - private static boolean isRunTime=false; + + private static boolean isRunTime = false; + @Override public void onTime(String time) { super.onTime(time); - if(isRunTime){ + if (isRunTime) { return; } - isRunTime=true; + isRunTime = true; String url = XiaoMiRouter.getDeviceListUrl(); JSONObject json = JSONObject.parseObject(HttpTools.get(url)); if (json.getInteger("code") == 0) { @@ -68,6 +70,7 @@ public class MiRouter extends Model { builder.append(item.getString("oname")); builder.append(" 欢迎回家!").append("\n"); builder.append("点击该链接开门:").append("\n"); + builder.append("http://192.168.31.88:802/openDoor.html"); QQBotManager.getInstance().sendMessage(_device.getLong("qq"), builder.toString()); _device.put("online", true); _device.put("name", item.getString("oname")); @@ -82,7 +85,7 @@ public class MiRouter extends Model { devices = (JSONArray) devs.clone(); for (Object device : devices) { JSONObject item = (JSONObject) device; - if (!links.contains(item.getString("mac"))&&item.getLong("linkTime")!=0) { + if (!links.contains(item.getString("mac")) && item.getLong("linkTime") != 0) { devs.remove(device); String builder = "你的设备:" + item.getString("name") + @@ -90,13 +93,13 @@ public class MiRouter extends Model { "在线时长:" + getOnLineTime(item.getString("linkTime")) + "\n"; QQBotManager.getInstance().sendMessage(item.getLong("qq"), builder); item.put("online", false); - item.put("linkTime",0); + item.put("linkTime", 0); devs.add(item); } } RedisTools.set(redis_key, devs.toJSONString()); - isRunTime=false; } + isRunTime = false; } private String getOnLineTime(String online) {