Class: MTProto::TL::SendMessage
- Inherits:
-
Object
- Object
- MTProto::TL::SendMessage
- Includes:
- Binary
- Defined in:
- lib/mtproto/tl/objects/send_message.rb
Constant Summary collapse
- INPUT_REPLY_TO_MESSAGE =
0x3bd4b7c2- INPUT_RICH_MESSAGE_MARKDOWN =
0x004b572c
Instance Method Summary collapse
-
#initialize(peer:, message: '', random_id: nil, reply_to: nil, reply_markup: nil, silent: false, entities: nil, rich_markdown: nil, quote_text: nil, quote_offset: nil) ⇒ SendMessage
constructor
A new instance of SendMessage.
- #serialize ⇒ Object
Methods included from Binary
#b_u32, #b_u64, #u32_b, #u64_b
Constructor Details
#initialize(peer:, message: '', random_id: nil, reply_to: nil, reply_markup: nil, silent: false, entities: nil, rich_markdown: nil, quote_text: nil, quote_offset: nil) ⇒ SendMessage
Returns a new instance of SendMessage.
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/mtproto/tl/objects/send_message.rb', line 14 def initialize(peer:, message: '', random_id: nil, reply_to: nil, reply_markup: nil, silent: false, entities: nil, rich_markdown: nil, quote_text: nil, quote_offset: nil) @peer = peer @message = @random_id = random_id || SecureRandom.random_number(2**63) @reply_to = reply_to @reply_markup = reply_markup @silent = silent @entities = entities @rich_markdown = rich_markdown @quote_text = quote_text @quote_offset = quote_offset end |
Instance Method Details
#serialize ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/mtproto/tl/objects/send_message.rb', line 28 def serialize flags = 0 flags |= (1 << 0) if @reply_to flags |= (1 << 2) if @reply_markup flags |= (1 << 3) if entities? flags |= (1 << 5) if @silent flags |= (1 << 23) if @rich_markdown # rich_message result = u32_b(Constructors::MESSAGES_SEND_MESSAGE) result += u32_b(flags) result += serialize_input_peer result += serialize_reply_to if @reply_to # Server-side rich markdown carries the whole message; the text field goes # empty and no entities are sent (matches Telegram Desktop's sendRichMessage). result += serialize_tl_string(@rich_markdown ? '' : @message) result += u64_b(@random_id) result += @reply_markup.serialize if @reply_markup result += MessageEntities.serialize(@entities) if entities? result += serialize_rich_markdown if @rich_markdown result end |