24
24
25
25
namespace td {
26
26
27
- static constexpr int32 REPLY_MARKUP_FLAG_NEED_RESIZE_KEYBOARD = 1 << 0 ;
28
- static constexpr int32 REPLY_MARKUP_FLAG_IS_ONE_TIME_KEYBOARD = 1 << 1 ;
29
- static constexpr int32 REPLY_MARKUP_FLAG_IS_PERSONAL = 1 << 2 ;
30
- static constexpr int32 REPLY_MARKUP_FLAG_HAS_PLACEHOLDER = 1 << 3 ;
31
- static constexpr int32 REPLY_MARKUP_FLAG_IS_PERSISTENT = 1 << 4 ;
32
-
33
27
static bool operator ==(const KeyboardButton &lhs, const KeyboardButton &rhs) {
34
28
return lhs.type == rhs.type && lhs.text == rhs.text && lhs.url == rhs.url ;
35
29
}
@@ -395,10 +389,10 @@ unique_ptr<ReplyMarkup> get_reply_markup(tl_object_ptr<telegram_api::ReplyMarkup
395
389
case telegram_api::replyKeyboardMarkup::ID: {
396
390
auto keyboard_markup = move_tl_object_as<telegram_api::replyKeyboardMarkup>(reply_markup_ptr);
397
391
reply_markup->type = ReplyMarkup::Type::ShowKeyboard;
398
- reply_markup->is_persistent = ( keyboard_markup->flags_ & REPLY_MARKUP_FLAG_IS_PERSISTENT) != 0 ;
399
- reply_markup->need_resize_keyboard = ( keyboard_markup->flags_ & REPLY_MARKUP_FLAG_NEED_RESIZE_KEYBOARD) != 0 ;
400
- reply_markup->is_one_time_keyboard = ( keyboard_markup->flags_ & REPLY_MARKUP_FLAG_IS_ONE_TIME_KEYBOARD) != 0 ;
401
- reply_markup->is_personal = ( keyboard_markup->flags_ & REPLY_MARKUP_FLAG_IS_PERSONAL) != 0 ;
392
+ reply_markup->is_persistent = keyboard_markup->persistent_ ;
393
+ reply_markup->need_resize_keyboard = keyboard_markup->resize_ ;
394
+ reply_markup->is_one_time_keyboard = keyboard_markup->single_use_ ;
395
+ reply_markup->is_personal = keyboard_markup->selective_ ;
402
396
reply_markup->placeholder = std::move (keyboard_markup->placeholder_ );
403
397
reply_markup->keyboard .reserve (keyboard_markup->rows_ .size ());
404
398
for (auto &row : keyboard_markup->rows_ ) {
@@ -422,13 +416,13 @@ unique_ptr<ReplyMarkup> get_reply_markup(tl_object_ptr<telegram_api::ReplyMarkup
422
416
case telegram_api::replyKeyboardHide::ID: {
423
417
auto hide_keyboard_markup = move_tl_object_as<telegram_api::replyKeyboardHide>(reply_markup_ptr);
424
418
reply_markup->type = ReplyMarkup::Type::RemoveKeyboard;
425
- reply_markup->is_personal = ( hide_keyboard_markup->flags_ & REPLY_MARKUP_FLAG_IS_PERSONAL) != 0 ;
419
+ reply_markup->is_personal = hide_keyboard_markup->selective_ ;
426
420
break ;
427
421
}
428
422
case telegram_api::replyKeyboardForceReply::ID: {
429
423
auto force_reply_markup = move_tl_object_as<telegram_api::replyKeyboardForceReply>(reply_markup_ptr);
430
424
reply_markup->type = ReplyMarkup::Type::ForceReply;
431
- reply_markup->is_personal = ( force_reply_markup->flags_ & REPLY_MARKUP_FLAG_IS_PERSONAL) != 0 ;
425
+ reply_markup->is_personal = force_reply_markup->selective_ ;
432
426
reply_markup->placeholder = std::move (force_reply_markup->placeholder_ );
433
427
break ;
434
428
}
@@ -978,20 +972,47 @@ tl_object_ptr<telegram_api::ReplyMarkup> ReplyMarkup::get_input_reply_markup(Use
978
972
}
979
973
rows.push_back (make_tl_object<telegram_api::keyboardButtonRow>(std::move (buttons)));
980
974
}
981
- return make_tl_object<telegram_api::replyKeyboardMarkup>(
982
- is_persistent * REPLY_MARKUP_FLAG_IS_PERSISTENT +
983
- need_resize_keyboard * REPLY_MARKUP_FLAG_NEED_RESIZE_KEYBOARD +
984
- is_one_time_keyboard * REPLY_MARKUP_FLAG_IS_ONE_TIME_KEYBOARD +
985
- is_personal * REPLY_MARKUP_FLAG_IS_PERSONAL + (!placeholder.empty ()) * REPLY_MARKUP_FLAG_HAS_PLACEHOLDER,
986
- false /* ignored*/ , false /* ignored*/ , false /* ignored*/ , false /* ignored*/ , std::move (rows), placeholder);
975
+ int32 flags = 0 ;
976
+ if (is_persistent) {
977
+ flags |= telegram_api::replyKeyboardMarkup::PERSISTENT_MASK;
978
+ }
979
+ if (need_resize_keyboard) {
980
+ flags |= telegram_api::replyKeyboardMarkup::RESIZE_MASK;
981
+ }
982
+ if (is_one_time_keyboard) {
983
+ flags |= telegram_api::replyKeyboardMarkup::SINGLE_USE_MASK;
984
+ }
985
+ if (is_personal) {
986
+ flags |= telegram_api::replyKeyboardMarkup::SELECTIVE_MASK;
987
+ }
988
+ if (!placeholder.empty ()) {
989
+ flags |= telegram_api::replyKeyboardMarkup::PLACEHOLDER_MASK;
990
+ }
991
+ return make_tl_object<telegram_api::replyKeyboardMarkup>(flags, false /* ignored*/ , false /* ignored*/ ,
992
+ false /* ignored*/ , false /* ignored*/ , std::move (rows),
993
+ placeholder);
994
+ }
995
+ case ReplyMarkup::Type::ForceReply: {
996
+ int32 flags = 0 ;
997
+ if (is_one_time_keyboard) {
998
+ flags |= telegram_api::replyKeyboardForceReply::SINGLE_USE_MASK;
999
+ }
1000
+ if (is_personal) {
1001
+ flags |= telegram_api::replyKeyboardForceReply::SELECTIVE_MASK;
1002
+ }
1003
+ if (!placeholder.empty ()) {
1004
+ flags |= telegram_api::replyKeyboardForceReply::PLACEHOLDER_MASK;
1005
+ }
1006
+ return make_tl_object<telegram_api::replyKeyboardForceReply>(flags, false /* ignored*/ , false /* ignored*/ ,
1007
+ placeholder);
1008
+ }
1009
+ case ReplyMarkup::Type::RemoveKeyboard: {
1010
+ int32 flags = 0 ;
1011
+ if (is_personal) {
1012
+ flags |= telegram_api::replyKeyboardHide::SELECTIVE_MASK;
1013
+ }
1014
+ return make_tl_object<telegram_api::replyKeyboardHide>(flags, false /* ignored*/ );
987
1015
}
988
- case ReplyMarkup::Type::ForceReply:
989
- return make_tl_object<telegram_api::replyKeyboardForceReply>(
990
- is_personal * REPLY_MARKUP_FLAG_IS_PERSONAL + (!placeholder.empty ()) * REPLY_MARKUP_FLAG_HAS_PLACEHOLDER,
991
- false /* ignored*/ , false /* ignored*/ , placeholder);
992
- case ReplyMarkup::Type::RemoveKeyboard:
993
- return make_tl_object<telegram_api::replyKeyboardHide>(is_personal * REPLY_MARKUP_FLAG_IS_PERSONAL,
994
- false /* ignored*/ );
995
1016
default :
996
1017
UNREACHABLE ();
997
1018
return nullptr ;
0 commit comments