From fceef8197bb1ab874b0141cbe76a19fba0264d2c Mon Sep 17 00:00:00 2001 From: starnakin Date: Wed, 11 Oct 2023 18:59:09 +0000 Subject: [PATCH] add: token in env var --- src/utils.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/utils.cpp b/src/utils.cpp index 0a42f20..757a51a 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -53,4 +53,16 @@ int get_article_data(std::string& str, unsigned int& quantity, float& price) quantity = get_quantity(str); return 0; +} + +std::string get_token(char** av, char** env) +{ + if (av[1] != NULL) + return av[1]; + for (size_t i = 0; env[i] != NULL; ++i) + { + if (std::strncmp("BOT_TOKEN", env[i], 9) == 0) + return env[i] + 10; + } + return BOT_TOKEN; } \ No newline at end of file