[go: up one dir, main page]

Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
xunx-ii committed May 26, 2023
1 parent a21caab commit 55304ee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ void application::run() {
// 使用中国的时区
int offset = 8 * 3600;

{
uint64_t now_time = get_local_time() + deviation_time;
time_t tt = static_cast<time_t>((now_time / 1000) + offset);
struct tm *time_info = gmtime(&tt);

char buffer[80];
std::strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", time_info);
spdlog::info("当前服务器时间 {}", buffer);
}

while (!should_exit_app) {

// 使用本地时区+网络时间校准偏移
Expand Down Expand Up @@ -174,8 +184,6 @@ uint64_t application::get_online_time() {
try {
nlohmann::json root = nlohmann::json::parse(response);
time_now = std::stoull(root["data"]["t"].get<std::string>());
spdlog::info("get_online_time {}:", time_now);

} catch (nlohmann::json::parse_error &e) {
spdlog::error("failed to parse message: {}", e.what());
}
Expand Down
5 changes: 3 additions & 2 deletions src/tasks/daily_news_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class daily_news_task : public task_base {
}

virtual void run(std::string &response) override {
response = "[CQ:at,qq=all][CQ:image,file=https://api.03c3.cn/zb/,cache=0]";
response = "[CQ:image,file=https://api.03c3.cn/zb/,cache=0]";
}

virtual void tick(mn::time time) override {
Expand All @@ -49,7 +49,8 @@ class daily_news_task : public task_base {
mn::meesage meesage;
std::string response;
run(response);
meesage.message = response;
// 订阅的消息
meesage.message = "[CQ:at,qq=all]" + response;

for (uint64_t id : setting.subscribed_groups) {
meesage.is_group_msg = true;
Expand Down

0 comments on commit 55304ee

Please sign in to comment.