diff --git a/resources/about.html.txt b/resources/about.html.txt
index d2661e46..5883f455 100644
--- a/resources/about.html.txt
+++ b/resources/about.html.txt
@@ -6,8 +6,8 @@
- Supported on Windows, macOS, Linux
BUILD INFO: HEAD
-Commit-Msg: %s
-Commit-Id: %s
-Repo URL: Here
+Commit-Msg: _commitmsg_
+Commit-Id: _commitid_
+Repo URL: Here
-OS | Compiler | Date: %s
+OS | Compiler | Date: _compilerver_
diff --git a/src/main.cpp b/src/main.cpp
index 48abf6a2..c759ee08 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -26,6 +26,8 @@
#include
#include
+#include
+
#ifdef USE_DATABASE
#include
#endif
@@ -153,12 +155,11 @@ int main(void) {
CompileRunHandler(BashHandleData{bot, message, true});
});
bot_AddCommandPermissive(gbot, "alive", [](const Bot &bot, const Message::Ptr &message) {
- static std::string version_str;
+ static std::string version;
static std::once_flag once;
std::call_once(once, [] {
char buf[1024] = {0};
- std::string commitid, commitmsg, originurl;
- std::string buffer;
+ std::string commitid, commitmsg, originurl, compilerver;
static const std::map commands = {
{&commitid, "git rev-parse HEAD"},
@@ -171,16 +172,19 @@ int main(void) {
*cmd.first = "(Command failed)";
}
}
- ReadFileToString(getResourcePath("about.html.txt"), &buffer);
- snprintf(buf, sizeof(buf), buffer.c_str(), commitmsg.c_str(), originurl.c_str(),
- commitid.c_str(), commitid.c_str(), originurl.c_str(), getCompileVersion().c_str());
- version_str = buf;
+ compilerver = getCompileVersion();
+ ReadFileToString(getResourcePath("about.html.txt"), &version);
+#define REPLACE_PLACEHOLDER(buf, name) boost::replace_all(buf, "_" #name "_", name)
+ REPLACE_PLACEHOLDER(version, commitid);
+ REPLACE_PLACEHOLDER(version, commitmsg);
+ REPLACE_PLACEHOLDER(version, originurl);
+ REPLACE_PLACEHOLDER(version, compilerver);
});
// Hardcoded Cum about it GIF
bot.getApi().sendAnimation(message->chat->id,
"CgACAgQAAx0CdY7-CgABARtpZLefgyKNpSLvyCJWcp8"
"mt5KF_REAAgkDAAI2tFRQIk0uTVxfZnsvBA",
- 0, 0, 0, "", version_str, message->messageId,
+ 0, 0, 0, "", version, message->messageId,
nullptr, "html");
});
bot_AddCommandPermissive(gbot, "flash", [](const Bot &bot, const Message::Ptr &message) {
@@ -563,7 +567,7 @@ int main(void) {
}
try {
gbot.getApi().restrictChatMember(handle->first, mapmsg.first,
- perms, 5 * 60);
+ perms, 5 * 60);
} catch (const std::exception &e) {
PRETTYF("Cannot mute user %ld in chat %ld: %s", mapmsg.first,
handle->first, e.what());