history_item_reply_markup.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. #include "base/flags.h"
  9. #include "data/data_chat_participant_status.h"
  10. namespace Data {
  11. class Session;
  12. } // namespace Data
  13. namespace InlineBots {
  14. enum class PeerType : uint8;
  15. using PeerTypes = base::flags<PeerType>;
  16. } // namespace InlineBots
  17. [[nodiscard]] InlineBots::PeerTypes PeerTypesFromMTP(
  18. const MTPvector<MTPInlineQueryPeerType> &types);
  19. enum class ReplyMarkupFlag : uint32 {
  20. None = (1U << 0),
  21. ForceReply = (1U << 1),
  22. HasSwitchInlineButton = (1U << 2),
  23. Inline = (1U << 3),
  24. Resize = (1U << 4),
  25. SingleUse = (1U << 5),
  26. Selective = (1U << 6),
  27. IsNull = (1U << 7),
  28. OnlyBuyButton = (1U << 8),
  29. Persistent = (1U << 9),
  30. };
  31. inline constexpr bool is_flag_type(ReplyMarkupFlag) { return true; }
  32. using ReplyMarkupFlags = base::flags<ReplyMarkupFlag>;
  33. struct RequestPeerQuery {
  34. enum class Type : uchar {
  35. User,
  36. Group,
  37. Broadcast,
  38. };
  39. enum class Restriction : uchar {
  40. Any,
  41. Yes,
  42. No,
  43. };
  44. int maxQuantity = 0;
  45. Type type = Type::User;
  46. Restriction userIsBot = Restriction::Any;
  47. Restriction userIsPremium = Restriction::Any;
  48. Restriction groupIsForum = Restriction::Any;
  49. Restriction hasUsername = Restriction::Any;
  50. bool amCreator = false;
  51. bool isBotParticipant = false;
  52. ChatAdminRights myRights = {};
  53. ChatAdminRights botRights = {};
  54. };
  55. static_assert(std::is_trivially_copy_assignable_v<RequestPeerQuery>);
  56. struct HistoryMessageMarkupButton {
  57. enum class Type {
  58. Default,
  59. Url,
  60. Callback,
  61. CallbackWithPassword,
  62. RequestPhone,
  63. RequestLocation,
  64. RequestPoll,
  65. RequestPeer,
  66. SwitchInline,
  67. SwitchInlineSame,
  68. Game,
  69. Buy,
  70. Auth,
  71. UserProfile,
  72. WebView,
  73. SimpleWebView,
  74. CopyText,
  75. };
  76. HistoryMessageMarkupButton(
  77. Type type,
  78. const QString &text,
  79. const QByteArray &data = QByteArray(),
  80. const QString &forwardText = QString(),
  81. int64 buttonId = 0);
  82. static HistoryMessageMarkupButton *Get(
  83. not_null<Data::Session*> owner,
  84. FullMsgId itemId,
  85. int row,
  86. int column);
  87. Type type;
  88. QString text, forwardText;
  89. QByteArray data;
  90. int64 buttonId = 0;
  91. InlineBots::PeerTypes peerTypes = 0;
  92. mutable mtpRequestId requestId = 0;
  93. };
  94. struct HistoryMessageMarkupData {
  95. HistoryMessageMarkupData() = default;
  96. explicit HistoryMessageMarkupData(const MTPReplyMarkup *data);
  97. void fillForwardedData(const HistoryMessageMarkupData &original);
  98. [[nodiscard]] bool isNull() const;
  99. [[nodiscard]] bool isTrivial() const;
  100. using Button = HistoryMessageMarkupButton;
  101. std::vector<std::vector<Button>> rows;
  102. ReplyMarkupFlags flags = ReplyMarkupFlag::IsNull;
  103. QString placeholder;
  104. private:
  105. void fillRows(const QVector<MTPKeyboardButtonRow> &v);
  106. };
  107. struct HistoryMessageRepliesData {
  108. HistoryMessageRepliesData() = default;
  109. explicit HistoryMessageRepliesData(const MTPMessageReplies *data);
  110. std::vector<PeerId> recentRepliers;
  111. ChannelId channelId = 0;
  112. MsgId readMaxId = 0;
  113. MsgId maxId = 0;
  114. int repliesCount = 0;
  115. bool isNull = true;
  116. int pts = 0;
  117. };