Class: MTProto::TL::ExportedBotToken

Inherits:
Object
  • Object
show all
Defined in:
lib/mtproto/tl/objects/exported_bot_token.rb

Constant Summary collapse

CONSTRUCTOR =
0x3c60b621

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token:) ⇒ ExportedBotToken

Returns a new instance of ExportedBotToken.



10
11
12
# File 'lib/mtproto/tl/objects/exported_bot_token.rb', line 10

def initialize(token:)
  @token = token
end

Instance Attribute Details

#tokenObject (readonly)

Returns the value of attribute token.



8
9
10
# File 'lib/mtproto/tl/objects/exported_bot_token.rb', line 8

def token
  @token
end

Class Method Details

.deserialize(bytes) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/mtproto/tl/objects/exported_bot_token.rb', line 14

def self.deserialize(bytes)
  body = bytes[4..]
  first = body.getbyte(0)
  token = if first == 254
            len = body.getbyte(1) | (body.getbyte(2) << 8) | (body.getbyte(3) << 16)
            body[4, len]
          else
            body[1, first]
          end
  new(token: token.force_encoding('UTF-8'))
end