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