From 5eb7dae619e67fbab4f9b5fc51370d9da0e7bbdf Mon Sep 17 00:00:00 2001 From: Giftina Date: Fri, 15 Jul 2022 16:57:13 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20=E5=85=B3=E9=97=AD=E7=BE=A4=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=90=8E=E7=BE=A4=E6=9C=8D=E5=8A=A1=E4=BB=8D=E7=84=B6?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E5=9C=B0=E8=A7=86=E4=B8=BA=E5=BC=80=E5=90=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/system/utils.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/system/utils.js b/plugins/system/utils.js index 35acc6bf..f77f85ff 100644 --- a/plugins/system/utils.js +++ b/plugins/system/utils.js @@ -315,8 +315,12 @@ module.exports = { } const group = await QQGroupModel.findOne({ where: { groupId } }); - // 如果没有获取到,应该是刚刚加入群,默认开启群服务 - return group?.serviceEnabled || true; + // 如果没有获取到群,应该是小夜刚刚加入群,默认开启群服务 + if (!group) { + return true; + } + + return group.serviceEnabled; }, /** From 1717e4d9f6f690097e622a7c8eaee1f674d05f96 Mon Sep 17 00:00:00 2001 From: Giftina Date: Mon, 18 Jul 2022 11:02:01 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=E5=BA=94=E7=94=A8=E6=88=B7=E9=9C=80?= =?UTF-8?q?=E6=B1=82=EF=BC=8C=E5=B0=86=E7=9C=BC=E4=BD=8D=E9=99=84=E8=BF=91?= =?UTF-8?q?=E6=89=80=E6=9C=89=E6=9C=BA=E5=8F=B0=E5=88=97=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/danceCube.js | 83 +++++++++++------- ...26e4872831f159e75953.jpg@128w_128h_1o.webp | Bin 2178 -> 0 bytes 2 files changed, 49 insertions(+), 34 deletions(-) delete mode 100644 static/xiaoye/images/c70fe35d0f06643a57f626e4872831f159e75953.jpg@128w_128h_1o.webp diff --git a/plugins/danceCube.js b/plugins/danceCube.js index 0a5fffbb..606af08f 100644 --- a/plugins/danceCube.js +++ b/plugins/danceCube.js @@ -4,7 +4,7 @@ const baiduAk = ""; module.exports = { 插件名: "舞立方信息查询插件", 指令: "^[/!]?(绑定|个人信息|战绩|插眼|我要出勤)(.*)", - 版本: "2.0", + 版本: "2.1", 作者: "Giftina", 描述: "舞立方信息查询,可以查询玩家信息以及机台状态。数据来源以及素材版权归属 胜骅科技 https://www.arccer.com/ ,如有侵权请联系作者删除。", 使用示例: "个人信息", @@ -82,7 +82,7 @@ module.exports = { const playerData = await DanceCubeModel.findOne({ where: { userId } }); if (!playerData) { return { type: "text", content: errorNoData }; - } else if (!playerData.location) { + } else if (playerData.location == {}) { return { type: "text", content: "你还没有插眼呢,禁止出勤,请发送 插眼 地名 在指定位置插眼吧" }; } @@ -150,11 +150,18 @@ async function BindUser(userId, playerId) { return `获取玩家资料失败:${playerInfo.error}`; } + let location = {}; + const { lng, lat } = await BaiduGeocoding(playerInfo.CityName); + if (!lng || !lat) { + console.log("获取玩家坐标失败,置为空".error); + } + location = { lng, lat }; + await DanceCubeModel.upsert({ userId, playerId, playerName: playerInfo.UserName, - location: playerInfo.CityName, + location, }, { where: { userId, @@ -414,14 +421,13 @@ async function GetPlayerRank(playerId, musicIndex) { } /** - * 插眼,根据玩家提供的地名查询经纬度并存入玩家数据库 - * @param {string} location 位置 + * 根据地名查询经纬度 */ -async function Geocoding(userId, location) { +async function BaiduGeocoding(address) { // 百度地理编码 const { lng, lat, error } = await axios.get(api.geocoding, { params: { - address: location, + address: address, ak: baiduAk, output: "json", }, @@ -438,6 +444,17 @@ async function Geocoding(userId, location) { return { error }; }); + return { lng, lat, error }; +} + +/** + * 插眼,根据玩家提供的地名查询经纬度并存入玩家数据库 + * @param {string} playerId 玩家id + * @param {string} address 位置 + */ +async function Geocoding(userId, address) { + const { lng, lat, error } = await BaiduGeocoding(address); + if (!lng || !lat) { return `插眼失败:${error},可能是这个地名不太好找,请换个地名再试试`; } @@ -454,8 +471,7 @@ async function Geocoding(userId, location) { } /** - * 查询眼位附近机台状态 - * @param {*} userId 用户id + * 查询眼位附近的机台状态 */ async function GoGoGo(userId) { /** @@ -471,36 +487,35 @@ async function GoGoGo(userId) { const machineList = await axios.get(api.machineListByLocation, { headers: headers, params: { ...location }, + validateStatus: (status) => status < 500, }) .then(async function (response) { - console.log(`查询眼位附近机台状态:${response.data} `); - return response.data; + if (response.status !== 200) { + return { error: response.data.Message }; + } + const machineList = response.data; + const reply = machineList.map((machine) => { + const machineName = machine.PlaceName.replace(/\n/g, ""); + const provinceAndCity = machine.ProvinceAndCity.replace(/\n/g, ""); + const address = machine.Address.replace(/\n/g, ""); + const status = machine.Online ? "🟢机台在线,立即出勤" : "🔴机台离线,散了吧"; + const machineGeneration = machine.Img1.includes("9700") ? "Ⅰ代" : "Ⅱ代"; // 按机台图片名判断其实不是很准确,但是大致看了下八九不离十 + const machinePicture1Link = `https://dancedemo.shenghuayule.com/Dance/${machine.Img1}`; + const machinePicture2Link = `https://dancedemo.shenghuayule.com/Dance/${machine.Img2}`; + // [CQ:image,file=${machinePicture1Link}][CQ:image,file=${machinePicture2Link}] + return `${status}\n${machineName} ${machineGeneration}\n${provinceAndCity} ${address}\n`; + }); + return `眼位附近有${machineList.length}台舞立方,下面播报舞立方状态: + + ${reply.join("\n")} +(机台在线状态和世代仅供参考,以实际状态为准) + `; }) .catch(function (error) { - console.log(`获取机台状态失败:${error} `.error); - return "获取机台状态失败:", error; + console.log(`获取机台状态失败: ${error} `.error); + return "获取机台状态失败: ", error; }); - - if (machineList.length === 0) { - return "获取机台状态失败:附近没有找到任何机台"; - } - - const machineCount = machineList.length; - const machine = machineList[0]; // 选择最近的一台舞立方 - const machineName = machine.PlaceName.replace(/\n/g, ""); - const provinceAndCity = machine.ProvinceAndCity.replace(/\n/g, ""); - const address = machine.Address.replace(/\n/g, ""); - const longitudeAndLatitude = `${machine.Longitude}, ${machine.Latitude} `; // 经纬度 - const status = machine.Online ? "🟢机台在线,立即出勤" : "🔴机台离线,散了吧"; - const machineGeneration = machine.Img1.includes("9700") ? "Ⅰ代机" : "Ⅱ代机"; - const machinePicture1Link = `https://dancedemo.shenghuayule.com/Dance/${machine.Img1}`; - const machinePicture2Link = `https://dancedemo.shenghuayule.com/Dance/${machine.Img2}`; - return `眼位附近有${machineCount}台舞立方,下面播报距离眼位最近的舞立方状态: -${status} -${machineName} ${machineGeneration} -${provinceAndCity} ${address} -坐标:${longitudeAndLatitude} -[CQ:image,file=${machinePicture1Link}][CQ:image,file=${machinePicture2Link}]`; + return machineList; } const DanceCubeModel = require(path.join(process.cwd(), "plugins", "system", "model", "danceCubeModel.js")); diff --git a/static/xiaoye/images/c70fe35d0f06643a57f626e4872831f159e75953.jpg@128w_128h_1o.webp b/static/xiaoye/images/c70fe35d0f06643a57f626e4872831f159e75953.jpg@128w_128h_1o.webp deleted file mode 100644 index f2ece7ae27a738c91de8945da7d6bffb41feca0c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2178 zcmV-|2z~cbNk&F`2mk@ctr z31 z@hcFRuWWg9+H(0~qtodTx4MR!7A?M$3B?Q{vn5zXvXLuA8@IUD zeBW$UD5U6*3N>RLQbbgb+vW(**0W1f49bDP?Tu zyxY`6UAJyfyj1YxyD>YyC=CqJg7EY%O_9kiJ2^X=g3B+`C7_IKE5gYF!ba$#6GSiv z&5|OzJZx_#9wpAFzbhJ&MrgL z^U6gDq)NB) zm~4#jD+@?EpI{Am%I$S-$N2D&_S@sknK4x&o4DD@_P3(*?AWkk)QsNp`yO!TaR`mj=r|um1oF%FE|W;JvIYs1o-$r9f?l?Mw6oKKc>jakZvnO8DX^u(RgI4VA)f zHY3S60{xQ%%7beVJI^TgnDw65HZJT5p3e}-oj==?U^(}y`u^YWHosU?Epw7Afw<>8W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9b696610aa26924e9c4be3e5e1db29 Mon Sep 17 00:00:00 2001 From: Giftina Date: Mon, 18 Jul 2022 11:03:41 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20=E8=88=9E=E7=AB=8B=E6=96=B9=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E5=9B=9E=E5=A4=8D=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/danceCube.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/danceCube.js b/plugins/danceCube.js index 606af08f..47a3d129 100644 --- a/plugins/danceCube.js +++ b/plugins/danceCube.js @@ -507,9 +507,8 @@ async function GoGoGo(userId) { }); return `眼位附近有${machineList.length}台舞立方,下面播报舞立方状态: - ${reply.join("\n")} -(机台在线状态和世代仅供参考,以实际状态为准) - `; +${reply.join("\n")} +(机台在线状态和世代仅供参考,以实际状态为准)`; }) .catch(function (error) { console.log(`获取机台状态失败: ${error} `.error); From e2778c1819c299f136271f4ce75e14e864e86cd1 Mon Sep 17 00:00:00 2001 From: Giftina Date: Mon, 18 Jul 2022 11:04:49 +0800 Subject: [PATCH 4/4] chore: v3.6.2 --- version.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.json b/version.json index 2d166d94..fd4c9207 100644 --- a/version.json +++ b/version.json @@ -1 +1 @@ -{ "versionNumber": "v3.6.2-dev" } +{ "versionNumber": "v3.6.2" }