diff --git a/Dice/DiceJob.cpp b/Dice/DiceJob.cpp index 49c41707..7522f054 100644 --- a/Dice/DiceJob.cpp +++ b/Dice/DiceJob.cpp @@ -369,6 +369,25 @@ void cloud_beat(AttrObject& job) { sch.add_job_for(5 * 60, job); } +void check_update(AttrObject& job) { + string ret; + if (!Network::GET("http://shiki.stringempty.xyz/DiceVer/update", ret)) { + console.log("获取版本信息时出错: \n" + ret, 0); + return; + } + string ver = isDev ? "dev" : "release"; + try { + fifo_json jInfo(fifo_json::parse(ret)); + if (unsigned short nBuild{ jInfo[ver]["build"] }; nBuild > Dice_Build) { + MsgNote(job, "发现Dice!的{ver}版本更新:" + jInfo["release"]["ver"].get() + "(" + to_string(nBuild) + ")\n更新说明:" + + UTF8toGBK(jInfo["release"]["changelog"].get()), 1); + } + } + catch (std::exception& e) { + console.log(string("获取更新失败:") + e.what(), 0); + } + sch.add_job_for(72 * 60 * 60, "check_update"); +} void dice_update(AttrObject& job) { string ret; if (!Network::GET("http://shiki.stringempty.xyz/DiceVer/update", ret)) { @@ -376,7 +395,7 @@ void dice_update(AttrObject& job) { return; } string ver{ job.get_str("ver")}; - if (ver.empty())ver = "release"; + if (ver.empty())ver = isDev ? "dev" : "release"; try { fifo_json jInfo(fifo_json::parse(ret)); if (unsigned short nBuild{ jInfo[ver]["build"] }; ver != "dev" && nBuild > Dice_Build) { diff --git a/Dice/DiceJob.h b/Dice/DiceJob.h index 30d6b042..3254fd14 100644 --- a/Dice/DiceJob.h +++ b/Dice/DiceJob.h @@ -21,6 +21,7 @@ void clear_group(AttrObject& job); void list_group(AttrObject& job); void cloud_beat(AttrObject& job); +void check_update(AttrObject& job); void dice_update(AttrObject& job); void dice_cloudblack(AttrObject& job); diff --git a/Dice/DiceSchedule.cpp b/Dice/DiceSchedule.cpp index 9e5d6afc..b04a7713 100644 --- a/Dice/DiceSchedule.cpp +++ b/Dice/DiceSchedule.cpp @@ -169,6 +169,7 @@ void DiceScheduler::start() { /*if (console["AutoFrameRemake"] > 0) add_job_for(console["AutoFrameRemake"] * 60 * 60, "remake"); else add_job_for(60 * 60, "remake");*/ + add_job_for(120, "check_update"); if (console["CloudBlackShare"] > 0) add_job_for(12 * 60 * 60, "cloudblack"); } diff --git a/Dice/GlobalVar.cpp b/Dice/GlobalVar.cpp index 47bef55d..de2f365f 100644 --- a/Dice/GlobalVar.cpp +++ b/Dice/GlobalVar.cpp @@ -402,7 +402,7 @@ const dict_ci PlainMsg {"strSelfName", "" }, {"strSelfNick", "&strSelfName" }, {"self", "&strSelfCall"}, - {"strBotHeader", "试作型 " }, + {"strBotHeader", "泛用型 " }, {"strBotMsg", "\n使用.help 查看{self}帮助文档"}, {"strHlpMsg", R"(请使用.dismiss ID(或后四位) 使{self}退群退讨论组 .bot on/off ID(或后四位) //开启或关闭指令 diff --git a/Dice/GlobalVar.h b/Dice/GlobalVar.h index aff3ffec..f4ceed8c 100644 --- a/Dice/GlobalVar.h +++ b/Dice/GlobalVar.h @@ -47,6 +47,7 @@ inline const std::string Dice_Ver_Without_Build = "2.6.5rc3"; constexpr auto DiceRequestHeader = "Dice/2.6.5"; inline const std::string Dice_Ver = Dice_Ver_Without_Build + "(" + std::to_string(Dice_Build) + ")"; inline const std::string Dice_Short_Ver = "Dice! by 溯洄 & Shiki Ver " + Dice_Ver; +constexpr bool isDev = false; #ifdef __clang__ diff --git a/Dice/SHKQuerier.h b/Dice/SHKQuerier.h index 9cd1574f..d65e79b1 100644 --- a/Dice/SHKQuerier.h +++ b/Dice/SHKQuerier.h @@ -9,7 +9,7 @@ #include #include #include -#include "strExtern.hpp" +#include "StrExtern.hpp" using std::string; using std::u16string; using std::vector;