Skip to content

Commit

Permalink
TgBot++: Make use of new bot api to set descs
Browse files Browse the repository at this point in the history
- Also, hide bot token on log, Instead add a startup time log
  • Loading branch information
Royna2544 committed Jun 26, 2024
1 parent 175f5c1 commit 6184e8c
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ int main(int argc, char* const* argv) {
std::optional<std::string> token;
std::optional<LogFileSink> log_sink;
const auto startTp = std::chrono::system_clock::now();
DurationPoint startupDp;
using namespace ConfigManager;

startupDp.init();
TgBot_AbslLogInit();
LOG(INFO) << "Registered LogSink_stdout";
copyCommandLine(CommandLineOp::INSERT, &argc, &argv);
Expand Down Expand Up @@ -149,6 +151,10 @@ int main(int argc, char* const* argv) {
return EXIT_FAILURE;
}

// Install signal handlers
installSignalHandler();

// Initialize subsystems
createAndDoInitCall<TgBotWebServer, ThreadManager::Usage::WEBSERVER_THREAD>(
8080);
#ifdef RTCOMMAND_LOADER
Expand All @@ -168,9 +174,24 @@ int main(int argc, char* const* argv) {
// Must be last
createAndDoInitCall<OnAnyMessageRegisterer>(gBot);

installSignalHandler();

DLOG(INFO) << "Token: " << token.value();
// Bot starts
LOG(INFO) << "Subsystems initialized, bot started: " << argv[0];
LOG(INFO) << "Started in " << startupDp.get().count() << " milliseconds";

gBot.getApi().setMyDescription("Royna's telegram bot, written in C++. Go on you can talk to him");
gBot.getApi().setMyShortDescription(
"One of @roynatech's C++ project bots. I'm currently hosted on "
#if BOOST_OS_WINDOWS
"Windows"
#elif BOOST_OS_LINUX
"Linux"
#elif BOOST_OS_MACOS
"macOS"
#else
"unknown platform"
#endif
);
// Main loop
DurationPoint dp;
do {
try {
Expand Down

0 comments on commit 6184e8c

Please sign in to comment.