Skip to content

Commit

Permalink
update check update
Browse files Browse the repository at this point in the history
  • Loading branch information
mystringEmpty committed Nov 18, 2022
1 parent 76ccb88 commit b4afcd5
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 3 deletions.
21 changes: 20 additions & 1 deletion Dice/DiceJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,14 +369,33 @@ 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<string>() + "(" + to_string(nBuild) + ")\n更新说明:" +
UTF8toGBK(jInfo["release"]["changelog"].get<string>()), 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)) {
reply(job, "{self}获取版本信息时出错: \n" + ret);
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) {
Expand Down
1 change: 1 addition & 0 deletions Dice/DiceJob.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions Dice/DiceSchedule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
2 changes: 1 addition & 1 deletion Dice/GlobalVar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ const dict_ci<string> PlainMsg
{"strSelfName", "" },
{"strSelfNick", "&strSelfName" },
{"self", "&strSelfCall"},
{"strBotHeader", "试作型 " },
{"strBotHeader", "泛用型 " },
{"strBotMsg", "\n使用.help 查看{self}帮助文档"},
{"strHlpMsg", R"(请使用.dismiss ID(或后四位) 使{self}退群退讨论组
.bot on/off ID(或后四位) //开启或关闭指令
Expand Down
1 change: 1 addition & 0 deletions Dice/GlobalVar.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__

Expand Down
2 changes: 1 addition & 1 deletion Dice/SHKQuerier.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include "strExtern.hpp"
#include "StrExtern.hpp"
using std::string;
using std::u16string;
using std::vector;
Expand Down

0 comments on commit b4afcd5

Please sign in to comment.