BareGit

Apply coding style and formatting

Author: MetroWind <chris.corsair@gmail.com>
Date: Mon Jan 12 11:38:52 2026 -0800
Commit: 6486ed749a0e95aea66097cff0b55ecbe28b9e93

Changes

diff --git a/src/main.cpp b/src/main.cpp
index 1b42db3..a28b3d6 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -34,7 +34,10 @@ public:
 
         mw::HTTPSession session;
         auto res = session.post(req);
-        if(!res.has_value()) return std::unexpected(res.error());
+        if(!res.has_value())
+        {
+            return std::unexpected(res.error());
+        }
 
         return json::parse((*res)->payloadAsStr());
     }
@@ -45,7 +48,10 @@ public:
                                       base_url_, offset, timeout);
         mw::HTTPSession session;
         auto res = session.get(url);
-        if(!res.has_value()) return std::unexpected(res.error());
+        if(!res.has_value())
+        {
+            return std::unexpected(res.error());
+        }
 
         return json::parse((*res)->payloadAsStr());
     }
@@ -101,7 +107,10 @@ public:
                     return;
                 }
 
-                ASSIGN_OR_RESPOND_ERROR(auto result, tg_client_.sendMessage(body["chat_id"], body["text"]), res);
+                ASSIGN_OR_RESPOND_ERROR(auto result,
+                                        tg_client_.sendMessage(body["chat_id"],
+                                                               body["text"]),
+                                        res);
                 res.status = 200;
                 res.set_content(result.dump(), "application/json");
             }
@@ -120,11 +129,13 @@ public:
                 if(!body.contains("chat_id") || !body.contains("callback_url"))
                 {
                     res.status = 400;
-                    res.set_content("Missing chat_id or callback_url", "text/plain");
+                    res.set_content("Missing chat_id or callback_url",
+                                    "text/plain");
                     return;
                 }
 
-                sub_manager_.addSubscription(body["chat_id"], body["callback_url"]);
+                sub_manager_.addSubscription(body["chat_id"],
+                                             body["callback_url"]);
                 res.status = 200;
                 res.set_content("Subscribed", "text/plain");
             }
@@ -144,7 +155,8 @@ public:
             auto updates = tg_client_.getUpdates(offset, 30);
             if(!updates.has_value())
             {
-                spdlog::error("Failed to get updates: {}", mw::errorMsg(updates.error()));
+                spdlog::error("Failed to get updates: {}",
+                              mw::errorMsg(updates.error()));
                 std::this_thread::sleep_for(std::chrono::seconds(5));
                 continue;
             }
@@ -185,7 +197,8 @@ private:
                 auto res = session.post(req);
                 if(!res.has_value())
                 {
-                    spdlog::error("Failed to post to callback {}: {}", url, mw::errorMsg(res.error()));
+                    spdlog::error("Failed to post to callback {}: {}", url,
+                                  mw::errorMsg(res.error()));
                 }
             }).detach();
         }
@@ -201,21 +214,23 @@ int main(int argc, char** argv)
     cxxopts::Options cmd_options("telegrammer", "Telegram Bot API Gateway");
     cmd_options.add_options()
         ("t,token", "Telegram Bot Token", cxxopts::value<std::string>())
-        ("p,port", "Port to listen on", cxxopts::value<int>()->default_value("8080"))
-        ("h,host", "Interface to bind to", cxxopts::value<std::string>()->default_value("0.0.0.0"))
+        ("p,port", "Port to listen on",
+         cxxopts::value<int>()->default_value("8080"))
+        ("h,host", "Interface to bind to",
+         cxxopts::value<std::string>()->default_value("0.0.0.0"))
         ("help", "Print help");
 
     try
     {
         auto result = cmd_options.parse(argc, argv);
 
-        if (result.count("help"))
+        if(result.count("help"))
         {
             std::cout << cmd_options.help() << std::endl;
             return 0;
         }
 
-        if (!result.count("token"))
+        if(!result.count("token"))
         {
             spdlog::error("Token is required. Use --token <TOKEN>");
             std::cout << cmd_options.help() << std::endl;
@@ -236,23 +251,30 @@ int main(int argc, char** argv)
         auto start_res = app.start();
         if(!start_res.has_value())
         {
-            spdlog::error("Failed to start server: {}", mw::errorMsg(start_res.error()));
+            spdlog::error("Failed to start server: {}",
+                          mw::errorMsg(start_res.error()));
             return 1;
         }
 
         spdlog::info("Server listening on {}:{}", host, port);
 
-        std::thread polling_thread([&app]() { app.runPolling(); });
+        std::thread polling_thread([&app]()
+        {
+            app.runPolling();
+        });
 
         app.wait();
         app.stopPolling();
-        if(polling_thread.joinable()) polling_thread.join();
+        if(polling_thread.joinable())
+        {
+            polling_thread.join();
+        }
     }
-    catch (const cxxopts::exceptions::exception& e)
+    catch(const cxxopts::exceptions::exception& e)
     {
         spdlog::error("Error parsing options: {}", e.what());
         return 1;
     }
 
     return 0;
-}
+}
\ No newline at end of file