mirror of
https://github.com/PaiGramTeam/telegram-bot-api.git
synced 2024-11-16 04:35:33 +00: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('t', "temp-dir", "directory for storing HTTP server temporary files",
|
||||
td::OptionParser::parse_string(temporary_directory));
|
||||
options.add_checked_option('\0', "filter",
|
||||
"\"<remainder>/<modulo>\". Allow only bots with 'bot_user_id % modulo == remainder'",
|
||||
options.add_checked_option(
|
||||
'\0', "filter", "\"<remainder>/<modulo>\". Allow only bots with 'bot_user_id % modulo == remainder'",
|
||||
[&](td::Slice rem_mod) {
|
||||
td::Slice rem;
|
||||
td::Slice mod;
|
||||
std::tie(rem, mod) = td::split(rem_mod, '/');
|
||||
TRY_RESULT(rem_i, td::to_integer_safe<td::uint64>(rem));
|
||||
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};
|
||||
return td::Status::OK();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user