mirror of
https://github.com/tdlight-team/tdlight-telegram-bot-api.git
synced 2024-11-27 14:16:49 +01:00
Add filter option argument checks.
This commit is contained in:
parent
2dd7ef910f
commit
91db058809
@ -184,14 +184,17 @@ int main(int argc, char *argv[]) {
|
|||||||
options.add_option('d', "dir", "server working directory", td::OptionParser::parse_string(working_directory));
|
options.add_option('d', "dir", "server working directory", td::OptionParser::parse_string(working_directory));
|
||||||
options.add_option('t', "temp-dir", "directory for storing HTTP server temporary files",
|
options.add_option('t', "temp-dir", "directory for storing HTTP server temporary files",
|
||||||
td::OptionParser::parse_string(temporary_directory));
|
td::OptionParser::parse_string(temporary_directory));
|
||||||
options.add_checked_option('\0', "filter",
|
options.add_checked_option(
|
||||||
"\"<remainder>/<modulo>\". Allow only bots with 'bot_user_id % modulo == remainder'",
|
'\0', "filter", "\"<remainder>/<modulo>\". Allow only bots with 'bot_user_id % modulo == remainder'",
|
||||||
[&](td::Slice rem_mod) {
|
[&](td::Slice rem_mod) {
|
||||||
td::Slice rem;
|
td::Slice rem;
|
||||||
td::Slice mod;
|
td::Slice mod;
|
||||||
std::tie(rem, mod) = td::split(rem_mod, '/');
|
std::tie(rem, mod) = td::split(rem_mod, '/');
|
||||||
TRY_RESULT(rem_i, td::to_integer_safe<td::uint64>(rem));
|
TRY_RESULT(rem_i, td::to_integer_safe<td::uint64>(rem));
|
||||||
TRY_RESULT(mod_i, td::to_integer_safe<td::uint64>(mod));
|
TRY_RESULT(mod_i, td::to_integer_safe<td::uint64>(mod));
|
||||||
|
if (rem_i < 0 || rem_i >= mod_i) {
|
||||||
|
return td::Status::Error("Wrong argument specified: ensure that 0 <= remainder < modulo");
|
||||||
|
}
|
||||||
token_range = {rem_i, mod_i};
|
token_range = {rem_i, mod_i};
|
||||||
return td::Status::OK();
|
return td::Status::OK();
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user