From 244c6925014fb8ea615c2a2581d83b2e3abb94ea Mon Sep 17 00:00:00 2001 From: MoYoez Date: Sat, 24 Feb 2024 00:28:57 +0800 Subject: [PATCH] fix: command expectly shown out --- go.mod | 2 +- go.sum | 4 +-- plugin/mai/main.go | 81 +++++++++++++++++++++++----------------------- 3 files changed, 43 insertions(+), 44 deletions(-) diff --git a/go.mod b/go.mod index 4fed3d4..6242f0a 100644 --- a/go.mod +++ b/go.mod @@ -58,4 +58,4 @@ replace modernc.org/sqlite => github.com/fumiama/sqlite3 v1.20.0-with-win386 replace github.com/remyoudompheng/bigfft => github.com/fumiama/bigfft v0.0.0-20211011143303-6e0bfa3c836b -replace github.com/fumiama/ReiBot => github.com/MoYoez/ReiBot v0.0.0-20231123124827-040a39af6eea +replace github.com/fumiama/ReiBot => github.com/MoYoez/ReiBot v0.0.0-20240223162232-5c2ab46deccd diff --git a/go.sum b/go.sum index e52913f..aa35b0b 100644 --- a/go.sum +++ b/go.sum @@ -10,8 +10,8 @@ github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b h1:tvciXWq2nuvTbFeJG github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b/go.mod h1:fHZFWGquNXuHttu9dUYoKuNbm3dzLETnIOnm1muSfDs= github.com/FloatTech/zbpctrl v1.5.3-0.20230130095145-714ad318cd52 h1:BrStRXeosWh8L0iA/EjPd8w6xNexDkqki39ITZko/9Q= github.com/FloatTech/zbpctrl v1.5.3-0.20230130095145-714ad318cd52/go.mod h1:qqMLUwR7tKpqnAqsgI7aZbn0hbs2FEVF4ylMXqIpBdY= -github.com/MoYoez/ReiBot v0.0.0-20231123124827-040a39af6eea h1:L/HRwoBYd5nSPOTOBiUqcQiJI0En1Q9AnFHrhNrEIo0= -github.com/MoYoez/ReiBot v0.0.0-20231123124827-040a39af6eea/go.mod h1:+QH0VtJBX7SEHriFNmJldFJCcBqM51Abkt/PaMFw8FI= +github.com/MoYoez/ReiBot v0.0.0-20240223162232-5c2ab46deccd h1:Od/aS1u2T17NFCoCveBFGCTbQEZTBqNV3omnTJF/0dY= +github.com/MoYoez/ReiBot v0.0.0-20240223162232-5c2ab46deccd/go.mod h1:+QH0VtJBX7SEHriFNmJldFJCcBqM51Abkt/PaMFw8FI= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e h1:wR3MXQ3VbUlPKOOUwLOYgh/QaJThBTYtsl673O3lqSA= github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e/go.mod h1:vD7Ra3Q9onRtojoY5sMCLQ7JBgjUsrXDnDKyFxqpf9w= diff --git a/plugin/mai/main.go b/plugin/mai/main.go index a3f27dc..11ddd3d 100644 --- a/plugin/mai/main.go +++ b/plugin/mai/main.go @@ -69,17 +69,15 @@ func init() { ctx.SendPlainMessage(true, "没有绑定~ 绑定方式: /mai userbind ") return } - getCodeRaw, err := strconv.ParseInt(getMaiID.Userid, 10, 64) + // getCodeRaw, err := strconv.ParseInt(getMaiID.Userid, 10, 64) + // if err != nil { + // panic(err) + // } + getCodeStat, err := web.GetData("https://maihook.lemonkoi.one/api/idunlocker?userid=" + getMaiID.Userid) if err != nil { panic(err) } - getCodeStat := Logout(getCodeRaw) - getCode := gjson.Get(getCodeStat, "returnCode").Int() - if getCode == 1 { - ctx.SendPlainMessage(true, "发信成功,服务器返回正常 , 如果未生效请重新尝试") - } else { - ctx.SendPlainMessage(true, "发信失败,如果未生效请重新尝试") - } + ctx.SendPlainMessage(true, string(getCodeStat)) case getSplitStringList[1] == "plate": if getSplitLength == 2 { SetUserPlateToLocal(ctx, "") @@ -110,14 +108,14 @@ func init() { ctx.SendPlainMessage(true, "没有绑定UserID~ 绑定方式: /mai userbind ") return } - getIntID, _ := strconv.ParseInt(getMaiID.Userid, 10, 64) - getReplyMsg := GetUserRegion(getIntID) - if strings.Contains(getReplyMsg, "{") == false { - ctx.SendPlainMessage(true, "返回了错误.png, ERROR:"+getReplyMsg) + // getIntID, _ := strconv.ParseInt(getMaiID.Userid, 10, 64) + getReplyMsg, _ := web.GetData("https://maihook.lemonkoi.one/api/getRegion?userid=" + getMaiID.Userid) + if strings.Contains(string(getReplyMsg), "{") == false { + ctx.SendPlainMessage(true, "返回了错误.png, ERROR:"+string(getReplyMsg)) return } var MixedMagic GetUserRegionStruct - json.Unmarshal(helper.StringToBytes(getReplyMsg), &MixedMagic) + json.Unmarshal(getReplyMsg, &MixedMagic) var returnText string for _, onlistLoader := range MixedMagic.UserRegionList { returnText = returnText + MixedRegionWriter(onlistLoader.RegionId-1, onlistLoader.PlayCount, onlistLoader.Created) + "\n\n" @@ -133,14 +131,10 @@ func init() { getZlibError := ReturnZlibError() // 20s one request. var getLucyRespHandler int - if getZlibError.Full.Field3 < 180 { - getLucyRespHandler = getZlibError.Full.Field3 - } else { - getLucyRespHandler = getZlibError.Full.Field3 - 180 - } + getLucyRespHandler = getZlibError.Full.Field3 getLucyRespHandlerStr := strconv.Itoa(getLucyRespHandler) getZlibWord := "Zlib 压缩跳过率: \n" + "10mins (" + ConvertZlib(getZlibError.ZlibError.Field1, getZlibError.Full.Field1) + " Loss)\n" + "30mins (" + ConvertZlib(getZlibError.ZlibError.Field2, getZlibError.Full.Field2) + " Loss)\n" + "60mins (" + ConvertZlib(getZlibError.ZlibError.Field3, getZlibError.Full.Field3) + " Loss)\n" - getWebStatusCount := "Web Uptime Ping:\n * MaimaiDXCN: " + ConvertFloat(getWebStatus.Details.MaimaiDXCN.Uptime*100) + "%\n * MaimaiDXCN Main Server: " + ConvertFloat(getWebStatus.Details.MaimaiDXCNMain.Uptime*100) + "%\n * MaimaiDXCN Title Server: " + ConvertFloat(float64(getWebStatus.Details.MaimaiDXCNTitle.Uptime*100)) + "%\n * MaimaiDXCN Update Server: " + ConvertFloat(float64(getWebStatus.Details.MaimaiDXCNUpdate.Uptime*100)) + "%\n * MaimaiDXCN NetLogin Server: " + ConvertFloat(getWebStatus.Details.MaimaiDXCNNetLogin.Uptime*100) + "%\n * MaimaiDXCN Net Server: " + ConvertFloat(getWebStatus.Details.MaimaiDXCNDXNet.Uptime*100) + "%\n" + getWebStatusCount := "Web Uptime Ping:\n * MaimaiDXCN: " + ConvertFloat(getWebStatus.Details.MaimaiDXCN.Uptime*100) + "%\n * MaimaiDXCN Main Server: " + ConvertFloat(getWebStatus.Details.MaimaiDXCNMain.Uptime*100) + "%\n * MaimaiDXCN Title Server: " + ConvertFloat(getWebStatus.Details.MaimaiDXCNTitle.Uptime*100) + "%\n * MaimaiDXCN Update Server: " + ConvertFloat(getWebStatus.Details.MaimaiDXCNUpdate.Uptime*100) + "%\n * MaimaiDXCN NetLogin Server: " + ConvertFloat(getWebStatus.Details.MaimaiDXCNNetLogin.Uptime*100) + "%\n * MaimaiDXCN Net Server: " + ConvertFloat(getWebStatus.Details.MaimaiDXCNDXNet.Uptime*100) + "%\n" ctx.SendPlainMessage(true, "* Zlib 压缩跳过率可以很好的反馈当前 MaiNet (Wahlap Service) 当前负载的情况\n* Web Uptime Ping 则可以反馈 MaiNet 在外部原因(DDOS) 下造成的负载详情 ( 100% 即代表服务器为稳定, uptime 越低则代表可用性越差 ) \n* 在 1小时 内,Lucy 共处理了 "+getLucyRespHandlerStr+"次 请求💫,其中详细数据如下:\n\n"+getZlibWord+getWebStatusCount+"\n* Title Server 爆炸 容易造成数据获取失败\n* Zlib 3% Loss 以下则 基本上可以正常游玩\n* 10% Loss 则会有明显断网现象(请准备小黑屋工具)\n* 30% Loss 则无法正常游玩(即使使用小黑屋工具) ") case getSplitStringList[1] == "update": getID, _ := toolchain.GetChatUserInfoID(ctx) @@ -159,11 +153,11 @@ func init() { return } // token is valid, get data. - getIntID, _ := strconv.ParseInt(getMaiID.Userid, 10, 64) + // getIntID, _ := strconv.ParseInt(getMaiID.Userid, 10, 64) // getFullData := GetMusicList(getIntID, 0, 600) - getFullData := GetMusicList(getIntID, 0, 1000) + getFullData, err := web.GetData("https://maihook.lemonkoi.one/api/getMusicList?userid=" + getMaiID.Userid) var unmashellData UserMusicListStruct - json.Unmarshal(helper.StringToBytes(getFullData), &unmashellData) + json.Unmarshal(getFullData, &unmashellData) getFullDataStruct := convert(unmashellData) jsonDumper := getFullDataStruct jsonDumperFull, err := json.Marshal(jsonDumper) @@ -208,32 +202,24 @@ func init() { ctx.SendPlainMessage(true, "没有绑定~ 绑定方式: /mai userbind ") return } - ticketToFormatNum, err := strconv.ParseInt(getSplitStringList[2], 10, 64) + _, err := strconv.ParseInt(getSplitStringList[2], 10, 64) if err != nil { ctx.SendPlainMessage(true, "传输的数据不合法~") return } - getMaiIDInt64, err := strconv.ParseInt(getMaiID.Userid, 10, 64) - getCode := TicketGain(getMaiIDInt64, int(ticketToFormatNum)) - switch { - case getCode == 500: - ctx.SendPlainMessage(true, "TicketID 为非限定内,可使用 2 | 3 | 5 | 20010 | 20020 ") - return - case getCode == 102: - ctx.SendPlainMessage(true, "请在 华立公众号 生成一次二维码 后使用") - return - case getCode == 105: - ctx.SendPlainMessage(true, "已经有了未使用的Ticket了x") - return - case getCode == 200: - ctx.SendPlainMessage(true, "使用成功~将在下一次游戏时自动使用") - return + getCodeRaw, err := web.GetData("https://maihook.lemonkoi.one/api/ticket?userid=" + getMaiID.Userid + "&ticket=" + getSplitStringList[2]) + if err != nil { + panic(err) } + getCode := string(getCodeRaw) + ctx.SendPlainMessage(true, getCode) + case getSplitStringList[1] == "raw" || getSplitStringList[1] == "file": + MaimaiRenderBase(ctx, true) default: ctx.SendPlainMessage(true, "未知的指令或者指令出现错误~") } } else { - MaimaiRenderBase(ctx) + MaimaiRenderBase(ctx, false) } }) } @@ -329,7 +315,7 @@ func SetUserDefaultPlateToDatabase(ctx *rei.Ctx, plateName string) { } // MaimaiRenderBase Render Base Maimai B50. -func MaimaiRenderBase(ctx *rei.Ctx) { +func MaimaiRenderBase(ctx *rei.Ctx, israw bool) { // check the user using. getUserID, _ := toolchain.GetChatUserInfoID(ctx) if GetUserSwitcherInfoFromDatabase(getUserID) == true { @@ -369,7 +355,20 @@ func MaimaiRenderBase(ctx *rei.Ctx) { _ = json.Unmarshal(getUserData, &data) renderImg := FullPageRender(data, ctx) _ = gg.NewContextForImage(renderImg).SavePNG(engine.DataFolder() + "save/" + strconv.Itoa(int(getUserID)) + ".png") - ctx.SendPhoto(tgba.FilePath(engine.DataFolder()+"save/"+strconv.Itoa(int(getUserID))+".png"), true, "") + + if israw { + getDocumentType := &tgba.DocumentConfig{ + BaseFile: tgba.BaseFile{BaseChat: tgba.BaseChat{ + ChatID: ctx.Message.Chat.ID, + }, + File: tgba.FilePath(engine.DataFolder() + "save/" + strconv.Itoa(int(getUserID)) + ".png")}, + Caption: "", + CaptionEntities: nil, + } + ctx.Send(true, getDocumentType) + } else { + ctx.SendPhoto(tgba.FilePath(engine.DataFolder()+"save/"+strconv.Itoa(int(getUserID))+".png"), true, "") + } } }