Class: MTProto::TL::SetBotCommands

Inherits:
Object
  • Object
show all
Includes:
Binary
Defined in:
lib/mtproto/tl/objects/set_bot_commands.rb

Constant Summary collapse

CONSTRUCTOR =
0x0517165a
BOT_COMMAND =
0xc27ac8c7

Instance Method Summary collapse

Methods included from Binary

#b_u32, #b_u64, #u32_b, #u64_b

Constructor Details

#initialize(commands:, scope: { type: :default }, lang_code: '') ⇒ SetBotCommands

commands: array of { command:, description: } scope: BotCommandScope hash (see BotCommandScope); defaults to default scope.



15
16
17
18
19
# File 'lib/mtproto/tl/objects/set_bot_commands.rb', line 15

def initialize(commands:, scope: { type: :default }, lang_code: '')
  @commands = commands
  @scope = scope
  @lang_code = lang_code
end

Instance Method Details

#serializeObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/mtproto/tl/objects/set_bot_commands.rb', line 21

def serialize
  result = u32_b(CONSTRUCTOR)
  result += BotCommandScope.serialize(@scope)
  result += serialize_tl_string(@lang_code)
  result += u32_b(Constructors::VECTOR)
  result += u32_b(@commands.size)
  @commands.each do |cmd|
    result += u32_b(BOT_COMMAND)
    result += serialize_tl_string(cmd[:command])
    result += serialize_tl_string(cmd[:description])
  end
  result
end