#  @include tlobject.R
NULL

#  @title AccessPointRule
#  @description Telegram API type AccessPointRule
#  @export
#  @noRd
#  @noRd
AccessPointRule <- R6::R6Class(
  "AccessPointRule",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4679b65f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb1aca0fd,


    #  @field phone_prefix_rules A string representing phone prefix rules.
    phone_prefix_rules = NULL,

    #  @field dc_id An integer representing the data center ID.
    dc_id = NULL,

    #  @field ips A list of TypeIpPort objects representing IPs.
    ips = NULL,

    #  @description
    #  Initializes the AccessPointRule with the given parameters.
    #  @param phone_prefix_rules A string representing phone prefix rules.
    #  @param dc_id An integer representing the data center ID.
    #  @param ips A list of TypeIpPort objects representing IPs.
    initialize = function(phone_prefix_rules, dc_id, ips) {
      self$phone_prefix_rules <- phone_prefix_rules
      self$dc_id <- dc_id
      self$ips <- ips
    },

    #  @description
    #  Converts the AccessPointRule object to a list (dictionary).
    #  @return A list representation of the AccessPointRule object.
    to_dict = function() {
      return(list(
        `_` = "AccessPointRule",
        phone_prefix_rules = self$phone_prefix_rules,
        dc_id = self$dc_id,
        ips = lapply(self$ips, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      ))
    },

    #  @description
    #  Serializes the AccessPointRule object to bytes.
    #  @return A raw vector representing the serialized bytes of the AccessPointRule object.
    bytes = function() {
      return(do.call(c, list(
        as.raw(c(0x5f, 0xb6, 0x79, 0x46)),
        self$serializebytes(self$phone_prefix_rules),
        writeBin(as.integer(self$dc_id), raw(), size = 4, endian = "little"),
        writeBin(as.integer(length(self$ips)), raw(), size = 4, endian = "little"),
        do.call(c, lapply(self$ips, function(x) x$bytes()))
      )))
    }
  ),
  private = list(
    #  Reads an AccessPointRule object from a BinaryReader.
    from_reader = function(reader) {
      phone_prefix_rules <- reader$tgread_string()
      dc_id <- reader$read_int()
      ips <- list()
      for (i in seq_len(reader$read_int())) {
        ips[[i]] <- reader$tgread_object()
      }
      return(AccessPointRule$new(phone_prefix_rules, dc_id, ips))
    }
  )
)

#  @title AccountDaysTTL
#  @description Telegram API type AccountDaysTTL
#  @export
#  @noRd
#  @noRd
AccountDaysTTL <- R6::R6Class(
  "AccountDaysTTL",
  inherit = TLObject,
  public = list(
    #  @field days An integer representing the number of days.
    days = NULL,

    #  @description
    #  Initializes the AccountDaysTTL with the given number of days.
    #  @param days An integer representing the number of days.
    initialize = function(days) {
      self$days <- days
    },

    #  @description
    #  Converts the AccountDaysTTL object to a list (dictionary).
    #  @return A list representation of the AccountDaysTTL object.
    to_dict = function() {
      return(list(
        `_` = "AccountDaysTTL",
        days = self$days
      ))
    },

    #  @description
    #  Serializes the AccountDaysTTL object to bytes.
    #  @return A raw vector representing the serialized bytes of the AccountDaysTTL object.
    bytes = function() {
      return(do.call(c, list(
        as.raw(c(0xdf, 0xaf, 0xd0, 0xb8)),
        writeBin(as.integer(self$days), raw(), size = 4, endian = "little")
      )))
    }
  )
)


#  @title AccountDaysTTL
#  @description Telegram API type AccountDaysTTL
#  @export
#  @noRd
#  @noRd
AccountDaysTTL <- R6::R6Class(
  "AccountDaysTTL",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb8d0afdf,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbaa39d88,


    #  @field days An integer representing the number of days.
    days = NULL,

    #  @description
    #  Initializes the AccountDaysTTL with the given number of days.
    #  @param days An integer representing the number of days.
    initialize = function(days) {
      self$days <- days
    },

    #  @description
    #  Converts the AccountDaysTTL object to a list (dictionary).
    #  @return A list representation of the AccountDaysTTL object.
    to_dict = function() {
      return(list(
        `_` = "AccountDaysTTL",
        days = self$days
      ))
    },

    #  @description
    #  Serializes the AccountDaysTTL object to bytes.
    #  @return A raw vector representing the serialized bytes of the AccountDaysTTL object.
    bytes = function() {
      return(do.call(c, list(
        as.raw(c(0xdf, 0xaf, 0xd0, 0xb8)),
        writeBin(as.integer(self$days), raw(), size = 4, endian = "little")
      )))
    }
  ),
  private = list(
    #  Reads an AccountDaysTTL object from a BinaryReader.
    from_reader = function(reader) {
      days <- reader$read_int()
      return(AccountDaysTTL$new(days))
    }
  )
)

#  @title AttachMenuBot
#  @description Telegram API type AttachMenuBot
#  @export
#  @noRd
#  @noRd
AttachMenuBot <- R6::R6Class(
  "AttachMenuBot",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd90d8dfe,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f087446,

    #  @field bot_id Field.
    bot_id = NULL,
    #  @field short_name Field.
    short_name = NULL,
    #  @field icons Field.
    icons = NULL,
    #  @field inactive Field.
    inactive = NULL,
    #  @field has_settings Field.
    has_settings = NULL,
    #  @field request_write_access Field.
    request_write_access = NULL,
    #  @field show_in_attach_menu Field.
    show_in_attach_menu = NULL,
    #  @field show_in_side_menu Field.
    show_in_side_menu = NULL,
    #  @field side_menu_disclaimer_needed Field.
    side_menu_disclaimer_needed = NULL,
    #  @field peer_types Field.
    peer_types = NULL,

    #  @description
    #  Initializes the AttachMenuBot with the given parameters.
    #  @param bot_id An integer representing the bot ID.
    #  @param short_name A string representing the short name.
    #  @param icons A list of TypeAttachMenuBotIcon objects.
    #  @param inactive Optional boolean indicating if inactive.
    #  @param has_settings Optional boolean indicating if has settings.
    #  @param request_write_access Optional boolean indicating if requests write access.
    #  @param show_in_attach_menu Optional boolean indicating if shows in attach menu.
    #  @param show_in_side_menu Optional boolean indicating if shows in side menu.
    #  @param side_menu_disclaimer_needed Optional boolean indicating if side menu disclaimer needed.
    #  @param peer_types Optional list of TypeAttachMenuPeerType objects.
    initialize = function(bot_id, short_name, icons, inactive = NULL, has_settings = NULL, request_write_access = NULL, show_in_attach_menu = NULL, show_in_side_menu = NULL, side_menu_disclaimer_needed = NULL, peer_types = NULL) {
      self$bot_id <- bot_id
      self$short_name <- short_name
      self$icons <- icons
      self$inactive <- inactive
      self$has_settings <- has_settings
      self$request_write_access <- request_write_access
      self$show_in_attach_menu <- show_in_attach_menu
      self$show_in_side_menu <- show_in_side_menu
      self$side_menu_disclaimer_needed <- side_menu_disclaimer_needed
      self$peer_types <- peer_types
    },

    #  @description
    #  Converts the AttachMenuBot object to a list (dictionary).
    #  @return A list representation of the AttachMenuBot object.
    to_dict = function() {
      return(list(
        `_` = "AttachMenuBot",
        bot_id = self$bot_id,
        short_name = self$short_name,
        icons = if (is.null(self$icons)) list() else lapply(self$icons, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        inactive = self$inactive,
        has_settings = self$has_settings,
        request_write_access = self$request_write_access,
        show_in_attach_menu = self$show_in_attach_menu,
        show_in_side_menu = self$show_in_side_menu,
        side_menu_disclaimer_needed = self$side_menu_disclaimer_needed,
        peer_types = if (is.null(self$peer_types)) list() else lapply(self$peer_types, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      ))
    },

    #  @description
    #  Serializes the AttachMenuBot object to bytes.
    #  @return A raw vector representing the serialized bytes of the AttachMenuBot object.
    bytes = function() {
      # Assert validation
      if (!((self$show_in_attach_menu || !is.null(self$show_in_attach_menu)) &&
        (self$peer_types || !is.null(self$peer_types))) &&
        !((is.null(self$show_in_attach_menu) || isFALSE(self$show_in_attach_menu)) &&
          (is.null(self$peer_types) || isFALSE(self$peer_types)))) {
        stop("show_in_attach_menu, peer_types parameters must all be FALSE-y (like NULL) or all be TRUE-y")
      }

      # Calculate flags
      flags <- 0
      if (!is.null(self$inactive) && self$inactive) flags <- flags + 1
      if (!is.null(self$has_settings) && self$has_settings) flags <- flags + 2
      if (!is.null(self$request_write_access) && self$request_write_access) flags <- flags + 4
      if (!is.null(self$show_in_attach_menu) && self$show_in_attach_menu) flags <- flags + 8
      if (!is.null(self$show_in_side_menu) && self$show_in_side_menu) flags <- flags + 16
      if (!is.null(self$side_menu_disclaimer_needed) && self$side_menu_disclaimer_needed) flags <- flags + 32
      if (!is.null(self$peer_types) && length(self$peer_types) > 0) flags <- flags + 8

      result <- list(
        as.raw(c(0xfe, 0x8d, 0x0d, 0xd9)),
        writeBin(as.integer(flags), raw(), size = 4, endian = "little"),
        writeBin(as.numeric(self$bot_id), raw(), size = 8, endian = "little"),
        self$serializebytes(self$short_name)
      )

      # Add peer_types if present
      if (!is.null(self$peer_types) && length(self$peer_types) > 0) {
        result <- append(result, list(
          as.raw(c(0x15, 0xc4, 0xb5, 0x1c)),
          writeBin(as.integer(length(self$peer_types)), raw(), size = 4, endian = "little"),
          do.call(c, lapply(self$peer_types, function(x) x$bytes()))
        ))
      }

      # Add icons
      result <- append(result, list(
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)),
        writeBin(as.integer(length(self$icons)), raw(), size = 4, endian = "little"),
        do.call(c, lapply(self$icons, function(x) x$bytes()))
      ))

      return(do.call(c, result))
    }
  ),
  private = list(
    #  Reads an AttachMenuBot object from a BinaryReader.
    from_reader = function(reader) {
      flags <- reader$read_int()

      inactive <- bitwAnd(flags, 1) != 0
      has_settings <- bitwAnd(flags, 2) != 0
      request_write_access <- bitwAnd(flags, 4) != 0
      show_in_attach_menu <- bitwAnd(flags, 8) != 0
      show_in_side_menu <- bitwAnd(flags, 16) != 0
      side_menu_disclaimer_needed <- bitwAnd(flags, 32) != 0

      bot_id <- reader$read_long()
      short_name <- reader$tgread_string()

      # Read peer_types if present
      peer_types <- NULL
      if (bitwAnd(flags, 8) != 0) {
        reader$read_int()
        peer_types <- list()
        npeer_types <- reader$read_int()
        for (i in seq_len(npeer_types)) {
          peer_types[[i]] <- reader$tgread_object()
        }
      }

      # Read icons
      reader$read_int()
      icons <- list()
      n_icons <- reader$read_int()
      for (i in seq_len(n_icons)) {
        icons[[i]] <- reader$tgread_object()
      }

      return(AttachMenuBot$new(
        bot_id = bot_id,
        short_name = short_name,
        icons = icons,
        inactive = inactive,
        has_settings = has_settings,
        request_write_access = request_write_access,
        show_in_attach_menu = show_in_attach_menu,
        show_in_side_menu = show_in_side_menu,
        side_menu_disclaimer_needed = side_menu_disclaimer_needed,
        peer_types = peer_types
      ))
    }
  )
)

#  @title AttachMenuBotIcon
#  @description Telegram API type AttachMenuBotIcon
#  @export
#  @noRd
#  @noRd
AttachMenuBotIcon <- R6::R6Class(
  "AttachMenuBotIcon",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb2a7386b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x80484555,

    #  @field name Field.
    name = NULL,
    #  @field icon Field.
    icon = NULL,
    #  @field colors Field.
    colors = NULL,

    #  @description
    #  Initializes the AttachMenuBotIcon with the given parameters.
    #  @param name A string representing the icon name.
    #  @param icon A TypeDocument object representing the icon.
    #  @param colors Optional list of TypeAttachMenuBotIconColor objects.
    initialize = function(name, icon, colors = NULL) {
      self$name <- name
      self$icon <- icon
      self$colors <- colors
    },

    #  @description
    #  Converts the AttachMenuBotIcon object to a list (dictionary).
    #  @return A list representation of the AttachMenuBotIcon object.
    to_dict = function() {
      return(list(
        `_` = "AttachMenuBotIcon",
        name = self$name,
        icon = if (inherits(self$icon, "TLObject")) self$icon$to_dict() else self$icon,
        colors = if (is.null(self$colors)) list() else lapply(self$colors, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      ))
    },

    #  @description
    #  Serializes the AttachMenuBotIcon object to bytes.
    #  @return A raw vector representing the serialized bytes of the AttachMenuBotIcon object.
    bytes = function() {
      flags <- if (!is.null(self$colors) && length(self$colors) > 0) 1 else 0

      result <- list(
        as.raw(c(0x6b, 0x38, 0xa7, 0xb2)),
        writeBin(as.integer(flags), raw(), size = 4, endian = "little"),
        self$serializebytes(self$name),
        self$icon$bytes()
      )

      if (!is.null(self$colors) && length(self$colors) > 0) {
        result <- append(result, list(
          as.raw(c(0x15, 0xc4, 0xb5, 0x1c)),
          writeBin(as.integer(length(self$colors)), raw(), size = 4, endian = "little"),
          do.call(c, lapply(self$colors, function(x) x$bytes()))
        ))
      }

      return(do.call(c, result))
    }
  ),
  private = list(
    #  Reads an AttachMenuBotIcon object from a BinaryReader.
    from_reader = function(reader) {
      flags <- reader$read_int()

      name <- reader$tgread_string()
      icon <- reader$tgread_object()

      colors <- NULL
      if (bitwAnd(flags, 1) != 0) {
        reader$read_int()
        colors <- list()
        n_colors <- reader$read_int()
        for (i in seq_len(n_colors)) {
          colors[[i]] <- reader$tgread_object()
        }
      }

      return(AttachMenuBotIcon$new(name = name, icon = icon, colors = colors))
    }
  )
)

#  @title AttachMenuBotIconColor
#  @description Telegram API type AttachMenuBotIconColor
#  @export
#  @noRd
#  @noRd
AttachMenuBotIconColor <- R6::R6Class(
  "AttachMenuBotIconColor",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4576f3f0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbea4cb6a,

    #  @field name Field.
    name = NULL,
    #  @field color Field.
    color = NULL,

    #  @description
    #  Initializes the AttachMenuBotIconColor with the given parameters.
    #  @param name A string representing the color name.
    #  @param color An integer representing the color value.
    initialize = function(name, color) {
      self$name <- name
      self$color <- color
    },

    #  @description
    #  Converts the AttachMenuBotIconColor object to a list (dictionary).
    #  @return A list representation of the AttachMenuBotIconColor object.
    to_dict = function() {
      return(list(
        `_` = "AttachMenuBotIconColor",
        name = self$name,
        color = self$color
      ))
    },

    #  @description
    #  Serializes the AttachMenuBotIconColor object to bytes.
    #  @return A raw vector representing the serialized bytes of the AttachMenuBotIconColor object.
    bytes = function() {
      return(do.call(c, list(
        as.raw(c(0xf0, 0xf3, 0x76, 0x45)),
        self$serializebytes(self$name),
        writeBin(as.integer(self$color), raw(), size = 4, endian = "little")
      )))
    }
  ),
  private = list(
    #  Reads an AttachMenuBotIconColor object from a BinaryReader.
    from_reader = function(reader) {
      name <- reader$tgread_string()
      color <- reader$read_int()
      return(AttachMenuBotIconColor$new(name = name, color = color))
    }
  )
)

#  @title AttachMenuBots
#  @description Telegram API type AttachMenuBots
#  @export
#  @noRd
#  @noRd
AttachMenuBots <- R6::R6Class(
  "AttachMenuBots",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x3c4301c0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x842e23da,

    #  @field hash Field.
    hash = NULL,
    #  @field bots Field.
    bots = NULL,
    #  @field users Field.
    users = NULL,

    #  @description
    #  Initializes the AttachMenuBots with the given parameters.
    #  @param hash An integer representing the hash value.
    #  @param bots A list of TypeAttachMenuBot objects.
    #  @param users A list of TypeUser objects.
    initialize = function(hash, bots, users) {
      self$hash <- hash
      self$bots <- bots
      self$users <- users
    },

    #  @description
    #  Converts the AttachMenuBots object to a list (dictionary).
    #  @return A list representation of the AttachMenuBots object.
    to_dict = function() {
      return(list(
        `_` = "AttachMenuBots",
        hash = self$hash,
        bots = if (is.null(self$bots)) list() else lapply(self$bots, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        users = if (is.null(self$users)) list() else lapply(self$users, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      ))
    },

    #  @description
    #  Serializes the AttachMenuBots object to bytes.
    #  @return A raw vector representing the serialized bytes of the AttachMenuBots object.
    bytes = function() {
      return(do.call(c, list(
        as.raw(c(0xc0, 0x01, 0x43, 0x3c)),
        writeBin(as.numeric(self$hash), raw(), size = 8, endian = "little"),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)),
        writeBin(as.integer(length(self$bots)), raw(), size = 4, endian = "little"),
        do.call(c, lapply(self$bots, function(x) x$bytes())),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)),
        writeBin(as.integer(length(self$users)), raw(), size = 4, endian = "little"),
        do.call(c, lapply(self$users, function(x) x$bytes()))
      )))
    }
  ),
  private = list(
    #  Reads an AttachMenuBots object from a BinaryReader.
    from_reader = function(reader) {
      hash <- reader$read_long()

      reader$read_int()
      bots <- list()
      n_bots <- reader$read_int()
      for (i in seq_len(n_bots)) {
        bots[[i]] <- reader$tgread_object()
      }

      reader$read_int()
      users <- list()
      n_users <- reader$read_int()
      for (i in seq_len(n_users)) {
        users[[i]] <- reader$tgread_object()
      }

      return(AttachMenuBots$new(hash = hash, bots = bots, users = users))
    }
  )
)

#  @title AttachMenuBotsBot
#  @description Telegram API type AttachMenuBotsBot
#  @export
#  @noRd
#  @noRd
AttachMenuBotsBot <- R6::R6Class(
  "AttachMenuBotsBot",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x93bf667f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xdb33883d,

    #  @field bot Field.
    bot = NULL,
    #  @field users Field.
    users = NULL,

    #  @description
    #  Initializes the AttachMenuBotsBot with the given parameters.
    #  @param bot A TypeAttachMenuBot object.
    #  @param users A list of TypeUser objects.
    initialize = function(bot, users) {
      self$bot <- bot
      self$users <- users
    },

    #  @description
    #  Converts the AttachMenuBotsBot object to a list (dictionary).
    #  @return A list representation of the AttachMenuBotsBot object.
    to_dict = function() {
      return(list(
        `_` = "AttachMenuBotsBot",
        bot = if (inherits(self$bot, "TLObject")) self$bot$to_dict() else self$bot,
        users = if (is.null(self$users)) list() else lapply(self$users, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      ))
    },

    #  @description
    #  Serializes the AttachMenuBotsBot object to bytes.
    #  @return A raw vector representing the serialized bytes of the AttachMenuBotsBot object.
    bytes = function() {
      return(do.call(c, list(
        as.raw(c(0x7f, 0x66, 0xbf, 0x93)),
        self$bot$bytes(),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)),
        writeBin(as.integer(length(self$users)), raw(), size = 4, endian = "little"),
        do.call(c, lapply(self$users, function(x) x$bytes()))
      )))
    }
  ),
  private = list(
    #  Reads an AttachMenuBotsBot object from a BinaryReader.
    from_reader = function(reader) {
      bot <- reader$tgread_object()

      reader$read_int()
      users <- list()
      n_users <- reader$read_int()
      for (i in seq_len(n_users)) {
        users[[i]] <- reader$tgread_object()
      }

      return(AttachMenuBotsBot$new(bot = bot, users = users))
    }
  )
)

#  @title AttachMenuBotsNotModified
#  @description Telegram API type AttachMenuBotsNotModified
#  @export
#  @noRd
#  @noRd
AttachMenuBotsNotModified <- R6::R6Class(
  "AttachMenuBotsNotModified",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf1d88a5c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x842e23da,


    #  @description
    #  Initializes the AttachMenuBotsNotModified object.
    initialize = function() {
      # No initialization needed for this class
    },

    #  @description
    #  Converts the AttachMenuBotsNotModified object to a list (dictionary).
    #  @return A list representation of the AttachMenuBotsNotModified object.
    to_dict = function() {
      return(list(
        `_` = "AttachMenuBotsNotModified"
      ))
    },

    #  @description
    #  Serializes the AttachMenuBotsNotModified object to bytes.
    #  @return A raw vector representing the serialized bytes of the AttachMenuBotsNotModified object.
    bytes = function() {
      return(as.raw(c(0x5c, 0x8a, 0xd8, 0xf1)))
    }
  ),
  private = list(
    #  Reads an AttachMenuBotsNotModified object from a BinaryReader.
    from_reader = function(reader) {
      return(AttachMenuBotsNotModified$new())
    }
  )
)

#  @title AttachMenuPeerTypeBotPM
#  @description Telegram API type AttachMenuPeerTypeBotPM
#  @export
#  @noRd
#  @noRd
AttachMenuPeerTypeBotPM <- R6::R6Class(
  "AttachMenuPeerTypeBotPM",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc32bfa1a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd1d886d0,


    #  @description
    #  Initializes the AttachMenuPeerTypeBotPM object.
    initialize = function() {
      # No initialization needed for this class
    },

    #  @description
    #  Converts the AttachMenuPeerTypeBotPM object to a list (dictionary).
    #  @return A list representation of the AttachMenuPeerTypeBotPM object.
    to_dict = function() {
      return(list(
        `_` = "AttachMenuPeerTypeBotPM"
      ))
    },

    #  @description
    #  Serializes the AttachMenuPeerTypeBotPM object to bytes.
    #  @return A raw vector representing the serialized bytes of the AttachMenuPeerTypeBotPM object.
    bytes = function() {
      return(as.raw(c(0x1a, 0xfa, 0x2b, 0xc3)))
    }
  ),
  private = list(
    #  Reads an AttachMenuPeerTypeBotPM object from a BinaryReader.
    from_reader = function(reader) {
      return(AttachMenuPeerTypeBotPM$new())
    }
  )
)

#  @title AttachMenuPeerTypeBroadcast
#  @description Telegram API type AttachMenuPeerTypeBroadcast
#  @export
#  @noRd
#  @noRd
AttachMenuPeerTypeBroadcast <- R6::R6Class(
  "AttachMenuPeerTypeBroadcast",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7bfbdefc,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd1d886d0,


    #  @description
    #  Initializes the AttachMenuPeerTypeBroadcast object.
    initialize = function() {
      # No initialization needed for this class
    },

    #  @description
    #  Converts the AttachMenuPeerTypeBroadcast object to a list (dictionary).
    #  @return A list representation of the AttachMenuPeerTypeBroadcast object.
    to_dict = function() {
      return(list(
        `_` = "AttachMenuPeerTypeBroadcast"
      ))
    },

    #  @description
    #  Serializes the AttachMenuPeerTypeBroadcast object to bytes.
    #  @return A raw vector representing the serialized bytes of the AttachMenuPeerTypeBroadcast object.
    bytes = function() {
      return(as.raw(c(0xfc, 0xde, 0xfb, 0x7b)))
    }
  ),
  private = list(
    #  Reads an AttachMenuPeerTypeBroadcast object from a BinaryReader.
    from_reader = function(reader) {
      return(AttachMenuPeerTypeBroadcast$new())
    }
  )
)

#  @title AttachMenuPeerTypeChat
#  @description Telegram API type AttachMenuPeerTypeChat
#  @export
#  @noRd
#  @noRd
AttachMenuPeerTypeChat <- R6::R6Class(
  "AttachMenuPeerTypeChat",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x0509113f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd1d886d0,


    #  @description
    #  Initializes the AttachMenuPeerTypeChat object.
    initialize = function() {
      # No initialization needed for this class
    },

    #  @description
    #  Converts the AttachMenuPeerTypeChat object to a list (dictionary).
    #  @return A list representation of the AttachMenuPeerTypeChat object.
    to_dict = function() {
      return(list(
        `_` = "AttachMenuPeerTypeChat"
      ))
    },

    #  @description
    #  Serializes the AttachMenuPeerTypeChat object to bytes.
    #  @return A raw vector representing the serialized bytes of the AttachMenuPeerTypeChat object.
    bytes = function() {
      return(as.raw(c(0x3f, 0x11, 0x09, 0x05)))
    }
  ),
  private = list(
    #  Reads an AttachMenuPeerTypeChat object from a BinaryReader.
    from_reader = function(reader) {
      return(AttachMenuPeerTypeChat$new())
    }
  )
)

#  @title AttachMenuPeerTypePM
#  @description Telegram API type AttachMenuPeerTypePM
#  @export
#  @noRd
#  @noRd
AttachMenuPeerTypePM <- R6::R6Class(
  "AttachMenuPeerTypePM",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf146d31f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd1d886d0,


    #  @description
    #  Initializes the AttachMenuPeerTypePM object.
    initialize = function() {
      # No initialization needed for this class
    },

    #  @description
    #  Converts the AttachMenuPeerTypePM object to a list (dictionary).
    #  @return A list representation of the AttachMenuPeerTypePM object.
    to_dict = function() {
      return(list(
        `_` = "AttachMenuPeerTypePM"
      ))
    },

    #  @description
    #  Serializes the AttachMenuPeerTypePM object to bytes.
    #  @return A raw vector representing the serialized bytes of the AttachMenuPeerTypePM object.
    bytes = function() {
      return(as.raw(c(0x1f, 0xd3, 0x46, 0xf1)))
    }
  ),
  private = list(
    #  Reads an AttachMenuPeerTypePM object from a BinaryReader.
    from_reader = function(reader) {
      return(AttachMenuPeerTypePM$new())
    }
  )
)

#  @title AttachMenuPeerTypeSameBotPM
#  @description Telegram API type AttachMenuPeerTypeSameBotPM
#  @export
#  @noRd
#  @noRd
AttachMenuPeerTypeSameBotPM <- R6::R6Class(
  "AttachMenuPeerTypeSameBotPM",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7d6be90e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd1d886d0,


    #  @description
    #  Initializes the AttachMenuPeerTypeSameBotPM object.
    initialize = function() {
      # No initialization needed for this class
    },

    #  @description
    #  Converts the AttachMenuPeerTypeSameBotPM object to a list (dictionary).
    #  @return A list representation of the AttachMenuPeerTypeSameBotPM object.
    to_dict = function() {
      return(list(
        `_` = "AttachMenuPeerTypeSameBotPM"
      ))
    },

    #  @description
    #  Serializes the AttachMenuPeerTypeSameBotPM object to bytes.
    #  @return A raw vector representing the serialized bytes of the AttachMenuPeerTypeSameBotPM object.
    bytes = function() {
      return(as.raw(c(0x0e, 0xe9, 0x6b, 0x7d)))
    }
  ),
  private = list(
    #  Reads an AttachMenuPeerTypeSameBotPM object from a BinaryReader.
    from_reader = function(reader) {
      return(AttachMenuPeerTypeSameBotPM$new())
    }
  )
)

#  @title Authorization
#  @description Telegram API type Authorization
#  @export
#  @noRd
#  @noRd
Authorization <- R6::R6Class(
  "Authorization",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xad01d61d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc913c01a,

    #  @field hash Field.
    hash = NULL,
    #  @field device_model Field.
    device_model = NULL,
    #  @field platform Field.
    platform = NULL,
    #  @field system_version Field.
    system_version = NULL,
    #  @field api_id Field.
    api_id = NULL,
    #  @field app_name Field.
    app_name = NULL,
    #  @field app_version Field.
    app_version = NULL,
    #  @field date_created Field.
    date_created = NULL,
    #  @field date_active Field.
    date_active = NULL,
    #  @field ip Field.
    ip = NULL,
    #  @field country Field.
    country = NULL,
    #  @field region Field.
    region = NULL,
    #  @field current Field.
    current = NULL,
    #  @field official_app Field.
    official_app = NULL,
    #  @field password_pending Field.
    password_pending = NULL,
    #  @field encrypted_requests_disabled Field.
    encrypted_requests_disabled = NULL,
    #  @field call_requests_disabled Field.
    call_requests_disabled = NULL,
    #  @field unconfirmed Field.
    unconfirmed = NULL,

    #  @description
    #  Initializes the Authorization with the given parameters.
    #  @param hash An integer representing the hash value.
    #  @param device_model A string representing the device model.
    #  @param platform A string representing the platform.
    #  @param system_version A string representing the system version.
    #  @param api_id An integer representing the API ID.
    #  @param app_name A string representing the application name.
    #  @param app_version A string representing the application version.
    #  @param date_created Optional datetime representing when created.
    #  @param date_active Optional datetime representing when last active.
    #  @param ip A string representing the IP address.
    #  @param country A string representing the country.
    #  @param region A string representing the region.
    #  @param current Optional boolean indicating if current session.
    #  @param official_app Optional boolean indicating if official app.
    #  @param password_pending Optional boolean indicating if password pending.
    #  @param encrypted_requests_disabled Optional boolean indicating if encrypted requests disabled.
    #  @param call_requests_disabled Optional boolean indicating if call requests disabled.
    #  @param unconfirmed Optional boolean indicating if unconfirmed.
    initialize = function(hash, device_model, platform, system_version, api_id, app_name, app_version, date_created, date_active, ip, country, region, current = NULL, official_app = NULL, password_pending = NULL, encrypted_requests_disabled = NULL, call_requests_disabled = NULL, unconfirmed = NULL) {
      self$hash <- hash
      self$device_model <- device_model
      self$platform <- platform
      self$system_version <- system_version
      self$api_id <- api_id
      self$app_name <- app_name
      self$app_version <- app_version
      self$date_created <- date_created
      self$date_active <- date_active
      self$ip <- ip
      self$country <- country
      self$region <- region
      self$current <- current
      self$official_app <- official_app
      self$password_pending <- password_pending
      self$encrypted_requests_disabled <- encrypted_requests_disabled
      self$call_requests_disabled <- call_requests_disabled
      self$unconfirmed <- unconfirmed
    },

    #  @description
    #  Converts the Authorization object to a list (dictionary).
    #  @return A list representation of the Authorization object.
    to_dict = function() {
      return(list(
        `_` = "Authorization",
        hash = self$hash,
        device_model = self$device_model,
        platform = self$platform,
        system_version = self$system_version,
        api_id = self$api_id,
        app_name = self$app_name,
        app_version = self$app_version,
        date_created = self$date_created,
        date_active = self$date_active,
        ip = self$ip,
        country = self$country,
        region = self$region,
        current = self$current,
        official_app = self$official_app,
        password_pending = self$password_pending,
        encrypted_requests_disabled = self$encrypted_requests_disabled,
        call_requests_disabled = self$call_requests_disabled,
        unconfirmed = self$unconfirmed
      ))
    },

    #  @description
    #  Serializes the Authorization object to bytes.
    #  @return A raw vector representing the serialized bytes of the Authorization object.
    bytes = function() {
      # Calculate flags
      flags <- 0
      if (!is.null(self$current) && self$current) flags <- flags + 1
      if (!is.null(self$official_app) && self$official_app) flags <- flags + 2
      if (!is.null(self$password_pending) && self$password_pending) flags <- flags + 4
      if (!is.null(self$encrypted_requests_disabled) && self$encrypted_requests_disabled) flags <- flags + 8
      if (!is.null(self$call_requests_disabled) && self$call_requests_disabled) flags <- flags + 16
      if (!is.null(self$unconfirmed) && self$unconfirmed) flags <- flags + 32

      return(do.call(c, list(
        as.raw(c(0x1d, 0xd6, 0x01, 0xad)),
        writeBin(as.integer(flags), raw(), size = 4, endian = "little"),
        writeBin(as.numeric(self$hash), raw(), size = 8, endian = "little"),
        self$serializebytes(self$device_model),
        self$serializebytes(self$platform),
        self$serializebytes(self$system_version),
        writeBin(as.integer(self$api_id), raw(), size = 4, endian = "little"),
        self$serializebytes(self$app_name),
        self$serializebytes(self$app_version),
        self$serialize_datetime(self$date_created),
        self$serialize_datetime(self$date_active),
        self$serializebytes(self$ip),
        self$serializebytes(self$country),
        self$serializebytes(self$region)
      )))
    }
  ),
  private = list(
    #  Reads an Authorization object from a BinaryReader.
    from_reader = function(reader) {
      flags <- reader$read_int()

      current <- bitwAnd(flags, 1) != 0
      official_app <- bitwAnd(flags, 2) != 0
      password_pending <- bitwAnd(flags, 4) != 0
      encrypted_requests_disabled <- bitwAnd(flags, 8) != 0
      call_requests_disabled <- bitwAnd(flags, 16) != 0
      unconfirmed <- bitwAnd(flags, 32) != 0

      hash <- reader$read_long()
      device_model <- reader$tgread_string()
      platform <- reader$tgread_string()
      system_version <- reader$tgread_string()
      api_id <- reader$read_int()
      app_name <- reader$tgread_string()
      app_version <- reader$tgread_string()
      date_created <- reader$tgread_date()
      date_active <- reader$tgread_date()
      ip <- reader$tgread_string()
      country <- reader$tgread_string()
      region <- reader$tgread_string()

      return(Authorization$new(
        hash = hash,
        device_model = device_model,
        platform = platform,
        system_version = system_version,
        api_id = api_id,
        app_name = app_name,
        app_version = app_version,
        date_created = date_created,
        date_active = date_active,
        ip = ip,
        country = country,
        region = region,
        current = current,
        official_app = official_app,
        password_pending = password_pending,
        encrypted_requests_disabled = encrypted_requests_disabled,
        call_requests_disabled = call_requests_disabled,
        unconfirmed = unconfirmed
      ))
    }
  )
)

#  @title AutoDownloadSettings
#  @description Telegram API type AutoDownloadSettings
#  @export
#  @noRd
#  @noRd
AutoDownloadSettings <- R6::R6Class(
  "AutoDownloadSettings",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbaa57628,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x512819c7,

    #  @field photo_size_max Field.
    photo_size_max = NULL,
    #  @field video_size_max Field.
    video_size_max = NULL,
    #  @field file_size_max Field.
    file_size_max = NULL,
    #  @field video_upload_maxbitrate Field.
    video_upload_maxbitrate = NULL,
    #  @field small_queue_active_operations_max Field.
    small_queue_active_operations_max = NULL,
    #  @field large_queue_active_operations_max Field.
    large_queue_active_operations_max = NULL,
    #  @field disabled Field.
    disabled = NULL,
    #  @field video_preload_large Field.
    video_preload_large = NULL,
    #  @field audio_preload_next Field.
    audio_preload_next = NULL,
    #  @field phonecalls_lessdata Field.
    phonecalls_lessdata = NULL,
    #  @field stories_preload Field.
    stories_preload = NULL,

    #  @description
    #  Initializes the AutoDownloadSettings with the given parameters.
    #  @param photo_size_max An integer representing the maximum photo size.
    #  @param video_size_max An integer representing the maximum video size.
    #  @param file_size_max An integer representing the maximum file size.
    #  @param video_upload_maxbitrate An integer representing the maximum video upload bitrate.
    #  @param small_queue_active_operations_max An integer representing the maximum small queue active operations.
    #  @param large_queue_active_operations_max An integer representing the maximum large queue active operations.
    #  @param disabled Optional boolean indicating if disabled.
    #  @param video_preload_large Optional boolean indicating if video preload large.
    #  @param audio_preload_next Optional boolean indicating if audio preload next.
    #  @param phonecalls_lessdata Optional boolean indicating if phonecalls use less data.
    #  @param stories_preload Optional boolean indicating if stories preload.
    initialize = function(photo_size_max, video_size_max, file_size_max, video_upload_maxbitrate, small_queue_active_operations_max, large_queue_active_operations_max, disabled = NULL, video_preload_large = NULL, audio_preload_next = NULL, phonecalls_lessdata = NULL, stories_preload = NULL) {
      self$photo_size_max <- photo_size_max
      self$video_size_max <- video_size_max
      self$file_size_max <- file_size_max
      self$video_upload_maxbitrate <- video_upload_maxbitrate
      self$small_queue_active_operations_max <- small_queue_active_operations_max
      self$large_queue_active_operations_max <- large_queue_active_operations_max
      self$disabled <- disabled
      self$video_preload_large <- video_preload_large
      self$audio_preload_next <- audio_preload_next
      self$phonecalls_lessdata <- phonecalls_lessdata
      self$stories_preload <- stories_preload
    },

    #  @description
    #  Converts the AutoDownloadSettings object to a list (dictionary).
    #  @return A list representation of the AutoDownloadSettings object.
    to_dict = function() {
      return(list(
        `_` = "AutoDownloadSettings",
        photo_size_max = self$photo_size_max,
        video_size_max = self$video_size_max,
        file_size_max = self$file_size_max,
        video_upload_maxbitrate = self$video_upload_maxbitrate,
        small_queue_active_operations_max = self$small_queue_active_operations_max,
        large_queue_active_operations_max = self$large_queue_active_operations_max,
        disabled = self$disabled,
        video_preload_large = self$video_preload_large,
        audio_preload_next = self$audio_preload_next,
        phonecalls_lessdata = self$phonecalls_lessdata,
        stories_preload = self$stories_preload
      ))
    },

    #  @description
    #  Serializes the AutoDownloadSettings object to bytes.
    #  @return A raw vector representing the serialized bytes of the AutoDownloadSettings object.
    bytes = function() {
      # Calculate flags
      flags <- 0
      if (!is.null(self$disabled) && self$disabled) flags <- flags + 1
      if (!is.null(self$video_preload_large) && self$video_preload_large) flags <- flags + 2
      if (!is.null(self$audio_preload_next) && self$audio_preload_next) flags <- flags + 4
      if (!is.null(self$phonecalls_lessdata) && self$phonecalls_lessdata) flags <- flags + 8
      if (!is.null(self$stories_preload) && self$stories_preload) flags <- flags + 16

      return(do.call(c, list(
        as.raw(c(0x28, 0x76, 0xa5, 0xba)),
        writeBin(as.integer(flags), raw(), size = 4, endian = "little"),
        writeBin(as.integer(self$photo_size_max), raw(), size = 4, endian = "little"),
        writeBin(as.numeric(self$video_size_max), raw(), size = 8, endian = "little"),
        writeBin(as.numeric(self$file_size_max), raw(), size = 8, endian = "little"),
        writeBin(as.integer(self$video_upload_maxbitrate), raw(), size = 4, endian = "little"),
        writeBin(as.integer(self$small_queue_active_operations_max), raw(), size = 4, endian = "little"),
        writeBin(as.integer(self$large_queue_active_operations_max), raw(), size = 4, endian = "little")
      )))
    }
  ),
  private = list(
    #  Reads an AutoDownloadSettings object from a BinaryReader.
    from_reader = function(reader) {
      flags <- reader$read_int()

      disabled <- bitwAnd(flags, 1) != 0
      video_preload_large <- bitwAnd(flags, 2) != 0
      audio_preload_next <- bitwAnd(flags, 4) != 0
      phonecalls_lessdata <- bitwAnd(flags, 8) != 0
      stories_preload <- bitwAnd(flags, 16) != 0

      photo_size_max <- reader$read_int()
      video_size_max <- reader$read_long()
      file_size_max <- reader$read_long()
      video_upload_maxbitrate <- reader$read_int()
      small_queue_active_operations_max <- reader$read_int()
      large_queue_active_operations_max <- reader$read_int()

      return(AutoDownloadSettings$new(
        photo_size_max = photo_size_max,
        video_size_max = video_size_max,
        file_size_max = file_size_max,
        video_upload_maxbitrate = video_upload_maxbitrate,
        small_queue_active_operations_max = small_queue_active_operations_max,
        large_queue_active_operations_max = large_queue_active_operations_max,
        disabled = disabled,
        video_preload_large = video_preload_large,
        audio_preload_next = audio_preload_next,
        phonecalls_lessdata = phonecalls_lessdata,
        stories_preload = stories_preload
      ))
    }
  )
)

#  @title AutoSaveException
#  @description Telegram API type AutoSaveException
#  @export
#  @noRd
#  @noRd
AutoSaveException <- R6::R6Class(
  "AutoSaveException",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x81602d47,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xdd868129,

    #  @field peer Field.
    peer = NULL,
    #  @field settings Field.
    settings = NULL,

    #  @description
    #  Initializes the AutoSaveException with the given parameters.
    #  @param peer A TypePeer object representing the peer.
    #  @param settings A TypeAutoSaveSettings object representing the settings.
    initialize = function(peer, settings) {
      self$peer <- peer
      self$settings <- settings
    },

    #  @description
    #  Converts the AutoSaveException object to a list (dictionary).
    #  @return A list representation of the AutoSaveException object.
    to_dict = function() {
      return(list(
        `_` = "AutoSaveException",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        settings = if (inherits(self$settings, "TLObject")) self$settings$to_dict() else self$settings
      ))
    },

    #  @description
    #  Serializes the AutoSaveException object to bytes.
    #  @return A raw vector representing the serialized bytes of the AutoSaveException object.
    bytes = function() {
      return(do.call(c, list(
        as.raw(c(0x47, 0x2d, 0x60, 0x81)),
        self$peer$bytes(),
        self$settings$bytes()
      )))
    }
  ),
  private = list(
    #  Reads an AutoSaveException object from a BinaryReader.
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      settings <- reader$tgread_object()
      return(AutoSaveException$new(peer = peer, settings = settings))
    }
  )
)

#  @title AutoSaveSettings
#  @description Telegram API type AutoSaveSettings
#  @export
#  @noRd
#  @noRd
AutoSaveSettings <- R6::R6Class(
  "AutoSaveSettings",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc84834ce,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xcd3b96e6,

    #  @field photos Field.
    photos = NULL,
    #  @field videos Field.
    videos = NULL,
    #  @field video_max_size Field.
    video_max_size = NULL,

    #  @description
    #  Initializes the AutoSaveSettings with the given parameters.
    #  @param photos Optional boolean indicating if photos should be auto-saved.
    #  @param videos Optional boolean indicating if videos should be auto-saved.
    #  @param video_max_size Optional integer representing the maximum video size.
    initialize = function(photos = NULL, videos = NULL, video_max_size = NULL) {
      self$photos <- photos
      self$videos <- videos
      self$video_max_size <- video_max_size
    },

    #  @description
    #  Converts the AutoSaveSettings object to a list (dictionary).
    #  @return A list representation of the AutoSaveSettings object.
    to_dict = function() {
      return(list(
        `_` = "AutoSaveSettings",
        photos = self$photos,
        videos = self$videos,
        video_max_size = self$video_max_size
      ))
    },

    #  @description
    #  Serializes the AutoSaveSettings object to bytes.
    #  @return A raw vector representing the serialized bytes of the AutoSaveSettings object.
    bytes = function() {
      # Calculate flags
      flags <- 0
      if (!is.null(self$photos) && self$photos) flags <- flags + 1
      if (!is.null(self$videos) && self$videos) flags <- flags + 2
      if (!is.null(self$video_max_size)) flags <- flags + 4

      result <- list(
        as.raw(c(0xce, 0x34, 0x48, 0xc8)),
        writeBin(as.integer(flags), raw(), size = 4, endian = "little")
      )

      if (!is.null(self$video_max_size)) {
        result <- append(result, list(
          writeBin(as.numeric(self$video_max_size), raw(), size = 8, endian = "little")
        ))
      }

      return(do.call(c, result))
    }
  ),
  private = list(
    #  Reads an AutoSaveSettings object from a BinaryReader.
    from_reader = function(reader) {
      flags <- reader$read_int()

      photos <- bitwAnd(flags, 1) != 0
      videos <- bitwAnd(flags, 2) != 0

      video_max_size <- NULL
      if (bitwAnd(flags, 4) != 0) {
        video_max_size <- reader$read_long()
      }

      return(AutoSaveSettings$new(
        photos = photos,
        videos = videos,
        video_max_size = video_max_size
      ))
    }
  )
)

#  @title AvailableEffect
#  @description Telegram API type AvailableEffect
#  @export
#  @noRd
#  @noRd
AvailableEffect <- R6::R6Class(
  "AvailableEffect",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x93c3e27e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x985a2f81,

    #  @field id Field.
    id = NULL,
    #  @field emoticon Field.
    emoticon = NULL,
    #  @field effect_sticker_id Field.
    effect_sticker_id = NULL,
    #  @field premium_required Field.
    premium_required = NULL,
    #  @field static_icon_id Field.
    static_icon_id = NULL,
    #  @field effect_animation_id Field.
    effect_animation_id = NULL,

    #  @description
    #  Initializes the AvailableEffect with the given parameters.
    #  @param id An integer representing the effect ID.
    #  @param emoticon A string representing the emoticon.
    #  @param effect_sticker_id An integer representing the effect sticker ID.
    #  @param premium_required Optional boolean indicating if premium is required.
    #  @param static_icon_id Optional integer representing the static icon ID.
    #  @param effect_animation_id Optional integer representing the effect animation ID.
    initialize = function(id, emoticon, effect_sticker_id, premium_required = NULL, static_icon_id = NULL, effect_animation_id = NULL) {
      self$id <- id
      self$emoticon <- emoticon
      self$effect_sticker_id <- effect_sticker_id
      self$premium_required <- premium_required
      self$static_icon_id <- static_icon_id
      self$effect_animation_id <- effect_animation_id
    },

    #  @description
    #  Converts the AvailableEffect object to a list (dictionary).
    #  @return A list representation of the AvailableEffect object.
    to_dict = function() {
      return(list(
        `_` = "AvailableEffect",
        id = self$id,
        emoticon = self$emoticon,
        effect_sticker_id = self$effect_sticker_id,
        premium_required = self$premium_required,
        static_icon_id = self$static_icon_id,
        effect_animation_id = self$effect_animation_id
      ))
    },

    #  @description
    #  Serializes the AvailableEffect object to bytes.
    #  @return A raw vector representing the serialized bytes of the AvailableEffect object.
    bytes = function() {
      # Calculate flags
      flags <- 0
      if (!is.null(self$premium_required) && self$premium_required) flags <- flags + 4
      if (!is.null(self$static_icon_id)) flags <- flags + 1
      if (!is.null(self$effect_animation_id)) flags <- flags + 2

      result <- list(
        as.raw(c(0x7e, 0xe2, 0xc3, 0x93)),
        writeBin(as.integer(flags), raw(), size = 4, endian = "little"),
        writeBin(as.numeric(self$id), raw(), size = 8, endian = "little"),
        self$serializebytes(self$emoticon)
      )

      if (!is.null(self$static_icon_id)) {
        result <- append(result, list(
          writeBin(as.numeric(self$static_icon_id), raw(), size = 8, endian = "little")
        ))
      }

      result <- append(result, list(
        writeBin(as.numeric(self$effect_sticker_id), raw(), size = 8, endian = "little")
      ))

      if (!is.null(self$effect_animation_id)) {
        result <- append(result, list(
          writeBin(as.numeric(self$effect_animation_id), raw(), size = 8, endian = "little")
        ))
      }

      return(do.call(c, result))
    }
  ),
  private = list(
    #  Reads an AvailableEffect object from a BinaryReader.
    from_reader = function(reader) {
      flags <- reader$read_int()

      premium_required <- bitwAnd(flags, 4) != 0
      id <- reader$read_long()
      emoticon <- reader$tgread_string()

      static_icon_id <- NULL
      if (bitwAnd(flags, 1) != 0) {
        static_icon_id <- reader$read_long()
      }

      effect_sticker_id <- reader$read_long()

      effect_animation_id <- NULL
      if (bitwAnd(flags, 2) != 0) {
        effect_animation_id <- reader$read_long()
      }

      return(AvailableEffect$new(
        id = id,
        emoticon = emoticon,
        effect_sticker_id = effect_sticker_id,
        premium_required = premium_required,
        static_icon_id = static_icon_id,
        effect_animation_id = effect_animation_id
      ))
    }
  )
)

#  @title AvailableReaction
#  @description Telegram API type AvailableReaction
#  @export
#  @noRd
#  @noRd
AvailableReaction <- R6::R6Class(
  "AvailableReaction",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc077ec01,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8c1c9d73,

    #  @field reaction Field.
    reaction = NULL,
    #  @field title Field.
    title = NULL,
    #  @field static_icon Field.
    static_icon = NULL,
    #  @field appear_animation Field.
    appear_animation = NULL,
    #  @field select_animation Field.
    select_animation = NULL,
    #  @field activate_animation Field.
    activate_animation = NULL,
    #  @field effect_animation Field.
    effect_animation = NULL,
    #  @field inactive Field.
    inactive = NULL,
    #  @field premium Field.
    premium = NULL,
    #  @field around_animation Field.
    around_animation = NULL,
    #  @field center_icon Field.
    center_icon = NULL,

    #  @description
    #  Initializes the AvailableReaction with the given parameters.
    #  @param reaction A string representing the reaction.
    #  @param title A string representing the title.
    #  @param static_icon A TLObject representing the static icon.
    #  @param appear_animation A TLObject representing the appear animation.
    #  @param select_animation A TLObject representing the select animation.
    #  @param activate_animation A TLObject representing the activate animation.
    #  @param effect_animation A TLObject representing the effect animation.
    #  @param inactive A logical indicating if inactive. Optional.
    #  @param premium A logical indicating if premium. Optional.
    #  @param around_animation A TLObject representing the around animation. Optional.
    #  @param center_icon A TLObject representing the center icon. Optional.
    initialize = function(reaction, title, static_icon, appear_animation, select_animation,
                          activate_animation, effect_animation, inactive = NULL, premium = NULL,
                          around_animation = NULL, center_icon = NULL) {
      self$reaction <- reaction
      self$title <- title
      self$static_icon <- static_icon
      self$appear_animation <- appear_animation
      self$select_animation <- select_animation
      self$activate_animation <- activate_animation
      self$effect_animation <- effect_animation
      self$inactive <- inactive
      self$premium <- premium
      self$around_animation <- around_animation
      self$center_icon <- center_icon
    },

    #  @description
    #  Converts the AvailableReaction object to a list (dictionary).
    #  @return A list representation of the AvailableReaction object.
    to_dict = function() {
      return(list(
        `_` = "AvailableReaction",
        reaction = self$reaction,
        title = self$title,
        static_icon = if (inherits(self$static_icon, "TLObject")) self$static_icon$to_dict() else self$static_icon,
        appear_animation = if (inherits(self$appear_animation, "TLObject")) self$appear_animation$to_dict() else self$appear_animation,
        select_animation = if (inherits(self$select_animation, "TLObject")) self$select_animation$to_dict() else self$select_animation,
        activate_animation = if (inherits(self$activate_animation, "TLObject")) self$activate_animation$to_dict() else self$activate_animation,
        effect_animation = if (inherits(self$effect_animation, "TLObject")) self$effect_animation$to_dict() else self$effect_animation,
        inactive = self$inactive,
        premium = self$premium,
        around_animation = if (inherits(self$around_animation, "TLObject")) self$around_animation$to_dict() else self$around_animation,
        center_icon = if (inherits(self$center_icon, "TLObject")) self$center_icon$to_dict() else self$center_icon
      ))
    },

    #  @description
    #  Serializes the AvailableReaction object to bytes.
    #  @return A raw vector representing the serialized bytes of the AvailableReaction object.
    bytes = function() {
      # Validation similar to the assertion in Python
      if (!(((!is.null(self$around_animation) && !identical(self$around_animation, FALSE)) &&
        (!is.null(self$center_icon) && !identical(self$center_icon, FALSE))) ||
        ((is.null(self$around_animation) || identical(self$around_animation, FALSE)) &&
          (is.null(self$center_icon) || identical(self$center_icon, FALSE))))) {
        stop("around_animation, center_icon parameters must all be falsy (like NULL) or all be truthy")
      }

      flags <- 0
      if (!is.null(self$inactive) && !identical(self$inactive, FALSE)) flags <- flags + 1 # 2^0
      if (!is.null(self$premium) && !identical(self$premium, FALSE)) flags <- flags + 4 # 2^2
      if (!is.null(self$around_animation) && !identical(self$around_animation, FALSE)) flags <- flags + 2 # 2^1
      if (!is.null(self$center_icon) && !identical(self$center_icon, FALSE)) flags <- flags + 2 # 2^1

      result <- list(
        as.raw(c(0x01, 0xec, 0x77, 0xc0)),
        writeBin(as.integer(flags), raw(), size = 4, endian = "little"),
        self$serializebytes(self$reaction),
        self$serializebytes(self$title),
        self$static_icon$`bytes`(),
        self$appear_animation$`bytes`(),
        self$select_animation$`bytes`(),
        self$activate_animation$`bytes`(),
        self$effect_animation$`bytes`()
      )

      if (!is.null(self$around_animation) && !identical(self$around_animation, FALSE)) {
        result <- append(result, list(self$around_animation$`bytes`()))
      }
      if (!is.null(self$center_icon) && !identical(self$center_icon, FALSE)) {
        result <- append(result, list(self$center_icon$`bytes`()))
      }

      return(do.call(c, result))
    }
  ),
  private = list(
    #  Reads an AvailableReaction object from a BinaryReader.
    from_reader = function(reader) {
      flags <- reader$read_int()

      inactive <- bitwAnd(flags, 1) != 0
      premium <- bitwAnd(flags, 4) != 0
      reaction <- reader$tgread_string()
      title <- reader$tgread_string()
      static_icon <- reader$tgread_object()
      appear_animation <- reader$tgread_object()
      select_animation <- reader$tgread_object()
      activate_animation <- reader$tgread_object()
      effect_animation <- reader$tgread_object()

      around_animation <- NULL
      if (bitwAnd(flags, 2) != 0) {
        around_animation <- reader$tgread_object()
      }

      center_icon <- NULL
      if (bitwAnd(flags, 2) != 0) {
        center_icon <- reader$tgread_object()
      }

      return(AvailableReaction$new(
        reaction = reaction,
        title = title,
        static_icon = static_icon,
        appear_animation = appear_animation,
        select_animation = select_animation,
        activate_animation = activate_animation,
        effect_animation = effect_animation,
        inactive = inactive,
        premium = premium,
        around_animation = around_animation,
        center_icon = center_icon
      ))
    }
  )
)

#  @title BadMsgNotification
#  @description Telegram API type BadMsgNotification
#  @export
#  @noRd
#  @noRd
BadMsgNotification <- R6::R6Class(
  "BadMsgNotification",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa7eff811,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xcebaa157,

    #  @field bad_msg_id Field.
    bad_msg_id = NULL,
    #  @field bad_msg_seqno Field.
    bad_msg_seqno = NULL,
    #  @field error_code Field.
    error_code = NULL,

    #  @description
    #  Initializes the BadMsgNotification with the given parameters.
    #  @param bad_msg_id An integer representing the bad message ID.
    #  @param bad_msg_seqno An integer representing the bad message sequence number.
    #  @param error_code An integer representing the error code.
    initialize = function(bad_msg_id, bad_msg_seqno, error_code) {
      self$bad_msg_id <- bad_msg_id
      self$bad_msg_seqno <- bad_msg_seqno
      self$error_code <- error_code
    },

    #  @description
    #  Converts the BadMsgNotification object to a list (dictionary).
    #  @return A list representation of the BadMsgNotification object.
    to_dict = function() {
      return(list(
        `_` = "BadMsgNotification",
        bad_msg_id = self$bad_msg_id,
        bad_msg_seqno = self$bad_msg_seqno,
        error_code = self$error_code
      ))
    },

    #  @description
    #  Serializes the BadMsgNotification object to bytes.
    #  @return A raw vector representing the serialized bytes of the BadMsgNotification object.
    bytes = function() {
      return(do.call(c, list(
        as.raw(c(0x11, 0xf8, 0xef, 0xa7)),
        writeBin(as.numeric(self$bad_msg_id), raw(), size = 8, endian = "little"),
        writeBin(as.integer(self$bad_msg_seqno), raw(), size = 4, endian = "little"),
        writeBin(as.integer(self$error_code), raw(), size = 4, endian = "little")
      )))
    }
  ),
  private = list(
    #  Reads a BadMsgNotification object from a BinaryReader.
    from_reader = function(reader) {
      bad_msg_id <- reader$read_long()
      bad_msg_seqno <- reader$read_int()
      error_code <- reader$read_int()
      return(BadMsgNotification$new(
        bad_msg_id = bad_msg_id,
        bad_msg_seqno = bad_msg_seqno,
        error_code = error_code
      ))
    }
  )
)

#  @title BadServerSalt
#  @description Telegram API type BadServerSalt
#  @export
#  @noRd
#  @noRd
BadServerSalt <- R6::R6Class(
  "BadServerSalt",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xedab447b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xcebaa157,

    #  @field bad_msg_id Field.
    bad_msg_id = NULL,
    #  @field bad_msg_seqno Field.
    bad_msg_seqno = NULL,
    #  @field error_code Field.
    error_code = NULL,
    #  @field new_server_salt Field.
    new_server_salt = NULL,

    #  @description
    #  Initializes the BadServerSalt with the given parameters.
    #  @param bad_msg_id An integer representing the bad message ID.
    #  @param bad_msg_seqno An integer representing the bad message sequence number.
    #  @param error_code An integer representing the error code.
    #  @param new_server_salt An integer representing the new server salt.
    initialize = function(bad_msg_id, bad_msg_seqno, error_code, new_server_salt) {
      self$bad_msg_id <- bad_msg_id
      self$bad_msg_seqno <- bad_msg_seqno
      self$error_code <- error_code
      self$new_server_salt <- new_server_salt
    },

    #  @description
    #  Converts the BadServerSalt object to a list (dictionary).
    #  @return A list representation of the BadServerSalt object.
    to_dict = function() {
      return(list(
        `_` = "BadServerSalt",
        bad_msg_id = self$bad_msg_id,
        bad_msg_seqno = self$bad_msg_seqno,
        error_code = self$error_code,
        new_server_salt = self$new_server_salt
      ))
    },

    #  @description
    #  Serializes the BadServerSalt object to bytes.
    #  @return A raw vector representing the serialized bytes of the BadServerSalt object.
    bytes = function() {
      return(do.call(c, list(
        as.raw(c(0x7b, 0x44, 0xab, 0xed)),
        writeBin(as.numeric(self$bad_msg_id), raw(), size = 8, endian = "little"),
        writeBin(as.integer(self$bad_msg_seqno), raw(), size = 4, endian = "little"),
        writeBin(as.integer(self$error_code), raw(), size = 4, endian = "little"),
        writeBin(as.numeric(self$new_server_salt), raw(), size = 8, endian = "little")
      )))
    }
  ),
  private = list(
    #  Reads a BadServerSalt object from a BinaryReader.
    from_reader = function(reader) {
      bad_msg_id <- reader$read_long()
      bad_msg_seqno <- reader$read_int()
      error_code <- reader$read_int()
      new_server_salt <- reader$read_long()
      return(BadServerSalt$new(
        bad_msg_id = bad_msg_id,
        bad_msg_seqno = bad_msg_seqno,
        error_code = error_code,
        new_server_salt = new_server_salt
      ))
    }
  )
)

#  @title BankCardOpenUrl
#  @description Telegram API type BankCardOpenUrl
#  @export
#  @noRd
#  @noRd
BankCardOpenUrl <- R6::R6Class(
  "BankCardOpenUrl",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf568028a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf2e2460e,

    #  @field url Field.
    url = NULL,
    #  @field name Field.
    name = NULL,

    #  @description
    #  Initializes the BankCardOpenUrl with the given parameters.
    #  @param url A string representing the URL.
    #  @param name A string representing the name.
    initialize = function(url, name) {
      self$url <- url
      self$name <- name
    },

    #  @description
    #  Converts the BankCardOpenUrl object to a list (dictionary).
    #  @return A list representation of the BankCardOpenUrl object.
    to_dict = function() {
      return(list(
        `_` = "BankCardOpenUrl",
        url = self$url,
        name = self$name
      ))
    },

    #  @description
    #  Serializes the BankCardOpenUrl object to bytes.
    #  @return A raw vector representing the serialized bytes of the BankCardOpenUrl object.
    bytes = function() {
      return(do.call(c, list(
        as.raw(c(0x8a, 0x02, 0x68, 0xf5)),
        self$serializebytes(self$url),
        self$serializebytes(self$name)
      )))
    }
  ),
  private = list(
    #  Reads a BankCardOpenUrl object from a BinaryReader.
    from_reader = function(reader) {
      url <- reader$tgread_string()
      name <- reader$tgread_string()
      return(BankCardOpenUrl$new(url = url, name = name))
    }
  )
)

#  @title BaseThemeArctic
#  @description Telegram API type BaseThemeArctic
#  @export
#  @noRd
#  @noRd
BaseThemeArctic <- R6::R6Class(
  "BaseThemeArctic",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5b11125a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1f03f444,

    #  @description
    #  Initializes the BaseThemeArctic with no parameters.
    initialize = function() {
      # No parameters to initialize
    },

    #  @description
    #  Converts the BaseThemeArctic object to a list (dictionary).
    #  @return A list representation of the BaseThemeArctic object.
    to_dict = function() {
      return(list(`_` = "BaseThemeArctic"))
    },

    #  @description
    #  Serializes the BaseThemeArctic object to bytes.
    #  @return A raw vector representing the serialized bytes of the BaseThemeArctic object.
    bytes = function() {
      return(as.raw(c(0x5a, 0x12, 0x11, 0x5b)))
    }
  ),
  private = list(
    #  Reads a BaseThemeArctic object from a BinaryReader.
    from_reader = function(reader) {
      return(BaseThemeArctic$new())
    }
  )
)

#  @title BaseThemeClassic
#  @description Telegram API type BaseThemeClassic
#  @export
#  @noRd
#  @noRd
BaseThemeClassic <- R6::R6Class(
  "BaseThemeClassic",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc3a12462,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1f03f444,

    #  @description
    #  Initializes the BaseThemeClassic with no parameters.
    initialize = function() {
      # No parameters to initialize
    },

    #  @description
    #  Converts the BaseThemeClassic object to a list (dictionary).
    #  @return A list representation of the BaseThemeClassic object.
    to_dict = function() {
      return(list(`_` = "BaseThemeClassic"))
    },

    #  @description
    #  Serializes the BaseThemeClassic object to bytes.
    #  @return A raw vector representing the serialized bytes of the BaseThemeClassic object.
    bytes = function() {
      return(as.raw(c(0x62, 0x24, 0xa1, 0xc3)))
    }
  ),
  private = list(
    #  Reads a BaseThemeClassic object from a BinaryReader.
    from_reader = function(reader) {
      return(BaseThemeClassic$new())
    }
  )
)

#  @title BaseThemeDay
#  @description Telegram API type BaseThemeDay
#  @export
#  @noRd
#  @noRd
BaseThemeDay <- R6::R6Class(
  "BaseThemeDay",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xfbd81688,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1f03f444,

    #  @description
    #  Initializes the BaseThemeDay with no parameters.
    initialize = function() {
      # No parameters to initialize
    },

    #  @description
    #  Converts the BaseThemeDay object to a list (dictionary).
    #  @return A list representation of the BaseThemeDay object.
    to_dict = function() {
      return(list(`_` = "BaseThemeDay"))
    },

    #  @description
    #  Serializes the BaseThemeDay object to bytes.
    #  @return A raw vector representing the serialized bytes of the BaseThemeDay object.
    bytes = function() {
      return(as.raw(c(0x88, 0x16, 0xd8, 0xfb)))
    }
  ),
  private = list(
    #  Reads a BaseThemeDay object from a BinaryReader.
    from_reader = function(reader) {
      return(BaseThemeDay$new())
    }
  )
)

#  @title BaseThemeNight
#  @description Telegram API type BaseThemeNight
#  @export
#  @noRd
#  @noRd
BaseThemeNight <- R6::R6Class(
  "BaseThemeNight",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb7b31ea8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1f03f444,

    #  @description
    #  Initializes the BaseThemeNight with no parameters.
    initialize = function() {
      # No parameters to initialize
    },

    #  @description
    #  Converts the BaseThemeNight object to a list (dictionary).
    #  @return A list representation of the BaseThemeNight object.
    to_dict = function() {
      return(list(`_` = "BaseThemeNight"))
    },

    #  @description
    #  Serializes the BaseThemeNight object to bytes.
    #  @return A raw vector representing the serialized bytes of the BaseThemeNight object.
    bytes = function() {
      return(as.raw(c(0xa8, 0x1e, 0xb3, 0xb7)))
    }
  ),
  private = list(
    #  Reads a BaseThemeNight object from a BinaryReader.
    from_reader = function(reader) {
      return(BaseThemeNight$new())
    }
  )
)

#  @title BaseThemeTinted
#  @description Telegram API type BaseThemeTinted
#  @export
#  @noRd
#  @noRd
BaseThemeTinted <- R6::R6Class(
  "BaseThemeTinted",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x6d5f77ee,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1f03f444,

    #  @description
    #  Initializes the BaseThemeTinted with no parameters.
    initialize = function() {
      # No parameters to initialize
    },

    #  @description
    #  Converts the BaseThemeTinted object to a list (dictionary).
    #  @return A list representation of the BaseThemeTinted object.
    to_dict = function() {
      return(list(`_` = "BaseThemeTinted"))
    },

    #  @description
    #  Serializes the BaseThemeTinted object to bytes.
    #  @return A raw vector representing the serialized bytes of the BaseThemeTinted object.
    bytes = function() {
      return(as.raw(c(0xee, 0x77, 0x5f, 0x6d)))
    }
  ),
  private = list(
    #  Reads a BaseThemeTinted object from a BinaryReader.
    from_reader = function(reader) {
      return(BaseThemeTinted$new())
    }
  )
)

#  @title BindAuthKeyInner
#  @description Telegram API type BindAuthKeyInner
#  @export
#  @noRd
#  @noRd
BindAuthKeyInner <- R6::R6Class(
  "BindAuthKeyInner",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x75a3f765,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x2f099171,

    #  @field nonce Field.
    nonce = NULL,
    #  @field temp_auth_key_id Field.
    temp_auth_key_id = NULL,
    #  @field perm_auth_key_id Field.
    perm_auth_key_id = NULL,
    #  @field temp_session_id Field.
    temp_session_id = NULL,
    #  @field expires_at Field.
    expires_at = NULL,

    #  @description
    #  Initializes the BindAuthKeyInner with the given parameters.
    #  @param nonce An integer representing the nonce.
    #  @param temp_auth_key_id An integer representing the temporary auth key ID.
    #  @param perm_auth_key_id An integer representing the permanent auth key ID.
    #  @param temp_session_id An integer representing the temporary session ID.
    #  @param expires_at A datetime object representing when this expires. Optional.
    initialize = function(nonce, temp_auth_key_id, perm_auth_key_id, temp_session_id, expires_at = NULL) {
      self$nonce <- nonce
      self$temp_auth_key_id <- temp_auth_key_id
      self$perm_auth_key_id <- perm_auth_key_id
      self$temp_session_id <- temp_session_id
      self$expires_at <- expires_at
    },

    #  @description
    #  Converts the BindAuthKeyInner object to a list (dictionary).
    #  @return A list representation of the BindAuthKeyInner object.
    to_dict = function() {
      return(list(
        `_` = "BindAuthKeyInner",
        nonce = self$nonce,
        temp_auth_key_id = self$temp_auth_key_id,
        perm_auth_key_id = self$perm_auth_key_id,
        temp_session_id = self$temp_session_id,
        expires_at = self$expires_at
      ))
    },

    #  @description
    #  Serializes the BindAuthKeyInner object to bytes.
    #  @return A raw vector representing the serialized bytes of the BindAuthKeyInner object.
    bytes = function() {
      return(do.call(c, list(
        as.raw(c(0x65, 0xf7, 0xa3, 0x75)),
        writeBin(as.numeric(self$nonce), raw(), size = 8, endian = "little"),
        writeBin(as.numeric(self$temp_auth_key_id), raw(), size = 8, endian = "little"),
        writeBin(as.numeric(self$perm_auth_key_id), raw(), size = 8, endian = "little"),
        writeBin(as.numeric(self$temp_session_id), raw(), size = 8, endian = "little"),
        self$serialize_datetime(self$expires_at)
      )))
    }
  ),
  private = list(
    #  Reads a BindAuthKeyInner object from a BinaryReader.
    from_reader = function(reader) {
      nonce <- reader$read_long()
      temp_auth_key_id <- reader$read_long()
      perm_auth_key_id <- reader$read_long()
      temp_session_id <- reader$read_long()
      expires_at <- reader$tgread_date()
      return(BindAuthKeyInner$new(
        nonce = nonce,
        temp_auth_key_id = temp_auth_key_id,
        perm_auth_key_id = perm_auth_key_id,
        temp_session_id = temp_session_id,
        expires_at = expires_at
      ))
    }
  )
)

#  @title Birthday
#  @description Telegram API type Birthday
#  @export
#  @noRd
#  @noRd
Birthday <- R6::R6Class(
  "Birthday",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x6c8e1e06,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbe7fd664,

    #  @field day Field.
    day = NULL,
    #  @field month Field.
    month = NULL,
    #  @field year Field.
    year = NULL,

    #  @description
    #  Initializes the Birthday with the given parameters.
    #  @param day An integer representing the day.
    #  @param month An integer representing the month.
    #  @param year An integer representing the year. Optional.
    initialize = function(day, month, year = NULL) {
      self$day <- day
      self$month <- month
      self$year <- year
    },

    #  @description
    #  Converts the Birthday object to a list (dictionary).
    #  @return A list representation of the Birthday object.
    to_dict = function() {
      return(list(
        `_` = "Birthday",
        day = self$day,
        month = self$month,
        year = self$year
      ))
    },

    #  @description
    #  Serializes the Birthday object to bytes.
    #  @return A raw vector representing the serialized bytes of the Birthday object.
    bytes = function() {
      flags <- 0
      if (!is.null(self$year)) flags <- flags + 1 # 2^0

      return(do.call(c, list(
        as.raw(c(0x06, 0x1e, 0x8e, 0x6c)),
        writeBin(as.integer(flags), raw(), size = 4, endian = "little"),
        writeBin(as.integer(self$day), raw(), size = 4, endian = "little"),
        writeBin(as.integer(self$month), raw(), size = 4, endian = "little"),
        if (!is.null(self$year)) writeBin(as.integer(self$year), raw(), size = 4, endian = "little") else raw()
      )))
    }
  ),
  private = list(
    #  Reads a Birthday object from a BinaryReader.
    from_reader = function(reader) {
      flags <- reader$read_int()

      day <- reader$read_int()
      month <- reader$read_int()
      year <- NULL
      if (bitwAnd(flags, 1) != 0) {
        year <- reader$read_int()
      }

      return(Birthday$new(day = day, month = month, year = year))
    }
  )
)

#  @title Boost
#  @description Telegram API type Boost
#  @export
#  @noRd
#  @noRd
Boost <- R6::R6Class(
  "Boost",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4b3e14d6,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x97a5086c,

    #  @field id Field.
    id = NULL,
    #  @field date Field.
    date = NULL,
    #  @field expires Field.
    expires = NULL,
    #  @field gift Field.
    gift = NULL,
    #  @field giveaway Field.
    giveaway = NULL,
    #  @field unclaimed Field.
    unclaimed = NULL,
    #  @field user_id Field.
    user_id = NULL,
    #  @field giveaway_msg_id Field.
    giveaway_msg_id = NULL,
    #  @field used_gift_slug Field.
    used_gift_slug = NULL,
    #  @field multiplier Field.
    multiplier = NULL,
    #  @field stars Field.
    stars = NULL,

    #  @description
    #  Initializes the Boost with the given parameters.
    #  @param id A string representing the boost ID.
    #  @param date A datetime object representing the boost date. Optional.
    #  @param expires A datetime object representing when the boost expires. Optional.
    #  @param gift A logical indicating if this is a gift boost. Optional.
    #  @param giveaway A logical indicating if this is a giveaway boost. Optional.
    #  @param unclaimed A logical indicating if the boost is unclaimed. Optional.
    #  @param user_id An integer representing the user ID. Optional.
    #  @param giveaway_msg_id An integer representing the giveaway message ID. Optional.
    #  @param used_gift_slug A string representing the used gift slug. Optional.
    #  @param multiplier An integer representing the multiplier. Optional.
    #  @param stars An integer representing the stars. Optional.
    initialize = function(id, date = NULL, expires = NULL, gift = NULL, giveaway = NULL,
                          unclaimed = NULL, user_id = NULL, giveaway_msg_id = NULL,
                          used_gift_slug = NULL, multiplier = NULL, stars = NULL) {
      # Validation similar to Python assertion
      if (!(((!is.null(giveaway) && giveaway) && (!is.null(giveaway_msg_id) && giveaway_msg_id)) ||
        ((is.null(giveaway) || !giveaway) && (is.null(giveaway_msg_id) || !giveaway_msg_id)))) {
        stop("giveaway, giveaway_msg_id parameters must all be truthy or all falsy")
      }

      self$id <- id
      self$date <- date
      self$expires <- expires
      self$gift <- gift
      self$giveaway <- giveaway
      self$unclaimed <- unclaimed
      self$user_id <- user_id
      self$giveaway_msg_id <- giveaway_msg_id
      self$used_gift_slug <- used_gift_slug
      self$multiplier <- multiplier
      self$stars <- stars
    },

    #  @description
    #  Converts the Boost object to a list (dictionary).
    #  @return A list representation of the Boost object.
    to_dict = function() {
      return(list(
        `_` = "Boost",
        id = self$id,
        date = self$date,
        expires = self$expires,
        gift = self$gift,
        giveaway = self$giveaway,
        unclaimed = self$unclaimed,
        user_id = self$user_id,
        giveaway_msg_id = self$giveaway_msg_id,
        used_gift_slug = self$used_gift_slug,
        multiplier = self$multiplier,
        stars = self$stars
      ))
    },

    #  @description
    #  Serializes the Boost object to bytes.
    #  @return A raw vector representing the serialized bytes of the Boost object.
    bytes = function() {
      flags <- 0
      if (!is.null(self$gift) && self$gift) flags <- flags + 2 # 2^1
      if (!is.null(self$giveaway) && self$giveaway) flags <- flags + 4 # 2^2
      if (!is.null(self$unclaimed) && self$unclaimed) flags <- flags + 8 # 2^3
      if (!is.null(self$user_id)) flags <- flags + 1 # 2^0
      if (!is.null(self$giveaway_msg_id)) flags <- flags + 4 # 2^2
      if (!is.null(self$used_gift_slug)) flags <- flags + 16 # 2^4
      if (!is.null(self$multiplier)) flags <- flags + 32 # 2^5
      if (!is.null(self$stars)) flags <- flags + 64 # 2^6

      result <- list(
        as.raw(c(0xd6, 0x14, 0x3e, 0x4b)),
        writeBin(as.integer(flags), raw(), size = 4, endian = "little"),
        self$serializebytes(self$id)
      )

      if (!is.null(self$user_id)) {
        result <- append(result, list(writeBin(as.numeric(self$user_id), raw(), size = 8, endian = "little")))
      }
      if (!is.null(self$giveaway_msg_id)) {
        result <- append(result, list(writeBin(as.integer(self$giveaway_msg_id), raw(), size = 4, endian = "little")))
      }

      result <- append(result, list(
        self$serialize_datetime(self$date),
        self$serialize_datetime(self$expires)
      ))

      if (!is.null(self$used_gift_slug)) {
        result <- append(result, list(self$serializebytes(self$used_gift_slug)))
      }
      if (!is.null(self$multiplier)) {
        result <- append(result, list(writeBin(as.integer(self$multiplier), raw(), size = 4, endian = "little")))
      }
      if (!is.null(self$stars)) {
        result <- append(result, list(writeBin(as.numeric(self$stars), raw(), size = 8, endian = "little")))
      }

      return(do.call(c, result))
    }
  ),
  private = list(
    #  Reads a Boost object from a BinaryReader.
    from_reader = function(reader) {
      flags <- reader$read_int()

      gift <- bitwAnd(flags, 2) != 0
      giveaway <- bitwAnd(flags, 4) != 0
      unclaimed <- bitwAnd(flags, 8) != 0

      id <- reader$tgread_string()

      user_id <- NULL
      if (bitwAnd(flags, 1) != 0) {
        user_id <- reader$read_long()
      }

      giveaway_msg_id <- NULL
      if (bitwAnd(flags, 4) != 0) {
        giveaway_msg_id <- reader$read_int()
      }

      date <- reader$tgread_date()
      expires <- reader$tgread_date()

      used_gift_slug <- NULL
      if (bitwAnd(flags, 16) != 0) {
        used_gift_slug <- reader$tgread_string()
      }

      multiplier <- NULL
      if (bitwAnd(flags, 32) != 0) {
        multiplier <- reader$read_int()
      }

      stars <- NULL
      if (bitwAnd(flags, 64) != 0) {
        stars <- reader$read_long()
      }

      return(Boost$new(
        id = id,
        date = date,
        expires = expires,
        gift = gift,
        giveaway = giveaway,
        unclaimed = unclaimed,
        user_id = user_id,
        giveaway_msg_id = giveaway_msg_id,
        used_gift_slug = used_gift_slug,
        multiplier = multiplier,
        stars = stars
      ))
    }
  )
)

#  @title BotApp
#  @description Telegram API type BotApp
#  @export
#  @noRd
#  @noRd
BotApp <- R6::R6Class(
  "BotApp",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x95fcd1d6,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x20f32ae,

    #  @field id Field.
    id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    #  @field short_name Field.
    short_name = NULL,
    #  @field title Field.
    title = NULL,
    #  @field description Field.
    description = NULL,
    #  @field photo Field.
    photo = NULL,
    #  @field hash Field.
    hash = NULL,
    #  @field document Field.
    document = NULL,

    #  @description
    #  Initializes the BotApp with the given parameters.
    #  @param id An integer representing the bot app ID.
    #  @param access_hash An integer representing the access hash.
    #  @param short_name A string representing the short name.
    #  @param title A string representing the title.
    #  @param description A string representing the description.
    #  @param photo A TLObject representing the photo.
    #  @param hash An integer representing the hash.
    #  @param document A TLObject representing the document. Optional.
    initialize = function(id, access_hash, short_name, title, description, photo, hash, document = NULL) {
      self$id <- id
      self$access_hash <- access_hash
      self$short_name <- short_name
      self$title <- title
      self$description <- description
      self$photo <- photo
      self$hash <- hash
      self$document <- document
    },

    #  @description
    #  Converts the BotApp object to a list (dictionary).
    #  @return A list representation of the BotApp object.
    to_dict = function() {
      result <- list(
        `_` = "BotApp",
        id = self$id,
        access_hash = self$access_hash,
        short_name = self$short_name,
        title = self$title,
        description = self$description,
        photo = if (inherits(self$photo, "TLObject")) self$photo$to_dict() else self$photo,
        hash = self$hash
      )

      if (!is.null(self$document)) {
        result$document <- if (inherits(self$document, "TLObject")) self$document$to_dict() else self$document
      }

      return(result)
    },

    #  @description
    #  Serializes the BotApp object to bytes.
    #  @return A raw vector representing the serialized bytes of the BotApp object.
    bytes = function() {
      flags <- 0
      if (!is.null(self$document)) flags <- flags + 1 # 2^0

      result <- list(
        as.raw(c(0xd6, 0xd1, 0xfc, 0x95)),
        writeBin(as.integer(flags), raw(), size = 4, endian = "little"),
        writeBin(as.numeric(self$id), raw(), size = 8, endian = "little"),
        writeBin(as.numeric(self$access_hash), raw(), size = 8, endian = "little"),
        self$serializebytes(self$short_name),
        self$serializebytes(self$title),
        self$serializebytes(self$description),
        self$photo$`bytes`()
      )

      if (!is.null(self$document)) {
        result <- append(result, list(self$document$`bytes`()))
      }

      result <- append(result, list(writeBin(as.numeric(self$hash), raw(), size = 8, endian = "little")))

      return(do.call(c, result))
    }
  ),
  private = list(
    #  Reads a BotApp object from a BinaryReader.
    from_reader = function(reader) {
      flags <- reader$read_int()

      id <- reader$read_long()
      access_hash <- reader$read_long()
      short_name <- reader$tgread_string()
      title <- reader$tgread_string()
      description <- reader$tgread_string()
      photo <- reader$tgread_object()

      document <- NULL
      if (bitwAnd(flags, 1) != 0) {
        document <- reader$tgread_object()
      }

      hash <- reader$read_long()

      return(BotApp$new(
        id = id,
        access_hash = access_hash,
        short_name = short_name,
        title = title,
        description = description,
        photo = photo,
        hash = hash,
        document = document
      ))
    }
  )
)

#  @title BotAppNotModified
#  @description Telegram API type BotAppNotModified
#  @export
#  @noRd
#  @noRd
BotAppNotModified <- R6::R6Class(
  "BotAppNotModified",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5da674b7,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x20f32ae,

    #  @description
    #  Initializes the BotAppNotModified with no parameters.
    initialize = function() {
      # No parameters to initialize
    },

    #  @description
    #  Converts the BotAppNotModified object to a list (dictionary).
    #  @return A list representation of the BotAppNotModified object.
    to_dict = function() {
      return(list(`_` = "BotAppNotModified"))
    },

    #  @description
    #  Serializes the BotAppNotModified object to bytes.
    #  @return A raw vector representing the serialized bytes of the BotAppNotModified object.
    bytes = function() {
      return(as.raw(c(0xb7, 0x74, 0xa6, 0x5d)))
    }
  ),
  private = list(
    #  Reads a BotAppNotModified object from a BinaryReader.
    from_reader = function(reader) {
      return(BotAppNotModified$new())
    }
  )
)

#  @title BotAppSettings
#  @description Telegram API type BotAppSettings
#  @export
#  @noRd
#  @noRd
BotAppSettings <- R6::R6Class(
  "BotAppSettings",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc99b1950,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x179e62e3,

    #  @field placeholder_path Field.
    placeholder_path = NULL,
    #  @field background_color Field.
    background_color = NULL,
    #  @field background_dark_color Field.
    background_dark_color = NULL,
    #  @field header_color Field.
    header_color = NULL,
    #  @field header_dark_color Field.
    header_dark_color = NULL,

    #  @description
    #  Initializes the BotAppSettings with the given parameters.
    #  @param placeholder_path A raw vector representing placeholder path bytes. Optional.
    #  @param background_color An integer representing the background color. Optional.
    #  @param background_dark_color An integer representing the dark background color. Optional.
    #  @param header_color An integer representing the header color. Optional.
    #  @param header_dark_color An integer representing the dark header color. Optional.
    initialize = function(placeholder_path = NULL, background_color = NULL, background_dark_color = NULL,
                          header_color = NULL, header_dark_color = NULL) {
      self$placeholder_path <- placeholder_path
      self$background_color <- background_color
      self$background_dark_color <- background_dark_color
      self$header_color <- header_color
      self$header_dark_color <- header_dark_color
    },

    #  @description
    #  Converts the BotAppSettings object to a list (dictionary).
    #  @return A list representation of the BotAppSettings object.
    to_dict = function() {
      return(list(
        `_` = "BotAppSettings",
        placeholder_path = self$placeholder_path,
        background_color = self$background_color,
        background_dark_color = self$background_dark_color,
        header_color = self$header_color,
        header_dark_color = self$header_dark_color
      ))
    },

    #  @description
    #  Serializes the BotAppSettings object to bytes.
    #  @return A raw vector representing the serialized bytes of the BotAppSettings object.
    bytes = function() {
      flags <- 0
      if (!is.null(self$placeholder_path)) flags <- flags + 1 # 2^0
      if (!is.null(self$background_color)) flags <- flags + 2 # 2^1
      if (!is.null(self$background_dark_color)) flags <- flags + 4 # 2^2
      if (!is.null(self$header_color)) flags <- flags + 8 # 2^3
      if (!is.null(self$header_dark_color)) flags <- flags + 16 # 2^4

      result <- list(
        as.raw(c(0x50, 0x19, 0x9b, 0xc9)),
        writeBin(as.integer(flags), raw(), size = 4, endian = "little")
      )

      if (!is.null(self$placeholder_path)) {
        result <- append(result, list(self$serializebytes(self$placeholder_path)))
      }
      if (!is.null(self$background_color)) {
        result <- append(result, list(writeBin(as.integer(self$background_color), raw(), size = 4, endian = "little")))
      }
      if (!is.null(self$background_dark_color)) {
        result <- append(result, list(writeBin(as.integer(self$background_dark_color), raw(), size = 4, endian = "little")))
      }
      if (!is.null(self$header_color)) {
        result <- append(result, list(writeBin(as.integer(self$header_color), raw(), size = 4, endian = "little")))
      }
      if (!is.null(self$header_dark_color)) {
        result <- append(result, list(writeBin(as.integer(self$header_dark_color), raw(), size = 4, endian = "little")))
      }

      return(do.call(c, result))
    }
  ),
  private = list(
    #  Reads a BotAppSettings object from a BinaryReader.
    from_reader = function(reader) {
      flags <- reader$read_int()

      placeholder_path <- NULL
      if (bitwAnd(flags, 1) != 0) {
        placeholder_path <- reader$tgreadbytes()
      }

      background_color <- NULL
      if (bitwAnd(flags, 2) != 0) {
        background_color <- reader$read_int()
      }

      background_dark_color <- NULL
      if (bitwAnd(flags, 4) != 0) {
        background_dark_color <- reader$read_int()
      }

      header_color <- NULL
      if (bitwAnd(flags, 8) != 0) {
        header_color <- reader$read_int()
      }

      header_dark_color <- NULL
      if (bitwAnd(flags, 16) != 0) {
        header_dark_color <- reader$read_int()
      }

      return(BotAppSettings$new(
        placeholder_path = placeholder_path,
        background_color = background_color,
        background_dark_color = background_dark_color,
        header_color = header_color,
        header_dark_color = header_dark_color
      ))
    }
  )
)

#  @title BotBusinessConnection
#  @description Telegram API type BotBusinessConnection
#  @export
#  @noRd
#  @noRd
BotBusinessConnection <- R6::R6Class(
  "BotBusinessConnection",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8f34b2f5,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9b130546,

    #  @field connection_id Field.
    connection_id = NULL,
    #  @field user_id Field.
    user_id = NULL,
    #  @field dc_id Field.
    dc_id = NULL,
    #  @field date Field.
    date = NULL,
    #  @field disabled Field.
    disabled = NULL,
    #  @field rights Field.
    rights = NULL,

    #  @description
    #  Initializes the BotBusinessConnection with the given parameters.
    #  @param connection_id A string representing the connection ID.
    #  @param user_id An integer representing the user ID.
    #  @param dc_id An integer representing the data center ID.
    #  @param date A datetime object representing the date. Optional.
    #  @param disabled A boolean indicating if disabled. Optional.
    #  @param rights A TLObject representing the rights. Optional.
    initialize = function(connection_id, user_id, dc_id, date = NULL, disabled = NULL, rights = NULL) {
      self$connection_id <- connection_id
      self$user_id <- user_id
      self$dc_id <- dc_id
      self$date <- date
      self$disabled <- disabled
      self$rights <- rights
    },

    #  @description
    #  Converts the BotBusinessConnection object to a list (dictionary).
    #  @return A list representation of the BotBusinessConnection object.
    to_dict = function() {
      result <- list(
        `_` = "BotBusinessConnection",
        connection_id = self$connection_id,
        user_id = self$user_id,
        dc_id = self$dc_id
      )

      if (!is.null(self$date)) {
        result$date <- self$date
      }
      if (!is.null(self$disabled)) {
        result$disabled <- self$disabled
      }
      if (!is.null(self$rights)) {
        result$rights <- if (inherits(self$rights, "TLObject")) self$rights$to_dict() else self$rights
      }

      return(result)
    },

    #  @description
    #  Serializes the BotBusinessConnection object to bytes.
    #  @return A raw vector representing the serialized bytes of the BotBusinessConnection object.
    bytes = function() {
      flags <- 0
      if (!is.null(self$disabled)) flags <- flags + 2 # 2^1
      if (!is.null(self$rights)) flags <- flags + 4 # 2^2

      result <- list(
        as.raw(c(0xf5, 0xb2, 0x34, 0x8f)),
        writeBin(as.integer(flags), raw(), size = 4, endian = "little"),
        self$serializebytes(self$connection_id),
        writeBin(as.numeric(self$user_id), raw(), size = 8, endian = "little"),
        writeBin(as.integer(self$dc_id), raw(), size = 4, endian = "little"),
        self$serialize_datetime(self$date)
      )

      if (!is.null(self$rights)) {
        result <- append(result, list(self$rights$`bytes`()))
      }

      return(do.call(c, result))
    }
  ),
  private = list(
    #  Reads a BotBusinessConnection object from a BinaryReader.
    from_reader = function(reader) {
      flags <- reader$read_int()

      disabled <- NULL
      if (bitwAnd(flags, 2) != 0) {
        disabled <- TRUE
      }

      connection_id <- reader$tgread_string()
      user_id <- reader$read_long()
      dc_id <- reader$read_int()
      date <- reader$tgread_date()

      rights <- NULL
      if (bitwAnd(flags, 4) != 0) {
        rights <- reader$tgread_object()
      }

      return(BotBusinessConnection$new(
        connection_id = connection_id,
        user_id = user_id,
        dc_id = dc_id,
        date = date,
        disabled = disabled,
        rights = rights
      ))
    }
  )
)

#  @title BotCommand
#  @description Telegram API type BotCommand
#  @export
#  @noRd
#  @noRd
BotCommand <- R6::R6Class(
  "BotCommand",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc27ac8c7,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xe1e62c2,

    #  @field command Field.
    command = NULL,
    #  @field description Field.
    description = NULL,

    #  @description
    #  Initializes the BotCommand with the given parameters.
    #  @param command A string representing the command.
    #  @param description A string representing the description.
    initialize = function(command, description) {
      self$command <- command
      self$description <- description
    },

    #  @description
    #  Converts the BotCommand object to a list (dictionary).
    #  @return A list representation of the BotCommand object.
    to_dict = function() {
      return(list(
        `_` = "BotCommand",
        command = self$command,
        description = self$description
      ))
    },

    #  @description
    #  Serializes the BotCommand object to bytes.
    #  @return A raw vector representing the serialized bytes of the BotCommand object.
    bytes = function() {
      return(c(
        as.raw(c(0xc7, 0xc8, 0x7a, 0xc2)),
        self$serializebytes(self$command),
        self$serializebytes(self$description)
      ))
    }
  ),
  private = list(
    #  Reads a BotCommand object from a BinaryReader.
    from_reader = function(reader) {
      command <- reader$tgread_string()
      description <- reader$tgread_string()

      return(BotCommand$new(
        command = command,
        description = description
      ))
    }
  )
)

#  @title BotCommandScopeChatAdmins
#  @description Telegram API type BotCommandScopeChatAdmins
#  @export
#  @noRd
#  @noRd
BotCommandScopeChatAdmins <- R6::R6Class(
  "BotCommandScopeChatAdmins",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb9aa606a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x4baf5d10,

    #  @description
    #  Initializes the BotCommandScopeChatAdmins with no parameters.
    initialize = function() {
      # No parameters to initialize
    },

    #  @description
    #  Converts the BotCommandScopeChatAdmins object to a list (dictionary).
    #  @return A list representation of the BotCommandScopeChatAdmins object.
    to_dict = function() {
      return(list(`_` = "BotCommandScopeChatAdmins"))
    },

    #  @description
    #  Serializes the BotCommandScopeChatAdmins object to bytes.
    #  @return A raw vector representing the serialized bytes of the BotCommandScopeChatAdmins object.
    bytes = function() {
      return(as.raw(c(0x6a, 0x60, 0xaa, 0xb9)))
    }
  ),
  private = list(
    #  Reads a BotCommandScopeChatAdmins object from a BinaryReader.
    from_reader = function(reader) {
      return(BotCommandScopeChatAdmins$new())
    }
  )
)

#  @title BotCommandScopeChats
#  @description Telegram API type BotCommandScopeChats
#  @export
#  @noRd
#  @noRd
BotCommandScopeChats <- R6::R6Class(
  "BotCommandScopeChats",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x6fe1a881,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x4baf5d10,

    #  @description
    #  Initializes the BotCommandScopeChats with no parameters.
    initialize = function() {
      # No parameters to initialize
    },

    #  @description
    #  Converts the BotCommandScopeChats object to a list (dictionary).
    #  @return A list representation of the BotCommandScopeChats object.
    to_dict = function() {
      return(list(`_` = "BotCommandScopeChats"))
    },

    #  @description
    #  Serializes the BotCommandScopeChats object to bytes.
    #  @return A raw vector representing the serialized bytes of the BotCommandScopeChats object.
    bytes = function() {
      return(as.raw(c(0x81, 0xa8, 0xe1, 0x6f)))
    }
  ),
  private = list(
    #  Reads a BotCommandScopeChats object from a BinaryReader.
    from_reader = function(reader) {
      return(BotCommandScopeChats$new())
    }
  )
)

#  @title BotCommandScopeDefault
#  @description Telegram API type BotCommandScopeDefault
#  @export
#  @noRd
#  @noRd
BotCommandScopeDefault <- R6::R6Class(
  "BotCommandScopeDefault",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x2f6cb2ab,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x4baf5d10,

    #  @description
    #  Initializes the BotCommandScopeDefault with no parameters.
    initialize = function() {
      # No parameters to initialize
    },

    #  @description
    #  Converts the BotCommandScopeDefault object to a list (dictionary).
    #  @return A list representation of the BotCommandScopeDefault object.
    to_dict = function() {
      return(list(`_` = "BotCommandScopeDefault"))
    },

    #  @description
    #  Serializes the BotCommandScopeDefault object to bytes.
    #  @return A raw vector representing the serialized bytes of the BotCommandScopeDefault object.
    bytes = function() {
      return(as.raw(c(0xab, 0xb2, 0x6c, 0x2f)))
    }
  ),
  private = list(
    #  Reads a BotCommandScopeDefault object from a BinaryReader.
    from_reader = function(reader) {
      return(BotCommandScopeDefault$new())
    }
  )
)

#  @title BotCommandScopePeer
#  @description Telegram API type BotCommandScopePeer
#  @export
#  @noRd
#  @noRd
BotCommandScopePeer <- R6::R6Class(
  "BotCommandScopePeer",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xdb9d897d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x4baf5d10,

    #  @field peer Field.
    peer = NULL,

    #  @description
    #  Initializes the BotCommandScopePeer with the given parameters.
    #  @param peer A TLObject representing the peer.
    initialize = function(peer) {
      self$peer <- peer
    },

    #  @description
    #  Converts the BotCommandScopePeer object to a list (dictionary).
    #  @return A list representation of the BotCommandScopePeer object.
    to_dict = function() {
      return(list(
        `_` = "BotCommandScopePeer",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer
      ))
    },

    #  @description
    #  Serializes the BotCommandScopePeer object to bytes.
    #  @return A raw vector representing the serialized bytes of the BotCommandScopePeer object.
    bytes = function() {
      return(c(
        as.raw(c(0x7d, 0x89, 0x9d, 0xdb)),
        self$peer$`bytes`()
      ))
    }
  ),
  private = list(
    #  Reads a BotCommandScopePeer object from a BinaryReader.
    from_reader = function(reader) {
      peer <- reader$tgread_object()

      return(BotCommandScopePeer$new(
        peer = peer
      ))
    }
  )
)

#  @title BotCommandScopePeerAdmins
#  @description Telegram API type BotCommandScopePeerAdmins
#  @export
#  @noRd
#  @noRd
BotCommandScopePeerAdmins <- R6::R6Class(
  "BotCommandScopePeerAdmins",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x3fd863d1,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x4baf5d10,

    #  @field peer Field.
    peer = NULL,

    #  @description
    #  Initializes the BotCommandScopePeerAdmins with the given parameters.
    #  @param peer A TLObject representing the peer.
    initialize = function(peer) {
      self$peer <- peer
    },

    #  @description
    #  Converts the BotCommandScopePeerAdmins object to a list (dictionary).
    #  @return A list representation of the BotCommandScopePeerAdmins object.
    to_dict = function() {
      return(list(
        `_` = "BotCommandScopePeerAdmins",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer
      ))
    },

    #  @description
    #  Serializes the BotCommandScopePeerAdmins object to bytes.
    #  @return A raw vector representing the serialized bytes of the BotCommandScopePeerAdmins object.
    bytes = function() {
      return(c(
        as.raw(c(0xd1, 0x63, 0xd8, 0x3f)),
        self$peer$`bytes`()
      ))
    }
  ),
  private = list(
    #  Reads a BotCommandScopePeerAdmins object from a BinaryReader.
    from_reader = function(reader) {
      peer <- reader$tgread_object()

      return(BotCommandScopePeerAdmins$new(
        peer = peer
      ))
    }
  )
)

#  @title BotCommandScopePeerUser
#  @description Telegram API type BotCommandScopePeerUser
#  @export
#  @noRd
#  @noRd
BotCommandScopePeerUser <- R6::R6Class(
  "BotCommandScopePeerUser",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa1321f3,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x4baf5d10,

    #  @field peer Field.
    peer = NULL,
    #  @field user_id Field.
    user_id = NULL,

    #  @description
    #  Initializes the BotCommandScopePeerUser with the given parameters.
    #  @param peer A TLObject representing the peer.
    #  @param user_id A TLObject representing the user ID.
    initialize = function(peer, user_id) {
      self$peer <- peer
      self$user_id <- user_id
    },

    #  @description
    #  Converts the BotCommandScopePeerUser object to a list (dictionary).
    #  @return A list representation of the BotCommandScopePeerUser object.
    to_dict = function() {
      return(list(
        `_` = "BotCommandScopePeerUser",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        user_id = if (inherits(self$user_id, "TLObject")) self$user_id$to_dict() else self$user_id
      ))
    },

    #  @description
    #  Serializes the BotCommandScopePeerUser object to bytes.
    #  @return A raw vector representing the serialized bytes of the BotCommandScopePeerUser object.
    bytes = function() {
      return(c(
        as.raw(c(0xf3, 0x21, 0x13, 0x0a)),
        self$peer$`bytes`(),
        self$user_id$`bytes`()
      ))
    }
  ),
  private = list(
    #  Reads a BotCommandScopePeerUser object from a BinaryReader.
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      user_id <- reader$tgread_object()

      return(BotCommandScopePeerUser$new(
        peer = peer,
        user_id = user_id
      ))
    }
  )
)

#  @title BotCommandScopeUsers
#  @description Telegram API type BotCommandScopeUsers
#  @export
#  @noRd
#  @noRd
BotCommandScopeUsers <- R6::R6Class(
  "BotCommandScopeUsers",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x3c4f04d8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x4baf5d10,

    #  @description
    #  Initializes the BotCommandScopeUsers with no parameters.
    initialize = function() {
      # No parameters to initialize
    },

    #  @description
    #  Converts the BotCommandScopeUsers object to a list (dictionary).
    #  @return A list representation of the BotCommandScopeUsers object.
    to_dict = function() {
      return(list(`_` = "BotCommandScopeUsers"))
    },

    #  @description
    #  Serializes the BotCommandScopeUsers object to bytes.
    #  @return A raw vector representing the serialized bytes of the BotCommandScopeUsers object.
    bytes = function() {
      return(as.raw(c(0xd8, 0x04, 0x4f, 0x3c)))
    }
  ),
  private = list(
    #  Reads a BotCommandScopeUsers object from a BinaryReader.
    from_reader = function(reader) {
      return(BotCommandScopeUsers$new())
    }
  )
)

#  @title BotInfo
#  @description Telegram API type BotInfo
#  @export
#  @noRd
#  @noRd
BotInfo <- R6::R6Class(
  "BotInfo",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4d8a0299,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf1f701db,

    #  @field has_preview_medias Field.
    has_preview_medias = NULL,
    #  @field user_id Field.
    user_id = NULL,
    #  @field description Field.
    description = NULL,
    #  @field description_photo Field.
    description_photo = NULL,
    #  @field description_document Field.
    description_document = NULL,
    #  @field commands Field.
    commands = NULL,
    #  @field menu_button Field.
    menu_button = NULL,
    #  @field privacy_policy_url Field.
    privacy_policy_url = NULL,
    #  @field app_settings Field.
    app_settings = NULL,
    #  @field verifier_settings Field.
    verifier_settings = NULL,

    #  @description
    #  Initializes the BotInfo with the given parameters.
    #  @param has_preview_medias A boolean indicating if has preview medias. Optional.
    #  @param user_id An integer representing the user ID. Optional.
    #  @param description A string representing the description. Optional.
    #  @param description_photo A TLObject representing the description photo. Optional.
    #  @param description_document A TLObject representing the description document. Optional.
    #  @param commands A list of TLObjects representing commands. Optional.
    #  @param menu_button A TLObject representing the menu button. Optional.
    #  @param privacy_policy_url A string representing the privacy policy URL. Optional.
    #  @param app_settings A TLObject representing the app settings. Optional.
    #  @param verifier_settings A TLObject representing the verifier settings. Optional.
    initialize = function(has_preview_medias = NULL, user_id = NULL, description = NULL, description_photo = NULL,
                          description_document = NULL, commands = NULL, menu_button = NULL, privacy_policy_url = NULL,
                          app_settings = NULL, verifier_settings = NULL) {
      self$has_preview_medias <- has_preview_medias
      self$user_id <- user_id
      self$description <- description
      self$description_photo <- description_photo
      self$description_document <- description_document
      self$commands <- commands
      self$menu_button <- menu_button
      self$privacy_policy_url <- privacy_policy_url
      self$app_settings <- app_settings
      self$verifier_settings <- verifier_settings
    },

    #  @description
    #  Converts the BotInfo object to a list (dictionary).
    #  @return A list representation of the BotInfo object.
    to_dict = function() {
      result <- list(`_` = "BotInfo")

      if (!is.null(self$has_preview_medias)) {
        result$has_preview_medias <- self$has_preview_medias
      }
      if (!is.null(self$user_id)) {
        result$user_id <- self$user_id
      }
      if (!is.null(self$description)) {
        result$description <- self$description
      }
      if (!is.null(self$description_photo)) {
        result$description_photo <- if (inherits(self$description_photo, "TLObject")) self$description_photo$to_dict() else self$description_photo
      }
      if (!is.null(self$description_document)) {
        result$description_document <- if (inherits(self$description_document, "TLObject")) self$description_document$to_dict() else self$description_document
      }
      if (!is.null(self$commands)) {
        result$commands <- lapply(self$commands, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      }
      if (!is.null(self$menu_button)) {
        result$menu_button <- if (inherits(self$menu_button, "TLObject")) self$menu_button$to_dict() else self$menu_button
      }
      if (!is.null(self$privacy_policy_url)) {
        result$privacy_policy_url <- self$privacy_policy_url
      }
      if (!is.null(self$app_settings)) {
        result$app_settings <- if (inherits(self$app_settings, "TLObject")) self$app_settings$to_dict() else self$app_settings
      }
      if (!is.null(self$verifier_settings)) {
        result$verifier_settings <- if (inherits(self$verifier_settings, "TLObject")) self$verifier_settings$to_dict() else self$verifier_settings
      }

      return(result)
    },

    #  @description
    #  Serializes the BotInfo object to bytes.
    #  @return A raw vector representing the serialized bytes of the BotInfo object.
    bytes = function() {
      flags <- 0
      if (!is.null(self$has_preview_medias)) flags <- flags + 64 # 2^6
      if (!is.null(self$user_id)) flags <- flags + 1 # 2^0
      if (!is.null(self$description)) flags <- flags + 2 # 2^1
      if (!is.null(self$description_photo)) flags <- flags + 16 # 2^4
      if (!is.null(self$description_document)) flags <- flags + 32 # 2^5
      if (!is.null(self$commands)) flags <- flags + 4 # 2^2
      if (!is.null(self$menu_button)) flags <- flags + 8 # 2^3
      if (!is.null(self$privacy_policy_url)) flags <- flags + 128 # 2^7
      if (!is.null(self$app_settings)) flags <- flags + 256 # 2^8
      if (!is.null(self$verifier_settings)) flags <- flags + 512 # 2^9

      result <- list(
        as.raw(c(0x99, 0x02, 0x8a, 0x4d)),
        writeBin(as.integer(flags), raw(), size = 4, endian = "little")
      )

      if (!is.null(self$user_id)) {
        result <- append(result, list(writeBin(as.numeric(self$user_id), raw(), size = 8, endian = "little")))
      }
      if (!is.null(self$description)) {
        result <- append(result, list(self$serializebytes(self$description)))
      }
      if (!is.null(self$description_photo)) {
        result <- append(result, list(self$description_photo$`bytes`()))
      }
      if (!is.null(self$description_document)) {
        result <- append(result, list(self$description_document$`bytes`()))
      }
      if (!is.null(self$commands)) {
        result <- append(result, list(
          as.raw(c(0x15, 0xc4, 0xb5, 0x1c)),
          writeBin(as.integer(length(self$commands)), raw(), size = 4, endian = "little"),
          do.call(c, lapply(self$commands, function(x) x$`bytes`()))
        ))
      }
      if (!is.null(self$menu_button)) {
        result <- append(result, list(self$menu_button$`bytes`()))
      }
      if (!is.null(self$privacy_policy_url)) {
        result <- append(result, list(self$serializebytes(self$privacy_policy_url)))
      }
      if (!is.null(self$app_settings)) {
        result <- append(result, list(self$app_settings$`bytes`()))
      }
      if (!is.null(self$verifier_settings)) {
        result <- append(result, list(self$verifier_settings$`bytes`()))
      }

      return(do.call(c, result))
    }
  ),
  private = list(
    #  Reads a BotInfo object from a BinaryReader.
    from_reader = function(reader) {
      flags <- reader$read_int()

      has_preview_medias <- NULL
      if (bitwAnd(flags, 64) != 0) {
        has_preview_medias <- TRUE
      }

      user_id <- NULL
      if (bitwAnd(flags, 1) != 0) {
        user_id <- reader$read_long()
      }

      description <- NULL
      if (bitwAnd(flags, 2) != 0) {
        description <- reader$tgread_string()
      }

      description_photo <- NULL
      if (bitwAnd(flags, 16) != 0) {
        description_photo <- reader$tgread_object()
      }

      description_document <- NULL
      if (bitwAnd(flags, 32) != 0) {
        description_document <- reader$tgread_object()
      }

      commands <- NULL
      if (bitwAnd(flags, 4) != 0) {
        reader$read_int() # Skip vector constructor
        commands <- list()
        for (i in 1:reader$read_int()) {
          commands <- append(commands, list(reader$tgread_object()))
        }
      }

      menu_button <- NULL
      if (bitwAnd(flags, 8) != 0) {
        menu_button <- reader$tgread_object()
      }

      privacy_policy_url <- NULL
      if (bitwAnd(flags, 128) != 0) {
        privacy_policy_url <- reader$tgread_string()
      }

      app_settings <- NULL
      if (bitwAnd(flags, 256) != 0) {
        app_settings <- reader$tgread_object()
      }

      verifier_settings <- NULL
      if (bitwAnd(flags, 512) != 0) {
        verifier_settings <- reader$tgread_object()
      }

      return(BotInfo$new(
        has_preview_medias = has_preview_medias,
        user_id = user_id,
        description = description,
        description_photo = description_photo,
        description_document = description_document,
        commands = commands,
        menu_button = menu_button,
        privacy_policy_url = privacy_policy_url,
        app_settings = app_settings,
        verifier_settings = verifier_settings
      ))
    }
  )
)

#  @title BotInlineMediaResult
#  @description Telegram API type BotInlineMediaResult
#  @export
#  @noRd
#  @noRd
BotInlineMediaResult <- R6::R6Class(
  "BotInlineMediaResult",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x17db940b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x3832b3d5,

    #  @field id Field.
    id = NULL,
    #  @field type Field.
    type = NULL,
    #  @field send_message Field.
    send_message = NULL,
    #  @field photo Field.
    photo = NULL,
    #  @field document Field.
    document = NULL,
    #  @field title Field.
    title = NULL,
    #  @field description Field.
    description = NULL,

    #  @description
    #  Initializes the BotInlineMediaResult with the given parameters.
    #  @param id A string representing the ID.
    #  @param type A string representing the type.
    #  @param send_message A TLObject representing the send message.
    #  @param photo A TLObject representing the photo. Optional.
    #  @param document A TLObject representing the document. Optional.
    #  @param title A string representing the title. Optional.
    #  @param description A string representing the description. Optional.
    initialize = function(id, type, send_message, photo = NULL, document = NULL, title = NULL, description = NULL) {
      self$id <- id
      self$type <- type
      self$send_message <- send_message
      self$photo <- photo
      self$document <- document
      self$title <- title
      self$description <- description
    },

    #  @description
    #  Converts the BotInlineMediaResult object to a list (dictionary).
    #  @return A list representation of the BotInlineMediaResult object.
    to_dict = function() {
      result <- list(
        `_` = "BotInlineMediaResult",
        id = self$id,
        type = self$type,
        send_message = if (inherits(self$send_message, "TLObject")) self$send_message$to_dict() else self$send_message
      )

      if (!is.null(self$photo)) {
        result$photo <- if (inherits(self$photo, "TLObject")) self$photo$to_dict() else self$photo
      }
      if (!is.null(self$document)) {
        result$document <- if (inherits(self$document, "TLObject")) self$document$to_dict() else self$document
      }
      if (!is.null(self$title)) {
        result$title <- self$title
      }
      if (!is.null(self$description)) {
        result$description <- self$description
      }

      return(result)
    },

    #  @description
    #  Serializes the BotInlineMediaResult object to bytes.
    #  @return A raw vector representing the serialized bytes of the BotInlineMediaResult object.
    bytes = function() {
      flags <- 0
      if (!is.null(self$photo)) flags <- flags + 1 # 2^0
      if (!is.null(self$document)) flags <- flags + 2 # 2^1
      if (!is.null(self$title)) flags <- flags + 4 # 2^2
      if (!is.null(self$description)) flags <- flags + 8 # 2^3

      result <- list(
        as.raw(c(0x0b, 0x94, 0xdb, 0x17)),
        writeBin(as.integer(flags), raw(), size = 4, endian = "little"),
        self$serializebytes(self$id),
        self$serializebytes(self$type)
      )

      if (!is.null(self$photo)) {
        result <- append(result, list(self$photo$`bytes`()))
      }
      if (!is.null(self$document)) {
        result <- append(result, list(self$document$`bytes`()))
      }
      if (!is.null(self$title)) {
        result <- append(result, list(self$serializebytes(self$title)))
      }
      if (!is.null(self$description)) {
        result <- append(result, list(self$serializebytes(self$description)))
      }

      result <- append(result, list(self$send_message$`bytes`()))

      return(do.call(c, result))
    }
  ),
  private = list(
    #  Reads a BotInlineMediaResult object from a BinaryReader.
    from_reader = function(reader) {
      flags <- reader$read_int()

      id <- reader$tgread_string()
      type <- reader$tgread_string()

      photo <- NULL
      if (bitwAnd(flags, 1) != 0) {
        photo <- reader$tgread_object()
      }

      document <- NULL
      if (bitwAnd(flags, 2) != 0) {
        document <- reader$tgread_object()
      }

      title <- NULL
      if (bitwAnd(flags, 4) != 0) {
        title <- reader$tgread_string()
      }

      description <- NULL
      if (bitwAnd(flags, 8) != 0) {
        description <- reader$tgread_string()
      }

      send_message <- reader$tgread_object()

      return(BotInlineMediaResult$new(
        id = id,
        type = type,
        send_message = send_message,
        photo = photo,
        document = document,
        title = title,
        description = description
      ))
    }
  )
)

#  @title BotInlineMessageMediaAuto
#  @description Telegram API type BotInlineMessageMediaAuto
#  @export
#  @noRd
#  @noRd
BotInlineMessageMediaAuto <- R6::R6Class(
  "BotInlineMessageMediaAuto",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x764cf810,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc4910f88,

    #  @field message Field.
    message = NULL,
    #  @field invert_media Field.
    invert_media = NULL,
    #  @field entities Field.
    entities = NULL,
    #  @field reply_markup Field.
    reply_markup = NULL,

    #  @description
    #  Initializes the BotInlineMessageMediaAuto with the given parameters.
    #  @param message A string representing the message.
    #  @param invert_media A boolean indicating if invert media. Optional.
    #  @param entities A list of TLObjects representing entities. Optional.
    #  @param reply_markup A TLObject representing the reply markup. Optional.
    initialize = function(message, invert_media = NULL, entities = NULL, reply_markup = NULL) {
      self$message <- message
      self$invert_media <- invert_media
      self$entities <- entities
      self$reply_markup <- reply_markup
    },

    #  @description
    #  Converts the BotInlineMessageMediaAuto object to a list (dictionary).
    #  @return A list representation of the BotInlineMessageMediaAuto object.
    to_dict = function() {
      result <- list(
        `_` = "BotInlineMessageMediaAuto",
        message = self$message
      )

      if (!is.null(self$invert_media)) {
        result$invert_media <- self$invert_media
      }
      if (!is.null(self$entities)) {
        result$entities <- lapply(self$entities, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      }
      if (!is.null(self$reply_markup)) {
        result$reply_markup <- if (inherits(self$reply_markup, "TLObject")) self$reply_markup$to_dict() else self$reply_markup
      }

      return(result)
    },

    #  @description
    #  Serializes the BotInlineMessageMediaAuto object to bytes.
    #  @return A raw vector representing the serialized bytes of the BotInlineMessageMediaAuto object.
    bytes = function() {
      flags <- 0
      if (!is.null(self$invert_media)) flags <- flags + 8 # 2^3
      if (!is.null(self$entities)) flags <- flags + 2 # 2^1
      if (!is.null(self$reply_markup)) flags <- flags + 4 # 2^2

      result <- list(
        as.raw(c(0x10, 0xf8, 0x4c, 0x76)),
        writeBin(as.integer(flags), raw(), size = 4, endian = "little"),
        self$serializebytes(self$message)
      )

      if (!is.null(self$entities)) {
        result <- append(result, list(
          as.raw(c(0x15, 0xc4, 0xb5, 0x1c)),
          writeBin(as.integer(length(self$entities)), raw(), size = 4, endian = "little"),
          do.call(c, lapply(self$entities, function(x) x$`bytes`()))
        ))
      }

      if (!is.null(self$reply_markup)) {
        result <- append(result, list(self$reply_markup$`bytes`()))
      }

      return(do.call(c, result))
    }
  ),
  private = list(
    #  Reads a BotInlineMessageMediaAuto object from a BinaryReader.
    from_reader = function(reader) {
      flags <- reader$read_int()

      invert_media <- NULL
      if (bitwAnd(flags, 8) != 0) {
        invert_media <- TRUE
      }

      message <- reader$tgread_string()

      entities <- NULL
      if (bitwAnd(flags, 2) != 0) {
        reader$read_int() # Skip vector constructor
        entities <- list()
        for (i in 1:reader$read_int()) {
          entities <- append(entities, list(reader$tgread_object()))
        }
      }

      reply_markup <- NULL
      if (bitwAnd(flags, 4) != 0) {
        reply_markup <- reader$tgread_object()
      }

      return(BotInlineMessageMediaAuto$new(
        message = message,
        invert_media = invert_media,
        entities = entities,
        reply_markup = reply_markup
      ))
    }
  )
)

#  @title BotInlineMessageMediaContact
#  @description Telegram API type BotInlineMessageMediaContact
#  @export
#  @noRd
#  @noRd
BotInlineMessageMediaContact <- R6::R6Class(
  "BotInlineMessageMediaContact",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x18d1cdc2,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc4910f88,

    #  @field phone_number Field.
    phone_number = NULL,
    #  @field first_name Field.
    first_name = NULL,
    #  @field last_name Field.
    last_name = NULL,
    #  @field vcard Field.
    vcard = NULL,
    #  @field reply_markup Field.
    reply_markup = NULL,

    #  @description
    #  Initializes the BotInlineMessageMediaContact with the given parameters.
    #  @param phone_number A string representing the phone number.
    #  @param first_name A string representing the first name.
    #  @param last_name A string representing the last name.
    #  @param vcard A string representing the vcard.
    #  @param reply_markup A TLObject representing the reply markup. Optional.
    initialize = function(phone_number, first_name, last_name, vcard, reply_markup = NULL) {
      self$phone_number <- phone_number
      self$first_name <- first_name
      self$last_name <- last_name
      self$vcard <- vcard
      self$reply_markup <- reply_markup
    },

    #  @description
    #  Converts the BotInlineMessageMediaContact object to a list (dictionary).
    #  @return A list representation of the BotInlineMessageMediaContact object.
    to_dict = function() {
      result <- list(
        `_` = "BotInlineMessageMediaContact",
        phone_number = self$phone_number,
        first_name = self$first_name,
        last_name = self$last_name,
        vcard = self$vcard
      )

      if (!is.null(self$reply_markup)) {
        result$reply_markup <- if (inherits(self$reply_markup, "TLObject")) self$reply_markup$to_dict() else self$reply_markup
      }

      return(result)
    },

    #  @description
    #  Serializes the BotInlineMessageMediaContact object to bytes.
    #  @return A raw vector representing the serialized bytes of the BotInlineMessageMediaContact object.
    bytes = function() {
      flags <- 0
      if (!is.null(self$reply_markup)) flags <- flags + 4 # 2^2

      result <- list(
        as.raw(c(0xc2, 0xcd, 0xd1, 0x18)),
        writeBin(as.integer(flags), raw(), size = 4, endian = "little"),
        self$serializebytes(self$phone_number),
        self$serializebytes(self$first_name),
        self$serializebytes(self$last_name),
        self$serializebytes(self$vcard)
      )

      if (!is.null(self$reply_markup)) {
        result <- append(result, list(self$reply_markup$`bytes`()))
      }

      return(do.call(c, result))
    }
  ),
  private = list(
    #  Reads a BotInlineMessageMediaContact object from a BinaryReader.
    from_reader = function(reader) {
      flags <- reader$read_int()

      phone_number <- reader$tgread_string()
      first_name <- reader$tgread_string()
      last_name <- reader$tgread_string()
      vcard <- reader$tgread_string()

      reply_markup <- NULL
      if (bitwAnd(flags, 4) != 0) {
        reply_markup <- reader$tgread_object()
      }

      return(BotInlineMessageMediaContact$new(
        phone_number = phone_number,
        first_name = first_name,
        last_name = last_name,
        vcard = vcard,
        reply_markup = reply_markup
      ))
    }
  )
)

#  @title BotInlineMessageMediaGeo
#  @description Telegram API type BotInlineMessageMediaGeo
#  @export
#  @noRd
#  @noRd
BotInlineMessageMediaGeo <- R6::R6Class(
  "BotInlineMessageMediaGeo",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x51846fd,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc4910f88,

    #  @field geo Field.
    geo = NULL,
    #  @field heading Field.
    heading = NULL,
    #  @field period Field.
    period = NULL,
    #  @field proximity_notification_radius Field.
    proximity_notification_radius = NULL,
    #  @field reply_markup Field.
    reply_markup = NULL,

    #  @description
    #  Initializes the BotInlineMessageMediaGeo with the given parameters.
    #  @param geo A TLObject representing the geo point.
    #  @param heading An integer representing the heading. Optional.
    #  @param period An integer representing the period. Optional.
    #  @param proximity_notification_radius An integer representing the proximity notification radius. Optional.
    #  @param reply_markup A TLObject representing the reply markup. Optional.
    initialize = function(geo, heading = NULL, period = NULL, proximity_notification_radius = NULL, reply_markup = NULL) {
      self$geo <- geo
      self$heading <- heading
      self$period <- period
      self$proximity_notification_radius <- proximity_notification_radius
      self$reply_markup <- reply_markup
    },

    #  @description
    #  Converts the BotInlineMessageMediaGeo object to a list (dictionary).
    #  @return A list representation of the BotInlineMessageMediaGeo object.
    to_dict = function() {
      result <- list(
        `_` = "BotInlineMessageMediaGeo",
        geo = if (inherits(self$geo, "TLObject")) self$geo$to_dict() else self$geo
      )

      if (!is.null(self$heading)) {
        result$heading <- self$heading
      }
      if (!is.null(self$period)) {
        result$period <- self$period
      }
      if (!is.null(self$proximity_notification_radius)) {
        result$proximity_notification_radius <- self$proximity_notification_radius
      }
      if (!is.null(self$reply_markup)) {
        result$reply_markup <- if (inherits(self$reply_markup, "TLObject")) self$reply_markup$to_dict() else self$reply_markup
      }

      return(result)
    },

    #  @description
    #  Serializes the BotInlineMessageMediaGeo object to bytes.
    #  @return A raw vector representing the serialized bytes of the BotInlineMessageMediaGeo object.
    bytes = function() {
      flags <- 0
      if (!is.null(self$heading)) flags <- flags + 1 # 2^0
      if (!is.null(self$period)) flags <- flags + 2 # 2^1
      if (!is.null(self$proximity_notification_radius)) flags <- flags + 8 # 2^3
      if (!is.null(self$reply_markup)) flags <- flags + 4 # 2^2

      result <- list(
        as.raw(c(0xfd, 0x46, 0x18, 0x05)),
        writeBin(as.integer(flags), raw(), size = 4, endian = "little"),
        self$geo$`bytes`()
      )

      if (!is.null(self$heading)) {
        result <- append(result, list(writeBin(as.integer(self$heading), raw(), size = 4, endian = "little")))
      }
      if (!is.null(self$period)) {
        result <- append(result, list(writeBin(as.integer(self$period), raw(), size = 4, endian = "little")))
      }
      if (!is.null(self$proximity_notification_radius)) {
        result <- append(result, list(writeBin(as.integer(self$proximity_notification_radius), raw(), size = 4, endian = "little")))
      }
      if (!is.null(self$reply_markup)) {
        result <- append(result, list(self$reply_markup$`bytes`()))
      }

      return(do.call(c, result))
    }
  ),
  private = list(
    #  Reads a BotInlineMessageMediaGeo object from a BinaryReader.
    from_reader = function(reader) {
      flags <- reader$read_int()

      geo <- reader$tgread_object()

      heading <- NULL
      if (bitwAnd(flags, 1) != 0) {
        heading <- reader$read_int()
      }

      period <- NULL
      if (bitwAnd(flags, 2) != 0) {
        period <- reader$read_int()
      }

      proximity_notification_radius <- NULL
      if (bitwAnd(flags, 8) != 0) {
        proximity_notification_radius <- reader$read_int()
      }

      reply_markup <- NULL
      if (bitwAnd(flags, 4) != 0) {
        reply_markup <- reader$tgread_object()
      }

      return(BotInlineMessageMediaGeo$new(
        geo = geo,
        heading = heading,
        period = period,
        proximity_notification_radius = proximity_notification_radius,
        reply_markup = reply_markup
      ))
    }
  )
)

#  @title BotInlineMessageMediaInvoice
#  @description Telegram API type BotInlineMessageMediaInvoice
#  @export
#  @noRd
#  @noRd
BotInlineMessageMediaInvoice <- R6::R6Class(
  "BotInlineMessageMediaInvoice",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x354a9b09,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc4910f88,

    #  @field title Field.
    title = NULL,
    #  @field description Field.
    description = NULL,
    #  @field currency Field.
    currency = NULL,
    #  @field total_amount Field.
    total_amount = NULL,
    #  @field shipping_address_requested Field.
    shipping_address_requested = NULL,
    #  @field test Field.
    test = NULL,
    #  @field photo Field.
    photo = NULL,
    #  @field reply_markup Field.
    reply_markup = NULL,

    #  @description
    #  Initializes the BotInlineMessageMediaInvoice with the given parameters.
    #  @param title A string representing the title.
    #  @param description A string representing the description.
    #  @param currency A string representing the currency.
    #  @param total_amount An integer representing the total amount.
    #  @param shipping_address_requested A boolean indicating if shipping address is requested. Optional.
    #  @param test A boolean indicating if it's a test. Optional.
    #  @param photo A TLObject representing the photo. Optional.
    #  @param reply_markup A TLObject representing the reply markup. Optional.
    initialize = function(title, description, currency, total_amount, shipping_address_requested = NULL,
                          test = NULL, photo = NULL, reply_markup = NULL) {
      self$title <- title
      self$description <- description
      self$currency <- currency
      self$total_amount <- total_amount
      self$shipping_address_requested <- shipping_address_requested
      self$test <- test
      self$photo <- photo
      self$reply_markup <- reply_markup
    },

    #  @description
    #  Converts the BotInlineMessageMediaInvoice object to a list (dictionary).
    #  @return A list representation of the BotInlineMessageMediaInvoice object.
    to_dict = function() {
      result <- list(
        `_` = "BotInlineMessageMediaInvoice",
        title = self$title,
        description = self$description,
        currency = self$currency,
        total_amount = self$total_amount
      )

      if (!is.null(self$shipping_address_requested)) {
        result$shipping_address_requested <- self$shipping_address_requested
      }
      if (!is.null(self$test)) {
        result$test <- self$test
      }
      if (!is.null(self$photo)) {
        result$photo <- if (inherits(self$photo, "TLObject")) self$photo$to_dict() else self$photo
      }
      if (!is.null(self$reply_markup)) {
        result$reply_markup <- if (inherits(self$reply_markup, "TLObject")) self$reply_markup$to_dict() else self$reply_markup
      }

      return(result)
    },

    #  @description
    #  Serializes the BotInlineMessageMediaInvoice object to bytes.
    #  @return A raw vector representing the serialized bytes of the BotInlineMessageMediaInvoice object.
    bytes = function() {
      flags <- 0
      if (!is.null(self$shipping_address_requested)) flags <- flags + 2 # 2^1
      if (!is.null(self$test)) flags <- flags + 8 # 2^3
      if (!is.null(self$photo)) flags <- flags + 1 # 2^0
      if (!is.null(self$reply_markup)) flags <- flags + 4 # 2^2

      result <- list(
        as.raw(c(0x09, 0x9b, 0x4a, 0x35)),
        writeBin(as.integer(flags), raw(), size = 4, endian = "little"),
        self$serializebytes(self$title),
        self$serializebytes(self$description)
      )

      if (!is.null(self$photo)) {
        result <- append(result, list(self$photo$`bytes`()))
      }

      result <- append(result, list(
        self$serializebytes(self$currency),
        writeBin(as.numeric(self$total_amount), raw(), size = 8, endian = "little")
      ))

      if (!is.null(self$reply_markup)) {
        result <- append(result, list(self$reply_markup$`bytes`()))
      }

      return(do.call(c, result))
    }
  ),
  private = list(
    #  Reads a BotInlineMessageMediaInvoice object from a BinaryReader.
    from_reader = function(reader) {
      flags <- reader$read_int()

      shipping_address_requested <- NULL
      if (bitwAnd(flags, 2) != 0) {
        shipping_address_requested <- TRUE
      }

      test <- NULL
      if (bitwAnd(flags, 8) != 0) {
        test <- TRUE
      }

      title <- reader$tgread_string()
      description <- reader$tgread_string()

      photo <- NULL
      if (bitwAnd(flags, 1) != 0) {
        photo <- reader$tgread_object()
      }

      currency <- reader$tgread_string()
      total_amount <- reader$read_long()

      reply_markup <- NULL
      if (bitwAnd(flags, 4) != 0) {
        reply_markup <- reader$tgread_object()
      }

      return(BotInlineMessageMediaInvoice$new(
        title = title,
        description = description,
        currency = currency,
        total_amount = total_amount,
        shipping_address_requested = shipping_address_requested,
        test = test,
        photo = photo,
        reply_markup = reply_markup
      ))
    }
  )
)

#  @title BotInlineMessageMediaVenue
#  @description Telegram API type BotInlineMessageMediaVenue
#  @export
#  @noRd
#  @noRd
BotInlineMessageMediaVenue <- R6::R6Class(
  "BotInlineMessageMediaVenue",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8a86659c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc4910f88,

    #  @field geo Field.
    geo = NULL,
    #  @field title Field.
    title = NULL,
    #  @field address Field.
    address = NULL,
    #  @field provider Field.
    provider = NULL,
    #  @field venue_id Field.
    venue_id = NULL,
    #  @field venue_type Field.
    venue_type = NULL,
    #  @field reply_markup Field.
    reply_markup = NULL,

    #  @description
    #  Initializes the BotInlineMessageMediaVenue with the given parameters.
    #  @param geo A TLObject representing the geo point.
    #  @param title A string representing the title.
    #  @param address A string representing the address.
    #  @param provider A string representing the provider.
    #  @param venue_id A string representing the venue ID.
    #  @param venue_type A string representing the venue type.
    #  @param reply_markup A TLObject representing the reply markup. Optional.
    initialize = function(geo, title, address, provider, venue_id, venue_type, reply_markup = NULL) {
      self$geo <- geo
      self$title <- title
      self$address <- address
      self$provider <- provider
      self$venue_id <- venue_id
      self$venue_type <- venue_type
      self$reply_markup <- reply_markup
    },

    #  @description
    #  Converts the BotInlineMessageMediaVenue object to a list (dictionary).
    #  @return A list representation of the BotInlineMessageMediaVenue object.
    to_dict = function() {
      result <- list(
        `_` = "BotInlineMessageMediaVenue",
        geo = if (inherits(self$geo, "TLObject")) self$geo$to_dict() else self$geo,
        title = self$title,
        address = self$address,
        provider = self$provider,
        venue_id = self$venue_id,
        venue_type = self$venue_type
      )

      if (!is.null(self$reply_markup)) {
        result$reply_markup <- if (inherits(self$reply_markup, "TLObject")) self$reply_markup$to_dict() else self$reply_markup
      }

      return(result)
    },

    #  @description
    #  Serializes the BotInlineMessageMediaVenue object to bytes.
    #  @return A raw vector representing the serialized bytes of the BotInlineMessageMediaVenue object.
    bytes = function() {
      flags <- 0
      if (!is.null(self$reply_markup)) flags <- flags + 4 # 2^2

      result <- list(
        as.raw(c(0x9c, 0x65, 0x86, 0x8a)),
        writeBin(as.integer(flags), raw(), size = 4, endian = "little"),
        self$geo$`bytes`(),
        self$serializebytes(self$title),
        self$serializebytes(self$address),
        self$serializebytes(self$provider),
        self$serializebytes(self$venue_id),
        self$serializebytes(self$venue_type)
      )

      if (!is.null(self$reply_markup)) {
        result <- append(result, list(self$reply_markup$`bytes`()))
      }

      return(do.call(c, result))
    }
  ),
  private = list(
    #  Reads a BotInlineMessageMediaVenue object from a BinaryReader.
    from_reader = function(reader) {
      flags <- reader$read_int()

      geo <- reader$tgread_object()
      title <- reader$tgread_string()
      address <- reader$tgread_string()
      provider <- reader$tgread_string()
      venue_id <- reader$tgread_string()
      venue_type <- reader$tgread_string()

      reply_markup <- NULL
      if (bitwAnd(flags, 4) != 0) {
        reply_markup <- reader$tgread_object()
      }

      return(BotInlineMessageMediaVenue$new(
        geo = geo,
        title = title,
        address = address,
        provider = provider,
        venue_id = venue_id,
        venue_type = venue_type,
        reply_markup = reply_markup
      ))
    }
  )
)

#  @title BotInlineMessageMediaWebPage
#  @description Telegram API type BotInlineMessageMediaWebPage
#  @export
#  @noRd
#  @noRd
BotInlineMessageMediaWebPage <- R6::R6Class(
  "BotInlineMessageMediaWebPage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x809ad9a6,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc4910f88,
    #  @field message Field.
    message = NULL,
    #  @field url Field.
    url = NULL,
    #  @field invert_media Field.
    invert_media = NULL,
    #  @field force_large_media Field.
    force_large_media = NULL,
    #  @field force_small_media Field.
    force_small_media = NULL,
    #  @field manual Field.
    manual = NULL,
    #  @field safe Field.
    safe = NULL,
    #  @field entities Field.
    entities = NULL,
    #  @field reply_markup Field.
    reply_markup = NULL,
    initialize = function(message, url, invert_media = NULL, force_large_media = NULL, force_small_media = NULL, manual = NULL, safe = NULL, entities = NULL, reply_markup = NULL) {
      self$message <- message
      self$url <- url
      self$invert_media <- invert_media
      self$force_large_media <- force_large_media
      self$force_small_media <- force_small_media
      self$manual <- manual
      self$safe <- safe
      self$entities <- entities
      self$reply_markup <- reply_markup
    },
    to_dict = function() {
      dict <- list(
        "_" = "BotInlineMessageMediaWebPage",
        "message" = self$message,
        "url" = self$url,
        "invert_media" = self$invert_media,
        "force_large_media" = self$force_large_media,
        "force_small_media" = self$force_small_media,
        "manual" = self$manual,
        "safe" = self$safe,
        "entities" = if (is.null(self$entities)) list() else lapply(self$entities, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        "reply_markup" = if (inherits(self$reply_markup, "TLObject")) self$reply_markup$to_dict() else self$reply_markup
      )
      dict
    }
  ),
  active = list(
    serialize = function() {
      flag_values <- c(
        if (is.null(self$invert_media) || !self$invert_media) 0 else 8,
        if (is.null(self$force_large_media) || !self$force_large_media) 0 else 16,
        if (is.null(self$force_small_media) || !self$force_small_media) 0 else 32,
        if (is.null(self$manual) || !self$manual) 0 else 128,
        if (is.null(self$safe) || !self$safe) 0 else 256,
        if (is.null(self$entities)) 0 else 2,
        if (is.null(self$reply_markup)) 0 else 4
      )

      flags <- Reduce(bitwOr, as.integer(flag_values), init = 0L)

      result <- c(
        packInt32(self$CONSTRUCTOR_ID),
        writeBin(flags, raw(), size = 4, endian = "little"),
        self$serializebytes(self$message)
      )

      if (!is.null(self$entities)) {
        result <- c(
          result,
          writeBin(as.integer(0x15c4b51c), raw(), size = 4, endian = "little"),
          writeBin(length(self$entities), raw(), size = 4, endian = "little"),
          unlist(lapply(self$entities, function(x) x$serialize()))
        )
      }

      result <- c(result, self$serializebytes(self$url))

      if (!is.null(self$reply_markup)) {
        result <- c(result, self$reply_markup$serialize())
      }

      result
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      invert_media <- bitwAnd(flags, 8) != 0
      force_large_media <- bitwAnd(flags, 16) != 0
      force_small_media <- bitwAnd(flags, 32) != 0
      manual <- bitwAnd(flags, 128) != 0
      safe <- bitwAnd(flags, 256) != 0

      message <- reader$tgread_string()

      entities <- NULL
      if (bitwAnd(flags, 2) != 0) {
        reader$read_int() # vector constructor
        entities_count <- reader$read_int()
        entities <- lapply(1:entities_count, function(i) reader$tgread_object())
      }

      url <- reader$tgread_string()

      reply_markup <- NULL
      if (bitwAnd(flags, 4) != 0) {
        reply_markup <- reader$tgread_object()
      }

      self$initialize(message, url, invert_media, force_large_media, force_small_media, manual, safe, entities, reply_markup)
    }
  )
)

#  @title BotInlineMessageText
#  @description Telegram API type BotInlineMessageText
#  @export
#  @noRd
#  @noRd
BotInlineMessageText <- R6::R6Class(
  "BotInlineMessageText",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8c7f65e2,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc4910f88,
    #  @field message Field.
    message = NULL,
    #  @field no_webpage Field.
    no_webpage = NULL,
    #  @field invert_media Field.
    invert_media = NULL,
    #  @field entities Field.
    entities = NULL,
    #  @field reply_markup Field.
    reply_markup = NULL,
    initialize = function(message, no_webpage = NULL, invert_media = NULL, entities = NULL, reply_markup = NULL) {
      self$message <- message
      self$no_webpage <- no_webpage
      self$invert_media <- invert_media
      self$entities <- entities
      self$reply_markup <- reply_markup
    },
    to_dict = function() {
      dict <- list(
        "_" = "BotInlineMessageText",
        "message" = self$message,
        "no_webpage" = self$no_webpage,
        "invert_media" = self$invert_media,
        "entities" = if (is.null(self$entities)) list() else lapply(self$entities, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        "reply_markup" = if (inherits(self$reply_markup, "TLObject")) self$reply_markup$to_dict() else self$reply_markup
      )
      dict
    }
  ),
  active = list(
    serialize = function() {
      flag_values <- c(
        if (is.null(self$no_webpage) || !self$no_webpage) 0 else 1,
        if (is.null(self$invert_media) || !self$invert_media) 0 else 8,
        if (is.null(self$entities)) 0 else 2,
        if (is.null(self$reply_markup)) 0 else 4
      )

      flags <- Reduce(bitwOr, as.integer(flag_values), init = 0L)

      result <- c(
        packInt32(self$CONSTRUCTOR_ID),
        writeBin(flags, raw(), size = 4, endian = "little"),
        self$serializebytes(self$message)
      )

      if (!is.null(self$entities)) {
        result <- c(
          result,
          writeBin(as.integer(0x15c4b51c), raw(), size = 4, endian = "little"),
          writeBin(length(self$entities), raw(), size = 4, endian = "little"),
          unlist(lapply(self$entities, function(x) x$serialize()))
        )
      }

      if (!is.null(self$reply_markup)) {
        result <- c(result, self$reply_markup$serialize())
      }

      result
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      no_webpage <- bitwAnd(flags, 1) != 0
      invert_media <- bitwAnd(flags, 8) != 0

      message <- reader$tgread_string()

      entities <- NULL
      if (bitwAnd(flags, 2) != 0) {
        reader$read_int() # vector constructor
        entities_count <- reader$read_int()
        entities <- lapply(1:entities_count, function(i) reader$tgread_object())
      }

      reply_markup <- NULL
      if (bitwAnd(flags, 4) != 0) {
        reply_markup <- reader$tgread_object()
      }

      self$initialize(message, no_webpage, invert_media, entities, reply_markup)
    }
  )
)

#  @title BotInlineResult
#  @description Telegram API type BotInlineResult
#  @export
#  @noRd
#  @noRd
BotInlineResult <- R6::R6Class(
  "BotInlineResult",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x11965f3a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x3832b3d5,
    #  @field id Field.
    id = NULL,
    #  @field type Field.
    type = NULL,
    #  @field send_message Field.
    send_message = NULL,
    #  @field title Field.
    title = NULL,
    #  @field description Field.
    description = NULL,
    #  @field url Field.
    url = NULL,
    #  @field thumb Field.
    thumb = NULL,
    #  @field content Field.
    content = NULL,
    initialize = function(id, type, send_message, title = NULL, description = NULL, url = NULL, thumb = NULL, content = NULL) {
      self$id <- id
      self$type <- type
      self$send_message <- send_message
      self$title <- title
      self$description <- description
      self$url <- url
      self$thumb <- thumb
      self$content <- content
    },
    to_dict = function() {
      dict <- list(
        "_" = "BotInlineResult",
        "id" = self$id,
        "type" = self$type,
        "send_message" = if (inherits(self$send_message, "TLObject")) self$send_message$to_dict() else self$send_message,
        "title" = self$title,
        "description" = self$description,
        "url" = self$url,
        "thumb" = if (inherits(self$thumb, "TLObject")) self$thumb$to_dict() else self$thumb,
        "content" = if (inherits(self$content, "TLObject")) self$content$to_dict() else self$content
      )
      dict
    }
  ),
  active = list(
    serialize = function() {
      flag_values <- c(
        if (is.null(self$title)) 0 else 2,
        if (is.null(self$description)) 0 else 4,
        if (is.null(self$url)) 0 else 8,
        if (is.null(self$thumb)) 0 else 16,
        if (is.null(self$content)) 0 else 32
      )

      flags <- Reduce(bitwOr, as.integer(flag_values), init = 0L)

      result <- c(
        packInt32(self$CONSTRUCTOR_ID),
        writeBin(flags, raw(), size = 4, endian = "little"),
        self$serializebytes(self$id),
        self$serializebytes(self$type)
      )

      if (!is.null(self$title)) {
        result <- c(result, self$serializebytes(self$title))
      }

      if (!is.null(self$description)) {
        result <- c(result, self$serializebytes(self$description))
      }

      if (!is.null(self$url)) {
        result <- c(result, self$serializebytes(self$url))
      }

      if (!is.null(self$thumb)) {
        result <- c(result, self$thumb$serialize())
      }

      if (!is.null(self$content)) {
        result <- c(result, self$content$serialize())
      }

      result <- c(result, self$send_message$serialize())

      result
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      id <- reader$tgread_string()
      type <- reader$tgread_string()

      title <- NULL
      if (bitwAnd(flags, 2) != 0) {
        title <- reader$tgread_string()
      }

      description <- NULL
      if (bitwAnd(flags, 4) != 0) {
        description <- reader$tgread_string()
      }

      url <- NULL
      if (bitwAnd(flags, 8) != 0) {
        url <- reader$tgread_string()
      }

      thumb <- NULL
      if (bitwAnd(flags, 16) != 0) {
        thumb <- reader$tgread_object()
      }

      content <- NULL
      if (bitwAnd(flags, 32) != 0) {
        content <- reader$tgread_object()
      }

      send_message <- reader$tgread_object()

      self$initialize(id, type, send_message, title, description, url, thumb, content)
    }
  )
)

#  @title BotMenuButton
#  @description Telegram API type BotMenuButton
#  @export
#  @noRd
#  @noRd
BotMenuButton <- R6::R6Class(
  "BotMenuButton",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc7b57ce6,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x4c71bd3c,
    #  @field text Field.
    text = NULL,
    #  @field url Field.
    url = NULL,
    initialize = function(text, url) {
      self$text <- text
      self$url <- url
    },
    to_dict = function() {
      dict <- list(
        "_" = "BotMenuButton",
        "text" = self$text,
        "url" = self$url
      )
      dict
    }
  ),
  active = list(
    serialize = function() {
      result <- c(
        packInt32(self$CONSTRUCTOR_ID),
        self$serializebytes(self$text),
        self$serializebytes(self$url)
      )
      result
    }
  ),
  private = list(
    from_reader = function(reader) {
      text <- reader$tgread_string()
      url <- reader$tgread_string()
      self$initialize(text, url)
    }
  )
)

#  @title BotMenuButtonCommands
#  @description Telegram API type BotMenuButtonCommands
#  @export
#  @noRd
#  @noRd
BotMenuButtonCommands <- R6::R6Class(
  "BotMenuButtonCommands",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4258c205,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x4c71bd3c,
    initialize = function() {
      # No parameters
    },
    to_dict = function() {
      dict <- list(
        "_" = "BotMenuButtonCommands"
      )
      dict
    }
  ),
  active = list(
    serialize = function() {
      result <- packInt32(self$CONSTRUCTOR_ID)
      result
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$initialize()
    }
  )
)

#  @title BotMenuButtonDefault
#  @description Telegram API type BotMenuButtonDefault
#  @export
#  @noRd
#  @noRd
BotMenuButtonDefault <- R6::R6Class(
  "BotMenuButtonDefault",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7533a588,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x4c71bd3c,
    initialize = function() {
      # No parameters
    },
    to_dict = function() {
      dict <- list(
        "_" = "BotMenuButtonDefault"
      )
      dict
    }
  ),
  active = list(
    serialize = function() {
      result <- packInt32(self$CONSTRUCTOR_ID)
      result
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$initialize()
    }
  )
)

#  @title BotPreviewMedia
#  @description Telegram API type BotPreviewMedia
#  @export
#  @noRd
#  @noRd
BotPreviewMedia <- R6::R6Class(
  "BotPreviewMedia",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x23e91ba3,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x562abc2d,
    #  @field date Field.
    date = NULL,
    #  @field media Field.
    media = NULL,
    initialize = function(date = NULL, media) {
      self$date <- date
      self$media <- media
    },
    to_dict = function() {
      dict <- list(
        "_" = "BotPreviewMedia",
        "date" = self$date,
        "media" = if (inherits(self$media, "TLObject")) self$media$to_dict() else self$media
      )
      dict
    }
  ),
  active = list(
    serialize = function() {
      result <- c(
        packInt32(self$CONSTRUCTOR_ID),
        self$serialize_datetime(self$date),
        self$media$serialize()
      )
      result
    }
  ),
  private = list(
    from_reader = function(reader) {
      date <- reader$tgread_date()
      media <- reader$tgread_object()
      self$initialize(date, media)
    }
  )
)

#  @title BotVerification
#  @description Telegram API type BotVerification
#  @export
#  @noRd
#  @noRd
BotVerification <- R6::R6Class(
  "BotVerification",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf93cd45c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x2cbf3c5a,
    #  @field bot_id Field.
    bot_id = NULL,
    #  @field icon Field.
    icon = NULL,
    #  @field description Field.
    description = NULL,
    initialize = function(bot_id, icon, description) {
      self$bot_id <- bot_id
      self$icon <- icon
      self$description <- description
    },
    to_dict = function() {
      dict <- list(
        "_" = "BotVerification",
        "bot_id" = self$bot_id,
        "icon" = self$icon,
        "description" = self$description
      )
      dict
    }
  ),
  active = list(
    serialize = function() {
      result <- c(
        packInt32(self$CONSTRUCTOR_ID),
        writeBin(self$bot_id, raw(), size = 8, endian = "little"),
        writeBin(self$icon, raw(), size = 8, endian = "little"),
        self$serializebytes(self$description)
      )
      result
    }
  ),
  private = list(
    from_reader = function(reader) {
      bot_id <- reader$read_long()
      icon <- reader$read_long()
      description <- reader$tgread_string()
      self$initialize(bot_id, icon, description)
    }
  )
)

#  @title BotVerifierSettings
#  @description Telegram API type BotVerifierSettings
#  @export
#  @noRd
#  @noRd
BotVerifierSettings <- R6::R6Class(
  "BotVerifierSettings",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb0cd6617,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf1d6034c,
    #  @field icon Field.
    icon = NULL,
    #  @field company Field.
    company = NULL,
    #  @field can_modify_custom_description Field.
    can_modify_custom_description = NULL,
    #  @field custom_description Field.
    custom_description = NULL,
    initialize = function(icon, company, can_modify_custom_description = NULL, custom_description = NULL) {
      self$icon <- icon
      self$company <- company
      self$can_modify_custom_description <- can_modify_custom_description
      self$custom_description <- custom_description
    },
    to_dict = function() {
      dict <- list(
        "_" = "BotVerifierSettings",
        "icon" = self$icon,
        "company" = self$company,
        "can_modify_custom_description" = self$can_modify_custom_description,
        "custom_description" = self$custom_description
      )
      dict
    }
  ),
  active = list(
    serialize = function() {
      flags <- bitwOr(
        if (is.null(self$can_modify_custom_description) || !self$can_modify_custom_description) 0 else 2,
        if (is.null(self$custom_description)) 0 else 1
      )

      result <- c(
        packInt32(self$CONSTRUCTOR_ID),
        writeBin(flags, raw(), size = 4, endian = "little"),
        writeBin(self$icon, raw(), size = 8, endian = "little"),
        self$serializebytes(self$company)
      )

      if (!is.null(self$custom_description)) {
        result <- c(result, self$serializebytes(self$custom_description))
      }

      result
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      can_modify_custom_description <- bitwAnd(flags, 2) != 0
      icon <- reader$read_long()
      company <- reader$tgread_string()

      custom_description <- NULL
      if (bitwAnd(flags, 1) != 0) {
        custom_description <- reader$tgread_string()
      }

      self$initialize(icon, company, can_modify_custom_description, custom_description)
    }
  )
)

#  @title BusinessAwayMessage
#  @description Telegram API type BusinessAwayMessage
#  @export
#  @noRd
#  @noRd
BusinessAwayMessage <- R6::R6Class(
  "BusinessAwayMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xef156a5c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf1d3ae24,
    #  @field shortcut_id Field.
    shortcut_id = NULL,
    #  @field schedule Field.
    schedule = NULL,
    #  @field recipients Field.
    recipients = NULL,
    #  @field offline_only Field.
    offline_only = NULL,
    initialize = function(shortcut_id, schedule, recipients, offline_only = NULL) {
      self$shortcut_id <- shortcut_id
      self$schedule <- schedule
      self$recipients <- recipients
      self$offline_only <- offline_only
    },
    to_dict = function() {
      dict <- list(
        "_" = "BusinessAwayMessage",
        "shortcut_id" = self$shortcut_id,
        "schedule" = if (inherits(self$schedule, "TLObject")) self$schedule$to_dict() else self$schedule,
        "recipients" = if (inherits(self$recipients, "TLObject")) self$recipients$to_dict() else self$recipients,
        "offline_only" = self$offline_only
      )
      dict
    }
  ),
  active = list(
    serialize = function() {
      flags <- if (is.null(self$offline_only) || !self$offline_only) 0 else 1

      result <- c(
        packInt32(self$CONSTRUCTOR_ID),
        writeBin(flags, raw(), size = 4, endian = "little"),
        writeBin(self$shortcut_id, raw(), size = 4, endian = "little"),
        self$schedule$serialize(),
        self$recipients$serialize()
      )
      result
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      offline_only <- bitwAnd(flags, 1) != 0
      shortcut_id <- reader$read_int()
      schedule <- reader$tgread_object()
      recipients <- reader$tgread_object()

      self$initialize(shortcut_id, schedule, recipients, offline_only)
    }
  )
)

#  @title BusinessAwayMessageScheduleAlways
#  @description Telegram API type BusinessAwayMessageScheduleAlways
#  @export
#  @noRd
#  @noRd
BusinessAwayMessageScheduleAlways <- R6::R6Class(
  "BusinessAwayMessageScheduleAlways",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc9b9e2b9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x2818a05e,
    initialize = function() {
      # No parameters
    },
    to_dict = function() {
      dict <- list(
        "_" = "BusinessAwayMessageScheduleAlways"
      )
      dict
    }
  ),
  active = list(
    serialize = function() {
      result <- packInt32(self$CONSTRUCTOR_ID)
      result
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$initialize()
    }
  )
)

#  @title BusinessAwayMessageScheduleCustom
#  @description Telegram API type BusinessAwayMessageScheduleCustom
#  @export
#  @noRd
#  @noRd
BusinessAwayMessageScheduleCustom <- R6::R6Class(
  "BusinessAwayMessageScheduleCustom",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xcc4d9ecc,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x2818a05e,
    #  @field start_date Field.
    start_date = NULL,
    #  @field end_date Field.
    end_date = NULL,
    initialize = function(start_date = NULL, end_date = NULL) {
      self$start_date <- start_date
      self$end_date <- end_date
    },
    to_dict = function() {
      dict <- list(
        "_" = "BusinessAwayMessageScheduleCustom",
        "start_date" = self$start_date,
        "end_date" = self$end_date
      )
      dict
    }
  ),
  active = list(
    serialize = function() {
      result <- c(
        packInt32(self$CONSTRUCTOR_ID),
        self$serialize_datetime(self$start_date),
        self$serialize_datetime(self$end_date)
      )
      result
    }
  ),
  private = list(
    from_reader = function(reader) {
      start_date <- reader$tgread_date()
      end_date <- reader$tgread_date()
      self$initialize(start_date, end_date)
    }
  )
)

#  @title BusinessAwayMessageScheduleOutsideWorkHours
#  @description Telegram API type BusinessAwayMessageScheduleOutsideWorkHours
#  @export
#  @noRd
#  @noRd
BusinessAwayMessageScheduleOutsideWorkHours <- R6::R6Class(
  "BusinessAwayMessageScheduleOutsideWorkHours",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc3f2f501,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x2818a05e,
    initialize = function() {
      # No parameters
    },
    to_dict = function() {
      dict <- list(
        "_" = "BusinessAwayMessageScheduleOutsideWorkHours"
      )
      dict
    }
  ),
  active = list(
    serialize = function() {
      result <- packInt32(self$CONSTRUCTOR_ID)
      result
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$initialize()
    }
  )
)

#  @title BusinessBotRecipients
#  @description Telegram API type BusinessBotRecipients
#  @export
#  @noRd
#  @noRd
BusinessBotRecipients <- R6::R6Class(
  "BusinessBotRecipients",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb88cf373,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf09283ca,
    #  @field existing_chats Field.
    existing_chats = NULL,
    #  @field new_chats Field.
    new_chats = NULL,
    #  @field contacts Field.
    contacts = NULL,
    #  @field non_contacts Field.
    non_contacts = NULL,
    #  @field exclude_selected Field.
    exclude_selected = NULL,
    #  @field users Field.
    users = NULL,
    #  @field exclude_users Field.
    exclude_users = NULL,
    initialize = function(existing_chats = NULL, new_chats = NULL, contacts = NULL, non_contacts = NULL, exclude_selected = NULL, users = NULL, exclude_users = NULL) {
      self$existing_chats <- existing_chats
      self$new_chats <- new_chats
      self$contacts <- contacts
      self$non_contacts <- non_contacts
      self$exclude_selected <- exclude_selected
      self$users <- users
      self$exclude_users <- exclude_users
    },
    to_dict = function() {
      dict <- list(
        "_" = "BusinessBotRecipients",
        "existing_chats" = self$existing_chats,
        "new_chats" = self$new_chats,
        "contacts" = self$contacts,
        "non_contacts" = self$non_contacts,
        "exclude_selected" = self$exclude_selected,
        "users" = if (is.null(self$users)) list() else self$users,
        "exclude_users" = if (is.null(self$exclude_users)) list() else self$exclude_users
      )
      dict
    }
  ),
  active = list(
    serialize = function() {
      flag_values <- c(
        if (is.null(self$existing_chats) || !self$existing_chats) 0 else 1,
        if (is.null(self$new_chats) || !self$new_chats) 0 else 2,
        if (is.null(self$contacts) || !self$contacts) 0 else 4,
        if (is.null(self$non_contacts) || !self$non_contacts) 0 else 8,
        if (is.null(self$exclude_selected) || !self$exclude_selected) 0 else 32,
        if (is.null(self$users)) 0 else 16,
        if (is.null(self$exclude_users)) 0 else 64
      )

      flags <- Reduce(bitwOr, as.integer(flag_values), init = 0L)

      result <- c(
        packInt32(self$CONSTRUCTOR_ID),
        writeBin(flags, raw(), size = 4, endian = "little")
      )

      if (!is.null(self$users)) {
        result <- c(
          result,
          writeBin(as.integer(0x15c4b51c), raw(), size = 4, endian = "little"),
          writeBin(length(self$users), raw(), size = 4, endian = "little"),
          unlist(lapply(self$users, function(x) writeBin(x, raw(), size = 8, endian = "little")))
        )
      }

      if (!is.null(self$exclude_users)) {
        result <- c(
          result,
          writeBin(as.integer(0x15c4b51c), raw(), size = 4, endian = "little"),
          writeBin(length(self$exclude_users), raw(), size = 4, endian = "little"),
          unlist(lapply(self$exclude_users, function(x) writeBin(x, raw(), size = 8, endian = "little")))
        )
      }

      result
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      existing_chats <- bitwAnd(flags, 1) != 0
      new_chats <- bitwAnd(flags, 2) != 0
      contacts <- bitwAnd(flags, 4) != 0
      non_contacts <- bitwAnd(flags, 8) != 0
      exclude_selected <- bitwAnd(flags, 32) != 0

      users <- NULL
      if (bitwAnd(flags, 16) != 0) {
        reader$read_int() # vector constructor
        users_count <- reader$read_int()
        users <- lapply(1:users_count, function(i) reader$read_long())
      }

      exclude_users <- NULL
      if (bitwAnd(flags, 64) != 0) {
        reader$read_int() # vector constructor
        exclude_users_count <- reader$read_int()
        exclude_users <- lapply(1:exclude_users_count, function(i) reader$read_long())
      }

      self$initialize(existing_chats, new_chats, contacts, non_contacts, exclude_selected, users, exclude_users)
    }
  )
)

#  @title BusinessBotRights
#  @description Telegram API type BusinessBotRights
#  @export
#  @noRd
#  @noRd
BusinessBotRights <- R6::R6Class(
  "BusinessBotRights",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa0624cf7,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb8dc759a,
    #  @field reply Field.
    reply = NULL,
    #  @field read_messages Field.
    read_messages = NULL,
    #  @field delete_sent_messages Field.
    delete_sent_messages = NULL,
    #  @field delete_received_messages Field.
    delete_received_messages = NULL,
    #  @field edit_name Field.
    edit_name = NULL,
    #  @field edit_bio Field.
    edit_bio = NULL,
    #  @field edit_profile_photo Field.
    edit_profile_photo = NULL,
    #  @field edit_username Field.
    edit_username = NULL,
    #  @field view_gifts Field.
    view_gifts = NULL,
    #  @field sell_gifts Field.
    sell_gifts = NULL,
    #  @field change_gift_settings Field.
    change_gift_settings = NULL,
    #  @field transfer_and_upgrade_gifts Field.
    transfer_and_upgrade_gifts = NULL,
    #  @field transfer_stars Field.
    transfer_stars = NULL,
    #  @field manage_stories Field.
    manage_stories = NULL,
    initialize = function(reply = NULL, read_messages = NULL, delete_sent_messages = NULL, delete_received_messages = NULL, edit_name = NULL, edit_bio = NULL, edit_profile_photo = NULL, edit_username = NULL, view_gifts = NULL, sell_gifts = NULL, change_gift_settings = NULL, transfer_and_upgrade_gifts = NULL, transfer_stars = NULL, manage_stories = NULL) {
      self$reply <- reply
      self$read_messages <- read_messages
      self$delete_sent_messages <- delete_sent_messages
      self$delete_received_messages <- delete_received_messages
      self$edit_name <- edit_name
      self$edit_bio <- edit_bio
      self$edit_profile_photo <- edit_profile_photo
      self$edit_username <- edit_username
      self$view_gifts <- view_gifts
      self$sell_gifts <- sell_gifts
      self$change_gift_settings <- change_gift_settings
      self$transfer_and_upgrade_gifts <- transfer_and_upgrade_gifts
      self$transfer_stars <- transfer_stars
      self$manage_stories <- manage_stories
    },
    to_dict = function() {
      dict <- list(
        "_" = "BusinessBotRights",
        "reply" = self$reply,
        "read_messages" = self$read_messages,
        "delete_sent_messages" = self$delete_sent_messages,
        "delete_received_messages" = self$delete_received_messages,
        "edit_name" = self$edit_name,
        "edit_bio" = self$edit_bio,
        "edit_profile_photo" = self$edit_profile_photo,
        "edit_username" = self$edit_username,
        "view_gifts" = self$view_gifts,
        "sell_gifts" = self$sell_gifts,
        "change_gift_settings" = self$change_gift_settings,
        "transfer_and_upgrade_gifts" = self$transfer_and_upgrade_gifts,
        "transfer_stars" = self$transfer_stars,
        "manage_stories" = self$manage_stories
      )
      dict
    }
  ),
  active = list(
    serialize = function() {
      flag_values <- c(
        if (is.null(self$reply) || !self$reply) 0 else 1,
        if (is.null(self$read_messages) || !self$read_messages) 0 else 2,
        if (is.null(self$delete_sent_messages) || !self$delete_sent_messages) 0 else 4,
        if (is.null(self$delete_received_messages) || !self$delete_received_messages) 0 else 8,
        if (is.null(self$edit_name) || !self$edit_name) 0 else 16,
        if (is.null(self$edit_bio) || !self$edit_bio) 0 else 32,
        if (is.null(self$edit_profile_photo) || !self$edit_profile_photo) 0 else 64,
        if (is.null(self$edit_username) || !self$edit_username) 0 else 128,
        if (is.null(self$view_gifts) || !self$view_gifts) 0 else 256,
        if (is.null(self$sell_gifts) || !self$sell_gifts) 0 else 512,
        if (is.null(self$change_gift_settings) || !self$change_gift_settings) 0 else 1024,
        if (is.null(self$transfer_and_upgrade_gifts) || !self$transfer_and_upgrade_gifts) 0 else 2048,
        if (is.null(self$transfer_stars) || !self$transfer_stars) 0 else 4096,
        if (is.null(self$manage_stories) || !self$manage_stories) 0 else 8192
      )

      flags <- Reduce(bitwOr, as.integer(flag_values), init = 0L)

      result <- c(
        packInt32(self$CONSTRUCTOR_ID),
        writeBin(flags, raw(), size = 4, endian = "little")
      )
      result
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      reply <- bitwAnd(flags, 1) != 0
      read_messages <- bitwAnd(flags, 2) != 0
      delete_sent_messages <- bitwAnd(flags, 4) != 0
      delete_received_messages <- bitwAnd(flags, 8) != 0
      edit_name <- bitwAnd(flags, 16) != 0
      edit_bio <- bitwAnd(flags, 32) != 0
      edit_profile_photo <- bitwAnd(flags, 64) != 0
      edit_username <- bitwAnd(flags, 128) != 0
      view_gifts <- bitwAnd(flags, 256) != 0
      sell_gifts <- bitwAnd(flags, 512) != 0
      change_gift_settings <- bitwAnd(flags, 1024) != 0
      transfer_and_upgrade_gifts <- bitwAnd(flags, 2048) != 0
      transfer_stars <- bitwAnd(flags, 4096) != 0
      manage_stories <- bitwAnd(flags, 8192) != 0

      self$initialize(reply, read_messages, delete_sent_messages, delete_received_messages, edit_name, edit_bio, edit_profile_photo, edit_username, view_gifts, sell_gifts, change_gift_settings, transfer_and_upgrade_gifts, transfer_stars, manage_stories)
    }
  )
)

#  @title BusinessChatLink
#  @description Telegram API type BusinessChatLink
#  @export
#  @noRd
#  @noRd
BusinessChatLink <- R6::R6Class(
  "BusinessChatLink",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb4ae666f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x3c0d4a8b,
    #  @field link Field.
    link = NULL,
    #  @field message Field.
    message = NULL,
    #  @field views Field.
    views = NULL,
    #  @field entities Field.
    entities = NULL,
    #  @field title Field.
    title = NULL,
    initialize = function(link, message, views, entities = NULL, title = NULL) {
      self$link <- link
      self$message <- message
      self$views <- views
      self$entities <- entities
      self$title <- title
    },
    to_dict = function() {
      dict <- list(
        "_" = "BusinessChatLink",
        "link" = self$link,
        "message" = self$message,
        "views" = self$views,
        "entities" = if (is.null(self$entities)) list() else lapply(self$entities, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        "title" = self$title
      )
      dict
    }
  ),
  active = list(
    serialize = function() {
      flags <- bitwOr(
        if (is.null(self$entities)) 0 else 1,
        if (is.null(self$title)) 0 else 2
      )

      result <- c(
        packInt32(self$CONSTRUCTOR_ID),
        writeBin(flags, raw(), size = 4, endian = "little"),
        self$serializebytes(self$link),
        self$serializebytes(self$message)
      )

      if (!is.null(self$entities)) {
        result <- c(
          result,
          writeBin(as.integer(0x15c4b51c), raw(), size = 4, endian = "little"),
          writeBin(length(self$entities), raw(), size = 4, endian = "little"),
          unlist(lapply(self$entities, function(x) x$serialize()))
        )
      }

      if (!is.null(self$title)) {
        result <- c(result, self$serializebytes(self$title))
      }

      result <- c(result, writeBin(self$views, raw(), size = 4, endian = "little"))
      result
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      link <- reader$tgread_string()
      message <- reader$tgread_string()

      entities <- NULL
      if (bitwAnd(flags, 1) != 0) {
        reader$read_int() # vector constructor
        entities_count <- reader$read_int()
        entities <- lapply(1:entities_count, function(i) reader$tgread_object())
      }

      title <- NULL
      if (bitwAnd(flags, 2) != 0) {
        title <- reader$tgread_string()
      }

      views <- reader$read_int()

      self$initialize(link, message, views, entities, title)
    }
  )
)

#  @title BusinessGreetingMessage
#  @description Telegram API type BusinessGreetingMessage
#  @export
#  @noRd
#  @noRd
BusinessGreetingMessage <- R6::R6Class(
  "BusinessGreetingMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe519abab,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb344eace,
    #  @field shortcut_id Field.
    shortcut_id = NULL,
    #  @field recipients Field.
    recipients = NULL,
    #  @field no_activity_days Field.
    no_activity_days = NULL,
    initialize = function(shortcut_id, recipients, no_activity_days) {
      self$shortcut_id <- shortcut_id
      self$recipients <- recipients
      self$no_activity_days <- no_activity_days
    },
    to_dict = function() {
      dict <- list(
        "_" = "BusinessGreetingMessage",
        "shortcut_id" = self$shortcut_id,
        "recipients" = if (inherits(self$recipients, "TLObject")) self$recipients$to_dict() else self$recipients,
        "no_activity_days" = self$no_activity_days
      )
      dict
    }
  ),
  active = list(
    serialize = function() {
      result <- c(
        packInt32(self$CONSTRUCTOR_ID),
        writeBin(self$shortcut_id, raw(), size = 4, endian = "little"),
        self$recipients$serialize(),
        writeBin(self$no_activity_days, raw(), size = 4, endian = "little")
      )
      result
    }
  ),
  private = list(
    from_reader = function(reader) {
      shortcut_id <- reader$read_int()
      recipients <- reader$tgread_object()
      no_activity_days <- reader$read_int()
      self$initialize(shortcut_id, recipients, no_activity_days)
    }
  )
)

#  @title BusinessIntro
#  @description Telegram API type BusinessIntro
#  @export
#  @noRd
#  @noRd
BusinessIntro <- R6::R6Class(
  "BusinessIntro",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5a0a066d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x6504d3c7,
    #  @field title Field.
    title = NULL,
    #  @field description Field.
    description = NULL,
    #  @field sticker Field.
    sticker = NULL,
    initialize = function(title, description, sticker = NULL) {
      self$title <- title
      self$description <- description
      self$sticker <- sticker
    },
    to_dict = function() {
      dict <- list(
        "_" = "BusinessIntro",
        "title" = self$title,
        "description" = self$description,
        "sticker" = if (inherits(self$sticker, "TLObject")) self$sticker$to_dict() else self$sticker
      )
      dict
    }
  ),
  active = list(
    serialize = function() {
      flags <- if (is.null(self$sticker)) 0 else 1

      result <- c(
        packInt32(self$CONSTRUCTOR_ID),
        writeBin(flags, raw(), size = 4, endian = "little"),
        self$serializebytes(self$title),
        self$serializebytes(self$description)
      )

      if (!is.null(self$sticker)) {
        result <- c(result, self$sticker$serialize())
      }

      result
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      title <- reader$tgread_string()
      description <- reader$tgread_string()

      sticker <- NULL
      if (bitwAnd(flags, 1) != 0) {
        sticker <- reader$tgread_object()
      }

      self$initialize(title, description, sticker)
    }
  )
)

#  @title BusinessLocation
#  @description Telegram API type BusinessLocation
#  @export
#  @noRd
#  @noRd
BusinessLocation <- R6::R6Class(
  "BusinessLocation",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xac5c1af7,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x99accad0,
    #  @field address Field.
    address = NULL,
    #  @field geo_point Field.
    geo_point = NULL,
    initialize = function(address, geo_point = NULL) {
      self$address <- address
      self$geo_point <- geo_point
    },
    to_dict = function() {
      dict <- list(
        "_" = "BusinessLocation",
        "address" = self$address,
        "geo_point" = if (inherits(self$geo_point, "TLObject")) self$geo_point$to_dict() else self$geo_point
      )
      dict
    }
  ),
  active = list(
    serialize = function() {
      flags <- if (is.null(self$geo_point)) 0 else 1

      result <- c(
        packInt32(self$CONSTRUCTOR_ID),
        writeBin(flags, raw(), size = 4, endian = "little")
      )

      if (!is.null(self$geo_point)) {
        result <- c(result, self$geo_point$serialize())
      }

      result <- c(result, self$serializebytes(self$address))
      result
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      geo_point <- NULL
      if (bitwAnd(flags, 1) != 0) {
        geo_point <- reader$tgread_object()
      }

      address <- reader$tgread_string()

      self$initialize(address, geo_point)
    }
  )
)

#  @title BusinessRecipients
#  @description Telegram API type BusinessRecipients
#  @export
#  @noRd
#  @noRd
BusinessRecipients <- R6::R6Class(
  "BusinessRecipients",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x21108ff7,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x52852e46,
    #  @field existing_chats Field.
    existing_chats = NULL,
    #  @field new_chats Field.
    new_chats = NULL,
    #  @field contacts Field.
    contacts = NULL,
    #  @field non_contacts Field.
    non_contacts = NULL,
    #  @field exclude_selected Field.
    exclude_selected = NULL,
    #  @field users Field.
    users = NULL,
    initialize = function(existing_chats = NULL, new_chats = NULL, contacts = NULL, non_contacts = NULL, exclude_selected = NULL, users = NULL) {
      self$existing_chats <- existing_chats
      self$new_chats <- new_chats
      self$contacts <- contacts
      self$non_contacts <- non_contacts
      self$exclude_selected <- exclude_selected
      self$users <- users
    },
    to_dict = function() {
      dict <- list(
        "_" = "BusinessRecipients",
        "existing_chats" = self$existing_chats,
        "new_chats" = self$new_chats,
        "contacts" = self$contacts,
        "non_contacts" = self$non_contacts,
        "exclude_selected" = self$exclude_selected,
        "users" = if (is.null(self$users)) list() else self$users
      )
      dict
    }
  ),
  active = list(
    serialize = function() {
      flag_values <- c(
        if (is.null(self$existing_chats) || !self$existing_chats) 0 else 1,
        if (is.null(self$new_chats) || !self$new_chats) 0 else 2,
        if (is.null(self$contacts) || !self$contacts) 0 else 4,
        if (is.null(self$non_contacts) || !self$non_contacts) 0 else 8,
        if (is.null(self$exclude_selected) || !self$exclude_selected) 0 else 32,
        if (is.null(self$users)) 0 else 16
      )

      flags <- Reduce(bitwOr, as.integer(flag_values), init = 0L)

      result <- c(
        packInt32(self$CONSTRUCTOR_ID),
        writeBin(flags, raw(), size = 4, endian = "little")
      )

      if (!is.null(self$users)) {
        result <- c(
          result,
          writeBin(as.integer(0x15c4b51c), raw(), size = 4, endian = "little"),
          writeBin(length(self$users), raw(), size = 4, endian = "little"),
          unlist(lapply(self$users, function(x) writeBin(x, raw(), size = 8, endian = "little")))
        )
      }

      result
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      existing_chats <- bitwAnd(flags, 1) != 0
      new_chats <- bitwAnd(flags, 2) != 0
      contacts <- bitwAnd(flags, 4) != 0
      non_contacts <- bitwAnd(flags, 8) != 0
      exclude_selected <- bitwAnd(flags, 32) != 0

      users <- NULL
      if (bitwAnd(flags, 16) != 0) {
        reader$read_int() # vector constructor
        users_count <- reader$read_int()
        users <- lapply(1:users_count, function(i) reader$read_long())
      }

      self$initialize(existing_chats, new_chats, contacts, non_contacts, exclude_selected, users)
    }
  )
)

#  @title BusinessWeeklyOpen
#  @description Telegram API type BusinessWeeklyOpen
#  @export
#  @noRd
#  @noRd
BusinessWeeklyOpen <- R6::R6Class(
  "BusinessWeeklyOpen",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x120b1ab9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x18402627,
    #  @field start_minute Field.
    start_minute = NULL,
    #  @field end_minute Field.
    end_minute = NULL,
    initialize = function(start_minute, end_minute) {
      self$start_minute <- start_minute
      self$end_minute <- end_minute
    },
    to_dict = function() {
      dict <- list(
        "_" = "BusinessWeeklyOpen",
        "start_minute" = self$start_minute,
        "end_minute" = self$end_minute
      )
      dict
    }
  ),
  active = list(
    serialize = function() {
      result <- c(
        packInt32(self$CONSTRUCTOR_ID),
        writeBin(self$start_minute, raw(), size = 4, endian = "little"),
        writeBin(self$end_minute, raw(), size = 4, endian = "little")
      )
      result
    }
  ),
  private = list(
    from_reader = function(reader) {
      start_minute <- reader$read_int()
      end_minute <- reader$read_int()
      self$initialize(start_minute, end_minute)
    }
  )
)

#  @title BusinessWorkHours
#  @description Telegram API type BusinessWorkHours
#  @export
#  @noRd
#  @noRd
BusinessWorkHours <- R6::R6Class(
  "BusinessWorkHours",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8c92b098,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x659fa805,
    #  @field timezone_id Field.
    timezone_id = NULL,
    #  @field weekly_open Field.
    weekly_open = NULL,
    #  @field open_now Field.
    open_now = NULL,
    initialize = function(timezone_id, weekly_open, open_now = NULL) {
      self$timezone_id <- timezone_id
      self$weekly_open <- weekly_open
      self$open_now <- open_now
    },
    to_dict = function() {
      dict <- list(
        "_" = "BusinessWorkHours",
        "timezone_id" = self$timezone_id,
        "weekly_open" = if (is.null(self$weekly_open)) list() else lapply(self$weekly_open, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        "open_now" = self$open_now
      )
      dict
    }
  ),
  active = list(
    serialize = function() {
      flags <- if (is.null(self$open_now) || !self$open_now) 0 else 1

      result <- c(
        packInt32(self$CONSTRUCTOR_ID),
        writeBin(flags, raw(), size = 4, endian = "little"),
        self$serializebytes(self$timezone_id),
        writeBin(as.integer(0x15c4b51c), raw(), size = 4, endian = "little"),
        writeBin(length(self$weekly_open), raw(), size = 4, endian = "little"),
        unlist(lapply(self$weekly_open, function(x) x$serialize()))
      )
      result
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      open_now <- bitwAnd(flags, 1) != 0
      timezone_id <- reader$tgread_string()

      reader$read_int() # vector constructor
      weekly_open_count <- reader$read_int()
      weekly_open <- lapply(1:weekly_open_count, function(i) reader$tgread_object())

      self$initialize(timezone_id, weekly_open, open_now)
    }
  )
)

#  @title CdnConfig
#  @description Telegram API type CdnConfig
#  @export
#  @noRd
#  @noRd
CdnConfig <- R6::R6Class(
  "CdnConfig",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5725e40a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xecda397c,
    #  @field public_keys Field.
    public_keys = NULL,
    initialize = function(public_keys) {
      self$public_keys <- public_keys
    },
    to_dict = function() {
      dict <- list(
        "_" = "CdnConfig",
        "public_keys" = if (is.null(self$public_keys)) list() else lapply(self$public_keys, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      )
      dict
    }
  ),
  active = list(
    serialize = function() {
      result <- c(
        packInt32(self$CONSTRUCTOR_ID),
        writeBin(as.integer(0x15c4b51c), raw(), size = 4, endian = "little"),
        writeBin(length(self$public_keys), raw(), size = 4, endian = "little"),
        unlist(lapply(self$public_keys, function(x) x$serialize()))
      )
      result
    }
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int() # vector constructor
      public_keys_count <- reader$read_int()
      public_keys <- lapply(1:public_keys_count, function(i) reader$tgread_object())
      self$initialize(public_keys)
    }
  )
)

#  @title CdnPublicKey
#  @description Telegram API type CdnPublicKey
#  @export
#  @noRd
#  @noRd
CdnPublicKey <- R6::R6Class(
  "CdnPublicKey",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc982eaba,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x16db47f3,
    #  @field dc_id Field.
    dc_id = NULL,
    #  @field public_key Field.
    public_key = NULL,
    initialize = function(dc_id, public_key) {
      self$dc_id <- dc_id
      self$public_key <- public_key
    },
    to_dict = function() {
      dict <- list(
        "_" = "CdnPublicKey",
        "dc_id" = self$dc_id,
        "public_key" = self$public_key
      )
      dict
    }
  ),
  active = list(
    serialize = function() {
      result <- c(
        packInt32(self$CONSTRUCTOR_ID),
        writeBin(self$dc_id, raw(), size = 4, endian = "little"),
        self$serializebytes(self$public_key)
      )
      result
    }
  ),
  private = list(
    from_reader = function(reader) {
      dc_id <- reader$read_int()
      public_key <- reader$tgread_string()
      self$initialize(dc_id, public_key)
    }
  )
)


#  @title Channel
#  @description Telegram API type Channel
#  @export
#  @noRd
#  @noRd
Channel <- R6::R6Class("Channel",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xfe685355,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc5af5d94,
    #  @field id Field.
    id = NULL,
    #  @field title Field.
    title = NULL,
    #  @field photo Field.
    photo = NULL,
    #  @field date Field.
    date = NULL,
    #  @field creator Field.
    creator = NULL,
    #  @field left Field.
    left = NULL,
    #  @field broadcast Field.
    broadcast = NULL,
    #  @field verified Field.
    verified = NULL,
    #  @field megagroup Field.
    megagroup = NULL,
    #  @field restricted Field.
    restricted = NULL,
    #  @field signatures Field.
    signatures = NULL,
    #  @field min Field.
    min = NULL,
    #  @field scam Field.
    scam = NULL,
    #  @field has_link Field.
    has_link = NULL,
    #  @field has_geo Field.
    has_geo = NULL,
    #  @field slowmode_enabled Field.
    slowmode_enabled = NULL,
    #  @field call_active Field.
    call_active = NULL,
    #  @field call_not_empty Field.
    call_not_empty = NULL,
    #  @field fake Field.
    fake = NULL,
    #  @field gigagroup Field.
    gigagroup = NULL,
    #  @field noforwards Field.
    noforwards = NULL,
    #  @field join_to_send Field.
    join_to_send = NULL,
    #  @field join_request Field.
    join_request = NULL,
    #  @field forum Field.
    forum = NULL,
    #  @field stories_hidden Field.
    stories_hidden = NULL,
    #  @field stories_hidden_min Field.
    stories_hidden_min = NULL,
    #  @field stories_unavailable Field.
    stories_unavailable = NULL,
    #  @field signature_profiles Field.
    signature_profiles = NULL,
    #  @field autotranslation Field.
    autotranslation = NULL,
    #  @field broadcast_messages_allowed Field.
    broadcast_messages_allowed = NULL,
    #  @field monoforum Field.
    monoforum = NULL,
    #  @field forum_tabs Field.
    forum_tabs = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    #  @field username Field.
    username = NULL,
    #  @field restriction_reason Field.
    restriction_reason = NULL,
    #  @field admin_rights Field.
    admin_rights = NULL,
    #  @field banned_rights Field.
    banned_rights = NULL,
    #  @field default_banned_rights Field.
    default_banned_rights = NULL,
    #  @field participants_count Field.
    participants_count = NULL,
    #  @field usernames Field.
    usernames = NULL,
    #  @field stories_max_id Field.
    stories_max_id = NULL,
    #  @field color Field.
    color = NULL,
    #  @field profile_color Field.
    profile_color = NULL,
    #  @field emoji_status Field.
    emoji_status = NULL,
    #  @field level Field.
    level = NULL,
    #  @field subscription_until_date Field.
    subscription_until_date = NULL,
    #  @field bot_verification_icon Field.
    bot_verification_icon = NULL,
    #  @field send_paid_messages_stars Field.
    send_paid_messages_stars = NULL,
    #  @field linked_monoforum_id Field.
    linked_monoforum_id = NULL,
    initialize = function(id, title, photo, date,
                          creator = NULL, left = NULL, broadcast = NULL, verified = NULL,
                          megagroup = NULL, restricted = NULL, signatures = NULL, min = NULL,
                          scam = NULL, has_link = NULL, has_geo = NULL, slowmode_enabled = NULL,
                          call_active = NULL, call_not_empty = NULL, fake = NULL, gigagroup = NULL,
                          noforwards = NULL, join_to_send = NULL, join_request = NULL, forum = NULL,
                          stories_hidden = NULL, stories_hidden_min = NULL, stories_unavailable = NULL,
                          signature_profiles = NULL, autotranslation = NULL, broadcast_messages_allowed = NULL,
                          monoforum = NULL, forum_tabs = NULL, access_hash = NULL, username = NULL,
                          restriction_reason = NULL, admin_rights = NULL, banned_rights = NULL,
                          default_banned_rights = NULL, participants_count = NULL, usernames = NULL,
                          stories_max_id = NULL, color = NULL, profile_color = NULL, emoji_status = NULL,
                          level = NULL, subscription_until_date = NULL, bot_verification_icon = NULL,
                          send_paid_messages_stars = NULL, linked_monoforum_id = NULL) {
      self$id <- id
      self$title <- title
      self$photo <- photo
      self$date <- date
      self$creator <- creator
      self$left <- left
      self$broadcast <- broadcast
      self$verified <- verified
      self$megagroup <- megagroup
      self$restricted <- restricted
      self$signatures <- signatures
      self$min <- min
      self$scam <- scam
      self$has_link <- has_link
      self$has_geo <- has_geo
      self$slowmode_enabled <- slowmode_enabled
      self$call_active <- call_active
      self$call_not_empty <- call_not_empty
      self$fake <- fake
      self$gigagroup <- gigagroup
      self$noforwards <- noforwards
      self$join_to_send <- join_to_send
      self$join_request <- join_request
      self$forum <- forum
      self$stories_hidden <- stories_hidden
      self$stories_hidden_min <- stories_hidden_min
      self$stories_unavailable <- stories_unavailable
      self$signature_profiles <- signature_profiles
      self$autotranslation <- autotranslation
      self$broadcast_messages_allowed <- broadcast_messages_allowed
      self$monoforum <- monoforum
      self$forum_tabs <- forum_tabs
      self$access_hash <- access_hash
      self$username <- username
      self$restriction_reason <- restriction_reason
      self$admin_rights <- admin_rights
      self$banned_rights <- banned_rights
      self$default_banned_rights <- default_banned_rights
      self$participants_count <- participants_count
      self$usernames <- usernames
      self$stories_max_id <- stories_max_id
      self$color <- color
      self$profile_color <- profile_color
      self$emoji_status <- emoji_status
      self$level <- level
      self$subscription_until_date <- subscription_until_date
      self$bot_verification_icon <- bot_verification_icon
      self$send_paid_messages_stars <- send_paid_messages_stars
      self$linked_monoforum_id <- linked_monoforum_id
    },
    to_dict = function() {
      list(
        "_" = "Channel",
        id = self$id,
        title = self$title,
        photo = if (inherits(self$photo, "TLObject")) self$photo$to_dict() else self$photo,
        date = self$date,
        creator = self$creator,
        left = self$left,
        broadcast = self$broadcast,
        verified = self$verified,
        megagroup = self$megagroup,
        restricted = self$restricted,
        signatures = self$signatures,
        min = self$min,
        scam = self$scam,
        has_link = self$has_link,
        has_geo = self$has_geo,
        slowmode_enabled = self$slowmode_enabled,
        call_active = self$call_active,
        call_not_empty = self$call_not_empty,
        fake = self$fake,
        gigagroup = self$gigagroup,
        noforwards = self$noforwards,
        join_to_send = self$join_to_send,
        join_request = self$join_request,
        forum = self$forum,
        stories_hidden = self$stories_hidden,
        stories_hidden_min = self$stories_hidden_min,
        stories_unavailable = self$stories_unavailable,
        signature_profiles = self$signature_profiles,
        autotranslation = self$autotranslation,
        broadcast_messages_allowed = self$broadcast_messages_allowed,
        monoforum = self$monoforum,
        forum_tabs = self$forum_tabs,
        access_hash = self$access_hash,
        username = self$username,
        restriction_reason = if (is.null(self$restriction_reason)) NULL else lapply(self$restriction_reason, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        admin_rights = if (inherits(self$admin_rights, "TLObject")) self$admin_rights$to_dict() else self$admin_rights,
        banned_rights = if (inherits(self$banned_rights, "TLObject")) self$banned_rights$to_dict() else self$banned_rights,
        default_banned_rights = if (inherits(self$default_banned_rights, "TLObject")) self$default_banned_rights$to_dict() else self$default_banned_rights,
        participants_count = self$participants_count,
        usernames = if (is.null(self$usernames)) NULL else lapply(self$usernames, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        stories_max_id = self$stories_max_id,
        color = if (inherits(self$color, "TLObject")) self$color$to_dict() else self$color,
        profile_color = if (inherits(self$profile_color, "TLObject")) self$profile_color$to_dict() else self$profile_color,
        emoji_status = if (inherits(self$emoji_status, "TLObject")) self$emoji_status$to_dict() else self$emoji_status,
        level = self$level,
        subscription_until_date = self$subscription_until_date,
        bot_verification_icon = self$bot_verification_icon,
        send_paid_messages_stars = self$send_paid_messages_stars,
        linked_monoforum_id = self$linked_monoforum_id
      )
    },
    bytes = function() {
      # Simplified - in practice, would need proper binary serialization
      # For now, just return a placeholder
      warning("bytes not fully implemented for R")
      as.raw(c(0xfe, 0x68, 0x53, 0x55)) # CONSTRUCTOR_ID
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      creator <- bitwAnd(flags, 1) != 0
      left <- bitwAnd(flags, 4) != 0
      broadcast <- bitwAnd(flags, 32) != 0
      verified <- bitwAnd(flags, 128) != 0
      megagroup <- bitwAnd(flags, 256) != 0
      restricted <- bitwAnd(flags, 512) != 0
      signatures <- bitwAnd(flags, 2048) != 0
      min <- bitwAnd(flags, 4096) != 0
      scam <- bitwAnd(flags, 524288) != 0
      has_link <- bitwAnd(flags, 1048576) != 0
      has_geo <- bitwAnd(flags, 2097152) != 0
      slowmode_enabled <- bitwAnd(flags, 4194304) != 0
      call_active <- bitwAnd(flags, 8388608) != 0
      call_not_empty <- bitwAnd(flags, 16777216) != 0
      fake <- bitwAnd(flags, 33554432) != 0
      gigagroup <- bitwAnd(flags, 67108864) != 0
      noforwards <- bitwAnd(flags, 134217728) != 0
      join_to_send <- bitwAnd(flags, 268435456) != 0
      join_request <- bitwAnd(flags, 536870912) != 0
      forum <- bitwAnd(flags, 1073741824) != 0

      flags2 <- reader$read_int()
      stories_hidden <- bitwAnd(flags2, 2) != 0
      stories_hidden_min <- bitwAnd(flags2, 4) != 0
      stories_unavailable <- bitwAnd(flags2, 8) != 0
      signature_profiles <- bitwAnd(flags2, 4096) != 0
      autotranslation <- bitwAnd(flags2, 32768) != 0
      broadcast_messages_allowed <- bitwAnd(flags2, 65536) != 0
      monoforum <- bitwAnd(flags2, 131072) != 0
      forum_tabs <- bitwAnd(flags2, 524288) != 0

      id <- reader$read_long()
      access_hash <- if (bitwAnd(flags, 8192) != 0) reader$read_long() else NULL
      title <- reader$tgread_string()
      username <- if (bitwAnd(flags, 64) != 0) reader$tgread_string() else NULL
      photo <- reader$tgread_object()
      date <- reader$tgread_date()

      restriction_reason <- if (bitwAnd(flags, 512) != 0) {
        reader$read_int() # vector ctor
        n <- reader$read_int()
        if (n > 0) lapply(seq_len(n), function(i) reader$tgread_object()) else list()
      } else {
        NULL
      }

      admin_rights <- if (bitwAnd(flags, 16384) != 0) reader$tgread_object() else NULL
      banned_rights <- if (bitwAnd(flags, 32768) != 0) reader$tgread_object() else NULL
      default_banned_rights <- if (bitwAnd(flags, 262144) != 0) reader$tgread_object() else NULL
      participants_count <- if (bitwAnd(flags, 131072) != 0) reader$read_int() else NULL

      usernames <- if (bitwAnd(flags2, 1) != 0) {
        reader$read_int() # vector ctor
        n <- reader$read_int()
        if (n > 0) lapply(seq_len(n), function(i) reader$tgread_object()) else list()
      } else {
        NULL
      }

      stories_max_id <- if (bitwAnd(flags2, 16) != 0) reader$read_int() else NULL
      color <- if (bitwAnd(flags2, 128) != 0) reader$tgread_object() else NULL
      profile_color <- if (bitwAnd(flags2, 256) != 0) reader$tgread_object() else NULL
      emoji_status <- if (bitwAnd(flags2, 512) != 0) reader$tgread_object() else NULL
      level <- if (bitwAnd(flags2, 1024) != 0) reader$read_int() else NULL
      subscription_until_date <- if (bitwAnd(flags2, 2048) != 0) reader$tgread_date() else NULL
      bot_verification_icon <- if (bitwAnd(flags2, 8192) != 0) reader$read_long() else NULL
      send_paid_messages_stars <- if (bitwAnd(flags2, 16384) != 0) reader$read_long() else NULL
      linked_monoforum_id <- if (bitwAnd(flags2, 262144) != 0) reader$read_long() else NULL

      list(
        id = id,
        title = title,
        photo = photo,
        date = date,
        creator = creator,
        left = left,
        broadcast = broadcast,
        verified = verified,
        megagroup = megagroup,
        restricted = restricted,
        signatures = signatures,
        min = min,
        scam = scam,
        has_link = has_link,
        has_geo = has_geo,
        slowmode_enabled = slowmode_enabled,
        call_active = call_active,
        call_not_empty = call_not_empty,
        fake = fake,
        gigagroup = gigagroup,
        noforwards = noforwards,
        join_to_send = join_to_send,
        join_request = join_request,
        forum = forum,
        stories_hidden = stories_hidden,
        stories_hidden_min = stories_hidden_min,
        stories_unavailable = stories_unavailable,
        signature_profiles = signature_profiles,
        autotranslation = autotranslation,
        broadcast_messages_allowed = broadcast_messages_allowed,
        monoforum = monoforum,
        forum_tabs = forum_tabs,
        access_hash = access_hash,
        username = username,
        restriction_reason = restriction_reason,
        admin_rights = admin_rights,
        banned_rights = banned_rights,
        default_banned_rights = default_banned_rights,
        participants_count = participants_count,
        usernames = usernames,
        stories_max_id = stories_max_id,
        color = color,
        profile_color = profile_color,
        emoji_status = emoji_status,
        level = level,
        subscription_until_date = subscription_until_date,
        bot_verification_icon = bot_verification_icon,
        send_paid_messages_stars = send_paid_messages_stars,
        linked_monoforum_id = linked_monoforum_id
      )
    }
  ),
  #  @field class Field.
  class = TRUE,
  lock_objects = FALSE
)

#  @title ChannelAdminLogEvent
#  @description Telegram API type ChannelAdminLogEvent
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEvent <- R6::R6Class("ChannelAdminLogEvent",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1fad68cd,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x408f0999,
    #  @field id Field.
    id = NULL,
    #  @field date Field.
    date = NULL,
    #  @field user_id Field.
    user_id = NULL,
    #  @field action Field.
    action = NULL,
    initialize = function(id, date, user_id, action) {
      self$id <- id
      self$date <- date
      self$user_id <- user_id
      self$action <- action
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEvent",
        id = self$id,
        date = self$date,
        user_id = self$user_id,
        action = if (inherits(self$action, "TLObject")) self$action$to_dict() else self$action
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x1f, 0xad, 0x68, 0xcd))
    }
  ),
  #  @field class Field.
  class = TRUE,
  lock_objects = FALSE
)

#  @title ChannelAdminLogEventActionChangeAbout
#  @description Telegram API type ChannelAdminLogEventActionChangeAbout
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionChangeAbout <- R6::R6Class("ChannelAdminLogEventActionChangeAbout",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x55188a2e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field prev_value Field.
    prev_value = NULL,
    #  @field new_value Field.
    new_value = NULL,
    initialize = function(prev_value, new_value) {
      self$prev_value <- prev_value
      self$new_value <- new_value
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionChangeAbout",
        prev_value = self$prev_value,
        new_value = self$new_value
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x55, 0x18, 0x8a, 0x2e))
    }
  ),
  #  @field class Field.
  class = TRUE,
  lock_objects = FALSE
)

#  @title ChannelAdminLogEventActionChangeAvailableReactions
#  @description Telegram API type ChannelAdminLogEventActionChangeAvailableReactions
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionChangeAvailableReactions <- R6::R6Class("ChannelAdminLogEventActionChangeAvailableReactions",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbe4e0ef8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field prev_value Field.
    prev_value = NULL,
    #  @field new_value Field.
    new_value = NULL,
    initialize = function(prev_value, new_value) {
      self$prev_value <- prev_value
      self$new_value <- new_value
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionChangeAvailableReactions",
        prev_value = if (inherits(self$prev_value, "TLObject")) self$prev_value$to_dict() else self$prev_value,
        new_value = if (inherits(self$new_value, "TLObject")) self$new_value$to_dict() else self$new_value
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0xbe, 0x4e, 0x0e, 0xf8))
    }
  ),
  #  @field class Field.
  class = TRUE
)

# ChannelAdminLogEventActionChangeEmojiStatus
#  @noRd
#  @noRd
ChannelAdminLogEventActionChangeEmojiStatus <- R6::R6Class("ChannelAdminLogEventActionChangeEmojiStatus",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x3ea9feb1,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field prev_value Field.
    prev_value = NULL,
    #  @field new_value Field.
    new_value = NULL,
    initialize = function(prev_value, new_value) {
      self$prev_value <- prev_value
      self$new_value <- new_value
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionChangeEmojiStatus",
        prev_value = if (inherits(self$prev_value, "TLObject")) self$prev_value$to_dict() else self$prev_value,
        new_value = if (inherits(self$new_value, "TLObject")) self$new_value$to_dict() else self$new_value
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x3e, 0xa9, 0xfe, 0xb1))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionChangeEmojiStickerSet
#  @description Telegram API type ChannelAdminLogEventActionChangeEmojiStickerSet
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionChangeEmojiStickerSet <- R6::R6Class("ChannelAdminLogEventActionChangeEmojiStickerSet",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x46d840ab,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field prev_stickerset Field.
    prev_stickerset = NULL,
    #  @field new_stickerset Field.
    new_stickerset = NULL,
    initialize = function(prev_stickerset, new_stickerset) {
      self$prev_stickerset <- prev_stickerset
      self$new_stickerset <- new_stickerset
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionChangeEmojiStickerSet",
        prev_stickerset = if (inherits(self$prev_stickerset, "TLObject")) self$prev_stickerset$to_dict() else self$prev_stickerset,
        new_stickerset = if (inherits(self$new_stickerset, "TLObject")) self$new_stickerset$to_dict() else self$new_stickerset
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x46, 0xd8, 0x40, 0xab))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionChangeHistoryTTL
#  @description Telegram API type ChannelAdminLogEventActionChangeHistoryTTL
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionChangeHistoryTTL <- R6::R6Class("ChannelAdminLogEventActionChangeHistoryTTL",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x6e941a38,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field prev_value Field.
    prev_value = NULL,
    #  @field new_value Field.
    new_value = NULL,
    initialize = function(prev_value, new_value) {
      self$prev_value <- prev_value
      self$new_value <- new_value
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionChangeHistoryTTL",
        prev_value = self$prev_value,
        new_value = self$new_value
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x6e, 0x94, 0x1a, 0x38))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionChangeLinkedChat
#  @description Telegram API type ChannelAdminLogEventActionChangeLinkedChat
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionChangeLinkedChat <- R6::R6Class("ChannelAdminLogEventActionChangeLinkedChat",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x50c7ac8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field prev_value Field.
    prev_value = NULL,
    #  @field new_value Field.
    new_value = NULL,
    initialize = function(prev_value, new_value) {
      self$prev_value <- prev_value
      self$new_value <- new_value
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionChangeLinkedChat",
        prev_value = self$prev_value,
        new_value = self$new_value
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x05, 0x0c, 0x7a, 0xc8))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionChangeLocation
#  @description Telegram API type ChannelAdminLogEventActionChangeLocation
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionChangeLocation <- R6::R6Class("ChannelAdminLogEventActionChangeLocation",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe6b76ae,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field prev_value Field.
    prev_value = NULL,
    #  @field new_value Field.
    new_value = NULL,
    initialize = function(prev_value, new_value) {
      self$prev_value <- prev_value
      self$new_value <- new_value
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionChangeLocation",
        prev_value = if (inherits(self$prev_value, "TLObject")) self$prev_value$to_dict() else self$prev_value,
        new_value = if (inherits(self$new_value, "TLObject")) self$new_value$to_dict() else self$new_value
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x0e, 0x6b, 0x76, 0xae))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionChangePeerColor
#  @description Telegram API type ChannelAdminLogEventActionChangePeerColor
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionChangePeerColor <- R6::R6Class("ChannelAdminLogEventActionChangePeerColor",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5796e780,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field prev_value Field.
    prev_value = NULL,
    #  @field new_value Field.
    new_value = NULL,
    initialize = function(prev_value, new_value) {
      self$prev_value <- prev_value
      self$new_value <- new_value
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionChangePeerColor",
        prev_value = if (inherits(self$prev_value, "TLObject")) self$prev_value$to_dict() else self$prev_value,
        new_value = if (inherits(self$new_value, "TLObject")) self$new_value$to_dict() else self$new_value
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x57, 0x96, 0xe7, 0x80))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionChangePhoto
#  @description Telegram API type ChannelAdminLogEventActionChangePhoto
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionChangePhoto <- R6::R6Class("ChannelAdminLogEventActionChangePhoto",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x434bd2af,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field prev_photo Field.
    prev_photo = NULL,
    #  @field new_photo Field.
    new_photo = NULL,
    initialize = function(prev_photo, new_photo) {
      self$prev_photo <- prev_photo
      self$new_photo <- new_photo
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionChangePhoto",
        prev_photo = if (inherits(self$prev_photo, "TLObject")) self$prev_photo$to_dict() else self$prev_photo,
        new_photo = if (inherits(self$new_photo, "TLObject")) self$new_photo$to_dict() else self$new_photo
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x43, 0x4b, 0xd2, 0xaf))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionChangeProfilePeerColor
#  @description Telegram API type ChannelAdminLogEventActionChangeProfilePeerColor
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionChangeProfilePeerColor <- R6::R6Class("ChannelAdminLogEventActionChangeProfilePeerColor",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5e477b25,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field prev_value Field.
    prev_value = NULL,
    #  @field new_value Field.
    new_value = NULL,
    initialize = function(prev_value, new_value) {
      self$prev_value <- prev_value
      self$new_value <- new_value
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionChangeProfilePeerColor",
        prev_value = if (inherits(self$prev_value, "TLObject")) self$prev_value$to_dict() else self$prev_value,
        new_value = if (inherits(self$new_value, "TLObject")) self$new_value$to_dict() else self$new_value
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x5e, 0x47, 0x7b, 0x25))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionChangeStickerSet
#  @description Telegram API type ChannelAdminLogEventActionChangeStickerSet
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionChangeStickerSet <- R6::R6Class("ChannelAdminLogEventActionChangeStickerSet",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb1c3caa7,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field prev_stickerset Field.
    prev_stickerset = NULL,
    #  @field new_stickerset Field.
    new_stickerset = NULL,
    initialize = function(prev_stickerset, new_stickerset) {
      self$prev_stickerset <- prev_stickerset
      self$new_stickerset <- new_stickerset
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionChangeStickerSet",
        prev_stickerset = if (inherits(self$prev_stickerset, "TLObject")) self$prev_stickerset$to_dict() else self$prev_stickerset,
        new_stickerset = if (inherits(self$new_stickerset, "TLObject")) self$new_stickerset$to_dict() else self$new_stickerset
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0xb1, 0xc3, 0xca, 0xa7))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionChangeTitle
#  @description Telegram API type ChannelAdminLogEventActionChangeTitle
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionChangeTitle <- R6::R6Class("ChannelAdminLogEventActionChangeTitle",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe6dfb825,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field prev_value Field.
    prev_value = NULL,
    #  @field new_value Field.
    new_value = NULL,
    initialize = function(prev_value, new_value) {
      self$prev_value <- prev_value
      self$new_value <- new_value
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionChangeTitle",
        prev_value = self$prev_value,
        new_value = self$new_value
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0xe6, 0xdf, 0xb8, 0x25))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionChangeUsername
#  @description Telegram API type ChannelAdminLogEventActionChangeUsername
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionChangeUsername <- R6::R6Class("ChannelAdminLogEventActionChangeUsername",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x6a4afc38,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field prev_value Field.
    prev_value = NULL,
    #  @field new_value Field.
    new_value = NULL,
    initialize = function(prev_value, new_value) {
      self$prev_value <- prev_value
      self$new_value <- new_value
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionChangeUsername",
        prev_value = self$prev_value,
        new_value = self$new_value
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x6a, 0x4a, 0xfc, 0x38))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionChangeUsernames
#  @description Telegram API type ChannelAdminLogEventActionChangeUsernames
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionChangeUsernames <- R6::R6Class("ChannelAdminLogEventActionChangeUsernames",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf04fb3a9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field prev_value Field.
    prev_value = NULL,
    #  @field new_value Field.
    new_value = NULL,
    initialize = function(prev_value, new_value) {
      self$prev_value <- prev_value
      self$new_value <- new_value
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionChangeUsernames",
        prev_value = if (is.null(self$prev_value)) NULL else self$prev_value,
        new_value = if (is.null(self$new_value)) NULL else self$new_value
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0xf0, 0x4f, 0xb3, 0xa9))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionChangeWallpaper
#  @description Telegram API type ChannelAdminLogEventActionChangeWallpaper
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionChangeWallpaper <- R6::R6Class("ChannelAdminLogEventActionChangeWallpaper",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x31bb5d52,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field prev_value Field.
    prev_value = NULL,
    #  @field new_value Field.
    new_value = NULL,
    initialize = function(prev_value, new_value) {
      self$prev_value <- prev_value
      self$new_value <- new_value
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionChangeWallpaper",
        prev_value = if (inherits(self$prev_value, "TLObject")) self$prev_value$to_dict() else self$prev_value,
        new_value = if (inherits(self$new_value, "TLObject")) self$new_value$to_dict() else self$new_value
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x31, 0xbb, 0x5d, 0x52))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionCreateTopic
#  @description Telegram API type ChannelAdminLogEventActionCreateTopic
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionCreateTopic <- R6::R6Class("ChannelAdminLogEventActionCreateTopic",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x58707d28,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field topic Field.
    topic = NULL,
    initialize = function(topic) {
      self$topic <- topic
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionCreateTopic",
        topic = if (inherits(self$topic, "TLObject")) self$topic$to_dict() else self$topic
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x58, 0x70, 0x7d, 0x28))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionDefaultBannedRights
#  @description Telegram API type ChannelAdminLogEventActionDefaultBannedRights
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionDefaultBannedRights <- R6::R6Class("ChannelAdminLogEventActionDefaultBannedRights",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x2df5fc0a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field prev_banned_rights Field.
    prev_banned_rights = NULL,
    #  @field new_banned_rights Field.
    new_banned_rights = NULL,
    initialize = function(prev_banned_rights, new_banned_rights) {
      self$prev_banned_rights <- prev_banned_rights
      self$new_banned_rights <- new_banned_rights
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionDefaultBannedRights",
        prev_banned_rights = if (inherits(self$prev_banned_rights, "TLObject")) self$prev_banned_rights$to_dict() else self$prev_banned_rights,
        new_banned_rights = if (inherits(self$new_banned_rights, "TLObject")) self$new_banned_rights$to_dict() else self$new_banned_rights
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x2d, 0xf5, 0xfc, 0x0a))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionDeleteMessage
#  @description Telegram API type ChannelAdminLogEventActionDeleteMessage
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionDeleteMessage <- R6::R6Class("ChannelAdminLogEventActionDeleteMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x42e047bb,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field message Field.
    message = NULL,
    initialize = function(message) {
      self$message <- message
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionDeleteMessage",
        message = if (inherits(self$message, "TLObject")) self$message$to_dict() else self$message
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x42, 0xe0, 0x47, 0xbb))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionDeleteTopic
#  @description Telegram API type ChannelAdminLogEventActionDeleteTopic
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionDeleteTopic <- R6::R6Class("ChannelAdminLogEventActionDeleteTopic",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xae168909,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field topic Field.
    topic = NULL,
    initialize = function(topic) {
      self$topic <- topic
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionDeleteTopic",
        topic = if (inherits(self$topic, "TLObject")) self$topic$to_dict() else self$topic
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0xae, 0x16, 0x89, 0x09))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionDiscardGroupCall
#  @description Telegram API type ChannelAdminLogEventActionDiscardGroupCall
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionDiscardGroupCall <- R6::R6Class("ChannelAdminLogEventActionDiscardGroupCall",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xdb9f9140,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field call Field.
    call = NULL,
    initialize = function(call) {
      self$call <- call
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionDiscardGroupCall",
        call = if (inherits(self$call, "TLObject")) self$call$to_dict() else self$call
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0xdb, 0x9f, 0x91, 0x40))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionEditMessage
#  @description Telegram API type ChannelAdminLogEventActionEditMessage
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionEditMessage <- R6::R6Class("ChannelAdminLogEventActionEditMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x709b2405,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field prev_message Field.
    prev_message = NULL,
    #  @field new_message Field.
    new_message = NULL,
    initialize = function(prev_message, new_message) {
      self$prev_message <- prev_message
      self$new_message <- new_message
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionEditMessage",
        prev_message = if (inherits(self$prev_message, "TLObject")) self$prev_message$to_dict() else self$prev_message,
        new_message = if (inherits(self$new_message, "TLObject")) self$new_message$to_dict() else self$new_message
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x70, 0x9b, 0x24, 0x05))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionEditTopic
#  @description Telegram API type ChannelAdminLogEventActionEditTopic
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionEditTopic <- R6::R6Class("ChannelAdminLogEventActionEditTopic",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf06fe208,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field prev_topic Field.
    prev_topic = NULL,
    #  @field new_topic Field.
    new_topic = NULL,
    initialize = function(prev_topic, new_topic) {
      self$prev_topic <- prev_topic
      self$new_topic <- new_topic
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionEditTopic",
        prev_topic = if (inherits(self$prev_topic, "TLObject")) self$prev_topic$to_dict() else self$prev_topic,
        new_topic = if (inherits(self$new_topic, "TLObject")) self$new_topic$to_dict() else self$new_topic
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0xf0, 0x6f, 0xe2, 0x08))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionExportedInviteDelete
#  @description Telegram API type ChannelAdminLogEventActionExportedInviteDelete
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionExportedInviteDelete <- R6::R6Class("ChannelAdminLogEventActionExportedInviteDelete",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5a50fca4,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field invite Field.
    invite = NULL,
    initialize = function(invite) {
      self$invite <- invite
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionExportedInviteDelete",
        invite = if (inherits(self$invite, "TLObject")) self$invite$to_dict() else self$invite
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x5a, 0x50, 0xfc, 0xa4))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionExportedInviteEdit
#  @description Telegram API type ChannelAdminLogEventActionExportedInviteEdit
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionExportedInviteEdit <- R6::R6Class("ChannelAdminLogEventActionExportedInviteEdit",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe90ebb59,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field prev_invite Field.
    prev_invite = NULL,
    #  @field new_invite Field.
    new_invite = NULL,
    initialize = function(prev_invite, new_invite) {
      self$prev_invite <- prev_invite
      self$new_invite <- new_invite
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionExportedInviteEdit",
        prev_invite = if (inherits(self$prev_invite, "TLObject")) self$prev_invite$to_dict() else self$prev_invite,
        new_invite = if (inherits(self$new_invite, "TLObject")) self$new_invite$to_dict() else self$new_invite
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0xe9, 0x0e, 0xbb, 0x59))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionExportedInviteRevoke
#  @description Telegram API type ChannelAdminLogEventActionExportedInviteRevoke
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionExportedInviteRevoke <- R6::R6Class("ChannelAdminLogEventActionExportedInviteRevoke",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x410a134e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field invite Field.
    invite = NULL,
    initialize = function(invite) {
      self$invite <- invite
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionExportedInviteRevoke",
        invite = if (inherits(self$invite, "TLObject")) self$invite$to_dict() else self$invite
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x41, 0x0a, 0x13, 0x4e))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionParticipantInvite
#  @description Telegram API type ChannelAdminLogEventActionParticipantInvite
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionParticipantInvite <- R6::R6Class("ChannelAdminLogEventActionParticipantInvite",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe31c34d8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field participant Field.
    participant = NULL,
    initialize = function(participant) {
      self$participant <- participant
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionParticipantInvite",
        participant = if (inherits(self$participant, "TLObject")) self$participant$to_dict() else self$participant
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0xe3, 0x1c, 0x34, 0xd8))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionParticipantJoin
#  @description Telegram API type ChannelAdminLogEventActionParticipantJoin
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionParticipantJoin <- R6::R6Class("ChannelAdminLogEventActionParticipantJoin",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x183040d3,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    initialize = function() {
      # No parameters
    },
    to_dict = function() {
      list("_" = "ChannelAdminLogEventActionParticipantJoin")
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x18, 0x30, 0x40, 0xd3))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionParticipantJoinByInvite
#  @description Telegram API type ChannelAdminLogEventActionParticipantJoinByInvite
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionParticipantJoinByInvite <- R6::R6Class("ChannelAdminLogEventActionParticipantJoinByInvite",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xfe9fc158,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field invite Field.
    invite = NULL,
    #  @field via_chatlist Field.
    via_chatlist = NULL,
    initialize = function(invite, via_chatlist = NULL) {
      self$invite <- invite
      self$via_chatlist <- via_chatlist
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionParticipantJoinByInvite",
        invite = if (inherits(self$invite, "TLObject")) self$invite$to_dict() else self$invite,
        via_chatlist = self$via_chatlist
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0xfe, 0x9f, 0xc1, 0x58))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionParticipantJoinByRequest
#  @description Telegram API type ChannelAdminLogEventActionParticipantJoinByRequest
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionParticipantJoinByRequest <- R6::R6Class("ChannelAdminLogEventActionParticipantJoinByRequest",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xafb6144a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field invite Field.
    invite = NULL,
    #  @field approved_by Field.
    approved_by = NULL,
    initialize = function(invite, approved_by) {
      self$invite <- invite
      self$approved_by <- approved_by
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionParticipantJoinByRequest",
        invite = if (inherits(self$invite, "TLObject")) self$invite$to_dict() else self$invite,
        approved_by = self$approved_by
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0xaf, 0xb6, 0x14, 0x4a))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionParticipantLeave
#  @description Telegram API type ChannelAdminLogEventActionParticipantLeave
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionParticipantLeave <- R6::R6Class("ChannelAdminLogEventActionParticipantLeave",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf89777f2,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    initialize = function() {
      # No parameters
    },
    to_dict = function() {
      list("_" = "ChannelAdminLogEventActionParticipantLeave")
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0xf8, 0x97, 0x77, 0xf2))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionParticipantMute
#  @description Telegram API type ChannelAdminLogEventActionParticipantMute
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionParticipantMute <- R6::R6Class("ChannelAdminLogEventActionParticipantMute",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf92424d2,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field participant Field.
    participant = NULL,
    initialize = function(participant) {
      self$participant <- participant
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionParticipantMute",
        participant = if (inherits(self$participant, "TLObject")) self$participant$to_dict() else self$participant
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0xf9, 0x24, 0x24, 0xd2))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionParticipantSubExtend
#  @description Telegram API type ChannelAdminLogEventActionParticipantSubExtend
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionParticipantSubExtend <- R6::R6Class("ChannelAdminLogEventActionParticipantSubExtend",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x64642db3,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field prev_participant Field.
    prev_participant = NULL,
    #  @field new_participant Field.
    new_participant = NULL,
    initialize = function(prev_participant, new_participant) {
      self$prev_participant <- prev_participant
      self$new_participant <- new_participant
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionParticipantSubExtend",
        prev_participant = if (inherits(self$prev_participant, "TLObject")) self$prev_participant$to_dict() else self$prev_participant,
        new_participant = if (inherits(self$new_participant, "TLObject")) self$new_participant$to_dict() else self$new_participant
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x64, 0x64, 0x2d, 0xb3))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionParticipantToggleAdmin
#  @description Telegram API type ChannelAdminLogEventActionParticipantToggleAdmin
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionParticipantToggleAdmin <- R6::R6Class("ChannelAdminLogEventActionParticipantToggleAdmin",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd5676710,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field prev_participant Field.
    prev_participant = NULL,
    #  @field new_participant Field.
    new_participant = NULL,
    initialize = function(prev_participant, new_participant) {
      self$prev_participant <- prev_participant
      self$new_participant <- new_participant
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionParticipantToggleAdmin",
        prev_participant = if (inherits(self$prev_participant, "TLObject")) self$prev_participant$to_dict() else self$prev_participant,
        new_participant = if (inherits(self$new_participant, "TLObject")) self$new_participant$to_dict() else self$new_participant
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0xd5, 0x67, 0x67, 0x10))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionParticipantToggleBan
#  @description Telegram API type ChannelAdminLogEventActionParticipantToggleBan
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionParticipantToggleBan <- R6::R6Class("ChannelAdminLogEventActionParticipantToggleBan",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe6d83d7e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field prev_participant Field.
    prev_participant = NULL,
    #  @field new_participant Field.
    new_participant = NULL,
    initialize = function(prev_participant, new_participant) {
      self$prev_participant <- prev_participant
      self$new_participant <- new_participant
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionParticipantToggleBan",
        prev_participant = if (inherits(self$prev_participant, "TLObject")) self$prev_participant$to_dict() else self$prev_participant,
        new_participant = if (inherits(self$new_participant, "TLObject")) self$new_participant$to_dict() else self$new_participant
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0xe6, 0xd8, 0x3d, 0x7e))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionParticipantUnmute
#  @description Telegram API type ChannelAdminLogEventActionParticipantUnmute
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionParticipantUnmute <- R6::R6Class("ChannelAdminLogEventActionParticipantUnmute",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe64429c0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field participant Field.
    participant = NULL,
    initialize = function(participant) {
      self$participant <- participant
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionParticipantUnmute",
        participant = if (inherits(self$participant, "TLObject")) self$participant$to_dict() else self$participant
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0xe6, 0x44, 0x29, 0xc0))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionParticipantVolume
#  @description Telegram API type ChannelAdminLogEventActionParticipantVolume
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionParticipantVolume <- R6::R6Class("ChannelAdminLogEventActionParticipantVolume",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x3e7f6847,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field participant Field.
    participant = NULL,
    initialize = function(participant) {
      self$participant <- participant
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionParticipantVolume",
        participant = if (inherits(self$participant, "TLObject")) self$participant$to_dict() else self$participant
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x3e, 0x7f, 0x68, 0x47))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionPinTopic
#  @description Telegram API type ChannelAdminLogEventActionPinTopic
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionPinTopic <- R6::R6Class("ChannelAdminLogEventActionPinTopic",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5d8d353b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field prev_topic Field.
    prev_topic = NULL,
    #  @field new_topic Field.
    new_topic = NULL,
    initialize = function(prev_topic = NULL, new_topic = NULL) {
      self$prev_topic <- prev_topic
      self$new_topic <- new_topic
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionPinTopic",
        prev_topic = if (inherits(self$prev_topic, "TLObject")) self$prev_topic$to_dict() else self$prev_topic,
        new_topic = if (inherits(self$new_topic, "TLObject")) self$new_topic$to_dict() else self$new_topic
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x5d, 0x8d, 0x35, 0x3b))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionSendMessage
#  @description Telegram API type ChannelAdminLogEventActionSendMessage
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionSendMessage <- R6::R6Class("ChannelAdminLogEventActionSendMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x278f2868,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field message Field.
    message = NULL,
    initialize = function(message) {
      self$message <- message
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionSendMessage",
        message = if (inherits(self$message, "TLObject")) self$message$to_dict() else self$message
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x27, 0x8f, 0x28, 0x68))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionStartGroupCall
#  @description Telegram API type ChannelAdminLogEventActionStartGroupCall
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionStartGroupCall <- R6::R6Class("ChannelAdminLogEventActionStartGroupCall",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x23209745,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field call Field.
    call = NULL,
    initialize = function(call) {
      self$call <- call
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionStartGroupCall",
        call = if (inherits(self$call, "TLObject")) self$call$to_dict() else self$call
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x23, 0x20, 0x97, 0x45))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionStopPoll
#  @description Telegram API type ChannelAdminLogEventActionStopPoll
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionStopPoll <- R6::R6Class("ChannelAdminLogEventActionStopPoll",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8f079643,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field message Field.
    message = NULL,
    initialize = function(message) {
      self$message <- message
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionStopPoll",
        message = if (inherits(self$message, "TLObject")) self$message$to_dict() else self$message
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x8f, 0x07, 0x96, 0x43))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionToggleAntiSpam
#  @description Telegram API type ChannelAdminLogEventActionToggleAntiSpam
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionToggleAntiSpam <- R6::R6Class("ChannelAdminLogEventActionToggleAntiSpam",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x64f36dfc,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field new_value Field.
    new_value = NULL,
    initialize = function(new_value) {
      self$new_value <- new_value
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionToggleAntiSpam",
        new_value = self$new_value
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x64, 0xf3, 0x6d, 0xfc))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionToggleAutotranslation
#  @description Telegram API type ChannelAdminLogEventActionToggleAutotranslation
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionToggleAutotranslation <- R6::R6Class("ChannelAdminLogEventActionToggleAutotranslation",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc517f77e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field new_value Field.
    new_value = NULL,
    initialize = function(new_value) {
      self$new_value <- new_value
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionToggleAutotranslation",
        new_value = self$new_value
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0xc5, 0x17, 0xf7, 0x7e))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionToggleForum
#  @description Telegram API type ChannelAdminLogEventActionToggleForum
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionToggleForum <- R6::R6Class("ChannelAdminLogEventActionToggleForum",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x2cc6383,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field new_value Field.
    new_value = NULL,
    initialize = function(new_value) {
      self$new_value <- new_value
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionToggleForum",
        new_value = self$new_value
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x02, 0xcc, 0x63, 0x83))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionToggleGroupCallSetting
#  @description Telegram API type ChannelAdminLogEventActionToggleGroupCallSetting
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionToggleGroupCallSetting <- R6::R6Class("ChannelAdminLogEventActionToggleGroupCallSetting",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x56d6a247,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field join_muted Field.
    join_muted = NULL,
    initialize = function(join_muted) {
      self$join_muted <- join_muted
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionToggleGroupCallSetting",
        join_muted = self$join_muted
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x56, 0xd6, 0xa2, 0x47))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionToggleInvites
#  @description Telegram API type ChannelAdminLogEventActionToggleInvites
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionToggleInvites <- R6::R6Class("ChannelAdminLogEventActionToggleInvites",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1b7907ae,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field new_value Field.
    new_value = NULL,
    initialize = function(new_value) {
      self$new_value <- new_value
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionToggleInvites",
        new_value = self$new_value
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x1b, 0x79, 0x07, 0xae))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionToggleNoForwards
#  @description Telegram API type ChannelAdminLogEventActionToggleNoForwards
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionToggleNoForwards <- R6::R6Class("ChannelAdminLogEventActionToggleNoForwards",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xcb2ac766,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field new_value Field.
    new_value = NULL,
    initialize = function(new_value) {
      self$new_value <- new_value
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionToggleNoForwards",
        new_value = self$new_value
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0xcb, 0x2a, 0xc7, 0x66))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionTogglePreHistoryHidden
#  @description Telegram API type ChannelAdminLogEventActionTogglePreHistoryHidden
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionTogglePreHistoryHidden <- R6::R6Class("ChannelAdminLogEventActionTogglePreHistoryHidden",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5f5c95f1,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field new_value Field.
    new_value = NULL,
    initialize = function(new_value) {
      self$new_value <- new_value
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionTogglePreHistoryHidden",
        new_value = self$new_value
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x5f, 0x5c, 0x95, 0xf1))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionToggleSignatureProfiles
#  @description Telegram API type ChannelAdminLogEventActionToggleSignatureProfiles
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionToggleSignatureProfiles <- R6::R6Class("ChannelAdminLogEventActionToggleSignatureProfiles",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x60a79c79,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field new_value Field.
    new_value = NULL,
    initialize = function(new_value) {
      self$new_value <- new_value
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionToggleSignatureProfiles",
        new_value = self$new_value
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x60, 0xa7, 0x9c, 0x79))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionToggleSignatures
#  @description Telegram API type ChannelAdminLogEventActionToggleSignatures
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionToggleSignatures <- R6::R6Class("ChannelAdminLogEventActionToggleSignatures",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x26ae0971,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field new_value Field.
    new_value = NULL,
    initialize = function(new_value) {
      self$new_value <- new_value
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionToggleSignatures",
        new_value = self$new_value
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x26, 0xae, 0x09, 0x71))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionToggleSlowMode
#  @description Telegram API type ChannelAdminLogEventActionToggleSlowMode
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionToggleSlowMode <- R6::R6Class("ChannelAdminLogEventActionToggleSlowMode",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x53909779,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field prev_value Field.
    prev_value = NULL,
    #  @field new_value Field.
    new_value = NULL,
    initialize = function(prev_value, new_value) {
      self$prev_value <- prev_value
      self$new_value <- new_value
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionToggleSlowMode",
        prev_value = self$prev_value,
        new_value = self$new_value
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x53, 0x90, 0x97, 0x79))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionUpdatePinned
#  @description Telegram API type ChannelAdminLogEventActionUpdatePinned
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionUpdatePinned <- R6::R6Class("ChannelAdminLogEventActionUpdatePinned",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe9e82c18,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    #  @field message Field.
    message = NULL,
    initialize = function(message) {
      self$message <- message
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionUpdatePinned",
        message = if (inherits(self$message, "TLObject")) self$message$to_dict() else self$message
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0xe9, 0xe8, 0x2c, 0x18))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventsFilter
#  @description Telegram API type ChannelAdminLogEventsFilter
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventsFilter <- R6::R6Class("ChannelAdminLogEventsFilter",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xea107ae4,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x7cbbf319,
    #  @field join Field.
    join = NULL,
    #  @field leave Field.
    leave = NULL,
    #  @field invite Field.
    invite = NULL,
    #  @field ban Field.
    ban = NULL,
    #  @field unban Field.
    unban = NULL,
    #  @field kick Field.
    kick = NULL,
    #  @field unkick Field.
    unkick = NULL,
    #  @field promote Field.
    promote = NULL,
    #  @field demote Field.
    demote = NULL,
    #  @field info Field.
    info = NULL,
    #  @field settings Field.
    settings = NULL,
    #  @field pinned Field.
    pinned = NULL,
    #  @field edit Field.
    edit = NULL,
    #  @field delete Field.
    delete = NULL,
    #  @field group_call Field.
    group_call = NULL,
    #  @field invites Field.
    invites = NULL,
    #  @field send Field.
    send = NULL,
    #  @field forums Field.
    forums = NULL,
    #  @field sub_extend Field.
    sub_extend = NULL,
    initialize = function(join = NULL, leave = NULL, invite = NULL, ban = NULL, unban = NULL,
                          kick = NULL, unkick = NULL, promote = NULL, demote = NULL, info = NULL,
                          settings = NULL, pinned = NULL, edit = NULL, delete = NULL, group_call = NULL,
                          invites = NULL, send = NULL, forums = NULL, sub_extend = NULL) {
      self$join <- join
      self$leave <- leave
      self$invite <- invite
      self$ban <- ban
      self$unban <- unban
      self$kick <- kick
      self$unkick <- unkick
      self$promote <- promote
      self$demote <- demote
      self$info <- info
      self$settings <- settings
      self$pinned <- pinned
      self$edit <- edit
      self$delete <- delete
      self$group_call <- group_call
      self$invites <- invites
      self$send <- send
      self$forums <- forums
      self$sub_extend <- sub_extend
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventsFilter",
        join = self$join,
        leave = self$leave,
        invite = self$invite,
        ban = self$ban,
        unban = self$unban,
        kick = self$kick,
        unkick = self$unkick,
        promote = self$promote,
        demote = self$demote,
        info = self$info,
        settings = self$settings,
        pinned = self$pinned,
        edit = self$edit,
        delete = self$delete,
        group_call = self$group_call,
        invites = self$invites,
        send = self$send,
        forums = self$forums,
        sub_extend = self$sub_extend
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0xea, 0x10, 0x7a, 0xe4))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelForbidden
#  @description Telegram API type ChannelForbidden
#  @export
#  @noRd
#  @noRd
ChannelForbidden <- R6::R6Class("ChannelForbidden",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x17d493d5,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc5af5d94,
    #  @field id Field.
    id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    #  @field title Field.
    title = NULL,
    #  @field broadcast Field.
    broadcast = NULL,
    #  @field megagroup Field.
    megagroup = NULL,
    #  @field until_date Field.
    until_date = NULL,
    initialize = function(id, access_hash, title, broadcast = NULL, megagroup = NULL, until_date = NULL) {
      self$id <- id
      self$access_hash <- access_hash
      self$title <- title
      self$broadcast <- broadcast
      self$megagroup <- megagroup
      self$until_date <- until_date
    },
    to_dict = function() {
      list(
        "_" = "ChannelForbidden",
        id = self$id,
        access_hash = self$access_hash,
        title = self$title,
        broadcast = self$broadcast,
        megagroup = self$megagroup,
        until_date = self$until_date
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x17, 0xd4, 0x93, 0xd5))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelFull
#  @description Telegram API type ChannelFull
#  @export
#  @noRd
#  @noRd
ChannelFull <- R6::R6Class("ChannelFull",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe4e0b29d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd49a2697,
    #  @field id Field.
    id = NULL,
    #  @field about Field.
    about = NULL,
    #  @field read_inbox_max_id Field.
    read_inbox_max_id = NULL,
    #  @field read_outbox_max_id Field.
    read_outbox_max_id = NULL,
    #  @field unread_count Field.
    unread_count = NULL,
    #  @field chat_photo Field.
    chat_photo = NULL,
    #  @field notify_settings Field.
    notify_settings = NULL,
    #  @field bot_info Field.
    bot_info = NULL,
    #  @field pts Field.
    pts = NULL,
    #  @field can_view_participants Field.
    can_view_participants = NULL,
    #  @field can_set_username Field.
    can_set_username = NULL,
    #  @field can_set_stickers Field.
    can_set_stickers = NULL,
    #  @field hidden_prehistory Field.
    hidden_prehistory = NULL,
    #  @field can_set_location Field.
    can_set_location = NULL,
    #  @field has_scheduled Field.
    has_scheduled = NULL,
    #  @field can_view_stats Field.
    can_view_stats = NULL,
    #  @field blocked Field.
    blocked = NULL,
    #  @field can_delete_channel Field.
    can_delete_channel = NULL,
    #  @field antispam Field.
    antispam = NULL,
    #  @field participants_hidden Field.
    participants_hidden = NULL,
    #  @field translations_disabled Field.
    translations_disabled = NULL,
    #  @field stories_pinned_available Field.
    stories_pinned_available = NULL,
    #  @field view_forum_as_messages Field.
    view_forum_as_messages = NULL,
    #  @field restricted_sponsored Field.
    restricted_sponsored = NULL,
    #  @field can_view_revenue Field.
    can_view_revenue = NULL,
    #  @field paid_media_allowed Field.
    paid_media_allowed = NULL,
    #  @field can_view_stars_revenue Field.
    can_view_stars_revenue = NULL,
    #  @field paid_reactions_available Field.
    paid_reactions_available = NULL,
    #  @field stargifts_available Field.
    stargifts_available = NULL,
    #  @field paid_messages_available Field.
    paid_messages_available = NULL,
    #  @field participants_count Field.
    participants_count = NULL,
    #  @field admins_count Field.
    admins_count = NULL,
    #  @field kicked_count Field.
    kicked_count = NULL,
    #  @field banned_count Field.
    banned_count = NULL,
    #  @field online_count Field.
    online_count = NULL,
    #  @field exported_invite Field.
    exported_invite = NULL,
    #  @field migrated_from_chat_id Field.
    migrated_from_chat_id = NULL,
    #  @field migrated_from_max_id Field.
    migrated_from_max_id = NULL,
    #  @field pinned_msg_id Field.
    pinned_msg_id = NULL,
    #  @field stickerset Field.
    stickerset = NULL,
    #  @field available_min_id Field.
    available_min_id = NULL,
    #  @field folder_id Field.
    folder_id = NULL,
    #  @field linked_chat_id Field.
    linked_chat_id = NULL,
    #  @field location Field.
    location = NULL,
    #  @field slowmode_seconds Field.
    slowmode_seconds = NULL,
    #  @field slowmode_next_send_date Field.
    slowmode_next_send_date = NULL,
    #  @field stats_dc Field.
    stats_dc = NULL,
    #  @field call Field.
    call = NULL,
    #  @field ttl_period Field.
    ttl_period = NULL,
    #  @field pending_suggestions Field.
    pending_suggestions = NULL,
    #  @field groupcall_default_join_as Field.
    groupcall_default_join_as = NULL,
    #  @field theme_emoticon Field.
    theme_emoticon = NULL,
    #  @field requests_pending Field.
    requests_pending = NULL,
    #  @field recent_requesters Field.
    recent_requesters = NULL,
    #  @field default_send_as Field.
    default_send_as = NULL,
    #  @field available_reactions Field.
    available_reactions = NULL,
    #  @field reactions_limit Field.
    reactions_limit = NULL,
    #  @field stories Field.
    stories = NULL,
    #  @field wallpaper Field.
    wallpaper = NULL,
    #  @field boosts_applied Field.
    boosts_applied = NULL,
    #  @field boosts_unrestrict Field.
    boosts_unrestrict = NULL,
    #  @field emojiset Field.
    emojiset = NULL,
    #  @field bot_verification Field.
    bot_verification = NULL,
    #  @field stargifts_count Field.
    stargifts_count = NULL,
    #  @field send_paid_messages_stars Field.
    send_paid_messages_stars = NULL,
    #  @field main_tab Field.
    main_tab = NULL,
    initialize = function(id, about, read_inbox_max_id, read_outbox_max_id, unread_count, chat_photo, notify_settings, bot_info, pts,
                          can_view_participants = NULL, can_set_username = NULL, can_set_stickers = NULL, hidden_prehistory = NULL,
                          can_set_location = NULL, has_scheduled = NULL, can_view_stats = NULL, blocked = NULL, can_delete_channel = NULL,
                          antispam = NULL, participants_hidden = NULL, translations_disabled = NULL, stories_pinned_available = NULL,
                          view_forum_as_messages = NULL, restricted_sponsored = NULL, can_view_revenue = NULL, paid_media_allowed = NULL,
                          can_view_stars_revenue = NULL, paid_reactions_available = NULL, stargifts_available = NULL, paid_messages_available = NULL,
                          participants_count = NULL, admins_count = NULL, kicked_count = NULL, banned_count = NULL, online_count = NULL,
                          exported_invite = NULL, migrated_from_chat_id = NULL, migrated_from_max_id = NULL, pinned_msg_id = NULL,
                          stickerset = NULL, available_min_id = NULL, folder_id = NULL, linked_chat_id = NULL, location = NULL,
                          slowmode_seconds = NULL, slowmode_next_send_date = NULL, stats_dc = NULL, call = NULL, ttl_period = NULL,
                          pending_suggestions = NULL, groupcall_default_join_as = NULL, theme_emoticon = NULL, requests_pending = NULL,
                          recent_requesters = NULL, default_send_as = NULL, available_reactions = NULL, reactions_limit = NULL,
                          stories = NULL, wallpaper = NULL, boosts_applied = NULL, boosts_unrestrict = NULL, emojiset = NULL,
                          bot_verification = NULL, stargifts_count = NULL, send_paid_messages_stars = NULL, main_tab = NULL) {
      self$id <- id
      self$about <- about
      self$read_inbox_max_id <- read_inbox_max_id
      self$read_outbox_max_id <- read_outbox_max_id
      self$unread_count <- unread_count
      self$chat_photo <- chat_photo
      self$notify_settings <- notify_settings
      self$bot_info <- bot_info
      self$pts <- pts
      self$can_view_participants <- can_view_participants
      self$can_set_username <- can_set_username
      self$can_set_stickers <- can_set_stickers
      self$hidden_prehistory <- hidden_prehistory
      self$can_set_location <- can_set_location
      self$has_scheduled <- has_scheduled
      self$can_view_stats <- can_view_stats
      self$blocked <- blocked
      self$can_delete_channel <- can_delete_channel
      self$antispam <- antispam
      self$participants_hidden <- participants_hidden
      self$translations_disabled <- translations_disabled
      self$stories_pinned_available <- stories_pinned_available
      self$view_forum_as_messages <- view_forum_as_messages
      self$restricted_sponsored <- restricted_sponsored
      self$can_view_revenue <- can_view_revenue
      self$paid_media_allowed <- paid_media_allowed
      self$can_view_stars_revenue <- can_view_stars_revenue
      self$paid_reactions_available <- paid_reactions_available
      self$stargifts_available <- stargifts_available
      self$paid_messages_available <- paid_messages_available
      self$participants_count <- participants_count
      self$admins_count <- admins_count
      self$kicked_count <- kicked_count
      self$banned_count <- banned_count
      self$online_count <- online_count
      self$exported_invite <- exported_invite
      self$migrated_from_chat_id <- migrated_from_chat_id
      self$migrated_from_max_id <- migrated_from_max_id
      self$pinned_msg_id <- pinned_msg_id
      self$stickerset <- stickerset
      self$available_min_id <- available_min_id
      self$folder_id <- folder_id
      self$linked_chat_id <- linked_chat_id
      self$location <- location
      self$slowmode_seconds <- slowmode_seconds
      self$slowmode_next_send_date <- slowmode_next_send_date
      self$stats_dc <- stats_dc
      self$call <- call
      self$ttl_period <- ttl_period
      self$pending_suggestions <- pending_suggestions
      self$groupcall_default_join_as <- groupcall_default_join_as
      self$theme_emoticon <- theme_emoticon
      self$requests_pending <- requests_pending
      self$recent_requesters <- recent_requesters
      self$default_send_as <- default_send_as
      self$available_reactions <- available_reactions
      self$reactions_limit <- reactions_limit
      self$stories <- stories
      self$wallpaper <- wallpaper
      self$boosts_applied <- boosts_applied
      self$boosts_unrestrict <- boosts_unrestrict
      self$emojiset <- emojiset
      self$bot_verification <- bot_verification
      self$stargifts_count <- stargifts_count
      self$send_paid_messages_stars <- send_paid_messages_stars
      self$main_tab <- main_tab
    },
    to_dict = function() {
      list(
        "_" = "ChannelFull",
        id = self$id,
        about = self$about,
        read_inbox_max_id = self$read_inbox_max_id,
        read_outbox_max_id = self$read_outbox_max_id,
        unread_count = self$unread_count,
        chat_photo = if (inherits(self$chat_photo, "TLObject")) self$chat_photo$to_dict() else self$chat_photo,
        notify_settings = if (inherits(self$notify_settings, "TLObject")) self$notify_settings$to_dict() else self$notify_settings,
        bot_info = if (is.null(self$bot_info)) NULL else lapply(self$bot_info, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        pts = self$pts,
        can_view_participants = self$can_view_participants,
        can_set_username = self$can_set_username,
        can_set_stickers = self$can_set_stickers,
        hidden_prehistory = self$hidden_prehistory,
        can_set_location = self$can_set_location,
        has_scheduled = self$has_scheduled,
        can_view_stats = self$can_view_stats,
        blocked = self$blocked,
        can_delete_channel = self$can_delete_channel,
        antispam = self$antispam,
        participants_hidden = self$participants_hidden,
        translations_disabled = self$translations_disabled,
        stories_pinned_available = self$stories_pinned_available,
        view_forum_as_messages = self$view_forum_as_messages,
        restricted_sponsored = self$restricted_sponsored,
        can_view_revenue = self$can_view_revenue,
        paid_media_allowed = self$paid_media_allowed,
        can_view_stars_revenue = self$can_view_stars_revenue,
        paid_reactions_available = self$paid_reactions_available,
        stargifts_available = self$stargifts_available,
        paid_messages_available = self$paid_messages_available,
        participants_count = self$participants_count,
        admins_count = self$admins_count,
        kicked_count = self$kicked_count,
        banned_count = self$banned_count,
        online_count = self$online_count,
        exported_invite = if (inherits(self$exported_invite, "TLObject")) self$exported_invite$to_dict() else self$exported_invite,
        migrated_from_chat_id = self$migrated_from_chat_id,
        migrated_from_max_id = self$migrated_from_max_id,
        pinned_msg_id = self$pinned_msg_id,
        stickerset = if (inherits(self$stickerset, "TLObject")) self$stickerset$to_dict() else self$stickerset,
        available_min_id = self$available_min_id,
        folder_id = self$folder_id,
        linked_chat_id = self$linked_chat_id,
        location = if (inherits(self$location, "TLObject")) self$location$to_dict() else self$location,
        slowmode_seconds = self$slowmode_seconds,
        slowmode_next_send_date = self$slowmode_next_send_date,
        stats_dc = self$stats_dc,
        call = if (inherits(self$call, "TLObject")) self$call$to_dict() else self$call,
        ttl_period = self$ttl_period,
        pending_suggestions = self$pending_suggestions,
        groupcall_default_join_as = if (inherits(self$groupcall_default_join_as, "TLObject")) self$groupcall_default_join_as$to_dict() else self$groupcall_default_join_as,
        theme_emoticon = self$theme_emoticon,
        requests_pending = self$requests_pending,
        recent_requesters = self$recent_requesters,
        default_send_as = if (inherits(self$default_send_as, "TLObject")) self$default_send_as$to_dict() else self$default_send_as,
        available_reactions = if (inherits(self$available_reactions, "TLObject")) self$available_reactions$to_dict() else self$available_reactions,
        reactions_limit = self$reactions_limit,
        stories = if (inherits(self$stories, "TLObject")) self$stories$to_dict() else self$stories,
        wallpaper = if (inherits(self$wallpaper, "TLObject")) self$wallpaper$to_dict() else self$wallpaper,
        boosts_applied = self$boosts_applied,
        boosts_unrestrict = self$boosts_unrestrict,
        emojiset = if (inherits(self$emojiset, "TLObject")) self$emojiset$to_dict() else self$emojiset,
        bot_verification = if (inherits(self$bot_verification, "TLObject")) self$bot_verification$to_dict() else self$bot_verification,
        stargifts_count = self$stargifts_count,
        send_paid_messages_stars = self$send_paid_messages_stars,
        main_tab = if (inherits(self$main_tab, "TLObject")) self$main_tab$to_dict() else self$main_tab
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0xe4, 0xe0, 0xb2, 0x9d))
    }
  ),
  #  @field class Field.
  class = TRUE
)

#  @title ChannelAdminLogEventActionPinTopic
#  @description Telegram API type ChannelAdminLogEventActionPinTopic
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionPinTopic <- R6::R6Class("ChannelAdminLogEventActionPinTopic",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5d8d353b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    initialize = function(prev_topic = NULL, new_topic = NULL) {
      self$prev_topic <- prev_topic
      self$new_topic <- new_topic
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionPinTopic",
        prev_topic = if (inherits(self$prev_topic, "TLObject")) self$prev_topic$to_dict() else self$prev_topic,
        new_topic = if (inherits(self$new_topic, "TLObject")) self$new_topic$to_dict() else self$new_topic
      )
    },
    bytes = function() {
      c(
        writeBin(as.integer(0x5d8d353b), raw(), size = 4, endian = "little"),
        writeBin(as.integer((if (is.null(self$prev_topic) || isFALSE(self$prev_topic)) 0 else 1) | (if (is.null(self$new_topic) || isFALSE(self$new_topic)) 0 else 2)), raw(), size = 4, endian = "little"),
        if (is.null(self$prev_topic) || isFALSE(self$prev_topic)) raw() else self$prev_topic$bytes(),
        if (is.null(self$new_topic) || isFALSE(self$new_topic)) raw() else self$new_topic$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      if (bitwAnd(flags, 1)) {
        prev_topic <- reader$tgread_object()
      } else {
        prev_topic <- NULL
      }
      if (bitwAnd(flags, 2)) {
        new_topic <- reader$tgread_object()
      } else {
        new_topic <- NULL
      }
      self$initialize(prev_topic = prev_topic, new_topic = new_topic)
    }
  )
)

#  @title ChannelAdminLogEventActionSendMessage
#  @description Telegram API type ChannelAdminLogEventActionSendMessage
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionSendMessage <- R6::R6Class("ChannelAdminLogEventActionSendMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x278f2868,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    initialize = function(message) {
      self$message <- message
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionSendMessage",
        message = if (inherits(self$message, "TLObject")) self$message$to_dict() else self$message
      )
    },
    bytes = function() {
      c(
        writeBin(as.integer(0x278f2868), raw(), size = 4, endian = "little"),
        self$message$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      message <- reader$tgread_object()
      self$initialize(message = message)
    }
  )
)

#  @title ChannelAdminLogEventActionStartGroupCall
#  @description Telegram API type ChannelAdminLogEventActionStartGroupCall
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionStartGroupCall <- R6::R6Class("ChannelAdminLogEventActionStartGroupCall",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x23209745,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    initialize = function(call) {
      self$call <- call
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionStartGroupCall",
        call = if (inherits(self$call, "TLObject")) self$call$to_dict() else self$call
      )
    },
    bytes = function() {
      c(
        writeBin(as.integer(0x23209745), raw(), size = 4, endian = "little"),
        self$call$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      call <- reader$tgread_object()
      self$initialize(call = call)
    }
  )
)

#  @title ChannelAdminLogEventActionStopPoll
#  @description Telegram API type ChannelAdminLogEventActionStopPoll
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionStopPoll <- R6::R6Class("ChannelAdminLogEventActionStopPoll",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8f079643,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    initialize = function(message) {
      self$message <- message
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionStopPoll",
        message = if (inherits(self$message, "TLObject")) self$message$to_dict() else self$message
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x43, 0x96, 0x07, 0x8f)),
        self$message$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      message <- reader$tgread_object()
      self$initialize(message = message)
    }
  )
)

#  @title ChannelAdminLogEventActionToggleAntiSpam
#  @description Telegram API type ChannelAdminLogEventActionToggleAntiSpam
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionToggleAntiSpam <- R6::R6Class("ChannelAdminLogEventActionToggleAntiSpam",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x64f36dfc,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    initialize = function(new_value) {
      self$new_value <- new_value
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionToggleAntiSpam",
        new_value = self$new_value
      )
    },
    bytes = function() {
      c(
        writeBin(as.integer(0x64f36dfc), raw(), size = 4, endian = "little"),
        writeBin(as.integer(if (self$new_value) 0xb5757299 else 0x3797bc7c), raw(), size = 4, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      new_value <- reader$tgread_bool()
      self$initialize(new_value = new_value)
    }
  )
)

#  @title ChannelAdminLogEventActionToggleAutotranslation
#  @description Telegram API type ChannelAdminLogEventActionToggleAutotranslation
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionToggleAutotranslation <- R6::R6Class("ChannelAdminLogEventActionToggleAutotranslation",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc517f77e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    initialize = function(new_value) {
      self$new_value <- new_value
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionToggleAutotranslation",
        new_value = self$new_value
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x7e, 0xf7, 0x17, 0xc5)),
        writeBin(as.integer(if (self$new_value) 0xb5757299 else 0x3797bc7c), raw(), size = 4, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      new_value <- reader$tgread_bool()
      self$initialize(new_value = new_value)
    }
  )
)

#  @title ChannelAdminLogEventActionToggleForum
#  @description Telegram API type ChannelAdminLogEventActionToggleForum
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionToggleForum <- R6::R6Class("ChannelAdminLogEventActionToggleForum",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x2cc6383,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    initialize = function(new_value) {
      self$new_value <- new_value
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionToggleForum",
        new_value = self$new_value
      )
    },
    bytes = function() {
      c(
        writeBin(as.integer(0x2cc6383), raw(), size = 4, endian = "little"),
        writeBin(as.integer(if (self$new_value) 0xb5757299 else 0x3797bc7c), raw(), size = 4, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      new_value <- reader$tgread_bool()
      self$initialize(new_value = new_value)
    }
  )
)

#  @title ChannelAdminLogEventActionToggleGroupCallSetting
#  @description Telegram API type ChannelAdminLogEventActionToggleGroupCallSetting
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionToggleGroupCallSetting <- R6::R6Class("ChannelAdminLogEventActionToggleGroupCallSetting",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x56d6a247,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    initialize = function(join_muted) {
      self$join_muted <- join_muted
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionToggleGroupCallSetting",
        join_muted = self$join_muted
      )
    },
    bytes = function() {
      c(
        writeBin(as.integer(0x56d6a247), raw(), size = 4, endian = "little"),
        writeBin(as.integer(if (self$join_muted) 0xb5757299 else 0x3797bc7c), raw(), size = 4, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      join_muted <- reader$tgread_bool()

      self$initialize(join_muted = join_muted)
    }
  )
)

#  @title ChannelAdminLogEventActionToggleInvites
#  @description Telegram API type ChannelAdminLogEventActionToggleInvites
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionToggleInvites <- R6::R6Class("ChannelAdminLogEventActionToggleInvites",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1b7907ae,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    initialize = function(new_value) {
      self$new_value <- new_value
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionToggleInvites",
        new_value = self$new_value
      )
    },
    bytes = function() {
      c(
        writeBin(as.integer(0x1b7907ae), raw(), size = 4, endian = "little"),
        writeBin(as.integer(if (self$new_value) 0xb5757299 else 0x3797bc7c), raw(), size = 4, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      new_value <- reader$tgread_bool()
      self$initialize(new_value = new_value)
    }
  )
)

#  @title ChannelAdminLogEventActionToggleNoForwards
#  @description Telegram API type ChannelAdminLogEventActionToggleNoForwards
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionToggleNoForwards <- R6::R6Class("ChannelAdminLogEventActionToggleNoForwards",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xcb2ac766,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    initialize = function(new_value) {
      self$new_value <- new_value
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionToggleNoForwards",
        new_value = self$new_value
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x66, 0xc7, 0x2a, 0xcb)),
        writeBin(as.integer(if (self$new_value) 0xb5757299 else 0x3797bc7c), raw(), size = 4, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      new_value <- reader$tgread_bool()
      self$initialize(new_value = new_value)
    }
  )
)

#  @title ChannelAdminLogEventActionTogglePreHistoryHidden
#  @description Telegram API type ChannelAdminLogEventActionTogglePreHistoryHidden
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionTogglePreHistoryHidden <- R6::R6Class("ChannelAdminLogEventActionTogglePreHistoryHidden",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5f5c95f1,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    initialize = function(new_value) {
      self$new_value <- new_value
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionTogglePreHistoryHidden",
        new_value = self$new_value
      )
    },
    bytes = function() {
      c(
        writeBin(as.integer(0x5f5c95f1), raw(), size = 4, endian = "little"),
        writeBin(as.integer(if (self$new_value) 0xb5757299 else 0x3797bc7c), raw(), size = 4, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      new_value <- reader$tgread_bool()
      self$initialize(new_value = new_value)
    }
  )
)

#  @title ChannelAdminLogEventActionToggleSignatureProfiles
#  @description Telegram API type ChannelAdminLogEventActionToggleSignatureProfiles
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionToggleSignatureProfiles <- R6::R6Class("ChannelAdminLogEventActionToggleSignatureProfiles",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x60a79c79,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    initialize = function(new_value) {
      self$new_value <- new_value
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionToggleSignatureProfiles",
        new_value = self$new_value
      )
    },
    bytes = function() {
      c(
        writeBin(as.integer(0x60a79c79), raw(), size = 4, endian = "little"),
        writeBin(as.integer(if (self$new_value) 0xb5757299 else 0x3797bc7c), raw(), size = 4, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      new_value <- reader$tgread_bool()
      self$initialize(new_value = new_value)
    }
  )
)

#  @title ChannelAdminLogEventActionToggleSignatures
#  @description Telegram API type ChannelAdminLogEventActionToggleSignatures
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionToggleSignatures <- R6::R6Class("ChannelAdminLogEventActionToggleSignatures",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x26ae0971,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    initialize = function(new_value) {
      self$new_value <- new_value
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionToggleSignatures",
        new_value = self$new_value
      )
    },
    bytes = function() {
      c(
        writeBin(as.integer(0x26ae0971), raw(), size = 4, endian = "little"),
        writeBin(as.integer(if (self$new_value) 0xb5757299 else 0x3797bc7c), raw(), size = 4, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      new_value <- reader$tgread_bool()
      self$initialize(new_value = new_value)
    }
  )
)

#  @title ChannelAdminLogEventActionToggleSlowMode
#  @description Telegram API type ChannelAdminLogEventActionToggleSlowMode
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionToggleSlowMode <- R6::R6Class("ChannelAdminLogEventActionToggleSlowMode",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x53909779,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    initialize = function(prev_value, new_value) {
      self$prev_value <- prev_value
      self$new_value <- new_value
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionToggleSlowMode",
        prev_value = self$prev_value,
        new_value = self$new_value
      )
    },
    bytes = function() {
      c(
        writeBin(as.integer(0x53909779), raw(), size = 4, endian = "little"),
        writeBin(as.integer(as.integer(self$prev_value)), raw(), size = 4, endian = "little"),
        writeBin(as.integer(as.integer(self$new_value)), raw(), size = 4, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      prev_value <- reader$read_int()
      new_value <- reader$read_int()
      self$initialize(prev_value = prev_value, new_value = new_value)
    }
  )
)

#  @title ChannelAdminLogEventActionUpdatePinned
#  @description Telegram API type ChannelAdminLogEventActionUpdatePinned
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventActionUpdatePinned <- R6::R6Class("ChannelAdminLogEventActionUpdatePinned",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe9e82c18,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb2b987f3,
    initialize = function(message) {
      self$message <- message
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventActionUpdatePinned",
        message = if (inherits(self$message, "TLObject")) self$message$to_dict() else self$message
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x18, 0x2c, 0xe8, 0xe9)),
        self$message$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      message <- reader$tgread_object()
      self$initialize(message = message)
    }
  )
)

#  @title ChannelAdminLogEventsFilter
#  @description Telegram API type ChannelAdminLogEventsFilter
#  @export
#  @noRd
#  @noRd
ChannelAdminLogEventsFilter <- R6::R6Class("ChannelAdminLogEventsFilter",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xea107ae4,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x7cbbf319,
    initialize = function(join = NULL, leave = NULL, invite = NULL, ban = NULL, unban = NULL, kick = NULL, unkick = NULL, promote = NULL, demote = NULL, info = NULL, settings = NULL, pinned = NULL, edit = NULL, delete = NULL, group_call = NULL, invites = NULL, send = NULL, forums = NULL, sub_extend = NULL) {
      self$join <- join
      self$leave <- leave
      self$invite <- invite
      self$ban <- ban
      self$unban <- unban
      self$kick <- kick
      self$unkick <- unkick
      self$promote <- promote
      self$demote <- demote
      self$info <- info
      self$settings <- settings
      self$pinned <- pinned
      self$edit <- edit
      self$delete <- delete
      self$group_call <- group_call
      self$invites <- invites
      self$send <- send
      self$forums <- forums
      self$sub_extend <- sub_extend
    },
    to_dict = function() {
      list(
        "_" = "ChannelAdminLogEventsFilter",
        join = self$join,
        leave = self$leave,
        invite = self$invite,
        ban = self$ban,
        unban = self$unban,
        kick = self$kick,
        unkick = self$unkick,
        promote = self$promote,
        demote = self$demote,
        info = self$info,
        settings = self$settings,
        pinned = self$pinned,
        edit = self$edit,
        delete = self$delete,
        group_call = self$group_call,
        invites = self$invites,
        send = self$send,
        forums = self$forums,
        sub_extend = self$sub_extend
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xe4, 0x7a, 0x10, 0xea)),
        writeBin(as.integer((if (is.null(self$join) || !self$join) 0 else 1) | (if (is.null(self$leave) || !self$leave) 0 else 2) | (if (is.null(self$invite) || !self$invite) 0 else 4) | (if (is.null(self$ban) || !self$ban) 0 else 8) | (if (is.null(self$unban) || !self$unban) 0 else 16) | (if (is.null(self$kick) || !self$kick) 0 else 32) | (if (is.null(self$unkick) || !self$unkick) 0 else 64) | (if (is.null(self$promote) || !self$promote) 0 else 128) | (if (is.null(self$demote) || !self$demote) 0 else 256) | (if (is.null(self$info) || !self$info) 0 else 512) | (if (is.null(self$settings) || !self$settings) 0 else 1024) | (if (is.null(self$pinned) || !self$pinned) 0 else 2048) | (if (is.null(self$edit) || !self$edit) 0 else 4096) | (if (is.null(self$delete) || !self$delete) 0 else 8192) | (if (is.null(self$group_call) || !self$group_call) 0 else 16384) | (if (is.null(self$invites) || !self$invites) 0 else 32768) | (if (is.null(self$send) || !self$send) 0 else 65536) | (if (is.null(self$forums) || !self$forums) 0 else 131072) | (if (is.null(self$sub_extend) || !self$sub_extend) 0 else 262144)), raw(), size = 4, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      join <- bitwAnd(flags, 1) != 0
      leave <- bitwAnd(flags, 2) != 0
      invite <- bitwAnd(flags, 4) != 0
      ban <- bitwAnd(flags, 8) != 0
      unban <- bitwAnd(flags, 16) != 0
      kick <- bitwAnd(flags, 32) != 0
      unkick <- bitwAnd(flags, 64) != 0
      promote <- bitwAnd(flags, 128) != 0
      demote <- bitwAnd(flags, 256) != 0
      info <- bitwAnd(flags, 512) != 0
      settings <- bitwAnd(flags, 1024) != 0
      pinned <- bitwAnd(flags, 2048) != 0
      edit <- bitwAnd(flags, 4096) != 0
      delete <- bitwAnd(flags, 8192) != 0
      group_call <- bitwAnd(flags, 16384) != 0
      invites <- bitwAnd(flags, 32768) != 0
      send <- bitwAnd(flags, 65536) != 0
      forums <- bitwAnd(flags, 131072) != 0
      sub_extend <- bitwAnd(flags, 262144) != 0
      self$initialize(join = join, leave = leave, invite = invite, ban = ban, unban = unban, kick = kick, unkick = unkick, promote = promote, demote = demote, info = info, settings = settings, pinned = pinned, edit = edit, delete = delete, group_call = group_call, invites = invites, send = send, forums = forums, sub_extend = sub_extend)
    }
  )
)

#  @title ChannelForbidden
#  @description Telegram API type ChannelForbidden
#  @export
#  @noRd
#  @noRd
ChannelForbidden <- R6::R6Class("ChannelForbidden",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x17d493d5,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc5af5d94,
    initialize = function(id, access_hash, title, broadcast = NULL, megagroup = NULL, until_date = NULL) {
      self$id <- id
      self$access_hash <- access_hash
      self$title <- title
      self$broadcast <- broadcast
      self$megagroup <- megagroup
      self$until_date <- until_date
    },
    to_dict = function() {
      list(
        "_" = "ChannelForbidden",
        id = self$id,
        access_hash = self$access_hash,
        title = self$title,
        broadcast = self$broadcast,
        megagroup = self$megagroup,
        until_date = self$until_date
      )
    },
    bytes = function() {
      c(
        writeBin(as.integer(0x17d493d5), raw(), size = 4, endian = "little"),
        writeBin(as.integer((if (is.null(self$broadcast) || !self$broadcast) 0 else 32) | (if (is.null(self$megagroup) || !self$megagroup) 0 else 256) | (if (is.null(self$until_date) || !self$until_date) 0 else 65536)), raw(), size = 4, endian = "little"),
        writeBin(as.numeric(self$id), raw(), size = 8, endian = "little"),
        writeBin(as.numeric(self$access_hash), raw(), size = 8, endian = "little"),
        self$serializebytes(self$title),
        if (is.null(self$until_date) || !self$until_date) raw() else self$serialize_datetime(self$until_date)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      broadcast <- bitwAnd(flags, 32) != 0
      megagroup <- bitwAnd(flags, 256) != 0
      id <- reader$read_long()
      access_hash <- reader$read_long()
      title <- reader$tgread_string()
      if (bitwAnd(flags, 65536) != 0) {
        until_date <- reader$tgread_date()
      } else {
        until_date <- NULL
      }
      self$initialize(id = id, access_hash = access_hash, title = title, broadcast = broadcast, megagroup = megagroup, until_date = until_date)
    }
  )
)

#  @title ChannelFull
#  @description Telegram API type ChannelFull
#  @export
#  @noRd
#  @noRd
ChannelFull <- R6::R6Class(
  "ChannelFull",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe4e0b29d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd49a2697,
    #  @field id Field.
    id = NULL,
    #  @field about Field.
    about = NULL,
    #  @field read_inbox_max_id Field.
    read_inbox_max_id = NULL,
    #  @field read_outbox_max_id Field.
    read_outbox_max_id = NULL,
    #  @field unread_count Field.
    unread_count = NULL,
    #  @field chat_photo Field.
    chat_photo = NULL,
    #  @field notify_settings Field.
    notify_settings = NULL,
    #  @field bot_info Field.
    bot_info = NULL,
    #  @field pts Field.
    pts = NULL,
    #  @field can_view_participants Field.
    can_view_participants = NULL,
    #  @field can_set_username Field.
    can_set_username = NULL,
    #  @field can_set_stickers Field.
    can_set_stickers = NULL,
    #  @field hidden_prehistory Field.
    hidden_prehistory = NULL,
    #  @field can_set_location Field.
    can_set_location = NULL,
    #  @field has_scheduled Field.
    has_scheduled = NULL,
    #  @field can_view_stats Field.
    can_view_stats = NULL,
    #  @field blocked Field.
    blocked = NULL,
    #  @field can_delete_channel Field.
    can_delete_channel = NULL,
    #  @field antispam Field.
    antispam = NULL,
    #  @field participants_hidden Field.
    participants_hidden = NULL,
    #  @field translations_disabled Field.
    translations_disabled = NULL,
    #  @field stories_pinned_available Field.
    stories_pinned_available = NULL,
    #  @field view_forum_as_messages Field.
    view_forum_as_messages = NULL,
    #  @field restricted_sponsored Field.
    restricted_sponsored = NULL,
    #  @field can_view_revenue Field.
    can_view_revenue = NULL,
    #  @field paid_media_allowed Field.
    paid_media_allowed = NULL,
    #  @field can_view_stars_revenue Field.
    can_view_stars_revenue = NULL,
    #  @field paid_reactions_available Field.
    paid_reactions_available = NULL,
    #  @field stargifts_available Field.
    stargifts_available = NULL,
    #  @field paid_messages_available Field.
    paid_messages_available = NULL,
    #  @field participants_count Field.
    participants_count = NULL,
    #  @field admins_count Field.
    admins_count = NULL,
    #  @field kicked_count Field.
    kicked_count = NULL,
    #  @field banned_count Field.
    banned_count = NULL,
    #  @field online_count Field.
    online_count = NULL,
    #  @field exported_invite Field.
    exported_invite = NULL,
    #  @field migrated_from_chat_id Field.
    migrated_from_chat_id = NULL,
    #  @field migrated_from_max_id Field.
    migrated_from_max_id = NULL,
    #  @field pinned_msg_id Field.
    pinned_msg_id = NULL,
    #  @field stickerset Field.
    stickerset = NULL,
    #  @field available_min_id Field.
    available_min_id = NULL,
    #  @field folder_id Field.
    folder_id = NULL,
    #  @field linked_chat_id Field.
    linked_chat_id = NULL,
    #  @field location Field.
    location = NULL,
    #  @field slowmode_seconds Field.
    slowmode_seconds = NULL,
    #  @field slowmode_next_send_date Field.
    slowmode_next_send_date = NULL,
    #  @field stats_dc Field.
    stats_dc = NULL,
    #  @field call Field.
    call = NULL,
    #  @field ttl_period Field.
    ttl_period = NULL,
    #  @field pending_suggestions Field.
    pending_suggestions = NULL,
    #  @field groupcall_default_join_as Field.
    groupcall_default_join_as = NULL,
    #  @field theme_emoticon Field.
    theme_emoticon = NULL,
    #  @field requests_pending Field.
    requests_pending = NULL,
    #  @field recent_requesters Field.
    recent_requesters = NULL,
    #  @field default_send_as Field.
    default_send_as = NULL,
    #  @field available_reactions Field.
    available_reactions = NULL,
    #  @field reactions_limit Field.
    reactions_limit = NULL,
    #  @field stories Field.
    stories = NULL,
    #  @field wallpaper Field.
    wallpaper = NULL,
    #  @field boosts_applied Field.
    boosts_applied = NULL,
    #  @field boosts_unrestrict Field.
    boosts_unrestrict = NULL,
    #  @field emojiset Field.
    emojiset = NULL,
    #  @field bot_verification Field.
    bot_verification = NULL,
    #  @field stargifts_count Field.
    stargifts_count = NULL,
    #  @field send_paid_messages_stars Field.
    send_paid_messages_stars = NULL,
    #  @field main_tab Field.
    main_tab = NULL,
    initialize = function(id, about, read_inbox_max_id, read_outbox_max_id, unread_count, chat_photo, notify_settings, bot_info, pts,
                          can_view_participants = NULL, can_set_username = NULL, can_set_stickers = NULL, hidden_prehistory = NULL,
                          can_set_location = NULL, has_scheduled = NULL, can_view_stats = NULL, blocked = NULL, can_delete_channel = NULL,
                          antispam = NULL, participants_hidden = NULL, translations_disabled = NULL, stories_pinned_available = NULL,
                          view_forum_as_messages = NULL, restricted_sponsored = NULL, can_view_revenue = NULL, paid_media_allowed = NULL,
                          can_view_stars_revenue = NULL, paid_reactions_available = NULL, stargifts_available = NULL, paid_messages_available = NULL,
                          participants_count = NULL, admins_count = NULL, kicked_count = NULL, banned_count = NULL, online_count = NULL,
                          exported_invite = NULL, migrated_from_chat_id = NULL, migrated_from_max_id = NULL, pinned_msg_id = NULL,
                          stickerset = NULL, available_min_id = NULL, folder_id = NULL, linked_chat_id = NULL, location = NULL,
                          slowmode_seconds = NULL, slowmode_next_send_date = NULL, stats_dc = NULL, call = NULL, ttl_period = NULL,
                          pending_suggestions = NULL, groupcall_default_join_as = NULL, theme_emoticon = NULL, requests_pending = NULL,
                          recent_requesters = NULL, default_send_as = NULL, available_reactions = NULL, reactions_limit = NULL, stories = NULL,
                          wallpaper = NULL, boosts_applied = NULL, boosts_unrestrict = NULL, emojiset = NULL, bot_verification = NULL,
                          stargifts_count = NULL, send_paid_messages_stars = NULL, main_tab = NULL) {
      self$id <- id
      self$about <- about
      self$read_inbox_max_id <- read_inbox_max_id
      self$read_outbox_max_id <- read_outbox_max_id
      self$unread_count <- unread_count
      self$chat_photo <- chat_photo
      self$notify_settings <- notify_settings
      self$bot_info <- bot_info
      self$pts <- pts
      self$can_view_participants <- can_view_participants
      self$can_set_username <- can_set_username
      self$can_set_stickers <- can_set_stickers
      self$hidden_prehistory <- hidden_prehistory
      self$can_set_location <- can_set_location
      self$has_scheduled <- has_scheduled
      self$can_view_stats <- can_view_stats
      self$blocked <- blocked
      self$can_delete_channel <- can_delete_channel
      self$antispam <- antispam
      self$participants_hidden <- participants_hidden
      self$translations_disabled <- translations_disabled
      self$stories_pinned_available <- stories_pinned_available
      self$view_forum_as_messages <- view_forum_as_messages
      self$restricted_sponsored <- restricted_sponsored
      self$can_view_revenue <- can_view_revenue
      self$paid_media_allowed <- paid_media_allowed
      self$can_view_stars_revenue <- can_view_stars_revenue
      self$paid_reactions_available <- paid_reactions_available
      self$stargifts_available <- stargifts_available
      self$paid_messages_available <- paid_messages_available
      self$participants_count <- participants_count
      self$admins_count <- admins_count
      self$kicked_count <- kicked_count
      self$banned_count <- banned_count
      self$online_count <- online_count
      self$exported_invite <- exported_invite
      self$migrated_from_chat_id <- migrated_from_chat_id
      self$migrated_from_max_id <- migrated_from_max_id
      self$pinned_msg_id <- pinned_msg_id
      self$stickerset <- stickerset
      self$available_min_id <- available_min_id
      self$folder_id <- folder_id
      self$linked_chat_id <- linked_chat_id
      self$location <- location
      self$slowmode_seconds <- slowmode_seconds
      self$slowmode_next_send_date <- slowmode_next_send_date
      self$stats_dc <- stats_dc
      self$call <- call
      self$ttl_period <- ttl_period
      self$pending_suggestions <- pending_suggestions
      self$groupcall_default_join_as <- groupcall_default_join_as
      self$theme_emoticon <- theme_emoticon
      self$requests_pending <- requests_pending
      self$recent_requesters <- recent_requesters
      self$default_send_as <- default_send_as
      self$available_reactions <- available_reactions
      self$reactions_limit <- reactions_limit
      self$stories <- stories
      self$wallpaper <- wallpaper
      self$boosts_applied <- boosts_applied
      self$boosts_unrestrict <- boosts_unrestrict
      self$emojiset <- emojiset
      self$bot_verification <- bot_verification
      self$stargifts_count <- stargifts_count
      self$send_paid_messages_stars <- send_paid_messages_stars
      self$main_tab <- main_tab
    },
    to_dict = function() {
      list(
        `_` = "ChannelFull",
        id = self$id,
        about = self$about,
        read_inbox_max_id = self$read_inbox_max_id,
        read_outbox_max_id = self$read_outbox_max_id,
        unread_count = self$unread_count,
        chat_photo = if (inherits(self$chat_photo, "TLObject")) self$chat_photo$to_dict() else self$chat_photo,
        notify_settings = if (inherits(self$notify_settings, "TLObject")) self$notify_settings$to_dict() else self$notify_settings,
        bot_info = if (is.null(self$bot_info)) list() else lapply(self$bot_info, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        pts = self$pts,
        can_view_participants = self$can_view_participants,
        can_set_username = self$can_set_username,
        can_set_stickers = self$can_set_stickers,
        hidden_prehistory = self$hidden_prehistory,
        can_set_location = self$can_set_location,
        has_scheduled = self$has_scheduled,
        can_view_stats = self$can_view_stats,
        blocked = self$blocked,
        can_delete_channel = self$can_delete_channel,
        antispam = self$antispam,
        participants_hidden = self$participants_hidden,
        translations_disabled = self$translations_disabled,
        stories_pinned_available = self$stories_pinned_available,
        view_forum_as_messages = self$view_forum_as_messages,
        restricted_sponsored = self$restricted_sponsored,
        can_view_revenue = self$can_view_revenue,
        paid_media_allowed = self$paid_media_allowed,
        can_view_stars_revenue = self$can_view_stars_revenue,
        paid_reactions_available = self$paid_reactions_available,
        stargifts_available = self$stargifts_available,
        paid_messages_available = self$paid_messages_available,
        participants_count = self$participants_count,
        admins_count = self$admins_count,
        kicked_count = self$kicked_count,
        banned_count = self$banned_count,
        online_count = self$online_count,
        exported_invite = if (inherits(self$exported_invite, "TLObject")) self$exported_invite$to_dict() else self$exported_invite,
        migrated_from_chat_id = self$migrated_from_chat_id,
        migrated_from_max_id = self$migrated_from_max_id,
        pinned_msg_id = self$pinned_msg_id,
        stickerset = if (inherits(self$stickerset, "TLObject")) self$stickerset$to_dict() else self$stickerset,
        available_min_id = self$available_min_id,
        folder_id = self$folder_id,
        linked_chat_id = self$linked_chat_id,
        location = if (inherits(self$location, "TLObject")) self$location$to_dict() else self$location,
        slowmode_seconds = self$slowmode_seconds,
        slowmode_next_send_date = self$slowmode_next_send_date,
        stats_dc = self$stats_dc,
        call = if (inherits(self$call, "TLObject")) self$call$to_dict() else self$call,
        ttl_period = self$ttl_period,
        pending_suggestions = if (is.null(self$pending_suggestions)) list() else self$pending_suggestions,
        groupcall_default_join_as = if (inherits(self$groupcall_default_join_as, "TLObject")) self$groupcall_default_join_as$to_dict() else self$groupcall_default_join_as,
        theme_emoticon = self$theme_emoticon,
        requests_pending = self$requests_pending,
        recent_requesters = if (is.null(self$recent_requesters)) list() else self$recent_requesters,
        default_send_as = if (inherits(self$default_send_as, "TLObject")) self$default_send_as$to_dict() else self$default_send_as,
        available_reactions = if (inherits(self$available_reactions, "TLObject")) self$available_reactions$to_dict() else self$available_reactions,
        reactions_limit = self$reactions_limit,
        stories = if (inherits(self$stories, "TLObject")) self$stories$to_dict() else self$stories,
        wallpaper = if (inherits(self$wallpaper, "TLObject")) self$wallpaper$to_dict() else self$wallpaper,
        boosts_applied = self$boosts_applied,
        boosts_unrestrict = self$boosts_unrestrict,
        emojiset = if (inherits(self$emojiset, "TLObject")) self$emojiset$to_dict() else self$emojiset,
        bot_verification = if (inherits(self$bot_verification, "TLObject")) self$bot_verification$to_dict() else self$bot_verification,
        stargifts_count = self$stargifts_count,
        send_paid_messages_stars = self$send_paid_messages_stars,
        main_tab = if (inherits(self$main_tab, "TLObject")) self$main_tab$to_dict() else self$main_tab
      )
    }
  )
)

#  @title ChannelLocation
#  @description Telegram API type ChannelLocation
#  @export
#  @noRd
#  @noRd
ChannelLocation <- R6::R6Class(
  "ChannelLocation",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x209b82db,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xec260b7f,
    #  @field geo_point Field.
    geo_point = NULL,
    #  @field address Field.
    address = NULL,
    initialize = function(geo_point, address) {
      self$geo_point <- geo_point
      self$address <- address
    },
    to_dict = function() {
      list(
        "_" = "ChannelLocation",
        geo_point = if (inherits(self$geo_point, "TLObject")) self$geo_point$to_dict() else self$geo_point,
        address = self$address
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xdb, 0x82, 0x9b, 0x20)),
        self$geo_point$bytes(),
        serialize_bytes(self$address)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      geo_point <- reader$tgread_object()
      address <- reader$tgread_string()
      self$initialize(geo_point = geo_point, address = address)
    }
  )
)

#  @title ChannelLocationEmpty
#  @description Telegram API type ChannelLocationEmpty
#  @export
#  @noRd
#  @noRd
ChannelLocationEmpty <- R6::R6Class("ChannelLocationEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbfb5ad8b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xec260b7f,
    initialize = function() {
      # no fields
    },
    to_dict = function() {
      list("_" = "ChannelLocationEmpty")
    },
    bytes = function() {
      warning("bytes not implemented for R")
      as.raw(c(0x8b, 0xad, 0xb5, 0xbf))
    }
  ),
  private = list(
    from_reader = function(reader) {
      # nothing to read for empty location
      self$initialize()
    }
  ),
  class = TRUE,
  lock_objects = FALSE
)

#  @title ChannelMessagesFilter
#  @description Telegram API type ChannelMessagesFilter
#  @export
#  @noRd
#  @noRd
ChannelMessagesFilter <- R6::R6Class("ChannelMessagesFilter",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xcd77d957,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x13336a56,
    #  @field ranges Field.
    ranges = NULL,
    #  @field exclude_new_messages Field.
    exclude_new_messages = NULL,
    initialize = function(ranges, exclude_new_messages = NULL) {
      self$ranges <- ranges
      self$exclude_new_messages <- exclude_new_messages
    },
    to_dict = function() {
      list(
        "_" = "ChannelMessagesFilter",
        ranges = if (is.null(self$ranges)) NULL else lapply(self$ranges, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        exclude_new_messages = self$exclude_new_messages
      )
    },
    bytes = function() {
      warning("bytes not fully implemented for R")
      as.raw(c(0x57, 0xd9, 0x77, 0xcd))
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      exclude_new_messages <- bitwAnd(flags, 2) != 0
      # read and ignore an int (was present in python generated code)
      reader$read_int()
      n <- reader$read_int()
      ranges <- list()
      for (i in seq_len(n)) {
        ranges[[i]] <- reader$tgread_object()
      }
      self$initialize(ranges = ranges, exclude_new_messages = exclude_new_messages)
    }
  ),
  class = TRUE,
  lock_objects = FALSE
)

#  @title ChannelMessagesFilterEmpty
#  @description Telegram API type ChannelMessagesFilterEmpty
#  @export
#  @noRd
#  @noRd
ChannelMessagesFilterEmpty <- R6::R6Class("ChannelMessagesFilterEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x94d42ee7,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x13336a56,
    initialize = function() {
      # empty
    },
    to_dict = function() {
      list("_" = "ChannelMessagesFilterEmpty")
    },
    bytes = function() {
      warning("bytes not implemented for R")
      as.raw(c(0xe7, 0x2e, 0xd4, 0x94))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$initialize()
    }
  ),
  class = TRUE,
  lock_objects = FALSE
)

#  @title ChannelParticipant
#  @description Telegram API type ChannelParticipant
#  @export
#  @noRd
#  @noRd
ChannelParticipant <- R6::R6Class(
  "ChannelParticipant",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xcb397619,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd9c7fc18,
    #  @field user_id Field.
    user_id = NULL,
    #  @field date Field.
    date = NULL,
    #  @field subscription_until_date Field.
    subscription_until_date = NULL,
    initialize = function(user_id, date, subscription_until_date = NULL) {
      self$user_id <- user_id
      self$date <- date
      self$subscription_until_date <- subscription_until_date
    },
    to_dict = function() {
      list(
        "_" = "ChannelParticipant",
        user_id = self$user_id,
        date = self$date,
        subscription_until_date = self$subscription_until_date
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x19, 0x76, 0x39, 0xcb)),
        writeBin(as.integer(if (is.null(self$subscription_until_date) || identical(self$subscription_until_date, FALSE)) 0 else 1), raw(), size = 4),
        writeBin(as.numeric(self$user_id), raw(), size = 8),
        self$serialize_datetime(self$date),
        if (is.null(self$subscription_until_date) || identical(self$subscription_until_date, FALSE)) raw() else self$serialize_datetime(self$subscription_until_date)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      user_id <- reader$read_long()
      date <- reader$tgread_date()
      subscription_until_date <- if (bitwAnd(flags, 1) != 0) reader$tgread_date() else NULL
      ChannelParticipant$new(user_id = user_id, date = date, subscription_until_date = subscription_until_date)
    }
  )
)

#  @title ChannelParticipantAdmin
#  @description Telegram API type ChannelParticipantAdmin
#  @export
#  @noRd
#  @noRd
ChannelParticipantAdmin <- R6::R6Class(
  "ChannelParticipantAdmin",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x34c3bb53,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd9c7fc18,
    #  @field user_id Field.
    user_id = NULL,
    #  @field promoted_by Field.
    promoted_by = NULL,
    #  @field date Field.
    date = NULL,
    #  @field admin_rights Field.
    admin_rights = NULL,
    #  @field can_edit Field.
    can_edit = NULL,
    #  @field is_self Field.
    is_self = NULL,
    #  @field inviter_id Field.
    inviter_id = NULL,
    #  @field rank Field.
    rank = NULL,
    initialize = function(user_id, promoted_by, date, admin_rights, can_edit = NULL, is_self = NULL, inviter_id = NULL, rank = NULL) {
      self$user_id <- user_id
      self$promoted_by <- promoted_by
      self$date <- date
      self$admin_rights <- admin_rights
      self$can_edit <- can_edit
      self$is_self <- is_self
      self$inviter_id <- inviter_id
      self$rank <- rank
    },
    to_dict = function() {
      list(
        "_" = "ChannelParticipantAdmin",
        user_id = self$user_id,
        promoted_by = self$promoted_by,
        date = self$date,
        admin_rights = if (inherits(self$admin_rights, "TLObject")) self$admin_rights$to_dict() else self$admin_rights,
        can_edit = self$can_edit,
        is_self = self$is_self,
        inviter_id = self$inviter_id,
        rank = self$rank
      )
    },
    bytes = function() {
      # is_self and inviter_id must both be NULL/FALSE or both not
      stopifnot(
        ((self$is_self || !is.null(self$is_self)) && (self$inviter_id || !is.null(self$inviter_id))) ||
          ((is.null(self$is_self) || identical(self$is_self, FALSE)) && (is.null(self$inviter_id) || identical(self$inviter_id, FALSE)))
      )
      flags <- (if (!is.null(self$can_edit) && self$can_edit) 1 else 0) |
        (if (!is.null(self$is_self) && self$is_self) 2 else 0) |
        (if (!is.null(self$inviter_id) && !identical(self$inviter_id, FALSE)) 2 else 0) |
        (if (!is.null(self$rank) && !identical(self$rank, FALSE)) 4 else 0)
      c(
        as.raw(c(0x53, 0xbb, 0xc3, 0x34)),
        writeBin(as.integer(flags), raw(), size = 4),
        writeBin(as.numeric(self$user_id), raw(), size = 8),
        if (is.null(self$inviter_id) || identical(self$inviter_id, FALSE)) raw() else writeBin(as.numeric(self$inviter_id), raw(), size = 8),
        writeBin(as.numeric(self$promoted_by), raw(), size = 8),
        self$serialize_datetime(self$date),
        self$admin_rights$bytes(),
        if (is.null(self$rank) || identical(self$rank, FALSE)) raw() else self$serializebytes(self$rank)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      can_edit <- bitwAnd(flags, 1) != 0
      is_self <- bitwAnd(flags, 2) != 0
      user_id <- reader$read_long()
      inviter_id <- if (bitwAnd(flags, 2) != 0) reader$read_long() else NULL
      promoted_by <- reader$read_long()
      date <- reader$tgread_date()
      admin_rights <- reader$tgread_object()
      rank <- if (bitwAnd(flags, 4) != 0) reader$tgread_string() else NULL
      ChannelParticipantAdmin$new(
        user_id = user_id, promoted_by = promoted_by, date = date, admin_rights = admin_rights,
        can_edit = can_edit, is_self = is_self, inviter_id = inviter_id, rank = rank
      )
    }
  )
)

#  @title ChannelParticipantBanned
#  @description Telegram API type ChannelParticipantBanned
#  @export
#  @noRd
#  @noRd
ChannelParticipantBanned <- R6::R6Class(
  "ChannelParticipantBanned",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x6df8014e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd9c7fc18,
    #  @field peer Field.
    peer = NULL,
    #  @field kicked_by Field.
    kicked_by = NULL,
    #  @field date Field.
    date = NULL,
    #  @field banned_rights Field.
    banned_rights = NULL,
    #  @field left Field.
    left = NULL,
    initialize = function(peer, kicked_by, date, banned_rights, left = NULL) {
      self$peer <- peer
      self$kicked_by <- kicked_by
      self$date <- date
      self$banned_rights <- banned_rights
      self$left <- left
    },
    to_dict = function() {
      list(
        "_" = "ChannelParticipantBanned",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        kicked_by = self$kicked_by,
        date = self$date,
        banned_rights = if (inherits(self$banned_rights, "TLObject")) self$banned_rights$to_dict() else self$banned_rights,
        left = self$left
      )
    },
    bytes = function() {
      flags <- if (!is.null(self$left) && self$left) 1 else 0
      c(
        as.raw(c(0x4e, 0x01, 0xf8, 0x6d)),
        writeBin(as.integer(flags), raw(), size = 4),
        self$peer$bytes(),
        writeBin(as.numeric(self$kicked_by), raw(), size = 8),
        self$serialize_datetime(self$date),
        self$banned_rights$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      left <- bitwAnd(flags, 1) != 0
      peer <- reader$tgread_object()
      kicked_by <- reader$read_long()
      date <- reader$tgread_date()
      banned_rights <- reader$tgread_object()
      ChannelParticipantBanned$new(peer = peer, kicked_by = kicked_by, date = date, banned_rights = banned_rights, left = left)
    }
  )
)

#  @title ChannelParticipantCreator
#  @description Telegram API type ChannelParticipantCreator
#  @export
#  @noRd
#  @noRd
ChannelParticipantCreator <- R6::R6Class(
  "ChannelParticipantCreator",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x2fe601d3,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd9c7fc18,
    #  @field user_id Field.
    user_id = NULL,
    #  @field admin_rights Field.
    admin_rights = NULL,
    #  @field rank Field.
    rank = NULL,
    initialize = function(user_id, admin_rights, rank = NULL) {
      self$user_id <- user_id
      self$admin_rights <- admin_rights
      self$rank <- rank
    },
    to_dict = function() {
      list(
        "_" = "ChannelParticipantCreator",
        user_id = self$user_id,
        admin_rights = if (inherits(self$admin_rights, "TLObject")) self$admin_rights$to_dict() else self$admin_rights,
        rank = self$rank
      )
    },
    bytes = function() {
      b <- c(
        as.raw(c(0xd3, 0x01, 0xe6, 0x2f)),
        writeBin(as.integer(!is.null(self$rank)), raw(), size = 4, endian = "little"),
        writeBin(as.numeric(self$user_id), raw(), size = 8, endian = "little"),
        self$admin_rights$`bytes`()
      )
      if (!is.null(self$rank)) {
        b <- c(b, self$serializebytes(self$rank))
      }
      b
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      user_id <- reader$read_long()
      admin_rights <- reader$tgread_object()
      rank <- if (bitwAnd(flags, 1)) reader$tgread_string() else NULL
      ChannelParticipantCreator$new(user_id = user_id, admin_rights = admin_rights, rank = rank)
    }
  )
)

#  @title ChannelParticipantLeft
#  @description Telegram API type ChannelParticipantLeft
#  @export
#  @noRd
#  @noRd
ChannelParticipantLeft <- R6::R6Class(
  "ChannelParticipantLeft",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1b03f006,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd9c7fc18,
    #  @field peer Field.
    peer = NULL,
    initialize = function(peer) {
      self$peer <- peer
    },
    to_dict = function() {
      list(
        "_" = "ChannelParticipantLeft",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x06, 0xf0, 0x03, 0x1b)),
        self$peer$`bytes`()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      ChannelParticipantLeft$new(peer = peer)
    }
  )
)

#  @title ChannelParticipantSelf
#  @description Telegram API type ChannelParticipantSelf
#  @export
#  @noRd
#  @noRd
ChannelParticipantSelf <- R6::R6Class(
  "ChannelParticipantSelf",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4f607bef,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd9c7fc18,
    #  @field user_id Field.
    user_id = NULL,
    #  @field inviter_id Field.
    inviter_id = NULL,
    #  @field date Field.
    date = NULL,
    #  @field via_request Field.
    via_request = NULL,
    #  @field subscription_until_date Field.
    subscription_until_date = NULL,
    initialize = function(user_id, inviter_id, date, via_request = NULL, subscription_until_date = NULL) {
      self$user_id <- user_id
      self$inviter_id <- inviter_id
      self$date <- date
      self$via_request <- via_request
      self$subscription_until_date <- subscription_until_date
    },
    to_dict = function() {
      list(
        "_" = "ChannelParticipantSelf",
        user_id = self$user_id,
        inviter_id = self$inviter_id,
        date = self$date,
        via_request = self$via_request,
        subscription_until_date = self$subscription_until_date
      )
    },
    bytes = function() {
      flags <- (if (!is.null(self$via_request)) 1 else 0) +
        (if (!is.null(self$subscription_until_date)) 2 else 0)
      b <- c(
        as.raw(c(0xef, 0x7b, 0x60, 0x4f)),
        writeBin(as.integer(flags), raw(), size = 4, endian = "little"),
        writeBin(as.numeric(self$user_id), raw(), size = 8, endian = "little"),
        writeBin(as.numeric(self$inviter_id), raw(), size = 8, endian = "little"),
        self$serialize_datetime(self$date)
      )
      if (!is.null(self$subscription_until_date)) {
        b <- c(b, self$serialize_datetime(self$subscription_until_date))
      }
      b
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      via_request <- bitwAnd(flags, 1) != 0
      user_id <- reader$read_long()
      inviter_id <- reader$read_long()
      date <- reader$tgread_date()
      subscription_until_date <- if (bitwAnd(flags, 2)) reader$tgread_date() else NULL
      ChannelParticipantSelf$new(user_id = user_id, inviter_id = inviter_id, date = date, via_request = via_request, subscription_until_date = subscription_until_date)
    }
  )
)

#  @title ChannelParticipantsAdmins
#  @description Telegram API type ChannelParticipantsAdmins
#  @export
#  @noRd
#  @noRd
ChannelParticipantsAdmins <- R6::R6Class(
  "ChannelParticipantsAdmins",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb4608969,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbf4e2753,
    to_dict = function() {
      list("_" = "ChannelParticipantsAdmins")
    },
    bytes = function() {
      as.raw(c(0x69, 0x89, 0x60, 0xb4))
    }
  ),
  private = list(
    from_reader = function(reader) {
      ChannelParticipantsAdmins$new()
    }
  )
)

#  @title ChannelParticipantsBanned
#  @description Telegram API type ChannelParticipantsBanned
#  @export
#  @noRd
#  @noRd
ChannelParticipantsBanned <- R6::R6Class(
  "ChannelParticipantsBanned",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1427a5e1,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbf4e2753,
    #  @field q Field.
    q = NULL,
    initialize = function(q) {
      self$q <- q
    },
    to_dict = function() {
      list("_" = "ChannelParticipantsBanned", q = self$q)
    },
    bytes = function() {
      c(
        as.raw(c(0xe1, 0xa5, 0x27, 0x14)),
        self$serializebytes(self$q)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      q <- reader$tgread_string()
      ChannelParticipantsBanned$new(q = q)
    }
  )
)

#  @title ChannelParticipantsBots
#  @description Telegram API type ChannelParticipantsBots
#  @export
#  @noRd
#  @noRd
ChannelParticipantsBots <- R6::R6Class(
  "ChannelParticipantsBots",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb0d1865b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbf4e2753,
    to_dict = function() {
      list("_" = "ChannelParticipantsBots")
    },
    bytes = function() {
      as.raw(c(0x5b, 0x86, 0xd1, 0xb0))
    }
  ),
  private = list(
    from_reader = function(reader) {
      ChannelParticipantsBots$new()
    }
  )
)

#  @title ChannelParticipantsContacts
#  @description Telegram API type ChannelParticipantsContacts
#  @export
#  @noRd
#  @noRd
ChannelParticipantsContacts <- R6::R6Class(
  "ChannelParticipantsContacts",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbb6ae88d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbf4e2753,
    #  @field q Field.
    q = NULL,
    initialize = function(q) {
      self$q <- q
    },
    to_dict = function() {
      list("_" = "ChannelParticipantsContacts", q = self$q)
    },
    bytes = function() {
      c(
        as.raw(c(0x8d, 0xe8, 0x6a, 0xbb)),
        self$serializebytes(self$q)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      q <- reader$tgread_string()
      ChannelParticipantsContacts$new(q = q)
    }
  )
)

#  @title ChannelParticipantsKicked
#  @description Telegram API type ChannelParticipantsKicked
#  @export
#  @noRd
#  @noRd
ChannelParticipantsKicked <- R6::R6Class(
  "ChannelParticipantsKicked",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa3b54985,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbf4e2753,
    #  @field q Field.
    q = NULL,
    initialize = function(q) {
      self$q <- q
    },
    to_dict = function() {
      list("_" = "ChannelParticipantsKicked", q = self$q)
    },
    bytes = function() {
      c(
        as.raw(c(0x85, 0x49, 0xb5, 0xa3)),
        self$serializebytes(self$q)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      q <- reader$tgread_string()
      ChannelParticipantsKicked$new(q = q)
    }
  )
)

#  @title ChannelParticipantsMentions
#  @description Telegram API type ChannelParticipantsMentions
#  @export
#  @noRd
#  @noRd
ChannelParticipantsMentions <- R6::R6Class(
  "ChannelParticipantsMentions",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe04b5ceb,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbf4e2753,
    #  @field q Field.
    q = NULL,
    #  @field top_msg_id Field.
    top_msg_id = NULL,
    initialize = function(q = NULL, top_msg_id = NULL) {
      self$q <- q
      self$top_msg_id <- top_msg_id
    },
    to_dict = function() {
      list("_" = "ChannelParticipantsMentions", q = self$q, top_msg_id = self$top_msg_id)
    },
    bytes = function() {
      flags <- (if (!is.null(self$q)) 1 else 0) +
        (if (!is.null(self$top_msg_id)) 2 else 0)
      b <- c(
        as.raw(c(0xeb, 0x5c, 0x4b, 0xe0)),
        writeBin(as.integer(flags), raw(), size = 4, endian = "little")
      )
      if (!is.null(self$q)) {
        b <- c(b, self$serializebytes(self$q))
      }
      if (!is.null(self$top_msg_id)) {
        b <- c(b, writeBin(as.integer(self$top_msg_id), raw(), size = 4, endian = "little"))
      }
      b
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      q <- if (bitwAnd(flags, 1)) reader$tgread_string() else NULL
      top_msg_id <- if (bitwAnd(flags, 2)) reader$read_int() else NULL
      ChannelParticipantsMentions$new(q = q, top_msg_id = top_msg_id)
    }
  )
)

#  @title ChannelParticipantsRecent
#  @description Telegram API type ChannelParticipantsRecent
#  @export
#  @noRd
#  @noRd
ChannelParticipantsRecent <- R6::R6Class(
  "ChannelParticipantsRecent",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xde3f3c79,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbf4e2753,
    to_dict = function() {
      list("_" = "ChannelParticipantsRecent")
    },
    bytes = function() {
      as.raw(c(0x79, 0x3f, 0x3f, 0xde))
    }
  ),
  private = list(
    from_reader = function(reader) {
      ChannelParticipantsRecent$new()
    }
  )
)

#  @title ChannelParticipantsSearch
#  @description Telegram API type ChannelParticipantsSearch
#  @export
#  @noRd
#  @noRd
ChannelParticipantsSearch <- R6::R6Class(
  "ChannelParticipantsSearch",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x656ac4b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbf4e2753,
    #  @field q Field.
    q = NULL,
    initialize = function(q) {
      self$q <- q
    },
    to_dict = function() {
      list("_" = "ChannelParticipantsSearch", q = self$q)
    },
    bytes = function() {
      c(
        as.raw(c(0x4b, 0xac, 0x56, 0x06)),
        self$serializebytes(self$q)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      q <- reader$tgread_string()
      ChannelParticipantsSearch$new(q = q)
    }
  )
)

#  @title ChatAdminRights
#  @description Telegram API type ChatAdminRights
#  @export
#  @noRd
#  @noRd
ChatAdminRights <- R6::R6Class(
  "ChatAdminRights",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5fb224d5,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x863dc7c4,
    #  @field change_info Field.
    change_info = NULL,
    #  @field post_messages Field.
    post_messages = NULL,
    #  @field edit_messages Field.
    edit_messages = NULL,
    #  @field delete_messages Field.
    delete_messages = NULL,
    #  @field ban_users Field.
    ban_users = NULL,
    #  @field invite_users Field.
    invite_users = NULL,
    #  @field pin_messages Field.
    pin_messages = NULL,
    #  @field add_admins Field.
    add_admins = NULL,
    #  @field anonymous Field.
    anonymous = NULL,
    #  @field manage_call Field.
    manage_call = NULL,
    #  @field other Field.
    other = NULL,
    #  @field manage_topics Field.
    manage_topics = NULL,
    #  @field post_stories Field.
    post_stories = NULL,
    #  @field edit_stories Field.
    edit_stories = NULL,
    #  @field delete_stories Field.
    delete_stories = NULL,
    #  @field manage_direct_messages Field.
    manage_direct_messages = NULL,
    initialize = function(change_info = NULL, post_messages = NULL, edit_messages = NULL, delete_messages = NULL, ban_users = NULL, invite_users = NULL, pin_messages = NULL, add_admins = NULL, anonymous = NULL, manage_call = NULL, other = NULL, manage_topics = NULL, post_stories = NULL, edit_stories = NULL, delete_stories = NULL, manage_direct_messages = NULL) {
      self$change_info <- change_info
      self$post_messages <- post_messages
      self$edit_messages <- edit_messages
      self$delete_messages <- delete_messages
      self$ban_users <- ban_users
      self$invite_users <- invite_users
      self$pin_messages <- pin_messages
      self$add_admins <- add_admins
      self$anonymous <- anonymous
      self$manage_call <- manage_call
      self$other <- other
      self$manage_topics <- manage_topics
      self$post_stories <- post_stories
      self$edit_stories <- edit_stories
      self$delete_stories <- delete_stories
      self$manage_direct_messages <- manage_direct_messages
    },
    to_list = function() {
      list(
        `_` = "ChatAdminRights",
        change_info = self$change_info,
        post_messages = self$post_messages,
        edit_messages = self$edit_messages,
        delete_messages = self$delete_messages,
        ban_users = self$ban_users,
        invite_users = self$invite_users,
        pin_messages = self$pin_messages,
        add_admins = self$add_admins,
        anonymous = self$anonymous,
        manage_call = self$manage_call,
        other = self$other,
        manage_topics = self$manage_topics,
        post_stories = self$post_stories,
        edit_stories = self$edit_stories,
        delete_stories = self$delete_stories,
        manage_direct_messages = self$manage_direct_messages
      )
    },
    bytes = function() {
      flag_values <- c(
        ifelse(isTRUE(self$change_info), 1, 0),
        ifelse(isTRUE(self$post_messages), 2, 0),
        ifelse(isTRUE(self$edit_messages), 4, 0),
        ifelse(isTRUE(self$delete_messages), 8, 0),
        ifelse(isTRUE(self$ban_users), 16, 0),
        ifelse(isTRUE(self$invite_users), 32, 0),
        ifelse(isTRUE(self$pin_messages), 128, 0),
        ifelse(isTRUE(self$add_admins), 512, 0),
        ifelse(isTRUE(self$anonymous), 1024, 0),
        ifelse(isTRUE(self$manage_call), 2048, 0),
        ifelse(isTRUE(self$other), 4096, 0),
        ifelse(isTRUE(self$manage_topics), 8192, 0),
        ifelse(isTRUE(self$post_stories), 16384, 0),
        ifelse(isTRUE(self$edit_stories), 32768, 0),
        ifelse(isTRUE(self$delete_stories), 65536, 0),
        ifelse(isTRUE(self$manage_direct_messages), 131072, 0)
      )

      flags <- Reduce(bitwOr, as.integer(flag_values), init = 0L)

      as.raw(
        c(
          0xd5, 0x24, 0xb2, 0x5f,
          flags
        )
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      change_info <- bitwAnd(flags, 1) != 0
      post_messages <- bitwAnd(flags, 2) != 0
      edit_messages <- bitwAnd(flags, 4) != 0
      delete_messages <- bitwAnd(flags, 8) != 0
      ban_users <- bitwAnd(flags, 16) != 0
      invite_users <- bitwAnd(flags, 32) != 0
      pin_messages <- bitwAnd(flags, 128) != 0
      add_admins <- bitwAnd(flags, 512) != 0
      anonymous <- bitwAnd(flags, 1024) != 0
      manage_call <- bitwAnd(flags, 2048) != 0
      other <- bitwAnd(flags, 4096) != 0
      manage_topics <- bitwAnd(flags, 8192) != 0
      post_stories <- bitwAnd(flags, 16384) != 0
      edit_stories <- bitwAnd(flags, 32768) != 0
      delete_stories <- bitwAnd(flags, 65536) != 0
      manage_direct_messages <- bitwAnd(flags, 131072) != 0

      ChatAdminRights$new(
        change_info = change_info,
        post_messages = post_messages,
        edit_messages = edit_messages,
        delete_messages = delete_messages,
        ban_users = ban_users,
        invite_users = invite_users,
        pin_messages = pin_messages,
        add_admins = add_admins,
        anonymous = anonymous,
        manage_call = manage_call,
        other = other,
        manage_topics = manage_topics,
        post_stories = post_stories,
        edit_stories = edit_stories,
        delete_stories = delete_stories,
        manage_direct_messages = manage_direct_messages
      )
    }
  )
)

#  @title ChatAdminWithInvites
#  @description Telegram API type ChatAdminWithInvites
#  @export
#  @noRd
#  @noRd
ChatAdminWithInvites <- R6::R6Class(
  "ChatAdminWithInvites",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf2ecef23,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5063f398,
    #  @field admin_id Field.
    admin_id = NULL,
    #  @field invites_count Field.
    invites_count = NULL,
    #  @field revoked_invites_count Field.
    revoked_invites_count = NULL,
    initialize = function(admin_id, invites_count, revoked_invites_count) {
      self$admin_id <- admin_id
      self$invites_count <- invites_count
      self$revoked_invites_count <- revoked_invites_count
    },
    to_list = function() {
      list(
        "_" = "ChatAdminWithInvites",
        admin_id = self$admin_id,
        invites_count = self$invites_count,
        revoked_invites_count = self$revoked_invites_count
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x23, 0xef, 0xec, 0xf2)),
        writeBin(as.integer64(self$admin_id), raw(), size = 8, endian = "little"),
        writeBin(as.integer(self$invites_count), raw(), size = 4, endian = "little"),
        writeBin(as.integer(self$revoked_invites_count), raw(), size = 4, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      admin_id <- reader$read_long()
      invites_count <- reader$read_int()
      revoked_invites_count <- reader$read_int()
      ChatAdminWithInvites$new(admin_id, invites_count, revoked_invites_count)
    }
  )
)

#  @title ChatBannedRights
#  @description Telegram API type ChatBannedRights
#  @export
#  @noRd
#  @noRd
ChatBannedRights <- R6::R6Class(
  "ChatBannedRights",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9f120418,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x4b5445a9,
    #  @field until_date Field.
    until_date = NULL,
    #  @field view_messages Field.
    view_messages = NULL,
    #  @field send_messages Field.
    send_messages = NULL,
    #  @field send_media Field.
    send_media = NULL,
    #  @field send_stickers Field.
    send_stickers = NULL,
    #  @field send_gifs Field.
    send_gifs = NULL,
    #  @field send_games Field.
    send_games = NULL,
    #  @field send_inline Field.
    send_inline = NULL,
    #  @field embed_links Field.
    embed_links = NULL,
    #  @field send_polls Field.
    send_polls = NULL,
    #  @field change_info Field.
    change_info = NULL,
    #  @field invite_users Field.
    invite_users = NULL,
    #  @field pin_messages Field.
    pin_messages = NULL,
    #  @field manage_topics Field.
    manage_topics = NULL,
    #  @field send_photos Field.
    send_photos = NULL,
    #  @field send_videos Field.
    send_videos = NULL,
    #  @field send_roundvideos Field.
    send_roundvideos = NULL,
    #  @field send_audios Field.
    send_audios = NULL,
    #  @field send_voices Field.
    send_voices = NULL,
    #  @field send_docs Field.
    send_docs = NULL,
    #  @field send_plain Field.
    send_plain = NULL,
    initialize = function(until_date, view_messages = NULL, send_messages = NULL, send_media = NULL, send_stickers = NULL, send_gifs = NULL, send_games = NULL, send_inline = NULL, embed_links = NULL, send_polls = NULL, change_info = NULL, invite_users = NULL, pin_messages = NULL, manage_topics = NULL, send_photos = NULL, send_videos = NULL, send_roundvideos = NULL, send_audios = NULL, send_voices = NULL, send_docs = NULL, send_plain = NULL) {
      self$until_date <- until_date
      self$view_messages <- view_messages
      self$send_messages <- send_messages
      self$send_media <- send_media
      self$send_stickers <- send_stickers
      self$send_gifs <- send_gifs
      self$send_games <- send_games
      self$send_inline <- send_inline
      self$embed_links <- embed_links
      self$send_polls <- send_polls
      self$change_info <- change_info
      self$invite_users <- invite_users
      self$pin_messages <- pin_messages
      self$manage_topics <- manage_topics
      self$send_photos <- send_photos
      self$send_videos <- send_videos
      self$send_roundvideos <- send_roundvideos
      self$send_audios <- send_audios
      self$send_voices <- send_voices
      self$send_docs <- send_docs
      self$send_plain <- send_plain
    },
    to_list = function() {
      list(
        "_" = "ChatBannedRights",
        until_date = self$until_date,
        view_messages = self$view_messages,
        send_messages = self$send_messages,
        send_media = self$send_media,
        send_stickers = self$send_stickers,
        send_gifs = self$send_gifs,
        send_games = self$send_games,
        send_inline = self$send_inline,
        embed_links = self$embed_links,
        send_polls = self$send_polls,
        change_info = self$change_info,
        invite_users = self$invite_users,
        pin_messages = self$pin_messages,
        manage_topics = self$manage_topics,
        send_photos = self$send_photos,
        send_videos = self$send_videos,
        send_roundvideos = self$send_roundvideos,
        send_audios = self$send_audios,
        send_voices = self$send_voices,
        send_docs = self$send_docs,
        send_plain = self$send_plain
      )
    },
    bytes = function() {
      flags <- (ifelse(isTRUE(self$view_messages), 1, 0) |
        ifelse(isTRUE(self$send_messages), 2, 0) |
        ifelse(isTRUE(self$send_media), 4, 0) |
        ifelse(isTRUE(self$send_stickers), 8, 0) |
        ifelse(isTRUE(self$send_gifs), 16, 0) |
        ifelse(isTRUE(self$send_games), 32, 0) |
        ifelse(isTRUE(self$send_inline), 64, 0) |
        ifelse(isTRUE(self$embed_links), 128, 0) |
        ifelse(isTRUE(self$send_polls), 256, 0) |
        ifelse(isTRUE(self$change_info), 1024, 0) |
        ifelse(isTRUE(self$invite_users), 32768, 0) |
        ifelse(isTRUE(self$pin_messages), 131072, 0) |
        ifelse(isTRUE(self$manage_topics), 262144, 0) |
        ifelse(isTRUE(self$send_photos), 524288, 0) |
        ifelse(isTRUE(self$send_videos), 1048576, 0) |
        ifelse(isTRUE(self$send_roundvideos), 2097152, 0) |
        ifelse(isTRUE(self$send_audios), 4194304, 0) |
        ifelse(isTRUE(self$send_voices), 8388608, 0) |
        ifelse(isTRUE(self$send_docs), 16777216, 0) |
        ifelse(isTRUE(self$send_plain), 33554432, 0))
      c(
        as.raw(c(0x18, 0x04, 0x12, 0x9f)),
        writeBin(as.integer(flags), raw(), size = 4),
        self$serialize_datetime(self$until_date)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      until_date <- reader$tgread_date()
      ChatBannedRights$new(
        until_date = until_date,
        view_messages = bitwAnd(flags, 1) != 0,
        send_messages = bitwAnd(flags, 2) != 0,
        send_media = bitwAnd(flags, 4) != 0,
        send_stickers = bitwAnd(flags, 8) != 0,
        send_gifs = bitwAnd(flags, 16) != 0,
        send_games = bitwAnd(flags, 32) != 0,
        send_inline = bitwAnd(flags, 64) != 0,
        embed_links = bitwAnd(flags, 128) != 0,
        send_polls = bitwAnd(flags, 256) != 0,
        change_info = bitwAnd(flags, 1024) != 0,
        invite_users = bitwAnd(flags, 32768) != 0,
        pin_messages = bitwAnd(flags, 131072) != 0,
        manage_topics = bitwAnd(flags, 262144) != 0,
        send_photos = bitwAnd(flags, 524288) != 0,
        send_videos = bitwAnd(flags, 1048576) != 0,
        send_roundvideos = bitwAnd(flags, 2097152) != 0,
        send_audios = bitwAnd(flags, 4194304) != 0,
        send_voices = bitwAnd(flags, 8388608) != 0,
        send_docs = bitwAnd(flags, 16777216) != 0,
        send_plain = bitwAnd(flags, 33554432) != 0
      )
    }
  )
)

#  @title ChatFull
#  @description Telegram API type ChatFull
#  @export
#  @noRd
#  @noRd
ChatFull <- R6::R6Class(
  "ChatFull",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x2633421b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd49a2697,
    #  @field id Field.
    id = NULL,
    #  @field about Field.
    about = NULL,
    #  @field participants Field.
    participants = NULL,
    #  @field notify_settings Field.
    notify_settings = NULL,
    #  @field can_set_username Field.
    can_set_username = NULL,
    #  @field has_scheduled Field.
    has_scheduled = NULL,
    #  @field translations_disabled Field.
    translations_disabled = NULL,
    #  @field chat_photo Field.
    chat_photo = NULL,
    #  @field exported_invite Field.
    exported_invite = NULL,
    #  @field bot_info Field.
    bot_info = NULL,
    #  @field pinned_msg_id Field.
    pinned_msg_id = NULL,
    #  @field folder_id Field.
    folder_id = NULL,
    #  @field call Field.
    call = NULL,
    #  @field ttl_period Field.
    ttl_period = NULL,
    #  @field groupcall_default_join_as Field.
    groupcall_default_join_as = NULL,
    #  @field theme_emoticon Field.
    theme_emoticon = NULL,
    #  @field requests_pending Field.
    requests_pending = NULL,
    #  @field recent_requesters Field.
    recent_requesters = NULL,
    #  @field available_reactions Field.
    available_reactions = NULL,
    #  @field reactions_limit Field.
    reactions_limit = NULL,
    initialize = function(id, about, participants, notify_settings,
                          can_set_username = NULL, has_scheduled = NULL,
                          translations_disabled = NULL, chat_photo = NULL,
                          exported_invite = NULL, bot_info = NULL,
                          pinned_msg_id = NULL, folder_id = NULL, call = NULL,
                          ttl_period = NULL, groupcall_default_join_as = NULL,
                          theme_emoticon = NULL, requests_pending = NULL,
                          recent_requesters = NULL, available_reactions = NULL,
                          reactions_limit = NULL) {
      self$id <- id
      self$about <- about
      self$participants <- participants
      self$notify_settings <- notify_settings
      self$can_set_username <- can_set_username
      self$has_scheduled <- has_scheduled
      self$translations_disabled <- translations_disabled
      self$chat_photo <- chat_photo
      self$exported_invite <- exported_invite
      self$bot_info <- bot_info
      self$pinned_msg_id <- pinned_msg_id
      self$folder_id <- folder_id
      self$call <- call
      self$ttl_period <- ttl_period
      self$groupcall_default_join_as <- groupcall_default_join_as
      self$theme_emoticon <- theme_emoticon
      self$requests_pending <- requests_pending
      self$recent_requesters <- recent_requesters
      self$available_reactions <- available_reactions
      self$reactions_limit <- reactions_limit
    },
    to_list = function() {
      list(
        "_" = "ChatFull",
        id = self$id,
        about = self$about,
        participants = if (inherits(self$participants, "TLObject")) self$participants$to_list() else self$participants,
        notify_settings = if (inherits(self$notify_settings, "TLObject")) self$notify_settings$to_list() else self$notify_settings,
        can_set_username = self$can_set_username,
        has_scheduled = self$has_scheduled,
        translations_disabled = self$translations_disabled,
        chat_photo = if (!is.null(self$chat_photo) && inherits(self$chat_photo, "TLObject")) self$chat_photo$to_list() else self$chat_photo,
        exported_invite = if (!is.null(self$exported_invite) && inherits(self$exported_invite, "TLObject")) self$exported_invite$to_list() else self$exported_invite,
        bot_info = if (is.null(self$bot_info)) list() else lapply(self$bot_info, function(x) if (inherits(x, "TLObject")) x$to_list() else x),
        pinned_msg_id = self$pinned_msg_id,
        folder_id = self$folder_id,
        call = if (!is.null(self$call) && inherits(self$call, "TLObject")) self$call$to_list() else self$call,
        ttl_period = self$ttl_period,
        groupcall_default_join_as = if (!is.null(self$groupcall_default_join_as) && inherits(self$groupcall_default_join_as, "TLObject")) self$groupcall_default_join_as$to_list() else self$groupcall_default_join_as,
        theme_emoticon = self$theme_emoticon,
        requests_pending = self$requests_pending,
        recent_requesters = if (is.null(self$recent_requesters)) list() else self$recent_requesters,
        available_reactions = if (!is.null(self$available_reactions) && inherits(self$available_reactions, "TLObject")) self$available_reactions$to_list() else self$available_reactions,
        reactions_limit = self$reactions_limit
      )
    },
    from_reader = function(reader) {
      flags <- reader$read_int()

      can_set_username <- as.logical(bitwAnd(flags, 128))
      has_scheduled <- as.logical(bitwAnd(flags, 256))
      translations_disabled <- as.logical(bitwAnd(flags, 524288))
      id <- reader$read_long()
      about <- reader$tgread_string()
      participants <- reader$tgread_object()
      chat_photo <- if (bitwAnd(flags, 4)) reader$tgread_object() else NULL
      notify_settings <- reader$tgread_object()
      exported_invite <- if (bitwAnd(flags, 8192)) reader$tgread_object() else NULL
      bot_info <- if (bitwAnd(flags, 8)) {
        reader$read_int()
        lapply(seq_len(reader$read_int()), function(x) reader$tgread_object())
      } else {
        NULL
      }
      pinned_msg_id <- if (bitwAnd(flags, 64)) reader$read_int() else NULL
      folder_id <- if (bitwAnd(flags, 2048)) reader$read_int() else NULL
      call <- if (bitwAnd(flags, 4096)) reader$tgread_object() else NULL
      ttl_period <- if (bitwAnd(flags, 16384)) reader$read_int() else NULL
      groupcall_default_join_as <- if (bitwAnd(flags, 32768)) reader$tgread_object() else NULL
      theme_emoticon <- if (bitwAnd(flags, 65536)) reader$tgread_string() else NULL
      requests_pending <- if (bitwAnd(flags, 131072)) reader$read_int() else NULL
      recent_requesters <- if (bitwAnd(flags, 131072)) {
        reader$read_int()
        lapply(seq_len(reader$read_int()), function(x) reader$read_long())
      } else {
        NULL
      }
      available_reactions <- if (bitwAnd(flags, 262144)) reader$tgread_object() else NULL
      reactions_limit <- if (bitwAnd(flags, 1048576)) reader$read_int() else NULL

      self$new(
        id = id, about = about, participants = participants, notify_settings = notify_settings,
        can_set_username = can_set_username, has_scheduled = has_scheduled,
        translations_disabled = translations_disabled, chat_photo = chat_photo,
        exported_invite = exported_invite, bot_info = bot_info, pinned_msg_id = pinned_msg_id,
        folder_id = folder_id, call = call, ttl_period = ttl_period,
        groupcall_default_join_as = groupcall_default_join_as, theme_emoticon = theme_emoticon,
        requests_pending = requests_pending, recent_requesters = recent_requesters,
        available_reactions = available_reactions, reactions_limit = reactions_limit
      )
    }
  )
)

#  @title ChatInvite
#  @description Telegram API type ChatInvite
#  @export
#  @noRd
#  @noRd
ChatInvite <- R6::R6Class(
  "ChatInvite",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5c9d3702,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x4561736,
    #  @field title Field.
    title = NULL,
    #  @field photo Field.
    photo = NULL,
    #  @field participants_count Field.
    participants_count = NULL,
    #  @field color Field.
    color = NULL,
    #  @field channel Field.
    channel = NULL,
    #  @field broadcast Field.
    broadcast = NULL,
    #  @field public Field.
    public = NULL,
    #  @field megagroup Field.
    megagroup = NULL,
    #  @field request_needed Field.
    request_needed = NULL,
    #  @field verified Field.
    verified = NULL,
    #  @field scam Field.
    scam = NULL,
    #  @field fake Field.
    fake = NULL,
    #  @field can_refulfill_subscription Field.
    can_refulfill_subscription = NULL,
    #  @field about Field.
    about = NULL,
    #  @field participants Field.
    participants = NULL,
    #  @field subscription_pricing Field.
    subscription_pricing = NULL,
    #  @field subscription_form_id Field.
    subscription_form_id = NULL,
    #  @field bot_verification Field.
    bot_verification = NULL,
    initialize = function(title, photo, participants_count, color, channel = NULL, broadcast = NULL, public = NULL, megagroup = NULL, request_needed = NULL, verified = NULL, scam = NULL, fake = NULL, can_refulfill_subscription = NULL, about = NULL, participants = NULL, subscription_pricing = NULL, subscription_form_id = NULL, bot_verification = NULL) {
      self$title <- title
      self$photo <- photo
      self$participants_count <- participants_count
      self$color <- color
      self$channel <- channel
      self$broadcast <- broadcast
      self$public <- public
      self$megagroup <- megagroup
      self$request_needed <- request_needed
      self$verified <- verified
      self$scam <- scam
      self$fake <- fake
      self$can_refulfill_subscription <- can_refulfill_subscription
      self$about <- about
      self$participants <- participants
      self$subscription_pricing <- subscription_pricing
      self$subscription_form_id <- subscription_form_id
      self$bot_verification <- bot_verification
    },
    to_dict = function() {
      list(
        "_" = "ChatInvite",
        title = self$title,
        photo = if (!is.null(self$photo) && inherits(self$photo, "TLObject")) self$photo$to_dict() else self$photo,
        participants_count = self$participants_count,
        color = self$color,
        channel = self$channel,
        broadcast = self$broadcast,
        public = self$public,
        megagroup = self$megagroup,
        request_needed = self$request_needed,
        verified = self$verified,
        scam = self$scam,
        fake = self$fake,
        can_refulfill_subscription = self$can_refulfill_subscription,
        about = self$about,
        participants = if (is.null(self$participants)) list() else lapply(self$participants, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        subscription_pricing = if (!is.null(self$subscription_pricing) && inherits(self$subscription_pricing, "TLObject")) self$subscription_pricing$to_dict() else self$subscription_pricing,
        subscription_form_id = self$subscription_form_id,
        bot_verification = if (!is.null(self$bot_verification) && inherits(self$bot_verification, "TLObject")) self$bot_verification$to_dict() else self$bot_verification
      )
    }
  )
)

#  @title ChatInviteAlready
#  @description Telegram API type ChatInviteAlready
#  @export
#  @noRd
#  @noRd
ChatInviteAlready <- R6::R6Class(
  "ChatInviteAlready",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5a686d7c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x4561736,
    #  @field chat Field.
    chat = NULL,
    initialize = function(chat) {
      self$chat <- chat
    },
    to_dict = function() {
      list(
        "_" = "ChatInviteAlready",
        chat = if (!is.null(self$chat) && inherits(self$chat, "TLObject")) self$chat$to_dict() else self$chat
      )
    }
  )
)

#  @title ChatInviteExported
#  @description Telegram API type ChatInviteExported
#  @export
#  @noRd
#  @noRd
ChatInviteExported <- R6::R6Class(
  "ChatInviteExported",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa22cbd96,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb4748a58,
    #  @field link Field.
    link = NULL,
    #  @field admin_id Field.
    admin_id = NULL,
    #  @field date Field.
    date = NULL,
    #  @field revoked Field.
    revoked = NULL,
    #  @field permanent Field.
    permanent = NULL,
    #  @field request_needed Field.
    request_needed = NULL,
    #  @field start_date Field.
    start_date = NULL,
    #  @field expire_date Field.
    expire_date = NULL,
    #  @field usage_limit Field.
    usage_limit = NULL,
    #  @field usage Field.
    usage = NULL,
    #  @field requested Field.
    requested = NULL,
    #  @field subscription_expired Field.
    subscription_expired = NULL,
    #  @field title Field.
    title = NULL,
    #  @field subscription_pricing Field.
    subscription_pricing = NULL,
    initialize = function(link, admin_id, date, revoked = NULL, permanent = NULL, request_needed = NULL, start_date = NULL, expire_date = NULL, usage_limit = NULL, usage = NULL, requested = NULL, subscription_expired = NULL, title = NULL, subscription_pricing = NULL) {
      self$link <- link
      self$admin_id <- admin_id
      self$date <- date
      self$revoked <- revoked
      self$permanent <- permanent
      self$request_needed <- request_needed
      self$start_date <- start_date
      self$expire_date <- expire_date
      self$usage_limit <- usage_limit
      self$usage <- usage
      self$requested <- requested
      self$subscription_expired <- subscription_expired
      self$title <- title
      self$subscription_pricing <- subscription_pricing
    },
    to_dict = function() {
      list(
        "_" = "ChatInviteExported",
        link = self$link,
        admin_id = self$admin_id,
        date = self$date,
        revoked = self$revoked,
        permanent = self$permanent,
        request_needed = self$request_needed,
        start_date = self$start_date,
        expire_date = self$expire_date,
        usage_limit = self$usage_limit,
        usage = self$usage,
        requested = self$requested,
        subscription_expired = self$subscription_expired,
        title = self$title,
        subscription_pricing = if (!is.null(self$subscription_pricing) && inherits(self$subscription_pricing, "TLObject")) self$subscription_pricing$to_dict() else self$subscription_pricing
      )
    }
  )
)

#  @title ChatInviteImporter
#  @description Telegram API type ChatInviteImporter
#  @export
#  @noRd
#  @noRd
ChatInviteImporter <- R6::R6Class(
  "ChatInviteImporter",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8c5adfd9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5312542e,
    #  @field user_id Field.
    user_id = NULL,
    #  @field date Field.
    date = NULL,
    #  @field requested Field.
    requested = NULL,
    #  @field via_chatlist Field.
    via_chatlist = NULL,
    #  @field about Field.
    about = NULL,
    #  @field approved_by Field.
    approved_by = NULL,
    initialize = function(user_id, date, requested = NULL, via_chatlist = NULL, about = NULL, approved_by = NULL) {
      self$user_id <- user_id
      self$date <- date
      self$requested <- requested
      self$via_chatlist <- via_chatlist
      self$about <- about
      self$approved_by <- approved_by
    },
    to_dict = function() {
      list(
        "_" = "ChatInviteImporter",
        user_id = self$user_id,
        date = self$date,
        requested = self$requested,
        via_chatlist = self$via_chatlist,
        about = self$about,
        approved_by = self$approved_by
      )
    }
  )
)

#  @title ChatInvitePeek
#  @description Telegram API type ChatInvitePeek
#  @export
#  @noRd
#  @noRd
ChatInvitePeek <- R6::R6Class(
  "ChatInvitePeek",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x61695cb0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x4561736,
    #  @field chat Field.
    chat = NULL,
    #  @field expires Field.
    expires = NULL,
    initialize = function(chat, expires) {
      self$chat <- chat
      self$expires <- expires
    },
    to_dict = function() {
      list(
        "_" = "ChatInvitePeek",
        chat = if (!is.null(self$chat) && inherits(self$chat, "TLObject")) self$chat$to_dict() else self$chat,
        expires = self$expires
      )
    }
  )
)

#  @title ChatInvitePublicJoinRequests
#  @description Telegram API type ChatInvitePublicJoinRequests
#  @export
#  @noRd
#  @noRd
ChatInvitePublicJoinRequests <- R6::R6Class(
  "ChatInvitePublicJoinRequests",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xed107ab7,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb4748a58,
    to_dict = function() {
      list("_" = "ChatInvitePublicJoinRequests")
    }
  )
)

#  @title ChatOnlines
#  @description Telegram API type ChatOnlines
#  @export
#  @noRd
#  @noRd
ChatOnlines <- R6::R6Class(
  "ChatOnlines",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf041e250,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8c81903a,
    #  @field onlines Field.
    onlines = NULL,
    initialize = function(onlines) {
      self$onlines <- onlines
    },
    to_dict = function() {
      list(
        "_" = "ChatOnlines",
        onlines = self$onlines
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x50, 0xe2, 0x41, 0xf0)),
        writeBin(as.integer(self$onlines), raw(), size = 4, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      onlines <- reader$read_int()
      self$new(onlines = onlines)
    }
  )
)

#  @title ChatParticipant
#  @description Telegram API type ChatParticipant
#  @export
#  @noRd
#  @noRd
ChatParticipant <- R6::R6Class(
  "ChatParticipant",
  inherit = TLObject,
  public = list(
    #  @field constructor_id Field.
    constructor_id = 0xc02d4007,
    #  @field subclass_of_id Field.
    subclass_of_id = 0x7d7c6f86,
    #  @field user_id Field.
    user_id = NULL,
    #  @field inviter_id Field.
    inviter_id = NULL,
    #  @field date Field.
    date = NULL,
    initialize = function(user_id, inviter_id, date) {
      self$user_id <- user_id
      self$inviter_id <- inviter_id
      self$date <- date
    },
    to_dict = function() {
      list(
        "_" = "ChatParticipant",
        user_id = self$user_id,
        inviter_id = self$inviter_id,
        date = self$date
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x07, 0x40, 0x2D, 0xC0)),
        writeBin(as.integer(self$user_id), raw(), size = 8, endian = "little"),
        writeBin(as.integer(self$inviter_id), raw(), size = 8, endian = "little"),
        self$serialize_datetime(self$date)
      )
    },
    from_reader = function(reader) {
      user_id <- reader$read_long()
      inviter_id <- reader$read_long()
      date <- reader$tgread_date()
      self$new(user_id = user_id, inviter_id = inviter_id, date = date)
    }
  )
)

#  @title ChatParticipantAdmin
#  @description Telegram API type ChatParticipantAdmin
#  @export
#  @noRd
#  @noRd
ChatParticipantAdmin <- R6::R6Class(
  "ChatParticipantAdmin",
  inherit = TLObject,
  public = list(
    #  @field constructor_id Field.
    constructor_id = 0xa0933f5b,
    #  @field subclass_of_id Field.
    subclass_of_id = 0x7d7c6f86,
    #  @field user_id Field.
    user_id = NULL,
    #  @field inviter_id Field.
    inviter_id = NULL,
    #  @field date Field.
    date = NULL,
    initialize = function(user_id, inviter_id, date) {
      self$user_id <- user_id
      self$inviter_id <- inviter_id
      self$date <- date
    },
    to_dict = function() {
      list(
        "_" = "ChatParticipantAdmin",
        user_id = self$user_id,
        inviter_id = self$inviter_id,
        date = self$date
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x5B, 0x3F, 0x93, 0xA0)),
        writeBin(as.integer(self$user_id), raw(), size = 8, endian = "little"),
        writeBin(as.integer(self$inviter_id), raw(), size = 8, endian = "little"),
        self$serialize_datetime(self$date)
      )
    },
    from_reader = function(reader) {
      user_id <- reader$read_long()
      inviter_id <- reader$read_long()
      date <- reader$tgread_date()
      self$new(user_id = user_id, inviter_id = inviter_id, date = date)
    }
  )
)

#  @title ChatParticipantCreator
#  @description Telegram API type ChatParticipantCreator
#  @export
#  @noRd
#  @noRd
ChatParticipantCreator <- R6::R6Class(
  "ChatParticipantCreator",
  inherit = TLObject,
  public = list(
    #  @field constructor_id Field.
    constructor_id = 0xe46bcee4,
    #  @field subclass_of_id Field.
    subclass_of_id = 0x7d7c6f86,
    #  @field user_id Field.
    user_id = NULL,
    initialize = function(user_id) {
      self$user_id <- user_id
    },
    to_dict = function() {
      list(
        "_" = "ChatParticipantCreator",
        user_id = self$user_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xE4, 0xCE, 0x6B, 0xE4)),
        writeBin(as.integer(self$user_id), raw(), size = 8, endian = "little")
      )
    },
    from_reader = function(reader) {
      user_id <- reader$read_long()
      self$new(user_id = user_id)
    }
  )
)

#  @title ChatParticipants
#  @description Telegram API type ChatParticipants
#  @export
#  @noRd
#  @noRd
ChatParticipants <- R6::R6Class(
  "ChatParticipants",
  inherit = TLObject,
  public = list(
    #  @field constructor_id Field.
    constructor_id = 0x3cbc93f8,
    #  @field subclass_of_id Field.
    subclass_of_id = 0x1fa89571,
    #  @field chat_id Field.
    chat_id = NULL,
    #  @field participants Field.
    participants = NULL,
    #  @field version Field.
    version = NULL,
    initialize = function(chat_id, participants, version) {
      self$chat_id <- chat_id
      self$participants <- participants
      self$version <- version
    },
    to_dict = function() {
      list(
        "_" = "ChatParticipants",
        chat_id = self$chat_id,
        participants = lapply(self$participants, function(x) x$to_dict()),
        version = self$version
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xF8, 0x93, 0xBC, 0x3C)),
        writeBin(as.integer(self$chat_id), raw(), size = 8, endian = "little"),
        as.raw(c(0x15, 0xC4, 0xB5, 0x1C)),
        writeBin(as.integer(length(self$participants)), raw(), size = 4, endian = "little"),
        unlist(lapply(self$participants, function(x) x$bytes())),
        writeBin(as.integer(self$version), raw(), size = 4, endian = "little")
      )
    },
    from_reader = function(reader) {
      chat_id <- reader$read_long()
      reader$read_int()
      participants <- list()
      for (i in seq_len(reader$read_int())) {
        participants[[i]] <- reader$tgread_object()
      }
      version <- reader$read_int()
      self$new(chat_id = chat_id, participants = participants, version = version)
    }
  )
)

#  @title ChatParticipantsForbidden
#  @description Telegram API type ChatParticipantsForbidden
#  @export
#  @noRd
#  @noRd
ChatParticipantsForbidden <- R6::R6Class(
  "ChatParticipantsForbidden",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8763d3e1,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1fa89571,
    #  @field chat_id Field.
    chat_id = NULL,
    #  @field self_participant Field.
    self_participant = NULL,
    initialize = function(chat_id, self_participant = NULL) {
      self$chat_id <- chat_id
      self$self_participant <- self_participant
    },
    to_dict = function() {
      list(
        "_" = "ChatParticipantsForbidden",
        chat_id = self$chat_id,
        self_participant = if (inherits(self$self_participant, "TLObject")) self$self_participant$to_dict() else self$self_participant
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xe1, 0xd3, 0x63, 0x87)),
        writeBin(as.integer(if (is.null(self$self_participant) || identical(self$self_participant, FALSE)) 0 else 1), raw(), size = 4, endian = "little"),
        writeBin(as.numeric(self$chat_id), raw(), size = 8, endian = "little"),
        if (is.null(self$self_participant) || identical(self$self_participant, FALSE)) raw() else self$self_participant$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      chat_id <- reader$read_long()
      self_participant <- if (bitwAnd(flags, 1) != 0) reader$tgread_object() else NULL
      self$new(chat_id = chat_id, self_participant = self_participant)
    }
  )
)


#  @title ChatPhoto
#  @description Telegram API type ChatPhoto
#  @export
#  @noRd
#  @noRd
ChatPhoto <- R6::R6Class(
  "ChatPhoto",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1c6e1c11,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xac3ec4e5,
    #  @field photo_id Field.
    photo_id = NULL,
    #  @field dc_id Field.
    dc_id = NULL,
    #  @field has_video Field.
    has_video = NULL,
    #  @field stripped_thumb Field.
    stripped_thumb = NULL,
    initialize = function(photo_id, dc_id, has_video = NULL, stripped_thumb = NULL) {
      self$photo_id <- photo_id
      self$dc_id <- dc_id
      self$has_video <- has_video
      self$stripped_thumb <- stripped_thumb
    },
    to_list = function() {
      list(
        "_" = "ChatPhoto",
        photo_id = self$photo_id,
        dc_id = self$dc_id,
        has_video = self$has_video,
        stripped_thumb = self$stripped_thumb
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x11, 0x1c, 0x6e, 0x1c)),
        as.raw(ifelse(is.null(self$has_video) || !self$has_video, 0, 1) | ifelse(is.null(self$stripped_thumb), 0, 2)),
        writeBin(as.integer(self$photo_id), raw(), size = 8),
        if (!is.null(self$stripped_thumb)) self$stripped_thumb else raw(),
        writeBin(as.integer(self$dc_id), raw(), size = 4)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      has_video <- bitwAnd(flags, 1) != 0
      photo_id <- reader$read_long()
      stripped_thumb <- if (bitwAnd(flags, 2) != 0) reader$tgread_bytes() else NULL
      dc_id <- reader$read_int()
      list(photo_id = photo_id, dc_id = dc_id, has_video = has_video, stripped_thumb = stripped_thumb)
    }
  )
)

#  @title ChatPhotoEmpty
#  @description Telegram API type ChatPhotoEmpty
#  @export
#  @noRd
#  @noRd
ChatPhotoEmpty <- R6::R6Class(
  "ChatPhotoEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x37c1011c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xac3ec4e5,
    to_list = function() {
      list("_" = "ChatPhotoEmpty")
    },
    bytes = function() {
      as.raw(c(0x1c, 0x01, 0xc1, 0x37))
    }
  )
)

#  @title ChatReactionsAll
#  @description Telegram API type ChatReactionsAll
#  @export
#  @noRd
#  @noRd
ChatReactionsAll <- R6::R6Class(
  "ChatReactionsAll",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x52928bca,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x131e24b5,
    #  @field allow_custom Field.
    allow_custom = NULL,
    initialize = function(allow_custom = NULL) {
      self$allow_custom <- allow_custom
    },
    to_list = function() {
      list(
        "_" = "ChatReactionsAll",
        allow_custom = self$allow_custom
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xca, 0x8b, 0x92, 0x52)),
        as.raw(ifelse(is.null(self$allow_custom) || !self$allow_custom, 0, 1))
      )
    }
  )
)

#  @title ChatReactionsNone
#  @description Telegram API type ChatReactionsNone
#  @export
#  @noRd
#  @noRd
ChatReactionsNone <- R6::R6Class(
  "ChatReactionsNone",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xeafc32bc,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x131e24b5,
    to_list = function() {
      list("_" = "ChatReactionsNone")
    },
    bytes = function() {
      as.raw(c(0xbc, 0x32, 0xfc, 0xea))
    }
  )
)

#  @title ChatReactionsSome
#  @description Telegram API type ChatReactionsSome
#  @export
#  @noRd
#  @noRd
ChatReactionsSome <- R6::R6Class(
  "ChatReactionsSome",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x661d4037,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x131e24b5,
    #  @field reactions Field.
    reactions = NULL,
    initialize = function(reactions) {
      self$reactions <- reactions
    },
    to_list = function() {
      list(
        "_" = "ChatReactionsSome",
        reactions = lapply(self$reactions, function(x) if (inherits(x, "TLObject")) x$to_list() else x)
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x37, 0x40, 0x1d, 0x66)),
        writeBin(as.integer(length(self$reactions)), raw(), size = 4),
        unlist(lapply(self$reactions, function(x) x$bytes()))
      )
    }
  )
)

#  @title ChatTheme
#  @description Telegram API type ChatTheme
#  @export
#  @noRd
#  @noRd
ChatTheme <- R6::R6Class(
  "ChatTheme",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc3dffc04,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x2ffca7f5,
    #  @field emoticon Field.
    emoticon = NULL,
    initialize = function(emoticon) {
      self$emoticon <- emoticon
    },
    to_list = function() {
      list(
        "_" = "ChatTheme",
        emoticon = self$emoticon
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x04, 0xfc, 0xdf, 0xc3)),
        charToRaw(self$emoticon)
      )
    }
  )
)

#  @title ChatThemeUniqueGift
#  @description Telegram API type ChatThemeUniqueGift
#  @export
#  @noRd
#  @noRd
ChatThemeUniqueGift <- R6::R6Class(
  "ChatThemeUniqueGift",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x3458f9c8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x2ffca7f5,
    #  @field gift Field.
    gift = NULL,
    #  @field theme_settings Field.
    theme_settings = NULL,
    initialize = function(gift, theme_settings) {
      self$gift <- gift
      self$theme_settings <- theme_settings
    },
    to_list = function() {
      list(
        "_" = "ChatThemeUniqueGift",
        gift = if (inherits(self$gift, "TLObject")) self$gift$to_list() else self$gift,
        theme_settings = lapply(self$theme_settings, function(x) if (inherits(x, "TLObject")) x$to_list() else x)
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xc8, 0xf9, 0x58, 0x34)),
        self$gift$bytes(),
        writeBin(as.integer(length(self$theme_settings)), raw(), size = 4),
        unlist(lapply(self$theme_settings, function(x) x$bytes()))
      )
    }
  )
)

#  @title ClientDHInnerData
#  @description Telegram API type ClientDHInnerData
#  @export
#  @noRd
#  @noRd
ClientDHInnerData <- R6::R6Class(
  "ClientDHInnerData",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x6643b654,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf8eeef6a,
    #  @field nonce Field.
    nonce = NULL,
    #  @field server_nonce Field.
    server_nonce = NULL,
    #  @field retry_id Field.
    retry_id = NULL,
    #  @field g_b Field.
    g_b = NULL,
    initialize = function(nonce, server_nonce, retry_id, g_b) {
      self$nonce <- nonce
      self$server_nonce <- server_nonce
      self$retry_id <- retry_id
      self$g_b <- g_b
    },
    to_list = function() {
      list(
        "_" = "ClientDHInnerData",
        nonce = self$nonce,
        server_nonce = self$server_nonce,
        retry_id = self$retry_id,
        g_b = self$g_b
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x54, 0xb6, 0x43, 0x66)),
        writeBin(as.integer(self$nonce), raw(), size = 16, endian = "little"),
        writeBin(as.integer(self$server_nonce), raw(), size = 16, endian = "little"),
        writeBin(as.integer(self$retry_id), raw(), size = 8, endian = "little"),
        self$serialize_bytes(self$g_b)
      )
    }
  )
)

#  @title CodeSettings
#  @description Telegram API type CodeSettings
#  @export
#  @noRd
#  @noRd
CodeSettings <- R6::R6Class(
  "CodeSettings",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xad253d78,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x48edbc8a,
    #  @field allow_flashcall Field.
    allow_flashcall = NULL,
    #  @field current_number Field.
    current_number = NULL,
    #  @field allow_app_hash Field.
    allow_app_hash = NULL,
    #  @field allow_missed_call Field.
    allow_missed_call = NULL,
    #  @field allow_firebase Field.
    allow_firebase = NULL,
    #  @field unknown_number Field.
    unknown_number = NULL,
    #  @field logout_tokens Field.
    logout_tokens = NULL,
    #  @field token Field.
    token = NULL,
    #  @field app_sandbox Field.
    app_sandbox = NULL,
    initialize = function(allow_flashcall = NULL, current_number = NULL, allow_app_hash = NULL,
                          allow_missed_call = NULL, allow_firebase = NULL, unknown_number = NULL,
                          logout_tokens = NULL, token = NULL, app_sandbox = NULL) {
      self$allow_flashcall <- allow_flashcall
      self$current_number <- current_number
      self$allow_app_hash <- allow_app_hash
      self$allow_missed_call <- allow_missed_call
      self$allow_firebase <- allow_firebase
      self$unknown_number <- unknown_number
      self$logout_tokens <- logout_tokens
      self$token <- token
      self$app_sandbox <- app_sandbox
    },
    to_list = function() {
      list(
        "_" = "CodeSettings",
        allow_flashcall = self$allow_flashcall,
        current_number = self$current_number,
        allow_app_hash = self$allow_app_hash,
        allow_missed_call = self$allow_missed_call,
        allow_firebase = self$allow_firebase,
        unknown_number = self$unknown_number,
        logout_tokens = if (is.null(self$logout_tokens)) list() else self$logout_tokens,
        token = self$token,
        app_sandbox = self$app_sandbox
      )
    }
  )
)

#  @title Config
#  @description Telegram API type Config
#  @export
#  @noRd
#  @noRd
Config <- R6::R6Class(
  "Config",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xcc1a241e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd3262a4a,
    #  @field date Field.
    date = NULL,
    #  @field expires Field.
    expires = NULL,
    #  @field test_mode Field.
    test_mode = NULL,
    #  @field this_dc Field.
    this_dc = NULL,
    #  @field dc_options Field.
    dc_options = NULL,
    #  @field dc_txt_domain_name Field.
    dc_txt_domain_name = NULL,
    #  @field chat_size_max Field.
    chat_size_max = NULL,
    #  @field megagroup_size_max Field.
    megagroup_size_max = NULL,
    #  @field forwarded_count_max Field.
    forwarded_count_max = NULL,
    #  @field online_update_period_ms Field.
    online_update_period_ms = NULL,
    #  @field offline_blur_timeout_ms Field.
    offline_blur_timeout_ms = NULL,
    #  @field offline_idle_timeout_ms Field.
    offline_idle_timeout_ms = NULL,
    #  @field online_cloud_timeout_ms Field.
    online_cloud_timeout_ms = NULL,
    #  @field notify_cloud_delay_ms Field.
    notify_cloud_delay_ms = NULL,
    #  @field notify_default_delay_ms Field.
    notify_default_delay_ms = NULL,
    #  @field push_chat_period_ms Field.
    push_chat_period_ms = NULL,
    #  @field push_chat_limit Field.
    push_chat_limit = NULL,
    #  @field edit_time_limit Field.
    edit_time_limit = NULL,
    #  @field revoke_time_limit Field.
    revoke_time_limit = NULL,
    #  @field revoke_pm_time_limit Field.
    revoke_pm_time_limit = NULL,
    #  @field rating_e_decay Field.
    rating_e_decay = NULL,
    #  @field stickers_recent_limit Field.
    stickers_recent_limit = NULL,
    #  @field channels_read_media_period Field.
    channels_read_media_period = NULL,
    #  @field call_receive_timeout_ms Field.
    call_receive_timeout_ms = NULL,
    #  @field call_ring_timeout_ms Field.
    call_ring_timeout_ms = NULL,
    #  @field call_connect_timeout_ms Field.
    call_connect_timeout_ms = NULL,
    #  @field call_packet_timeout_ms Field.
    call_packet_timeout_ms = NULL,
    #  @field me_url_prefix Field.
    me_url_prefix = NULL,
    #  @field caption_length_max Field.
    caption_length_max = NULL,
    #  @field message_length_max Field.
    message_length_max = NULL,
    #  @field webfile_dc_id Field.
    webfile_dc_id = NULL,
    #  @field default_p2p_contacts Field.
    default_p2p_contacts = NULL,
    #  @field preload_featured_stickers Field.
    preload_featured_stickers = NULL,
    #  @field revoke_pm_inbox Field.
    revoke_pm_inbox = NULL,
    #  @field blocked_mode Field.
    blocked_mode = NULL,
    #  @field force_try_ipv6 Field.
    force_try_ipv6 = NULL,
    #  @field tmp_sessions Field.
    tmp_sessions = NULL,
    #  @field autoupdate_url_prefix Field.
    autoupdate_url_prefix = NULL,
    #  @field gif_search_username Field.
    gif_search_username = NULL,
    #  @field venue_search_username Field.
    venue_search_username = NULL,
    #  @field img_search_username Field.
    img_search_username = NULL,
    #  @field static_maps_provider Field.
    static_maps_provider = NULL,
    #  @field suggested_lang_code Field.
    suggested_lang_code = NULL,
    #  @field lang_pack_version Field.
    lang_pack_version = NULL,
    #  @field base_lang_pack_version Field.
    base_lang_pack_version = NULL,
    #  @field reactions_default Field.
    reactions_default = NULL,
    #  @field autologin_token Field.
    autologin_token = NULL,
    initialize = function(date, expires, test_mode, this_dc, dc_options, dc_txt_domain_name,
                          chat_size_max, megagroup_size_max, forwarded_count_max,
                          online_update_period_ms, offline_blur_timeout_ms, offline_idle_timeout_ms,
                          online_cloud_timeout_ms, notify_cloud_delay_ms, notify_default_delay_ms,
                          push_chat_period_ms, push_chat_limit, edit_time_limit, revoke_time_limit,
                          revoke_pm_time_limit, rating_e_decay, stickers_recent_limit,
                          channels_read_media_period, call_receive_timeout_ms, call_ring_timeout_ms,
                          call_connect_timeout_ms, call_packet_timeout_ms, me_url_prefix,
                          caption_length_max, message_length_max, webfile_dc_id,
                          default_p2p_contacts = NULL, preload_featured_stickers = NULL,
                          revoke_pm_inbox = NULL, blocked_mode = NULL, force_try_ipv6 = NULL,
                          tmp_sessions = NULL, autoupdate_url_prefix = NULL, gif_search_username = NULL,
                          venue_search_username = NULL, img_search_username = NULL,
                          static_maps_provider = NULL, suggested_lang_code = NULL,
                          lang_pack_version = NULL, base_lang_pack_version = NULL,
                          reactions_default = NULL, autologin_token = NULL) {
      self$date <- date
      self$expires <- expires
      self$test_mode <- test_mode
      self$this_dc <- this_dc
      self$dc_options <- dc_options
      self$dc_txt_domain_name <- dc_txt_domain_name
      self$chat_size_max <- chat_size_max
      self$megagroup_size_max <- megagroup_size_max
      self$forwarded_count_max <- forwarded_count_max
      self$online_update_period_ms <- online_update_period_ms
      self$offline_blur_timeout_ms <- offline_blur_timeout_ms
      self$offline_idle_timeout_ms <- offline_idle_timeout_ms
      self$online_cloud_timeout_ms <- online_cloud_timeout_ms
      self$notify_cloud_delay_ms <- notify_cloud_delay_ms
      self$notify_default_delay_ms <- notify_default_delay_ms
      self$push_chat_period_ms <- push_chat_period_ms
      self$push_chat_limit <- push_chat_limit
      self$edit_time_limit <- edit_time_limit
      self$revoke_time_limit <- revoke_time_limit
      self$revoke_pm_time_limit <- revoke_pm_time_limit
      self$rating_e_decay <- rating_e_decay
      self$stickers_recent_limit <- stickers_recent_limit
      self$channels_read_media_period <- channels_read_media_period
      self$call_receive_timeout_ms <- call_receive_timeout_ms
      self$call_ring_timeout_ms <- call_ring_timeout_ms
      self$call_connect_timeout_ms <- call_connect_timeout_ms
      self$call_packet_timeout_ms <- call_packet_timeout_ms
      self$me_url_prefix <- me_url_prefix
      self$caption_length_max <- caption_length_max
      self$message_length_max <- message_length_max
      self$webfile_dc_id <- webfile_dc_id
      self$default_p2p_contacts <- default_p2p_contacts
      self$preload_featured_stickers <- preload_featured_stickers
      self$revoke_pm_inbox <- revoke_pm_inbox
      self$blocked_mode <- blocked_mode
      self$force_try_ipv6 <- force_try_ipv6
      self$tmp_sessions <- tmp_sessions
      self$autoupdate_url_prefix <- autoupdate_url_prefix
      self$gif_search_username <- gif_search_username
      self$venue_search_username <- venue_search_username
      self$img_search_username <- img_search_username
      self$static_maps_provider <- static_maps_provider
      self$suggested_lang_code <- suggested_lang_code
      self$lang_pack_version <- lang_pack_version
      self$base_lang_pack_version <- base_lang_pack_version
      self$reactions_default <- reactions_default
      self$autologin_token <- autologin_token
    },
    to_list = function() {
      list(
        "_" = "Config",
        date = self$date,
        expires = self$expires,
        test_mode = self$test_mode,
        this_dc = self$this_dc,
        dc_options = lapply(self$dc_options, function(x) if (inherits(x, "TLObject")) x$to_list() else x),
        dc_txt_domain_name = self$dc_txt_domain_name,
        chat_size_max = self$chat_size_max,
        megagroup_size_max = self$megagroup_size_max,
        forwarded_count_max = self$forwarded_count_max,
        online_update_period_ms = self$online_update_period_ms,
        offline_blur_timeout_ms = self$offline_blur_timeout_ms,
        offline_idle_timeout_ms = self$offline_idle_timeout_ms,
        online_cloud_timeout_ms = self$online_cloud_timeout_ms,
        notify_cloud_delay_ms = self$notify_cloud_delay_ms,
        notify_default_delay_ms = self$notify_default_delay_ms,
        push_chat_period_ms = self$push_chat_period_ms,
        push_chat_limit = self$push_chat_limit,
        edit_time_limit = self$edit_time_limit,
        revoke_time_limit = self$revoke_time_limit,
        revoke_pm_time_limit = self$revoke_pm_time_limit,
        rating_e_decay = self$rating_e_decay,
        stickers_recent_limit = self$stickers_recent_limit,
        channels_read_media_period = self$channels_read_media_period,
        call_receive_timeout_ms = self$call_receive_timeout_ms,
        call_ring_timeout_ms = self$call_ring_timeout_ms,
        call_connect_timeout_ms = self$call_connect_timeout_ms,
        call_packet_timeout_ms = self$call_packet_timeout_ms,
        me_url_prefix = self$me_url_prefix,
        caption_length_max = self$caption_length_max,
        message_length_max = self$message_length_max,
        webfile_dc_id = self$webfile_dc_id,
        default_p2p_contacts = self$default_p2p_contacts,
        preload_featured_stickers = self$preload_featured_stickers,
        revoke_pm_inbox = self$revoke_pm_inbox,
        blocked_mode = self$blocked_mode,
        force_try_ipv6 = self$force_try_ipv6,
        tmp_sessions = self$tmp_sessions,
        autoupdate_url_prefix = self$autoupdate_url_prefix,
        gif_search_username = self$gif_search_username,
        venue_search_username = self$venue_search_username,
        img_search_username = self$img_search_username,
        static_maps_provider = self$static_maps_provider,
        suggested_lang_code = self$suggested_lang_code,
        lang_pack_version = self$lang_pack_version,
        base_lang_pack_version = self$base_lang_pack_version,
        reactions_default = if (inherits(self$reactions_default, "TLObject")) self$reactions_default$to_list() else self$reactions_default,
        autologin_token = self$autologin_token
      )
    }
  )
)

#  @title ConnectedBot
#  @description Telegram API type ConnectedBot
#  @export
#  @noRd
#  @noRd
ConnectedBot <- R6::R6Class(
  "ConnectedBot",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xcd64636c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x35e81b9e,
    #  @field bot_id Field.
    bot_id = NULL,
    #  @field recipients Field.
    recipients = NULL,
    #  @field rights Field.
    rights = NULL,
    initialize = function(bot_id, recipients, rights) {
      self$bot_id <- bot_id
      self$recipients <- recipients
      self$rights <- rights
    },
    to_dict = function() {
      list(
        "_" = "ConnectedBot",
        bot_id = self$bot_id,
        recipients = if (inherits(self$recipients, "TLObject")) self$recipients$to_dict() else self$recipients,
        rights = if (inherits(self$rights, "TLObject")) self$rights$to_dict() else self$rights
      )
    },
    bytes = function() {
      # Placeholder for bytes serialization
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      bot_id <- reader$read_long()
      recipients <- reader$tgread_object()
      rights <- reader$tgread_object()
      self$new(bot_id = bot_id, recipients = recipients, rights = rights)
    }
  )
)

#  @title ConnectedBotStarRef
#  @description Telegram API type ConnectedBotStarRef
#  @export
#  @noRd
#  @noRd
ConnectedBotStarRef <- R6::R6Class(
  "ConnectedBotStarRef",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x19a13f71,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xa0528f8c,
    #  @field url Field.
    url = NULL,
    #  @field date Field.
    date = NULL,
    #  @field bot_id Field.
    bot_id = NULL,
    #  @field commission_permille Field.
    commission_permille = NULL,
    #  @field participants Field.
    participants = NULL,
    #  @field revenue Field.
    revenue = NULL,
    #  @field revoked Field.
    revoked = NULL,
    #  @field duration_months Field.
    duration_months = NULL,
    initialize = function(url, date, bot_id, commission_permille, participants, revenue, revoked = NULL, duration_months = NULL) {
      self$url <- url
      self$date <- date
      self$bot_id <- bot_id
      self$commission_permille <- commission_permille
      self$participants <- participants
      self$revenue <- revenue
      self$revoked <- revoked
      self$duration_months <- duration_months
    },
    to_dict = function() {
      list(
        "_" = "ConnectedBotStarRef",
        url = self$url,
        date = self$date,
        bot_id = self$bot_id,
        commission_permille = self$commission_permille,
        participants = self$participants,
        revenue = self$revenue,
        revoked = self$revoked,
        duration_months = self$duration_months
      )
    },
    bytes = function() {
      # Placeholder for bytes serialization
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      revoked <- as.logical(bitwAnd(flags, 2))
      url <- reader$tgread_string()
      date <- reader$tgread_date()
      bot_id <- reader$read_long()
      commission_permille <- reader$read_int()
      duration_months <- if (bitwAnd(flags, 1) != 0) reader$read_int() else NULL
      participants <- reader$read_long()
      revenue <- reader$read_long()
      self$new(url = url, date = date, bot_id = bot_id, commission_permille = commission_permille, participants = participants, revenue = revenue, revoked = revoked, duration_months = duration_months)
    }
  )
)

#  @title Contact
#  @description Telegram API type Contact
#  @export
#  @noRd
#  @noRd
Contact <- R6::R6Class(
  "Contact",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x145ade0b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x83dfdfa4,
    #  @field user_id Field.
    user_id = NULL,
    #  @field mutual Field.
    mutual = NULL,
    initialize = function(user_id, mutual) {
      self$user_id <- user_id
      self$mutual <- mutual
    },
    to_dict = function() {
      list(
        "_" = "Contact",
        user_id = self$user_id,
        mutual = self$mutual
      )
    },
    bytes = function() {
      # Placeholder for bytes serialization
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      user_id <- reader$read_long()
      mutual <- reader$tgread_bool()
      self$new(user_id = user_id, mutual = mutual)
    }
  )
)

#  @title ContactBirthday
#  @description Telegram API type ContactBirthday
#  @export
#  @noRd
#  @noRd
ContactBirthday <- R6::R6Class(
  "ContactBirthday",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1d998733,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd8dd2806,
    #  @field contact_id Field.
    contact_id = NULL,
    #  @field birthday Field.
    birthday = NULL,
    initialize = function(contact_id, birthday) {
      self$contact_id <- contact_id
      self$birthday <- birthday
    },
    to_dict = function() {
      list(
        "_" = "ContactBirthday",
        contact_id = self$contact_id,
        birthday = if (inherits(self$birthday, "TLObject")) self$birthday$to_dict() else self$birthday
      )
    },
    bytes = function() {
      # Placeholder for bytes serialization
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      contact_id <- reader$read_long()
      birthday <- reader$tgread_object()
      self$new(contact_id = contact_id, birthday = birthday)
    }
  )
)

#  @title ContactStatus
#  @description Telegram API type ContactStatus
#  @export
#  @noRd
#  @noRd
ContactStatus <- R6::R6Class(
  "ContactStatus",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x16d9703b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x68c0d74c,
    #  @field user_id Field.
    user_id = NULL,
    #  @field status Field.
    status = NULL,
    initialize = function(user_id, status) {
      self$user_id <- user_id
      self$status <- status
    },
    to_dict = function() {
      list(
        "_" = "ContactStatus",
        user_id = self$user_id,
        status = if (inherits(self$status, "TLObject")) self$status$to_dict() else self$status
      )
    },
    bytes = function() {
      # Placeholder for bytes serialization
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      user_id <- reader$read_long()
      status <- reader$tgread_object()
      self$new(user_id = user_id, status = status)
    }
  )
)

#  @title DataJSON
#  @description Telegram API type DataJSON
#  @export
#  @noRd
#  @noRd
DataJSON <- R6::R6Class(
  "DataJSON",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7d748d04,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xad0352e8,
    #  @field data Field.
    data = NULL,
    initialize = function(data) {
      self$data <- data
    },
    to_dict = function() {
      list(
        "_" = "DataJSON",
        data = self$data
      )
    },
    bytes = function() {
      # Placeholder for bytes serialization
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      data <- reader$tgread_string()
      self$new(data = data)
    }
  )
)

#  @title DcOption
#  @description Telegram API type DcOption
#  @export
#  @noRd
#  @noRd
DcOption <- R6::R6Class(
  "DcOption",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x18b7a10d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9e43e123,
    #  @field id Field.
    id = NULL,
    #  @field ip_address Field.
    ip_address = NULL,
    #  @field port Field.
    port = NULL,
    #  @field ipv6 Field.
    ipv6 = NULL,
    #  @field media_only Field.
    media_only = NULL,
    #  @field tcpo_only Field.
    tcpo_only = NULL,
    #  @field cdn Field.
    cdn = NULL,
    #  @field static Field.
    static = NULL,
    #  @field this_port_only Field.
    this_port_only = NULL,
    #  @field secret Field.
    secret = NULL,
    initialize = function(id, ip_address, port, ipv6 = NULL, media_only = NULL, tcpo_only = NULL, cdn = NULL, static = NULL, this_port_only = NULL, secret = NULL) {
      self$id <- id
      self$ip_address <- ip_address
      self$port <- port
      self$ipv6 <- ipv6
      self$media_only <- media_only
      self$tcpo_only <- tcpo_only
      self$cdn <- cdn
      self$static <- static
      self$this_port_only <- this_port_only
      self$secret <- secret
    },
    to_dict = function() {
      list(
        "_" = "DcOption",
        id = self$id,
        ip_address = self$ip_address,
        port = self$port,
        ipv6 = self$ipv6,
        media_only = self$media_only,
        tcpo_only = self$tcpo_only,
        cdn = self$cdn,
        static = self$static,
        this_port_only = self$this_port_only,
        secret = self$secret
      )
    },
    bytes = function() {
      # Placeholder for bytes serialization
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      ipv6 <- as.logical(bitwAnd(flags, 1))
      media_only <- as.logical(bitwAnd(flags, 2))
      tcpo_only <- as.logical(bitwAnd(flags, 4))
      cdn <- as.logical(bitwAnd(flags, 8))
      static <- as.logical(bitwAnd(flags, 16))
      this_port_only <- as.logical(bitwAnd(flags, 32))
      id <- reader$read_int()
      ip_address <- reader$tgread_string()
      port <- reader$read_int()
      secret <- if (bitwAnd(flags, 1024) != 0) reader$tgreadbytes() else NULL
      self$new(id = id, ip_address = ip_address, port = port, ipv6 = ipv6, media_only = media_only, tcpo_only = tcpo_only, cdn = cdn, static = static, this_port_only = this_port_only, secret = secret)
    }
  )
)

#  @title DefaultHistoryTTL
#  @description Telegram API type DefaultHistoryTTL
#  @export
#  @noRd
#  @noRd
DefaultHistoryTTL <- R6::R6Class(
  "DefaultHistoryTTL",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x43b46b20,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf00d3367,
    #  @field period Field.
    period = NULL,
    initialize = function(period) {
      self$period <- period
    },
    to_dict = function() {
      list(
        "_" = "DefaultHistoryTTL",
        period = self$period
      )
    },
    bytes = function() {
      # Placeholder for bytes serialization
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      period <- reader$read_int()
      self$new(period = period)
    }
  )
)

#  @title DestroyAuthKeyFail
#  @description Telegram API type DestroyAuthKeyFail
#  @export
#  @noRd
#  @noRd
DestroyAuthKeyFail <- R6::R6Class(
  "DestroyAuthKeyFail",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xea109b13,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8291e68e,
    to_dict = function() {
      list("_" = "DestroyAuthKeyFail")
    },
    bytes = function() {
      as.raw(c(0x13, 0x9b, 0x10, 0xea))
    }
  ),
  private = list(
    from_reader = function(reader) {
      DestroyAuthKeyFail$new()
    }
  )
)

#  @title DestroyAuthKeyNone
#  @description Telegram API type DestroyAuthKeyNone
#  @export
#  @noRd
#  @noRd
DestroyAuthKeyNone <- R6::R6Class(
  "DestroyAuthKeyNone",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x0a9f2259,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8291e68e,
    to_dict = function() {
      list("_" = "DestroyAuthKeyNone")
    },
    bytes = function() {
      as.raw(c(0x59, 0x22, 0x9f, 0x0a))
    }
  ),
  private = list(
    from_reader = function(reader) {
      DestroyAuthKeyNone$new()
    }
  )
)

#  @title DestroyAuthKeyOk
#  @description Telegram API type DestroyAuthKeyOk
#  @export
#  @noRd
#  @noRd
DestroyAuthKeyOk <- R6::R6Class(
  "DestroyAuthKeyOk",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf660e1d4,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8291e68e,
    to_dict = function() {
      list("_" = "DestroyAuthKeyOk")
    },
    bytes = function() {
      as.raw(c(0xd4, 0xe1, 0x60, 0xf6))
    }
  ),
  private = list(
    from_reader = function(reader) {
      DestroyAuthKeyOk$new()
    }
  )
)

#  @title DestroySessionNone
#  @description Telegram API type DestroySessionNone
#  @export
#  @noRd
#  @noRd
DestroySessionNone <- R6::R6Class(
  "DestroySessionNone",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x62d350c9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xaf0ce7bd,
    #  @field session_id Field.
    session_id = NULL,
    initialize = function(session_id) {
      self$session_id <- session_id
    },
    to_dict = function() {
      list(
        "_" = "DestroySessionNone",
        session_id = self$session_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xc9, 0x50, 0xd3, 0x62)),
        writeBin(as.integer64(self$session_id), raw(), size = 8, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      session_id <- reader$read_long()
      DestroySessionNone$new(session_id = session_id)
    }
  )
)

#  @title DestroySessionOk
#  @description Telegram API type DestroySessionOk
#  @export
#  @noRd
#  @noRd
DestroySessionOk <- R6::R6Class(
  "DestroySessionOk",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe22045fc,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xaf0ce7bd,
    #  @field session_id Field.
    session_id = NULL,
    initialize = function(session_id) {
      self$session_id <- session_id
    },
    to_dict = function() {
      list(
        "_" = "DestroySessionOk",
        session_id = self$session_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xfc, 0x45, 0x20, 0xe2)),
        writeBin(as.integer64(self$session_id), raw(), size = 8, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      session_id <- reader$read_long()
      DestroySessionOk$new(session_id = session_id)
    }
  )
)

#  @title DhGenFail
#  @description Telegram API type DhGenFail
#  @export
#  @noRd
#  @noRd
DhGenFail <- R6::R6Class(
  "DhGenFail",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa69dae02,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x55dd6cdb,
    #  @field nonce Field.
    nonce = NULL,
    #  @field server_nonce Field.
    server_nonce = NULL,
    #  @field new_nonce_hash3 Field.
    new_nonce_hash3 = NULL,
    initialize = function(nonce, server_nonce, new_nonce_hash3) {
      self$nonce <- nonce
      self$server_nonce <- server_nonce
      self$new_nonce_hash3 <- new_nonce_hash3
    },
    to_dict = function() {
      list(
        "_" = "DhGenFail",
        nonce = self$nonce,
        server_nonce = self$server_nonce,
        new_nonce_hash3 = self$new_nonce_hash3
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x02, 0xae, 0x9d, 0xa6)),
        writeBin(as.integer(self$nonce), raw(), size = 16, endian = "little"),
        writeBin(as.integer(self$server_nonce), raw(), size = 16, endian = "little"),
        writeBin(as.integer(self$new_nonce_hash3), raw(), size = 16, endian = "little")
      )
    }
  )
)

#  @title DhGenOk
#  @description Telegram API type DhGenOk
#  @export
#  @noRd
#  @noRd
DhGenOk <- R6::R6Class(
  "DhGenOk",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x3bcbf734,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x55dd6cdb,
    #  @field nonce Field.
    nonce = NULL,
    #  @field server_nonce Field.
    server_nonce = NULL,
    #  @field new_nonce_hash1 Field.
    new_nonce_hash1 = NULL,
    initialize = function(nonce, server_nonce, new_nonce_hash1) {
      self$nonce <- nonce
      self$server_nonce <- server_nonce
      self$new_nonce_hash1 <- new_nonce_hash1
    },
    to_dict = function() {
      list(
        "_" = "DhGenOk",
        nonce = self$nonce,
        server_nonce = self$server_nonce,
        new_nonce_hash1 = self$new_nonce_hash1
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x34, 0xf7, 0xcb, 0x3b)),
        writeBin(as.integer(self$nonce), raw(), size = 16, endian = "little"),
        writeBin(as.integer(self$server_nonce), raw(), size = 16, endian = "little"),
        writeBin(as.integer(self$new_nonce_hash1), raw(), size = 16, endian = "little")
      )
    }
  )
)

#  @title DhGenRetry
#  @description Telegram API type DhGenRetry
#  @export
#  @noRd
#  @noRd
DhGenRetry <- R6::R6Class(
  "DhGenRetry",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x46dc1fb9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x55dd6cdb,
    #  @field nonce Field.
    nonce = NULL,
    #  @field server_nonce Field.
    server_nonce = NULL,
    #  @field new_nonce_hash2 Field.
    new_nonce_hash2 = NULL,
    initialize = function(nonce, server_nonce, new_nonce_hash2) {
      self$nonce <- nonce
      self$server_nonce <- server_nonce
      self$new_nonce_hash2 <- new_nonce_hash2
    },
    to_dict = function() {
      list(
        "_" = "DhGenRetry",
        nonce = self$nonce,
        server_nonce = self$server_nonce,
        new_nonce_hash2 = self$new_nonce_hash2
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xb9, 0x1f, 0xdc, 0x46)),
        writeBin(as.integer(self$nonce), raw(), size = 16, endian = "little"),
        writeBin(as.integer(self$server_nonce), raw(), size = 16, endian = "little"),
        writeBin(as.integer(self$new_nonce_hash2), raw(), size = 16, endian = "little")
      )
    }
  )
)

#  @title Dialog
#  @description Telegram API type Dialog
#  @export
#  @noRd
#  @noRd
Dialog <- R6::R6Class(
  "Dialog",
  inherit = TLObject,
  public = list(
    #  @field peer Field.
    peer = NULL,
    #  @field top_message Field.
    top_message = NULL,
    #  @field read_inbox_max_id Field.
    read_inbox_max_id = NULL,
    #  @field read_outbox_max_id Field.
    read_outbox_max_id = NULL,
    #  @field unread_count Field.
    unread_count = NULL,
    #  @field unread_mentions_count Field.
    unread_mentions_count = NULL,
    #  @field unread_reactions_count Field.
    unread_reactions_count = NULL,
    #  @field notify_settings Field.
    notify_settings = NULL,
    #  @field pinned Field.
    pinned = NULL,
    #  @field unread_mark Field.
    unread_mark = NULL,
    #  @field view_forum_as_messages Field.
    view_forum_as_messages = NULL,
    #  @field pts Field.
    pts = NULL,
    #  @field draft Field.
    draft = NULL,
    #  @field folder_id Field.
    folder_id = NULL,
    #  @field ttl_period Field.
    ttl_period = NULL,
    initialize = function(peer, top_message, read_inbox_max_id, read_outbox_max_id, unread_count, unread_mentions_count, unread_reactions_count, notify_settings, pinned = NULL, unread_mark = NULL, view_forum_as_messages = NULL, pts = NULL, draft = NULL, folder_id = NULL, ttl_period = NULL) {
      self$peer <- peer
      self$top_message <- top_message
      self$read_inbox_max_id <- read_inbox_max_id
      self$read_outbox_max_id <- read_outbox_max_id
      self$unread_count <- unread_count
      self$unread_mentions_count <- unread_mentions_count
      self$unread_reactions_count <- unread_reactions_count
      self$notify_settings <- notify_settings
      self$pinned <- pinned
      self$unread_mark <- unread_mark
      self$view_forum_as_messages <- view_forum_as_messages
      self$pts <- pts
      self$draft <- draft
      self$folder_id <- folder_id
      self$ttl_period <- ttl_period
    },
    to_list = function() {
      list(
        "_" = "Dialog",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_list() else self$peer,
        top_message = self$top_message,
        read_inbox_max_id = self$read_inbox_max_id,
        read_outbox_max_id = self$read_outbox_max_id,
        unread_count = self$unread_count,
        unread_mentions_count = self$unread_mentions_count,
        unread_reactions_count = self$unread_reactions_count,
        notify_settings = if (inherits(self$notify_settings, "TLObject")) self$notify_settings$to_list() else self$notify_settings,
        pinned = self$pinned,
        unread_mark = self$unread_mark,
        view_forum_as_messages = self$view_forum_as_messages,
        pts = self$pts,
        draft = if (inherits(self$draft, "TLObject")) self$draft$to_list() else self$draft,
        folder_id = self$folder_id,
        ttl_period = self$ttl_period
      )
    }
  )
)

#  @title DialogFilter
#  @description Telegram API type DialogFilter
#  @export
#  @noRd
#  @noRd
DialogFilter <- R6::R6Class(
  "DialogFilter",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xaa472651,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x692bc457,
    #  @field id Field.
    id = NULL,
    #  @field title Field.
    title = NULL,
    #  @field pinned_peers Field.
    pinned_peers = NULL,
    #  @field include_peers Field.
    include_peers = NULL,
    #  @field exclude_peers Field.
    exclude_peers = NULL,
    #  @field contacts Field.
    contacts = NULL,
    #  @field non_contacts Field.
    non_contacts = NULL,
    #  @field groups Field.
    groups = NULL,
    #  @field broadcasts Field.
    broadcasts = NULL,
    #  @field bots Field.
    bots = NULL,
    #  @field exclude_muted Field.
    exclude_muted = NULL,
    #  @field exclude_read Field.
    exclude_read = NULL,
    #  @field exclude_archived Field.
    exclude_archived = NULL,
    #  @field title_noanimate Field.
    title_noanimate = NULL,
    #  @field emoticon Field.
    emoticon = NULL,
    #  @field color Field.
    color = NULL,
    initialize = function(id, title, pinned_peers, include_peers, exclude_peers, contacts = NULL, non_contacts = NULL, groups = NULL, broadcasts = NULL, bots = NULL, exclude_muted = NULL, exclude_read = NULL, exclude_archived = NULL, title_noanimate = NULL, emoticon = NULL, color = NULL) {
      self$id <- id
      self$title <- title
      self$pinned_peers <- pinned_peers
      self$include_peers <- include_peers
      self$exclude_peers <- exclude_peers
      self$contacts <- contacts
      self$non_contacts <- non_contacts
      self$groups <- groups
      self$broadcasts <- broadcasts
      self$bots <- bots
      self$exclude_muted <- exclude_muted
      self$exclude_read <- exclude_read
      self$exclude_archived <- exclude_archived
      self$title_noanimate <- title_noanimate
      self$emoticon <- emoticon
      self$color <- color
    },
    to_list = function() {
      list(
        "_" = "DialogFilter",
        id = self$id,
        title = if (inherits(self$title, "TLObject")) self$title$to_list() else self$title,
        pinned_peers = lapply(self$pinned_peers, function(x) if (inherits(x, "TLObject")) x$to_list() else x),
        include_peers = lapply(self$include_peers, function(x) if (inherits(x, "TLObject")) x$to_list() else x),
        exclude_peers = lapply(self$exclude_peers, function(x) if (inherits(x, "TLObject")) x$to_list() else x),
        contacts = self$contacts,
        non_contacts = self$non_contacts,
        groups = self$groups,
        broadcasts = self$broadcasts,
        bots = self$bots,
        exclude_muted = self$exclude_muted,
        exclude_read = self$exclude_read,
        exclude_archived = self$exclude_archived,
        title_noanimate = self$title_noanimate,
        emoticon = self$emoticon,
        color = self$color
      )
    }
  )
)

#  @title DialogFolder
#  @description Telegram API type DialogFolder
#  @export
#  @noRd
#  @noRd
DialogFolder <- R6::R6Class(
  "DialogFolder",
  inherit = TLObject,
  public = list(
    #  @field folder Field.
    folder = NULL,
    #  @field peer Field.
    peer = NULL,
    #  @field top_message Field.
    top_message = NULL,
    #  @field unread_muted_peers_count Field.
    unread_muted_peers_count = NULL,
    #  @field unread_unmuted_peers_count Field.
    unread_unmuted_peers_count = NULL,
    #  @field unread_muted_messages_count Field.
    unread_muted_messages_count = NULL,
    #  @field unread_unmuted_messages_count Field.
    unread_unmuted_messages_count = NULL,
    #  @field pinned Field.
    pinned = NULL,
    initialize = function(folder, peer, top_message, unread_muted_peers_count, unread_unmuted_peers_count, unread_muted_messages_count, unread_unmuted_messages_count, pinned = NULL) {
      self$folder <- folder
      self$peer <- peer
      self$top_message <- top_message
      self$unread_muted_peers_count <- unread_muted_peers_count
      self$unread_unmuted_peers_count <- unread_unmuted_peers_count
      self$unread_muted_messages_count <- unread_muted_messages_count
      self$unread_unmuted_messages_count <- unread_unmuted_messages_count
      self$pinned <- pinned
    },
    to_list = function() {
      list(
        "_" = "DialogFolder",
        folder = if (inherits(self$folder, "TLObject")) self$folder$to_list() else self$folder,
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_list() else self$peer,
        top_message = self$top_message,
        unread_muted_peers_count = self$unread_muted_peers_count,
        unread_unmuted_peers_count = self$unread_unmuted_peers_count,
        unread_muted_messages_count = self$unread_muted_messages_count,
        unread_unmuted_messages_count = self$unread_unmuted_messages_count,
        pinned = self$pinned
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x4C, 0x13, 0xBD, 0x71)),
        as.raw(ifelse(is.null(self$pinned) || !self$pinned, 0, 4)),
        self$folder$bytes(),
        self$peer$bytes(),
        writeBin(as.integer(self$top_message), raw(), size = 4),
        writeBin(as.integer(self$unread_muted_peers_count), raw(), size = 4),
        writeBin(as.integer(self$unread_unmuted_peers_count), raw(), size = 4),
        writeBin(as.integer(self$unread_muted_messages_count), raw(), size = 4),
        writeBin(as.integer(self$unread_unmuted_messages_count), raw(), size = 4)
      )
    }
  )
)

#  @title DialogFilterChatlist
#  @description Telegram API type DialogFilterChatlist
#  @export
#  @noRd
#  @noRd
DialogFilterChatlist <- R6::R6Class(
  "DialogFilterChatlist",
  inherit = TLObject,
  public = list(
    #  @field id Field.
    id = NULL,
    #  @field title Field.
    title = NULL,
    #  @field pinned_peers Field.
    pinned_peers = NULL,
    #  @field include_peers Field.
    include_peers = NULL,
    #  @field has_my_invites Field.
    has_my_invites = NULL,
    #  @field title_noanimate Field.
    title_noanimate = NULL,
    #  @field emoticon Field.
    emoticon = NULL,
    #  @field color Field.
    color = NULL,
    initialize = function(id, title, pinned_peers, include_peers, has_my_invites = NULL, title_noanimate = NULL, emoticon = NULL, color = NULL) {
      self$id <- id
      self$title <- title
      self$pinned_peers <- pinned_peers
      self$include_peers <- include_peers
      self$has_my_invites <- has_my_invites
      self$title_noanimate <- title_noanimate
      self$emoticon <- emoticon
      self$color <- color
    },
    to_list = function() {
      list(
        "_" = "DialogFilterChatlist",
        id = self$id,
        title = if (inherits(self$title, "TLObject")) self$title$to_list() else self$title,
        pinned_peers = if (is.null(self$pinned_peers)) list() else lapply(self$pinned_peers, function(x) if (inherits(x, "TLObject")) x$to_list() else x),
        include_peers = if (is.null(self$include_peers)) list() else lapply(self$include_peers, function(x) if (inherits(x, "TLObject")) x$to_list() else x),
        has_my_invites = self$has_my_invites,
        title_noanimate = self$title_noanimate,
        emoticon = self$emoticon,
        color = self$color
      )
    }
  )
)

#  @title DialogFilterDefault
#  @description Telegram API type DialogFilterDefault
#  @export
#  @noRd
#  @noRd
DialogFilterDefault <- R6::R6Class(
  "DialogFilterDefault",
  inherit = TLObject,
  public = list(
    to_list = function() {
      list("_" = "DialogFilterDefault")
    }
  )
)

#  @title DialogFilterSuggested
#  @description Telegram API type DialogFilterSuggested
#  @export
#  @noRd
#  @noRd
DialogFilterSuggested <- R6::R6Class(
  "DialogFilterSuggested",
  inherit = TLObject,
  public = list(
    #  @field filter Field.
    filter = NULL,
    #  @field description Field.
    description = NULL,
    initialize = function(filter, description) {
      self$filter <- filter
      self$description <- description
    },
    to_list = function() {
      list(
        "_" = "DialogFilterSuggested",
        filter = if (inherits(self$filter, "TLObject")) self$filter$to_list() else self$filter,
        description = self$description
      )
    }
  )
)

#  @title DialogPeer
#  @description Telegram API type DialogPeer
#  @export
#  @noRd
#  @noRd
DialogPeer <- R6::R6Class(
  "DialogPeer",
  inherit = TLObject,
  public = list(
    #  @field peer Field.
    peer = NULL,
    initialize = function(peer) {
      self$peer <- peer
    },
    to_list = function() {
      list(
        "_" = "DialogPeer",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_list() else self$peer
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x05, 0xBF, 0x6D, 0xE5)),
        self$peer$bytes()
      )
    }
  )
)

#  @title DialogPeerFolder
#  @description Telegram API type DialogPeerFolder
#  @export
#  @noRd
#  @noRd
DialogPeerFolder <- R6::R6Class(
  "DialogPeerFolder",
  inherit = TLObject,
  public = list(
    #  @field folder_id Field.
    folder_id = NULL,
    initialize = function(folder_id) {
      self$folder_id <- folder_id
    },
    to_list = function() {
      list(
        "_" = "DialogPeerFolder",
        folder_id = self$folder_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xE2, 0x19, 0x45, 0x51)),
        writeBin(as.integer(self$folder_id), raw(), size = 4)
      )
    }
  )
)

#  @title DisallowedGiftsSettings
#  @description Telegram API type DisallowedGiftsSettings
#  @export
#  @noRd
#  @noRd
DisallowedGiftsSettings <- R6::R6Class(
  "DisallowedGiftsSettings",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x71f276c4,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x382e9ab,
    #  @field disallow_unlimited_stargifts Field.
    disallow_unlimited_stargifts = NULL,
    #  @field disallow_limited_stargifts Field.
    disallow_limited_stargifts = NULL,
    #  @field disallow_unique_stargifts Field.
    disallow_unique_stargifts = NULL,
    #  @field disallow_premium_gifts Field.
    disallow_premium_gifts = NULL,
    initialize = function(disallow_unlimited_stargifts = NULL, disallow_limited_stargifts = NULL, disallow_unique_stargifts = NULL, disallow_premium_gifts = NULL) {
      self$disallow_unlimited_stargifts <- disallow_unlimited_stargifts
      self$disallow_limited_stargifts <- disallow_limited_stargifts
      self$disallow_unique_stargifts <- disallow_unique_stargifts
      self$disallow_premium_gifts <- disallow_premium_gifts
    },
    to_list = function() {
      list(
        "_" = "DisallowedGiftsSettings",
        disallow_unlimited_stargifts = self$disallow_unlimited_stargifts,
        disallow_limited_stargifts = self$disallow_limited_stargifts,
        disallow_unique_stargifts = self$disallow_unique_stargifts,
        disallow_premium_gifts = self$disallow_premium_gifts
      )
    },
    bytes = function() {
      flags <- (if (is.null(self$disallow_unlimited_stargifts) || !self$disallow_unlimited_stargifts) 0 else 1) |
        (if (is.null(self$disallow_limited_stargifts) || !self$disallow_limited_stargifts) 0 else 2) |
        (if (is.null(self$disallow_unique_stargifts) || !self$disallow_unique_stargifts) 0 else 4) |
        (if (is.null(self$disallow_premium_gifts) || !self$disallow_premium_gifts) 0 else 8)
      c(as.raw(0xc4), as.raw(0x76), as.raw(0xf2), as.raw(0x71), as.raw(flags))
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      disallow_unlimited_stargifts <- as.logical(bitwAnd(flags, 1))
      disallow_limited_stargifts <- as.logical(bitwAnd(flags, 2))
      disallow_unique_stargifts <- as.logical(bitwAnd(flags, 4))
      disallow_premium_gifts <- as.logical(bitwAnd(flags, 8))
      self$new(
        disallow_unlimited_stargifts = disallow_unlimited_stargifts,
        disallow_limited_stargifts = disallow_limited_stargifts,
        disallow_unique_stargifts = disallow_unique_stargifts,
        disallow_premium_gifts = disallow_premium_gifts
      )
    }
  )
)

#  @title Document
#  @description Telegram API type Document
#  @export
#  @noRd
#  @noRd
Document <- R6::R6Class(
  "Document",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8fd4c4d8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x211fe820,
    #  @field id Field.
    id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    #  @field file_reference Field.
    file_reference = NULL,
    #  @field date Field.
    date = NULL,
    #  @field mime_type Field.
    mime_type = NULL,
    #  @field size Field.
    size = NULL,
    #  @field dc_id Field.
    dc_id = NULL,
    #  @field attributes Field.
    attributes = NULL,
    #  @field thumbs Field.
    thumbs = NULL,
    #  @field video_thumbs Field.
    video_thumbs = NULL,
    initialize = function(id, access_hash, file_reference, date, mime_type, size, dc_id, attributes, thumbs = NULL, video_thumbs = NULL) {
      self$id <- id
      self$access_hash <- access_hash
      self$file_reference <- file_reference
      self$date <- date
      self$mime_type <- mime_type
      self$size <- size
      self$dc_id <- dc_id
      self$attributes <- attributes
      self$thumbs <- thumbs
      self$video_thumbs <- video_thumbs
    },
    to_list = function() {
      list(
        "_" = "Document",
        id = self$id,
        access_hash = self$access_hash,
        file_reference = self$file_reference,
        date = self$date,
        mime_type = self$mime_type,
        size = self$size,
        dc_id = self$dc_id,
        attributes = if (is.null(self$attributes)) list() else lapply(self$attributes, function(x) if (inherits(x, "TLObject")) x$to_list() else x),
        thumbs = if (is.null(self$thumbs)) list() else lapply(self$thumbs, function(x) if (inherits(x, "TLObject")) x$to_list() else x),
        video_thumbs = if (is.null(self$video_thumbs)) list() else lapply(self$video_thumbs, function(x) if (inherits(x, "TLObject")) x$to_list() else x)
      )
    },
    to_dict = function() {
      self$to_list()
    },
    bytes = function() {
      c(
        as.raw(c(0xd8, 0xc4, 0xd4, 0x8f)),
        as.raw(bitwOr(if (is.null(self$thumbs)) 0 else 1, if (is.null(self$video_thumbs)) 0 else 2)),
        writeBin(as.integer64(self$id), raw(), size = 8),
        writeBin(as.integer64(self$access_hash), raw(), size = 8),
        self$serialize_bytes(self$file_reference),
        self$serialize_datetime(self$date),
        self$serialize_bytes(self$mime_type),
        writeBin(as.integer64(self$size), raw(), size = 8),
        if (!is.null(self$thumbs)) c(as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), writeBin(length(self$thumbs), raw(), size = 4), unlist(lapply(self$thumbs, function(x) x$bytes()))),
        if (!is.null(self$video_thumbs)) c(as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), writeBin(length(self$video_thumbs), raw(), size = 4), unlist(lapply(self$video_thumbs, function(x) x$bytes()))),
        writeBin(as.integer(self$dc_id), raw(), size = 4),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)),
        writeBin(length(self$attributes), raw(), size = 4),
        unlist(lapply(self$attributes, function(x) x$bytes()))
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      id <- reader$read_long()
      access_hash <- reader$read_long()
      file_reference <- reader$tgread_bytes()
      date <- reader$tgread_date()
      mime_type <- reader$tgread_string()
      size <- reader$read_long()

      thumbs <- if (bitwAnd(flags, 1)) {
        reader$read_int()
        lapply(seq_len(reader$read_int()), function(i) reader$tgread_object())
      } else {
        NULL
      }

      video_thumbs <- if (bitwAnd(flags, 2)) {
        reader$read_int()
        lapply(seq_len(reader$read_int()), function(i) reader$tgread_object())
      } else {
        NULL
      }

      dc_id <- reader$read_int()
      reader$read_int()
      attributes <- lapply(seq_len(reader$read_int()), function(i) reader$tgread_object())

      self$new(id = id, access_hash = access_hash, file_reference = file_reference, date = date, mime_type = mime_type, size = size, dc_id = dc_id, attributes = attributes, thumbs = thumbs, video_thumbs = video_thumbs)
    }
  )
)

#  @title DocumentAttributeAnimated
#  @description Telegram API type DocumentAttributeAnimated
#  @export
#  @noRd
#  @noRd
DocumentAttributeAnimated <- R6::R6Class(
  "DocumentAttributeAnimated",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x11b58939,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf729eb9b,
    to_dict = function() {
      list("_" = "DocumentAttributeAnimated")
    },
    bytes = function() {
      as.raw(c(0x39, 0x89, 0xb5, 0x11))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$new()
    }
  )
)

#  @title DocumentAttributeAudio
#  @description Telegram API type DocumentAttributeAudio
#  @export
#  @noRd
#  @noRd
DocumentAttributeAudio <- R6::R6Class(
  "DocumentAttributeAudio",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9852f9c6,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf729eb9b,
    #  @field duration Field.
    duration = NULL,
    #  @field voice Field.
    voice = NULL,
    #  @field title Field.
    title = NULL,
    #  @field performer Field.
    performer = NULL,
    #  @field waveform Field.
    waveform = NULL,
    initialize = function(duration, voice = NULL, title = NULL, performer = NULL, waveform = NULL) {
      self$duration <- duration
      self$voice <- voice
      self$title <- title
      self$performer <- performer
      self$waveform <- waveform
    },
    to_dict = function() {
      list(
        "_" = "DocumentAttributeAudio",
        duration = self$duration,
        voice = self$voice,
        title = self$title,
        performer = self$performer,
        waveform = self$waveform
      )
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      voice <- bitwAnd(flags, 1024) != 0
      duration <- reader$read_int()
      title <- if (bitwAnd(flags, 1) != 0) reader$tgread_string() else NULL
      performer <- if (bitwAnd(flags, 2) != 0) reader$tgread_string() else NULL
      waveform <- if (bitwAnd(flags, 4) != 0) reader$tgread_bytes() else NULL
      self$new(duration = duration, voice = voice, title = title, performer = performer, waveform = waveform)
    }
  )
)

#  @title DocumentAttributeCustomEmoji
#  @description Telegram API type DocumentAttributeCustomEmoji
#  @export
#  @noRd
#  @noRd
DocumentAttributeCustomEmoji <- R6::R6Class(
  "DocumentAttributeCustomEmoji",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xfd149899,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf729eb9b,
    #  @field alt Field.
    alt = NULL,
    #  @field stickerset Field.
    stickerset = NULL,
    #  @field free Field.
    free = NULL,
    #  @field text_color Field.
    text_color = NULL,
    initialize = function(alt, stickerset, free = NULL, text_color = NULL) {
      self$alt <- alt
      self$stickerset <- stickerset
      self$free <- free
      self$text_color <- text_color
    },
    to_dict = function() {
      list(
        "_" = "DocumentAttributeCustomEmoji",
        alt = self$alt,
        stickerset = if (inherits(self$stickerset, "TLObject")) self$stickerset$to_dict() else self$stickerset,
        free = self$free,
        text_color = self$text_color
      )
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      free <- bitwAnd(flags, 1) != 0
      text_color <- bitwAnd(flags, 2) != 0
      alt <- reader$tgread_string()
      stickerset <- reader$tgread_object()
      self$new(alt = alt, stickerset = stickerset, free = free, text_color = text_color)
    }
  )
)

#  @title DocumentAttributeFilename
#  @description Telegram API type DocumentAttributeFilename
#  @export
#  @noRd
#  @noRd
DocumentAttributeFilename <- R6::R6Class(
  "DocumentAttributeFilename",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x15590068,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf729eb9b,
    #  @field file_name Field.
    file_name = NULL,
    initialize = function(file_name) {
      self$file_name <- file_name
    },
    to_dict = function() {
      list(
        "_" = "DocumentAttributeFilename",
        file_name = self$file_name
      )
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      file_name <- reader$tgread_string()
      self$new(file_name = file_name)
    }
  )
)

#  @title DocumentAttributeHasStickers
#  @description Telegram API type DocumentAttributeHasStickers
#  @export
#  @noRd
#  @noRd
DocumentAttributeHasStickers <- R6::R6Class(
  "DocumentAttributeHasStickers",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9801d2f7,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf729eb9b,
    to_dict = function() {
      list("_" = "DocumentAttributeHasStickers")
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$new()
    }
  )
)

#  @title DocumentAttributeImageSize
#  @description Telegram API type DocumentAttributeImageSize
#  @export
#  @noRd
#  @noRd
DocumentAttributeImageSize <- R6::R6Class(
  "DocumentAttributeImageSize",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x6c37c15c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf729eb9b,
    #  @field w Field.
    w = NULL,
    #  @field h Field.
    h = NULL,
    initialize = function(w, h) {
      self$w <- w
      self$h <- h
    },
    to_dict = function() {
      list(
        "_" = "DocumentAttributeImageSize",
        w = self$w,
        h = self$h
      )
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      w <- reader$read_int()
      h <- reader$read_int()
      self$new(w = w, h = h)
    }
  )
)

#  @title DocumentAttributeSticker
#  @description Telegram API type DocumentAttributeSticker
#  @export
#  @noRd
#  @noRd
DocumentAttributeSticker <- R6::R6Class(
  "DocumentAttributeSticker",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x6319d612,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf729eb9b,
    #  @field alt Field.
    alt = NULL,
    #  @field stickerset Field.
    stickerset = NULL,
    #  @field mask Field.
    mask = NULL,
    #  @field mask_coords Field.
    mask_coords = NULL,
    initialize = function(alt, stickerset, mask = NULL, mask_coords = NULL) {
      self$alt <- alt
      self$stickerset <- stickerset
      self$mask <- mask
      self$mask_coords <- mask_coords
    },
    to_dict = function() {
      list(
        "_" = "DocumentAttributeSticker",
        alt = self$alt,
        stickerset = if (inherits(self$stickerset, "TLObject")) self$stickerset$to_dict() else self$stickerset,
        mask = self$mask,
        mask_coords = if (inherits(self$mask_coords, "TLObject")) self$mask_coords$to_dict() else self$mask_coords
      )
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      mask <- bitwAnd(flags, 2) != 0
      alt <- reader$tgread_string()
      stickerset <- reader$tgread_object()
      mask_coords <- if (bitwAnd(flags, 1) != 0) reader$tgread_object() else NULL
      self$new(alt = alt, stickerset = stickerset, mask = mask, mask_coords = mask_coords)
    }
  )
)

#  @title DocumentAttributeVideo
#  @description Telegram API type DocumentAttributeVideo
#  @export
#  @noRd
#  @noRd
DocumentAttributeVideo <- R6::R6Class(
  "DocumentAttributeVideo",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x43c57c48,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf729eb9b,
    #  @field duration Field.
    duration = NULL,
    #  @field w Field.
    w = NULL,
    #  @field h Field.
    h = NULL,
    #  @field round_message Field.
    round_message = NULL,
    #  @field supports_streaming Field.
    supports_streaming = NULL,
    #  @field nosound Field.
    nosound = NULL,
    #  @field preload_prefix_size Field.
    preload_prefix_size = NULL,
    #  @field video_start_ts Field.
    video_start_ts = NULL,
    #  @field video_codec Field.
    video_codec = NULL,
    initialize = function(duration, w, h, round_message = NULL, supports_streaming = NULL, nosound = NULL, preload_prefix_size = NULL, video_start_ts = NULL, video_codec = NULL) {
      self$duration <- duration
      self$w <- w
      self$h <- h
      self$round_message <- round_message
      self$supports_streaming <- supports_streaming
      self$nosound <- nosound
      self$preload_prefix_size <- preload_prefix_size
      self$video_start_ts <- video_start_ts
      self$video_codec <- video_codec
    },
    to_dict = function() {
      list(
        "_" = "DocumentAttributeVideo",
        duration = self$duration,
        w = self$w,
        h = self$h,
        round_message = self$round_message,
        supports_streaming = self$supports_streaming,
        nosound = self$nosound,
        preload_prefix_size = self$preload_prefix_size,
        video_start_ts = self$video_start_ts,
        video_codec = self$video_codec
      )
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      round_message <- bitwAnd(flags, 1) != 0
      supports_streaming <- bitwAnd(flags, 2) != 0
      nosound <- bitwAnd(flags, 8) != 0
      duration <- reader$read_double()
      w <- reader$read_int()
      h <- reader$read_int()
      preload_prefix_size <- if (bitwAnd(flags, 4) != 0) reader$read_int() else NULL
      video_start_ts <- if (bitwAnd(flags, 16) != 0) reader$read_double() else NULL
      video_codec <- if (bitwAnd(flags, 32) != 0) reader$tgread_string() else NULL
      self$new(
        duration = duration,
        w = w,
        h = h,
        round_message = round_message,
        supports_streaming = supports_streaming,
        nosound = nosound,
        preload_prefix_size = preload_prefix_size,
        video_start_ts = video_start_ts,
        video_codec = video_codec
      )
    }
  )
)

#  @title DocumentEmpty
#  @description Telegram API type DocumentEmpty
#  @export
#  @noRd
#  @noRd
DocumentEmpty <- R6::R6Class(
  "DocumentEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x36f8c871,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x211fe820,
    #  @field id Field.
    id = NULL,
    initialize = function(id) {
      self$id <- id
    },
    to_dict = function() {
      list(
        "_" = "DocumentEmpty",
        id = self$id
      )
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      id <- reader$read_long()
      self$new(id = id)
    }
  )
)

#  @title DraftMessage
#  @description Telegram API type DraftMessage
#  @export
#  @noRd
#  @noRd
DraftMessage <- R6::R6Class(
  "DraftMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x96eaa5eb,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x33d47f45,
    #  @field message Field.
    message = NULL,
    #  @field date Field.
    date = NULL,
    #  @field no_webpage Field.
    no_webpage = NULL,
    #  @field invert_media Field.
    invert_media = NULL,
    #  @field reply_to Field.
    reply_to = NULL,
    #  @field entities Field.
    entities = NULL,
    #  @field media Field.
    media = NULL,
    #  @field effect Field.
    effect = NULL,
    #  @field suggested_post Field.
    suggested_post = NULL,
    initialize = function(message, date = NULL, no_webpage = NULL, invert_media = NULL, reply_to = NULL, entities = NULL, media = NULL, effect = NULL, suggested_post = NULL) {
      self$message <- message
      self$date <- date
      self$no_webpage <- no_webpage
      self$invert_media <- invert_media
      self$reply_to <- reply_to
      self$entities <- entities
      self$media <- media
      self$effect <- effect
      self$suggested_post <- suggested_post
    },
    to_dict = function() {
      list(
        "_" = "DraftMessage",
        message = self$message,
        date = self$date,
        no_webpage = self$no_webpage,
        invert_media = self$invert_media,
        reply_to = if (inherits(self$reply_to, "TLObject")) self$reply_to$to_dict() else self$reply_to,
        entities = if (is.null(self$entities)) list() else lapply(self$entities, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        media = if (inherits(self$media, "TLObject")) self$media$to_dict() else self$media,
        effect = self$effect,
        suggested_post = if (inherits(self$suggested_post, "TLObject")) self$suggested_post$to_dict() else self$suggested_post
      )
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  )
)

#  @title DraftMessageEmpty
#  @description Telegram API type DraftMessageEmpty
#  @export
#  @noRd
#  @noRd
DraftMessageEmpty <- R6::R6Class(
  "DraftMessageEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1b0c841a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x33d47f45,
    #  @field date Field.
    date = NULL,
    initialize = function(date = NULL) {
      self$date <- date
    },
    to_dict = function() {
      list(
        "_" = "DraftMessageEmpty",
        date = self$date
      )
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  )
)

#  @title EmailVerificationApple
#  @description Telegram API type EmailVerificationApple
#  @export
#  @noRd
#  @noRd
EmailVerificationApple <- R6::R6Class(
  "EmailVerificationApple",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x96d074fd,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x241ee240,
    #  @field token Field.
    token = NULL,
    initialize = function(token) {
      self$token <- token
    },
    to_dict = function() {
      list(
        "_" = "EmailVerificationApple",
        token = self$token
      )
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  )
)

#  @title EmailVerificationCode
#  @description Telegram API type EmailVerificationCode
#  @export
#  @noRd
#  @noRd
EmailVerificationCode <- R6::R6Class(
  "EmailVerificationCode",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x922e55a9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x241ee240,
    #  @field code Field.
    code = NULL,
    initialize = function(code) {
      self$code <- code
    },
    to_dict = function() {
      list(
        "_" = "EmailVerificationCode",
        code = self$code
      )
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  )
)

#  @title EmailVerificationGoogle
#  @description Telegram API type EmailVerificationGoogle
#  @export
#  @noRd
#  @noRd
EmailVerificationGoogle <- R6::R6Class(
  "EmailVerificationGoogle",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xdb909ec2,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x241ee240,
    #  @field token Field.
    token = NULL,
    initialize = function(token) {
      self$token <- token
    },
    to_dict = function() {
      list(
        "_" = "EmailVerificationGoogle",
        token = self$token
      )
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  )
)

#  @title EmailVerifyPurposeLoginChange
#  @description Telegram API type EmailVerifyPurposeLoginChange
#  @export
#  @noRd
#  @noRd
EmailVerifyPurposeLoginChange <- R6::R6Class(
  "EmailVerifyPurposeLoginChange",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x527d22eb,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb9686ae8,
    to_dict = function() {
      list("_" = "EmailVerifyPurposeLoginChange")
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  )
)

#  @title EmailVerifyPurposeLoginSetup
#  @description Telegram API type EmailVerifyPurposeLoginSetup
#  @export
#  @noRd
#  @noRd
EmailVerifyPurposeLoginSetup <- R6::R6Class(
  "EmailVerifyPurposeLoginSetup",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4345be73,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb9686ae8,
    #  @field phone_number Field.
    phone_number = NULL,
    #  @field phone_code_hash Field.
    phone_code_hash = NULL,
    initialize = function(phone_number, phone_code_hash) {
      self$phone_number <- phone_number
      self$phone_code_hash <- phone_code_hash
    },
    to_dict = function() {
      list(
        "_" = "EmailVerifyPurposeLoginSetup",
        phone_number = self$phone_number,
        phone_code_hash = self$phone_code_hash
      )
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  )
)

#  @title EmailVerifyPurposePassport
#  @description Telegram API type EmailVerifyPurposePassport
#  @export
#  @noRd
#  @noRd
EmailVerifyPurposePassport <- R6::R6Class(
  "EmailVerifyPurposePassport",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbbf51685,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb9686ae8,
    to_dict = function() {
      list("_" = "EmailVerifyPurposePassport")
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  )
)

#  @title EmojiGroup
#  @description Telegram API type EmojiGroup
#  @export
#  @noRd
#  @noRd
EmojiGroup <- R6::R6Class(
  "EmojiGroup",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7a9abda9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x55e0a193,
    #  @field title Field.
    title = NULL,
    #  @field icon_emoji_id Field.
    icon_emoji_id = NULL,
    #  @field emoticons Field.
    emoticons = NULL,
    initialize = function(title, icon_emoji_id, emoticons) {
      self$title <- title
      self$icon_emoji_id <- icon_emoji_id
      self$emoticons <- emoticons
    },
    to_list = function() {
      list(
        "_" = "EmojiGroup",
        title = self$title,
        icon_emoji_id = self$icon_emoji_id,
        emoticons = if (is.null(self$emoticons)) list() else self$emoticons
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xa9, 0xbd, 0x9a, 0x7a)),
        serialize_bytes(self$title),
        writeBin(as.integer64(self$icon_emoji_id), raw(), size = 8),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)),
        writeBin(length(self$emoticons), raw(), size = 4),
        unlist(lapply(self$emoticons, serialize_bytes))
      )
    }
  )
)

#  @title EmojiGroupGreeting
#  @description Telegram API type EmojiGroupGreeting
#  @export
#  @noRd
#  @noRd
EmojiGroupGreeting <- R6::R6Class(
  "EmojiGroupGreeting",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x80d26cc7,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x55e0a193,
    #  @field title Field.
    title = NULL,
    #  @field icon_emoji_id Field.
    icon_emoji_id = NULL,
    #  @field emoticons Field.
    emoticons = NULL,
    initialize = function(title, icon_emoji_id, emoticons) {
      self$title <- title
      self$icon_emoji_id <- icon_emoji_id
      self$emoticons <- emoticons
    },
    to_list = function() {
      list(
        "_" = "EmojiGroupGreeting",
        title = self$title,
        icon_emoji_id = self$icon_emoji_id,
        emoticons = if (is.null(self$emoticons)) list() else self$emoticons
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xc7, 0x6c, 0xd2, 0x80)),
        serialize_bytes(self$title),
        writeBin(as.integer64(self$icon_emoji_id), raw(), size = 8),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)),
        writeBin(length(self$emoticons), raw(), size = 4),
        unlist(lapply(self$emoticons, serialize_bytes))
      )
    }
  )
)

#  @title EmojiGroupPremium
#  @description Telegram API type EmojiGroupPremium
#  @export
#  @noRd
#  @noRd
EmojiGroupPremium <- R6::R6Class(
  "EmojiGroupPremium",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x93bcf34,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x55e0a193,
    #  @field title Field.
    title = NULL,
    #  @field icon_emoji_id Field.
    icon_emoji_id = NULL,
    initialize = function(title, icon_emoji_id) {
      self$title <- title
      self$icon_emoji_id <- icon_emoji_id
    },
    to_list = function() {
      list(
        "_" = "EmojiGroupPremium",
        title = self$title,
        icon_emoji_id = self$icon_emoji_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x34, 0xcf, 0x3b, 0x09)),
        serialize_bytes(self$title),
        writeBin(as.integer(self$icon_emoji_id), raw(), size = 8, endian = "little")
      )
    }
  )
)

#  @title EmojiKeyword
#  @description Telegram API type EmojiKeyword
#  @export
#  @noRd
#  @noRd
EmojiKeyword <- R6::R6Class(
  "EmojiKeyword",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd5b3b9f9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x6612a53e,
    #  @field keyword Field.
    keyword = NULL,
    #  @field emoticons Field.
    emoticons = NULL,
    initialize = function(keyword, emoticons) {
      self$keyword <- keyword
      self$emoticons <- emoticons
    },
    to_list = function() {
      list(
        "_" = "EmojiKeyword",
        keyword = self$keyword,
        emoticons = if (is.null(self$emoticons)) list() else self$emoticons
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xf9, 0xb9, 0xb3, 0xd5)),
        serialize_bytes(self$keyword),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)),
        writeBin(as.integer(length(self$emoticons)), raw(), size = 4, endian = "little"),
        unlist(lapply(self$emoticons, serialize_bytes))
      )
    }
  )
)

#  @title EmojiKeywordDeleted
#  @description Telegram API type EmojiKeywordDeleted
#  @export
#  @noRd
#  @noRd
EmojiKeywordDeleted <- R6::R6Class(
  "EmojiKeywordDeleted",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x236df622,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x6612a53e,
    #  @field keyword Field.
    keyword = NULL,
    #  @field emoticons Field.
    emoticons = NULL,
    initialize = function(keyword, emoticons) {
      self$keyword <- keyword
      self$emoticons <- emoticons
    },
    to_list = function() {
      list(
        "_" = "EmojiKeywordDeleted",
        keyword = self$keyword,
        emoticons = if (is.null(self$emoticons)) list() else self$emoticons
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x22, 0xf6, 0x6d, 0x23)),
        serialize_bytes(self$keyword),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)),
        writeBin(length(self$emoticons), raw(), size = 4),
        unlist(lapply(self$emoticons, serialize_bytes))
      )
    }
  )
)

#  @title EmojiKeywordsDifference
#  @description Telegram API type EmojiKeywordsDifference
#  @export
#  @noRd
#  @noRd
EmojiKeywordsDifference <- R6::R6Class(
  "EmojiKeywordsDifference",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5cc761bd,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd279c672,
    #  @field lang_code Field.
    lang_code = NULL,
    #  @field from_version Field.
    from_version = NULL,
    #  @field version Field.
    version = NULL,
    #  @field keywords Field.
    keywords = NULL,
    initialize = function(lang_code, from_version, version, keywords) {
      self$lang_code <- lang_code
      self$from_version <- from_version
      self$version <- version
      self$keywords <- keywords
    },
    to_list = function() {
      list(
        "_" = "EmojiKeywordsDifference",
        lang_code = self$lang_code,
        from_version = self$from_version,
        version = self$version,
        keywords = if (is.null(self$keywords)) list() else lapply(self$keywords, function(x) if (inherits(x, "TLObject")) x$to_list() else x)
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xbd, 0x61, 0xc7, 0x5c)),
        serialize_bytes(self$lang_code),
        writeBin(self$from_version, raw(), size = 4),
        writeBin(self$version, raw(), size = 4),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)),
        writeBin(length(self$keywords), raw(), size = 4),
        unlist(lapply(self$keywords, function(x) x$bytes()))
      )
    }
  )
)

#  @title EmojiLanguage
#  @description Telegram API type EmojiLanguage
#  @export
#  @noRd
#  @noRd
EmojiLanguage <- R6::R6Class(
  "EmojiLanguage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb3fb5361,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xa48d04ee,
    #  @field lang_code Field.
    lang_code = NULL,
    initialize = function(lang_code) {
      self$lang_code <- lang_code
    },
    to_list = function() {
      list(
        "_" = "EmojiLanguage",
        lang_code = self$lang_code
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xb3, 0xfb, 0x53, 0x61)),
        serialize_bytes(self$lang_code)
      )
    }
  )
)

#  @title EmojiList
#  @description Telegram API type EmojiList
#  @export
#  @noRd
#  @noRd
EmojiList <- R6::R6Class(
  "EmojiList",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7a1e11d1,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbcef6aba,
    #  @field hash Field.
    hash = NULL,
    #  @field document_id Field.
    document_id = NULL,
    initialize = function(hash, document_id) {
      self$hash <- hash
      self$document_id <- document_id
    },
    to_list = function() {
      list(
        "_" = "EmojiList",
        hash = self$hash,
        document_id = if (is.null(self$document_id)) list() else self$document_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xd1, 0x11, 0x1e, 0x7a)),
        writeBin(as.integer(self$hash), raw(), size = 8, endian = "little"),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)),
        writeBin(as.integer(length(self$document_id)), raw(), size = 4, endian = "little"),
        unlist(lapply(self$document_id, function(x) writeBin(as.integer(x), raw(), size = 8, endian = "little")))
      )
    }
  )
)

#  @title EmojiListNotModified
#  @description Telegram API type EmojiListNotModified
#  @export
#  @noRd
#  @noRd
EmojiListNotModified <- R6::R6Class(
  "EmojiListNotModified",
  inherit = TLObject,
  public = list(
    to_list = function() {
      list("_" = "EmojiListNotModified")
    },
    bytes = function() {
      as.raw(c(0xfa, 0xad, 0x1e, 0x48))
    }
  )
)

#  @title EmojiStatus
#  @description Telegram API type EmojiStatus
#  @export
#  @noRd
#  @noRd
EmojiStatus <- R6::R6Class(
  "EmojiStatus",
  inherit = TLObject,
  public = list(
    #  @field document_id Field.
    document_id = NULL,
    #  @field until Field.
    until = NULL,
    initialize = function(document_id, until = NULL) {
      self$document_id <- document_id
      self$until <- until
    },
    to_list = function() {
      list(
        "_" = "EmojiStatus",
        document_id = self$document_id,
        until = self$until
      )
    },
    bytes = function() {
      flags <- if (is.null(self$until)) 0 else 1
      c(
        as.raw(c(0x8a, 0x06, 0xff, 0xe7)),
        as.raw(flags),
        writeBin(as.integer(self$document_id), raw(), size = 8, endian = "little"),
        if (!is.null(self$until)) serialize_datetime(self$until) else raw()
      )
    }
  )
)

#  @title EmojiStatusCollectible
#  @description Telegram API type EmojiStatusCollectible
#  @export
#  @noRd
#  @noRd
EmojiStatusCollectible <- R6::R6Class(
  "EmojiStatusCollectible",
  inherit = TLObject,
  public = list(
    #  @field collectible_id Field.
    collectible_id = NULL,
    #  @field document_id Field.
    document_id = NULL,
    #  @field title Field.
    title = NULL,
    #  @field slug Field.
    slug = NULL,
    #  @field pattern_document_id Field.
    pattern_document_id = NULL,
    #  @field center_color Field.
    center_color = NULL,
    #  @field edge_color Field.
    edge_color = NULL,
    #  @field pattern_color Field.
    pattern_color = NULL,
    #  @field text_color Field.
    text_color = NULL,
    #  @field until Field.
    until = NULL,
    initialize = function(collectible_id, document_id, title, slug, pattern_document_id, center_color, edge_color, pattern_color, text_color, until = NULL) {
      self$collectible_id <- collectible_id
      self$document_id <- document_id
      self$title <- title
      self$slug <- slug
      self$pattern_document_id <- pattern_document_id
      self$center_color <- center_color
      self$edge_color <- edge_color
      self$pattern_color <- pattern_color
      self$text_color <- text_color
      self$until <- until
    },
    to_list = function() {
      list(
        "_" = "EmojiStatusCollectible",
        collectible_id = self$collectible_id,
        document_id = self$document_id,
        title = self$title,
        slug = self$slug,
        pattern_document_id = self$pattern_document_id,
        center_color = self$center_color,
        edge_color = self$edge_color,
        pattern_color = self$pattern_color,
        text_color = self$text_color,
        until = self$until
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x3B, 0x60, 0x84, 0x71)),
        as.raw(if (is.null(self$until) || self$until == FALSE) 0 else 1),
        writeBin(as.integer64(self$collectible_id), raw(), size = 8),
        writeBin(as.integer64(self$document_id), raw(), size = 8),
        serialize(self$title, NULL),
        serialize(self$slug, NULL),
        writeBin(as.integer64(self$pattern_document_id), raw(), size = 8),
        writeBin(as.integer(self$center_color), raw(), size = 4),
        writeBin(as.integer(self$edge_color), raw(), size = 4),
        writeBin(as.integer(self$pattern_color), raw(), size = 4),
        writeBin(as.integer(self$text_color), raw(), size = 4),
        if (!is.null(self$until) && self$until != FALSE) serialize(self$until, NULL) else raw()
      )
    }
  )
)

#  @title EmojiStatusEmpty
#  @description Telegram API type EmojiStatusEmpty
#  @export
#  @noRd
#  @noRd
EmojiStatusEmpty <- R6::R6Class(
  "EmojiStatusEmpty",
  inherit = TLObject,
  public = list(
    to_list = function() {
      list("_" = "EmojiStatusEmpty")
    },
    bytes = function() {
      as.raw(c(0xae, 0x1a, 0xe1, 0x2d))
    }
  )
)

#  @title EmojiURL
#  @description Telegram API type EmojiURL
#  @export
#  @noRd
#  @noRd
EmojiURL <- R6::R6Class(
  "EmojiURL",
  inherit = TLObject,
  public = list(
    #  @field url Field.
    url = NULL,
    initialize = function(url) {
      self$url <- url
    },
    to_list = function() {
      list("_" = "EmojiURL", url = self$url)
    },
    bytes = function() {
      c(as.raw(c(0x9d, 0x73, 0x75, 0xa5)), charToRaw(self$url))
    }
  )
)


#  @title EncryptedChat
#  @description Telegram API type EncryptedChat
#  @export
#  @noRd
#  @noRd
EncryptedChat <- R6::R6Class(
  "EncryptedChat",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x61f0d4c7,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x6d28a37a,
    #  @field id Field.
    id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    #  @field date Field.
    date = NULL,
    #  @field admin_id Field.
    admin_id = NULL,
    #  @field participant_id Field.
    participant_id = NULL,
    #  @field g_a_or_b Field.
    g_a_or_b = NULL,
    #  @field key_fingerprint Field.
    key_fingerprint = NULL,
    initialize = function(id, access_hash, date, admin_id, participant_id, g_a_or_b, key_fingerprint) {
      self$id <- id
      self$access_hash <- access_hash
      self$date <- date
      self$admin_id <- admin_id
      self$participant_id <- participant_id
      self$g_a_or_b <- g_a_or_b
      self$key_fingerprint <- key_fingerprint
    },
    to_list = function() {
      list(
        "_" = "EncryptedChat",
        id = self$id,
        access_hash = self$access_hash,
        date = self$date,
        admin_id = self$admin_id,
        participant_id = self$participant_id,
        g_a_or_b = self$g_a_or_b,
        key_fingerprint = self$key_fingerprint
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xc7, 0xd4, 0xf0, 0x61)),
        writeBin(as.integer(self$id), raw(), size = 4, endian = "little"),
        writeBin(as.numeric(self$access_hash), raw(), size = 8, endian = "little"),
        self$serialize_datetime(self$date),
        writeBin(as.numeric(self$admin_id), raw(), size = 8, endian = "little"),
        writeBin(as.numeric(self$participant_id), raw(), size = 8, endian = "little"),
        self$serialize_bytes(self$g_a_or_b),
        writeBin(as.numeric(self$key_fingerprint), raw(), size = 8, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      id <- reader$read_int()
      access_hash <- reader$read_long()
      date <- reader$tgread_date()
      admin_id <- reader$read_long()
      participant_id <- reader$read_long()
      g_a_or_b <- reader$tgread_bytes()
      key_fingerprint <- reader$read_long()
      EncryptedChat$new(
        id = id,
        access_hash = access_hash,
        date = date,
        admin_id = admin_id,
        participant_id = participant_id,
        g_a_or_b = g_a_or_b,
        key_fingerprint = key_fingerprint
      )
    }
  )
)

#  @title EncryptedChatDiscarded
#  @description Telegram API type EncryptedChatDiscarded
#  @export
#  @noRd
#  @noRd
EncryptedChatDiscarded <- R6::R6Class(
  "EncryptedChatDiscarded",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1e1c7c45,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x6d28a37a,
    #  @field id Field.
    id = NULL,
    #  @field history_deleted Field.
    history_deleted = NULL,
    initialize = function(id, history_deleted = NULL) {
      self$id <- id
      self$history_deleted <- history_deleted
    },
    to_list = function() {
      list(
        "_" = "EncryptedChatDiscarded",
        id = self$id,
        history_deleted = self$history_deleted
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x45, 0x7c, 0x1c, 0x1e)),
        as.raw(ifelse(is.null(self$history_deleted) || !self$history_deleted, 0, 1)),
        writeBin(as.integer(self$id), raw(), size = 4, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      history_deleted <- as.logical(bitwAnd(flags, 1))
      id <- reader$read_int()
      self$new(id = id, history_deleted = history_deleted)
    }
  )
)

#  @title EncryptedChatEmpty
#  @description Telegram API type EncryptedChatEmpty
#  @export
#  @noRd
#  @noRd
EncryptedChatEmpty <- R6::R6Class(
  "EncryptedChatEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xab7ec0a0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x6d28a37a,
    #  @field id Field.
    id = NULL,
    initialize = function(id) {
      self$id <- id
    },
    to_list = function() {
      list(
        "_" = "EncryptedChatEmpty",
        id = self$id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xa0, 0xc0, 0x7e, 0xab)),
        writeBin(as.integer(self$id), raw(), size = 4, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      id <- reader$read_int()
      self$new(id = id)
    }
  )
)

#  @title EncryptedChatRequested
#  @description Telegram API type EncryptedChatRequested
#  @export
#  @noRd
#  @noRd
EncryptedChatRequested <- R6::R6Class(
  "EncryptedChatRequested",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x48f1d94c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x6d28a37a,
    #  @field id Field.
    id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    #  @field date Field.
    date = NULL,
    #  @field admin_id Field.
    admin_id = NULL,
    #  @field participant_id Field.
    participant_id = NULL,
    #  @field g_a Field.
    g_a = NULL,
    #  @field folder_id Field.
    folder_id = NULL,
    initialize = function(id, access_hash, date, admin_id, participant_id, g_a, folder_id = NULL) {
      self$id <- id
      self$access_hash <- access_hash
      self$date <- date
      self$admin_id <- admin_id
      self$participant_id <- participant_id
      self$g_a <- g_a
      self$folder_id <- folder_id
    },
    to_list = function() {
      list(
        "_" = "EncryptedChatRequested",
        id = self$id,
        access_hash = self$access_hash,
        date = self$date,
        admin_id = self$admin_id,
        participant_id = self$participant_id,
        g_a = self$g_a,
        folder_id = self$folder_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x48, 0xf1, 0xd9, 0x4c)),
        if (is.null(self$folder_id)) as.raw(0) else as.raw(1),
        if (!is.null(self$folder_id)) writeBin(as.integer(self$folder_id), raw(), size = 4),
        writeBin(as.integer(self$id), raw(), size = 4),
        writeBin(as.integer64(self$access_hash), raw(), size = 8),
        self$serialize_datetime(self$date),
        writeBin(as.integer64(self$admin_id), raw(), size = 8),
        writeBin(as.integer64(self$participant_id), raw(), size = 8),
        self$serialize_bytes(self$g_a)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      folder_id <- if (bitwAnd(flags, 1) != 0) reader$read_int() else NULL
      id <- reader$read_int()
      access_hash <- reader$read_long()
      date <- reader$tgread_date()
      admin_id <- reader$read_long()
      participant_id <- reader$read_long()
      g_a <- reader$tgread_bytes()

      self$new(
        id = id,
        access_hash = access_hash,
        date = date,
        admin_id = admin_id,
        participant_id = participant_id,
        g_a = g_a,
        folder_id = folder_id
      )
    }
  )
)

#  @title EncryptedChatWaiting
#  @description Telegram API type EncryptedChatWaiting
#  @export
#  @noRd
#  @noRd
EncryptedChatWaiting <- R6::R6Class(
  "EncryptedChatWaiting",
  inherit = TLObject,
  public = list(
    #  @field id Field.
    id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    #  @field date Field.
    date = NULL,
    #  @field admin_id Field.
    admin_id = NULL,
    #  @field participant_id Field.
    participant_id = NULL,
    initialize = function(id, access_hash, date, admin_id, participant_id) {
      self$id <- id
      self$access_hash <- access_hash
      self$date <- date
      self$admin_id <- admin_id
      self$participant_id <- participant_id
    },
    to_list = function() {
      list(
        "_" = "EncryptedChatWaiting",
        id = self$id,
        access_hash = self$access_hash,
        date = self$date,
        admin_id = self$admin_id,
        participant_id = self$participant_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x53, 0xB2, 0x66)),
        writeBin(as.integer(self$id), raw(), size = 4, endian = "little"),
        writeBin(as.numeric(self$access_hash), raw(), size = 8, endian = "little"),
        serialize_datetime(self$date),
        writeBin(as.numeric(self$admin_id), raw(), size = 8, endian = "little"),
        writeBin(as.numeric(self$participant_id), raw(), size = 8, endian = "little")
      )
    }
  )
)

#  @title EncryptedFile
#  @description Telegram API type EncryptedFile
#  @export
#  @noRd
#  @noRd
EncryptedFile <- R6::R6Class(
  "EncryptedFile",
  inherit = TLObject,
  public = list(
    #  @field id Field.
    id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    #  @field size Field.
    size = NULL,
    #  @field dc_id Field.
    dc_id = NULL,
    #  @field key_fingerprint Field.
    key_fingerprint = NULL,
    initialize = function(id, access_hash, size, dc_id, key_fingerprint) {
      self$id <- id
      self$access_hash <- access_hash
      self$size <- size
      self$dc_id <- dc_id
      self$key_fingerprint <- key_fingerprint
    },
    to_list = function() {
      list(
        "_" = "EncryptedFile",
        id = self$id,
        access_hash = self$access_hash,
        size = self$size,
        dc_id = self$dc_id,
        key_fingerprint = self$key_fingerprint
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xD8, 0x8C, 0x00, 0xA8)),
        writeBin(as.numeric(self$id), raw(), size = 8, endian = "little"),
        writeBin(as.numeric(self$access_hash), raw(), size = 8, endian = "little"),
        writeBin(as.numeric(self$size), raw(), size = 8, endian = "little"),
        writeBin(as.integer(self$dc_id), raw(), size = 4, endian = "little"),
        writeBin(as.integer(self$key_fingerprint), raw(), size = 4, endian = "little")
      )
    }
  )
)


#  @title EncryptedFileEmpty
#  @description Telegram API type EncryptedFileEmpty
#  @export
#  @noRd
#  @noRd
EncryptedFileEmpty <- R6::R6Class("EncryptedFileEmpty",
  public = list(
    to_list = function() {
      list(`_` = "EncryptedFileEmpty")
    }
  )
)

#  @title EncryptedMessage
#  @description Telegram API type EncryptedMessage
#  @export
#  @noRd
#  @noRd
EncryptedMessage <- R6::R6Class("EncryptedMessage",
  public = list(
    #  @field chat_id Field.
    chat_id = NULL,
    #  @field date Field.
    date = NULL,
    #  @field bytes Field.
    bytes = NULL,
    #  @field file Field.
    file = NULL,
    #  @field random_id Field.
    random_id = NULL,
    initialize = function(chat_id, date = NULL, bytes, file, random_id = NULL) {
      self$chat_id <- chat_id
      self$date <- date
      self$bytes <- bytes
      self$file <- file
      self$random_id <- if (is.null(random_id)) as.integer(runif(1, 0, .Machine$integer.max)) else random_id
    },
    to_list = function() {
      list(
        `_` = "EncryptedMessage",
        chat_id = self$chat_id,
        date = self$date,
        bytes = self$bytes,
        file = if (inherits(self$file, "R6")) self$file$to_list() else self$file,
        random_id = self$random_id
      )
    }
  )
)

#  @title EncryptedMessageService
#  @description Telegram API type EncryptedMessageService
#  @export
#  @noRd
#  @noRd
EncryptedMessageService <- R6::R6Class("EncryptedMessageService",
  public = list(
    #  @field chat_id Field.
    chat_id = NULL,
    #  @field date Field.
    date = NULL,
    #  @field bytes Field.
    bytes = NULL,
    #  @field random_id Field.
    random_id = NULL,
    initialize = function(chat_id, date = NULL, bytes, random_id = NULL) {
      self$chat_id <- chat_id
      self$date <- date
      self$bytes <- bytes
      self$random_id <- if (is.null(random_id)) as.integer(runif(1, 0, .Machine$integer.max)) else random_id
    },
    to_list = function() {
      list(
        `_` = "EncryptedMessageService",
        chat_id = self$chat_id,
        date = self$date,
        bytes = self$bytes,
        random_id = self$random_id
      )
    }
  )
)

#  @title ExportedChatlistInvite
#  @description Telegram API type ExportedChatlistInvite
#  @export
#  @noRd
#  @noRd
ExportedChatlistInvite <- R6::R6Class("ExportedChatlistInvite",
  public = list(
    #  @field title Field.
    title = NULL,
    #  @field url Field.
    url = NULL,
    #  @field peers Field.
    peers = NULL,
    initialize = function(title, url, peers) {
      self$title <- title
      self$url <- url
      self$peers <- peers
    },
    to_list = function() {
      list(
        `_` = "ExportedChatlistInvite",
        title = self$title,
        url = self$url,
        peers = if (is.null(self$peers)) list() else lapply(self$peers, function(x) if (inherits(x, "R6")) x$to_list() else x)
      )
    }
  )
)

#  @title ExportedContactToken
#  @description Telegram API type ExportedContactToken
#  @export
#  @noRd
#  @noRd
ExportedContactToken <- R6::R6Class("ExportedContactToken",
  public = list(
    #  @field url Field.
    url = NULL,
    #  @field expires Field.
    expires = NULL,
    initialize = function(url, expires = NULL) {
      self$url <- url
      self$expires <- expires
    },
    to_list = function() {
      list(
        `_` = "ExportedContactToken",
        url = self$url,
        expires = self$expires
      )
    }
  )
)

#  @title ExportedMessageLink
#  @description Telegram API type ExportedMessageLink
#  @export
#  @noRd
#  @noRd
ExportedMessageLink <- R6::R6Class("ExportedMessageLink",
  public = list(
    #  @field link Field.
    link = NULL,
    #  @field html Field.
    html = NULL,
    initialize = function(link, html) {
      self$link <- link
      self$html <- html
    },
    to_list = function() {
      list(
        `_` = "ExportedMessageLink",
        link = self$link,
        html = self$html
      )
    }
  )
)

#  @title ExportedStoryLink
#  @description Telegram API type ExportedStoryLink
#  @export
#  @noRd
#  @noRd
ExportedStoryLink <- R6::R6Class("ExportedStoryLink",
  public = list(
    #  @field link Field.
    link = NULL,
    initialize = function(link) {
      self$link <- link
    },
    to_list = function() {
      list(
        `_` = "ExportedStoryLink",
        link = self$link
      )
    }
  )
)

#  @title FactCheck
#  @description Telegram API type FactCheck
#  @export
#  @noRd
#  @noRd
FactCheck <- R6::R6Class("FactCheck",
  public = list(
    #  @field hash Field.
    hash = NULL,
    #  @field need_check Field.
    need_check = NULL,
    #  @field country Field.
    country = NULL,
    #  @field text Field.
    text = NULL,
    initialize = function(hash, need_check = NULL, country = NULL, text = NULL) {
      self$hash <- hash
      self$need_check <- need_check
      self$country <- country
      self$text <- text
    },
    to_list = function() {
      list(
        `_` = "FactCheck",
        hash = self$hash,
        need_check = self$need_check,
        country = self$country,
        text = if (inherits(self$text, "R6")) self$text$to_list() else self$text
      )
    }
  )
)

#  @title FileHash
#  @description Telegram API type FileHash
#  @export
#  @noRd
#  @noRd
FileHash <- R6::R6Class("FileHash",
  public = list(
    #  @field offset Field.
    offset = NULL,
    #  @field limit Field.
    limit = NULL,
    #  @field hash Field.
    hash = NULL,
    initialize = function(offset, limit, hash) {
      self$offset <- offset
      self$limit <- limit
      self$hash <- hash
    },
    to_list = function() {
      list(
        `_` = "FileHash",
        offset = self$offset,
        limit = self$limit,
        hash = self$hash
      )
    }
  )
)

#  @title Folder
#  @description Telegram API type Folder
#  @export
#  @noRd
#  @noRd
Folder <- R6::R6Class("Folder",
  public = list(
    #  @field id Field.
    id = NULL,
    #  @field title Field.
    title = NULL,
    #  @field autofill_new_broadcasts Field.
    autofill_new_broadcasts = NULL,
    #  @field autofill_public_groups Field.
    autofill_public_groups = NULL,
    #  @field autofill_new_correspondents Field.
    autofill_new_correspondents = NULL,
    #  @field photo Field.
    photo = NULL,
    initialize = function(id, title, autofill_new_broadcasts = NULL, autofill_public_groups = NULL, autofill_new_correspondents = NULL, photo = NULL) {
      self$id <- id
      self$title <- title
      self$autofill_new_broadcasts <- autofill_new_broadcasts
      self$autofill_public_groups <- autofill_public_groups
      self$autofill_new_correspondents <- autofill_new_correspondents
      self$photo <- photo
    },
    to_list = function() {
      list(
        `_` = "Folder",
        id = self$id,
        title = self$title,
        autofill_new_broadcasts = self$autofill_new_broadcasts,
        autofill_public_groups = self$autofill_public_groups,
        autofill_new_correspondents = self$autofill_new_correspondents,
        photo = if (inherits(self$photo, "R6")) self$photo$to_list() else self$photo
      )
    }
  )
)

#  @title FolderPeer
#  @description Telegram API type FolderPeer
#  @export
#  @noRd
#  @noRd
FolderPeer <- R6::R6Class("FolderPeer",
  public = list(
    #  @field peer Field.
    peer = NULL,
    #  @field folder_id Field.
    folder_id = NULL,
    initialize = function(peer, folder_id) {
      self$peer <- peer
      self$folder_id <- folder_id
    },
    to_list = function() {
      list(
        `_` = "FolderPeer",
        peer = if (inherits(self$peer, "R6")) self$peer$to_list() else self$peer,
        folder_id = self$folder_id
      )
    }
  )
)

#  @title ForumTopic
#  @description Telegram API type ForumTopic
#  @export
#  @noRd
#  @noRd
ForumTopic <- R6::R6Class("ForumTopic",
  public = list(
    #  @field id Field.
    id = NULL,
    #  @field date Field.
    date = NULL,
    #  @field title Field.
    title = NULL,
    #  @field icon_color Field.
    icon_color = NULL,
    #  @field top_message Field.
    top_message = NULL,
    #  @field read_inbox_max_id Field.
    read_inbox_max_id = NULL,
    #  @field read_outbox_max_id Field.
    read_outbox_max_id = NULL,
    #  @field unread_count Field.
    unread_count = NULL,
    #  @field unread_mentions_count Field.
    unread_mentions_count = NULL,
    #  @field unread_reactions_count Field.
    unread_reactions_count = NULL,
    #  @field from_id Field.
    from_id = NULL,
    #  @field notify_settings Field.
    notify_settings = NULL,
    #  @field my Field.
    my = NULL,
    #  @field closed Field.
    closed = NULL,
    #  @field pinned Field.
    pinned = NULL,
    #  @field short Field.
    short = NULL,
    #  @field hidden Field.
    hidden = NULL,
    #  @field icon_emoji_id Field.
    icon_emoji_id = NULL,
    #  @field draft Field.
    draft = NULL,
    initialize = function(id, date = NULL, title, icon_color, top_message, read_inbox_max_id, read_outbox_max_id, unread_count, unread_mentions_count, unread_reactions_count, from_id, notify_settings, my = NULL, closed = NULL, pinned = NULL, short = NULL, hidden = NULL, icon_emoji_id = NULL, draft = NULL) {
      self$id <- id
      self$date <- date
      self$title <- title
      self$icon_color <- icon_color
      self$top_message <- top_message
      self$read_inbox_max_id <- read_inbox_max_id
      self$read_outbox_max_id <- read_outbox_max_id
      self$unread_count <- unread_count
      self$unread_mentions_count <- unread_mentions_count
      self$unread_reactions_count <- unread_reactions_count
      self$from_id <- from_id
      self$notify_settings <- notify_settings
      self$my <- my
      self$closed <- closed
      self$pinned <- pinned
      self$short <- short
      self$hidden <- hidden
      self$icon_emoji_id <- icon_emoji_id
      self$draft <- draft
    },
    to_list = function() {
      list(
        `_` = "ForumTopic",
        id = self$id,
        date = self$date,
        title = self$title,
        icon_color = self$icon_color,
        top_message = self$top_message,
        read_inbox_max_id = self$read_inbox_max_id,
        read_outbox_max_id = self$read_outbox_max_id,
        unread_count = self$unread_count,
        unread_mentions_count = self$unread_mentions_count,
        unread_reactions_count = self$unread_reactions_count,
        from_id = if (inherits(self$from_id, "R6")) self$from_id$to_list() else self$from_id,
        notify_settings = if (inherits(self$notify_settings, "R6")) self$notify_settings$to_list() else self$notify_settings,
        my = self$my,
        closed = self$closed,
        pinned = self$pinned,
        short = self$short,
        hidden = self$hidden,
        icon_emoji_id = self$icon_emoji_id,
        draft = if (inherits(self$draft, "R6")) self$draft$to_list() else self$draft
      )
    }
  )
)

#  @title ForumTopicDeleted
#  @description Telegram API type ForumTopicDeleted
#  @export
#  @noRd
#  @noRd
ForumTopicDeleted <- R6::R6Class("ForumTopicDeleted",
  public = list(
    #  @field id Field.
    id = NULL,
    initialize = function(id) {
      self$id <- id
    },
    to_list = function() {
      list(
        `_` = "ForumTopicDeleted",
        id = self$id
      )
    }
  )
)

#  @title FoundStory
#  @description Telegram API type FoundStory
#  @export
#  @noRd
#  @noRd
FoundStory <- R6::R6Class("FoundStory",
  public = list(
    #  @field peer Field.
    peer = NULL,
    #  @field story Field.
    story = NULL,
    initialize = function(peer, story) {
      self$peer <- peer
      self$story <- story
    },
    to_list = function() {
      list(
        `_` = "FoundStory",
        peer = if (inherits(self$peer, "R6")) self$peer$to_list() else self$peer,
        story = if (inherits(self$story, "R6")) self$story$to_list() else self$story
      )
    }
  )
)

#  @title FutureSalt
#  @description Telegram API type FutureSalt
#  @export
#  @noRd
#  @noRd
FutureSalt <- R6::R6Class("FutureSalt",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x0949d9dc,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x0949d9dc,

    #  @field valid_since Field.
    valid_since = NULL,
    #  @field valid_until Field.
    valid_until = NULL,
    #  @field salt Field.
    salt = NULL,
    initialize = function(valid_since = NULL, valid_until = NULL, salt = NULL) {
      self$valid_since <- valid_since
      self$valid_until <- valid_until
      self$salt <- salt
    },
    to_list = function() {
      list(
        `_` = "FutureSalt",
        valid_since = self$valid_since,
        valid_until = self$valid_until,
        salt = self$salt
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      valid_since <- reader$read_int()
      valid_until <- reader$read_int()
      salt <- reader$read_long()
      FutureSalt$new(valid_since = valid_since, valid_until = valid_until, salt = salt)
    }
  )
)

#  @title FutureSalts
#  @description Telegram API type FutureSalts
#  @export
#  @noRd
#  @noRd
FutureSalts <- R6::R6Class("FutureSalts",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xae500895,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xae500895,

    #  @field req_msg_id Field.
    req_msg_id = NULL,
    #  @field now Field.
    now = NULL,
    #  @field salts Field.
    salts = NULL,
    initialize = function(req_msg_id = NULL, now = NULL, salts = NULL) {
      self$req_msg_id <- req_msg_id
      self$now <- now
      self$salts <- salts
    },
    to_list = function() {
      list(
        `_` = "FutureSalts",
        req_msg_id = self$req_msg_id,
        now = self$now,
        salts = if (is.null(self$salts)) list() else lapply(self$salts, function(x) if (inherits(x, "R6")) x$to_list() else x)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      req_msg_id <- reader$read_long()
      now <- reader$read_int()
      count <- reader$read_int()
      salts <- list()
      for (i in seq_len(count)) {
        valid_since <- reader$read_int()
        valid_until <- reader$read_int()
        salt <- reader$read_long()
        salts[[i]] <- FutureSalt$new(valid_since = valid_since, valid_until = valid_until, salt = salt)
      }
      FutureSalts$new(req_msg_id = req_msg_id, now = now, salts = salts)
    }
  )
)

#  @title Game
#  @description Telegram API type Game
#  @export
#  @noRd
#  @noRd
Game <- R6::R6Class("Game",
  public = list(
    #  @field id Field.
    id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    #  @field short_name Field.
    short_name = NULL,
    #  @field title Field.
    title = NULL,
    #  @field description Field.
    description = NULL,
    #  @field photo Field.
    photo = NULL,
    #  @field document Field.
    document = NULL,
    initialize = function(id, access_hash, short_name, title, description, photo, document = NULL) {
      self$id <- id
      self$access_hash <- access_hash
      self$short_name <- short_name
      self$title <- title
      self$description <- description
      self$photo <- photo
      self$document <- document
    },
    to_list = function() {
      list(
        `_` = "Game",
        id = self$id,
        access_hash = self$access_hash,
        short_name = self$short_name,
        title = self$title,
        description = self$description,
        photo = if (inherits(self$photo, "R6")) self$photo$to_list() else self$photo,
        document = if (inherits(self$document, "R6")) self$document$to_list() else self$document
      )
    }
  )
)

#  @title GeoPoint
#  @description Telegram API type GeoPoint
#  @export
#  @noRd
#  @noRd
GeoPoint <- R6::R6Class("GeoPoint",
  public = list(
    #  @field long Field.
    long = NULL,
    #  @field lat Field.
    lat = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    #  @field accuracy_radius Field.
    accuracy_radius = NULL,
    initialize = function(long, lat, access_hash, accuracy_radius = NULL) {
      self$long <- long
      self$lat <- lat
      self$access_hash <- access_hash
      self$accuracy_radius <- accuracy_radius
    },
    to_list = function() {
      list(
        `_` = "GeoPoint",
        long = self$long,
        lat = self$lat,
        access_hash = self$access_hash,
        accuracy_radius = self$accuracy_radius
      )
    }
  )
)

#  @title GeoPointAddress
#  @description Telegram API type GeoPointAddress
#  @export
#  @noRd
#  @noRd
GeoPointAddress <- R6::R6Class("GeoPointAddress",
  public = list(
    #  @field country_iso2 Field.
    country_iso2 = NULL,
    #  @field state Field.
    state = NULL,
    #  @field city Field.
    city = NULL,
    #  @field street Field.
    street = NULL,
    initialize = function(country_iso2, state = NULL, city = NULL, street = NULL) {
      self$country_iso2 <- country_iso2
      self$state <- state
      self$city <- city
      self$street <- street
    },
    to_list = function() {
      list(
        `_` = "GeoPointAddress",
        country_iso2 = self$country_iso2,
        state = self$state,
        city = self$city,
        street = self$street
      )
    }
  )
)

#  @title GeoPointEmpty
#  @description Telegram API type GeoPointEmpty
#  @export
#  @noRd
#  @noRd
GeoPointEmpty <- R6::R6Class("GeoPointEmpty",
  public = list(
    to_list = function() {
      list(`_` = "GeoPointEmpty")
    }
  )
)

#  @title GlobalPrivacySettings
#  @description Telegram API type GlobalPrivacySettings
#  @export
#  @noRd
#  @noRd
GlobalPrivacySettings <- R6::R6Class("GlobalPrivacySettings",
  public = list(
    #  @field archive_and_mute_new_noncontactpeers Field.
    archive_and_mute_new_noncontactpeers = NULL,
    #  @field keep_archived_unmuted Field.
    keep_archived_unmuted = NULL,
    #  @field keep_archived_folders Field.
    keep_archived_folders = NULL,
    #  @field hide_read_marks Field.
    hide_read_marks = NULL,
    #  @field new_noncontactpeers_require_premium Field.
    new_noncontactpeers_require_premium = NULL,
    #  @field display_gifts_button Field.
    display_gifts_button = NULL,
    #  @field noncontactpeers_paid_stars Field.
    noncontactpeers_paid_stars = NULL,
    #  @field disallowed_gifts Field.
    disallowed_gifts = NULL,
    initialize = function(archive_and_mute_new_noncontactpeers = NULL, keep_archived_unmuted = NULL, keep_archived_folders = NULL, hide_read_marks = NULL, new_noncontactpeers_require_premium = NULL, display_gifts_button = NULL, noncontactpeers_paid_stars = NULL, disallowed_gifts = NULL) {
      self$archive_and_mute_new_noncontactpeers <- archive_and_mute_new_noncontactpeers
      self$keep_archived_unmuted <- keep_archived_unmuted
      self$keep_archived_folders <- keep_archived_folders
      self$hide_read_marks <- hide_read_marks
      self$new_noncontactpeers_require_premium <- new_noncontactpeers_require_premium
      self$display_gifts_button <- display_gifts_button
      self$noncontactpeers_paid_stars <- noncontactpeers_paid_stars
      self$disallowed_gifts <- disallowed_gifts
    },
    to_list = function() {
      list(
        `_` = "GlobalPrivacySettings",
        archive_and_mute_new_noncontactpeers = self$archive_and_mute_new_noncontactpeers,
        keep_archived_unmuted = self$keep_archived_unmuted,
        keep_archived_folders = self$keep_archived_folders,
        hide_read_marks = self$hide_read_marks,
        new_noncontactpeers_require_premium = self$new_noncontactpeers_require_premium,
        display_gifts_button = self$display_gifts_button,
        noncontactpeers_paid_stars = self$noncontactpeers_paid_stars,
        disallowed_gifts = if (inherits(self$disallowed_gifts, "R6")) self$disallowed_gifts$to_list() else self$disallowed_gifts
      )
    }
  )
)

#  @title GroupCall
#  @description Telegram API type GroupCall
#  @export
#  @noRd
#  @noRd
GroupCall <- R6::R6Class(
  "GroupCall",
  inherit = TLObject,
  public = list(
    #  @field id Field.
    id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    #  @field participants_count Field.
    participants_count = NULL,
    #  @field unmuted_video_limit Field.
    unmuted_video_limit = NULL,
    #  @field version Field.
    version = NULL,
    #  @field join_muted Field.
    join_muted = NULL,
    #  @field can_change_join_muted Field.
    can_change_join_muted = NULL,
    #  @field join_date_asc Field.
    join_date_asc = NULL,
    #  @field schedule_start_subscribed Field.
    schedule_start_subscribed = NULL,
    #  @field can_start_video Field.
    can_start_video = NULL,
    #  @field record_video_active Field.
    record_video_active = NULL,
    #  @field rtmp_stream Field.
    rtmp_stream = NULL,
    #  @field listeners_hidden Field.
    listeners_hidden = NULL,
    #  @field conference Field.
    conference = NULL,
    #  @field creator Field.
    creator = NULL,
    #  @field title Field.
    title = NULL,
    #  @field stream_dc_id Field.
    stream_dc_id = NULL,
    #  @field record_start_date Field.
    record_start_date = NULL,
    #  @field schedule_date Field.
    schedule_date = NULL,
    #  @field unmuted_video_count Field.
    unmuted_video_count = NULL,
    #  @field invite_link Field.
    invite_link = NULL,
    initialize = function(id, access_hash, participants_count, unmuted_video_limit, version,
                          join_muted = NULL, can_change_join_muted = NULL, join_date_asc = NULL,
                          schedule_start_subscribed = NULL, can_start_video = NULL,
                          record_video_active = NULL, rtmp_stream = NULL, listeners_hidden = NULL,
                          conference = NULL, creator = NULL, title = NULL, stream_dc_id = NULL,
                          record_start_date = NULL, schedule_date = NULL, unmuted_video_count = NULL,
                          invite_link = NULL) {
      self$id <- id
      self$access_hash <- access_hash
      self$participants_count <- participants_count
      self$unmuted_video_limit <- unmuted_video_limit
      self$version <- version
      self$join_muted <- join_muted
      self$can_change_join_muted <- can_change_join_muted
      self$join_date_asc <- join_date_asc
      self$schedule_start_subscribed <- schedule_start_subscribed
      self$can_start_video <- can_start_video
      self$record_video_active <- record_video_active
      self$rtmp_stream <- rtmp_stream
      self$listeners_hidden <- listeners_hidden
      self$conference <- conference
      self$creator <- creator
      self$title <- title
      self$stream_dc_id <- stream_dc_id
      self$record_start_date <- record_start_date
      self$schedule_date <- schedule_date
      self$unmuted_video_count <- unmuted_video_count
      self$invite_link <- invite_link
    },
    to_list = function() {
      list(
        "_" = "GroupCall",
        id = self$id,
        access_hash = self$access_hash,
        participants_count = self$participants_count,
        unmuted_video_limit = self$unmuted_video_limit,
        version = self$version,
        join_muted = self$join_muted,
        can_change_join_muted = self$can_change_join_muted,
        join_date_asc = self$join_date_asc,
        schedule_start_subscribed = self$schedule_start_subscribed,
        can_start_video = self$can_start_video,
        record_video_active = self$record_video_active,
        rtmp_stream = self$rtmp_stream,
        listeners_hidden = self$listeners_hidden,
        conference = self$conference,
        creator = self$creator,
        title = self$title,
        stream_dc_id = self$stream_dc_id,
        record_start_date = self$record_start_date,
        schedule_date = self$schedule_date,
        unmuted_video_count = self$unmuted_video_count,
        invite_link = self$invite_link
      )
    }
  )
)

#  @title GroupCallDiscarded
#  @description Telegram API type GroupCallDiscarded
#  @export
#  @noRd
#  @noRd
GroupCallDiscarded <- R6::R6Class(
  "GroupCallDiscarded",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7780bcb4,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x20b4f320,
    #  @field id Field.
    id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    #  @field duration Field.
    duration = NULL,
    initialize = function(id, access_hash, duration) {
      self$id <- id
      self$access_hash <- access_hash
      self$duration <- duration
    },
    to_dict = function() {
      list(
        "_" = "GroupCallDiscarded",
        id = self$id,
        access_hash = self$access_hash,
        duration = self$duration
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xb4, 0xbc, 0x80, 0x77)),
        writeBin(as.integer64(self$id), raw(), size = 8, endian = "little"),
        writeBin(as.integer64(self$access_hash), raw(), size = 8, endian = "little"),
        writeBin(as.integer(self$duration), raw(), size = 4, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      id <- reader$read_long()
      access_hash <- reader$read_long()
      duration <- reader$read_int()
      self$new(id = id, access_hash = access_hash, duration = duration)
    }
  )
)

#  @title GroupCallParticipant
#  @description Telegram API type GroupCallParticipant
#  @export
#  @noRd
#  @noRd
GroupCallParticipant <- R6::R6Class(
  "GroupCallParticipant",
  inherit = TLObject,
  public = list(
    #  @field peer Field.
    peer = NULL,
    #  @field date Field.
    date = NULL,
    #  @field source Field.
    source = NULL,
    #  @field muted Field.
    muted = NULL,
    #  @field left Field.
    left = NULL,
    #  @field can_self_unmute Field.
    can_self_unmute = NULL,
    #  @field just_joined Field.
    just_joined = NULL,
    #  @field versioned Field.
    versioned = NULL,
    #  @field min Field.
    min = NULL,
    #  @field muted_by_you Field.
    muted_by_you = NULL,
    #  @field volume_by_admin Field.
    volume_by_admin = NULL,
    #  @field is_self Field.
    is_self = NULL,
    #  @field video_joined Field.
    video_joined = NULL,
    #  @field active_date Field.
    active_date = NULL,
    #  @field volume Field.
    volume = NULL,
    #  @field about Field.
    about = NULL,
    #  @field raise_hand_rating Field.
    raise_hand_rating = NULL,
    #  @field video Field.
    video = NULL,
    #  @field presentation Field.
    presentation = NULL,
    initialize = function(peer, date = NULL, source, muted = NULL, left = NULL, can_self_unmute = NULL,
                          just_joined = NULL, versioned = NULL, min = NULL, muted_by_you = NULL,
                          volume_by_admin = NULL, is_self = NULL, video_joined = NULL, active_date = NULL,
                          volume = NULL, about = NULL, raise_hand_rating = NULL, video = NULL,
                          presentation = NULL) {
      self$peer <- peer
      self$date <- date
      self$source <- source
      self$muted <- muted
      self$left <- left
      self$can_self_unmute <- can_self_unmute
      self$just_joined <- just_joined
      self$versioned <- versioned
      self$min <- min
      self$muted_by_you <- muted_by_you
      self$volume_by_admin <- volume_by_admin
      self$is_self <- is_self
      self$video_joined <- video_joined
      self$active_date <- active_date
      self$volume <- volume
      self$about <- about
      self$raise_hand_rating <- raise_hand_rating
      self$video <- video
      self$presentation <- presentation
    },
    to_list = function() {
      list(
        "_" = "GroupCallParticipant",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_list() else self$peer,
        date = self$date,
        source = self$source,
        muted = self$muted,
        left = self$left,
        can_self_unmute = self$can_self_unmute,
        just_joined = self$just_joined,
        versioned = self$versioned,
        min = self$min,
        muted_by_you = self$muted_by_you,
        volume_by_admin = self$volume_by_admin,
        is_self = self$is_self,
        video_joined = self$video_joined,
        active_date = self$active_date,
        volume = self$volume,
        about = self$about,
        raise_hand_rating = self$raise_hand_rating,
        video = if (inherits(self$video, "TLObject")) self$video$to_list() else self$video,
        presentation = if (inherits(self$presentation, "TLObject")) self$presentation$to_list() else self$presentation
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      muted <- as.logical(bitwAnd(flags, 1))
      left <- as.logical(bitwAnd(flags, 2))
      can_self_unmute <- as.logical(bitwAnd(flags, 4))
      just_joined <- as.logical(bitwAnd(flags, 16))
      versioned <- as.logical(bitwAnd(flags, 32))
      min <- as.logical(bitwAnd(flags, 256))
      muted_by_you <- as.logical(bitwAnd(flags, 512))
      volume_by_admin <- as.logical(bitwAnd(flags, 1024))
      is_self <- as.logical(bitwAnd(flags, 4096))
      video_joined <- as.logical(bitwAnd(flags, 32768))

      peer <- reader$tgread_object()
      date <- reader$tgread_date()

      active_date <- if (bitwAnd(flags, 8)) reader$tgread_date() else NULL
      source <- reader$read_int()
      volume <- if (bitwAnd(flags, 128)) reader$read_int() else NULL
      about <- if (bitwAnd(flags, 2048)) reader$tgread_string() else NULL
      raise_hand_rating <- if (bitwAnd(flags, 8192)) reader$read_long() else NULL
      video <- if (bitwAnd(flags, 64)) reader$tgread_object() else NULL
      presentation <- if (bitwAnd(flags, 16384)) reader$tgread_object() else NULL

      self$new(
        peer = peer, date = date, source = source, muted = muted, left = left,
        can_self_unmute = can_self_unmute, just_joined = just_joined, versioned = versioned,
        min = min, muted_by_you = muted_by_you, volume_by_admin = volume_by_admin,
        is_self = is_self, video_joined = video_joined, active_date = active_date,
        volume = volume, about = about, raise_hand_rating = raise_hand_rating,
        video = video, presentation = presentation
      )
    }
  )
)

#  @title GroupCallParticipantVideo
#  @description Telegram API type GroupCallParticipantVideo
#  @export
#  @noRd
#  @noRd
GroupCallParticipantVideo <- R6::R6Class(
  "GroupCallParticipantVideo",
  inherit = TLObject,
  public = list(
    #  @field endpoint Field.
    endpoint = NULL,
    #  @field source_groups Field.
    source_groups = NULL,
    #  @field paused Field.
    paused = NULL,
    #  @field audio_source Field.
    audio_source = NULL,
    initialize = function(endpoint, source_groups, paused = NULL, audio_source = NULL) {
      self$endpoint <- endpoint
      self$source_groups <- source_groups
      self$paused <- paused
      self$audio_source <- audio_source
    },
    to_list = function() {
      list(
        "_" = "GroupCallParticipantVideo",
        endpoint = self$endpoint,
        source_groups = if (is.null(self$source_groups)) list() else lapply(self$source_groups, function(x) if (inherits(x, "TLObject")) x$to_list() else x),
        paused = self$paused,
        audio_source = self$audio_source
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xc8, 0x3a, 0x75, 0x67)),
        as.raw(bitwOr(if (is.null(self$paused) || !self$paused) 0 else 1, if (is.null(self$audio_source)) 0 else 2)),
        serialize_bytes(self$endpoint),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)),
        serialize_int(length(self$source_groups)),
        unlist(lapply(self$source_groups, function(x) x$bytes())),
        if (is.null(self$audio_source)) raw() else serialize_int(self$audio_source)
      )
    }
  )
)

#  @title GroupCallParticipantVideoSourceGroup
#  @description Telegram API type GroupCallParticipantVideoSourceGroup
#  @export
#  @noRd
#  @noRd
GroupCallParticipantVideoSourceGroup <- R6::R6Class(
  "GroupCallParticipantVideoSourceGroup",
  inherit = TLObject,
  public = list(
    #  @field semantics Field.
    semantics = NULL,
    #  @field sources Field.
    sources = NULL,
    initialize = function(semantics, sources) {
      self$semantics <- semantics
      self$sources <- sources
    },
    to_list = function() {
      list(
        "_" = "GroupCallParticipantVideoSourceGroup",
        semantics = self$semantics,
        sources = if (is.null(self$sources)) list() else self$sources
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xb7, 0x18, 0xb1, 0xdc)),
        serialize_bytes(self$semantics),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)),
        serialize_int(length(self$sources)),
        unlist(lapply(self$sources, serialize_int))
      )
    }
  )
)

#  @title GroupCallStreamChannel
#  @description Telegram API type GroupCallStreamChannel
#  @export
#  @noRd
#  @noRd
GroupCallStreamChannel <- R6::R6Class(
  "GroupCallStreamChannel",
  public = list(
    #  @field channel Field.
    channel = NULL,
    #  @field scale Field.
    scale = NULL,
    #  @field lastTimestampMs Field.
    lastTimestampMs = NULL,
    initialize = function(channel, scale, lastTimestampMs) {
      self$channel <- channel
      self$scale <- scale
      self$lastTimestampMs <- lastTimestampMs
    },
    to_list = function() {
      list(
        "_" = "GroupCallStreamChannel",
        channel = self$channel,
        scale = self$scale,
        lastTimestampMs = self$lastTimestampMs
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xaf, 0x48, 0xeb, 0x80)),
        writeBin(as.integer(self$channel), raw(), size = 4, endian = "little"),
        writeBin(as.integer(self$scale), raw(), size = 4, endian = "little"),
        writeBin(as.numeric(self$lastTimestampMs), raw(), size = 8, endian = "little")
      )
    }
  )
)

#  @title HighScore
#  @description Telegram API type HighScore
#  @export
#  @noRd
#  @noRd
HighScore <- R6::R6Class(
  "HighScore",
  public = list(
    #  @field pos Field.
    pos = NULL,
    #  @field userId Field.
    userId = NULL,
    #  @field score Field.
    score = NULL,
    initialize = function(pos, userId, score) {
      self$pos <- pos
      self$userId <- userId
      self$score <- score
    },
    to_list = function() {
      list(
        "_" = "HighScore",
        pos = self$pos,
        userId = self$userId,
        score = self$score
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xeb, 0x79, 0xa3, 0x73)),
        writeBin(as.integer(self$pos), raw(), size = 4, endian = "little"),
        writeBin(as.numeric(self$userId), raw(), size = 8, endian = "little"),
        writeBin(as.integer(self$score), raw(), size = 4, endian = "little")
      )
    }
  )
)

#  @title HttpWait
#  @description Telegram API type HttpWait
#  @export
#  @noRd
#  @noRd
HttpWait <- R6::R6Class(
  "HttpWait",
  public = list(
    #  @field max_delay Field.
    max_delay = NULL,
    #  @field wait_after Field.
    wait_after = NULL,
    #  @field max_wait Field.
    max_wait = NULL,
    initialize = function(max_delay, wait_after, max_wait) {
      self$max_delay <- max_delay
      self$wait_after <- wait_after
      self$max_wait <- max_wait
    },
    to_list = function() {
      list(
        "_" = "HttpWait",
        max_delay = self$max_delay,
        wait_after = self$wait_after,
        max_wait = self$max_wait
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x9f, 0x35, 0x99, 0x92)),
        writeBin(as.integer(self$max_delay), raw(), size = 4, endian = "little"),
        writeBin(as.integer(self$wait_after), raw(), size = 4, endian = "little"),
        writeBin(as.integer(self$max_wait), raw(), size = 4, endian = "little")
      )
    }
  )
)

#  @title ImportedContact
#  @description Telegram API type ImportedContact
#  @export
#  @noRd
#  @noRd
ImportedContact <- R6::R6Class(
  "ImportedContact",
  public = list(
    #  @field user_id Field.
    user_id = NULL,
    #  @field client_id Field.
    client_id = NULL,
    initialize = function(user_id, client_id) {
      self$user_id <- user_id
      self$client_id <- client_id
    },
    to_list = function() {
      list(
        "_" = "ImportedContact",
        user_id = self$user_id,
        client_id = self$client_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x50, 0x3c, 0x3e, 0xc1)),
        writeBin(as.integer(self$user_id), raw(), size = 8, endian = "little"),
        writeBin(as.integer(self$client_id), raw(), size = 8, endian = "little")
      )
    }
  )
)

#  @title InlineBotSwitchPM
#  @description Telegram API type InlineBotSwitchPM
#  @export
#  @noRd
#  @noRd
InlineBotSwitchPM <- R6::R6Class(
  "InlineBotSwitchPM",
  public = list(
    #  @field text Field.
    text = NULL,
    #  @field start_param Field.
    start_param = NULL,
    initialize = function(text, start_param) {
      self$text <- text
      self$start_param <- start_param
    },
    to_list = function() {
      list(
        "_" = "InlineBotSwitchPM",
        text = self$text,
        start_param = self$start_param
      )
    },
    bytes = function() {
      paste0(
        "\x9f\x62\x20\x3c",
        self$serialize_bytes(self$text),
        self$serialize_bytes(self$start_param)
      )
    },
    serialize_bytes = function(value) {
      # Placeholder for serialization logic
      value
    }
  )
)

#  @title InlineBotWebView
#  @description Telegram API type InlineBotWebView
#  @export
#  @noRd
#  @noRd
InlineBotWebView <- R6::R6Class(
  "InlineBotWebView",
  public = list(
    #  @field text Field.
    text = NULL,
    #  @field url Field.
    url = NULL,
    initialize = function(text, url) {
      self$text <- text
      self$url <- url
    },
    to_list = function() {
      list(
        "_" = "InlineBotWebView",
        text = self$text,
        url = self$url
      )
    },
    bytes = function() {
      paste0(
        "\xd5\x95\x72\xb5",
        self$serialize_bytes(self$text),
        self$serialize_bytes(self$url)
      )
    },
    serialize_bytes = function(value) {
      # Placeholder for serialization logic
      value
    }
  )
)

#  @title InlineQueryPeerTypeBotPM
#  @description Telegram API type InlineQueryPeerTypeBotPM
#  @export
#  @noRd
#  @noRd
InlineQueryPeerTypeBotPM <- R6::R6Class(
  "InlineQueryPeerTypeBotPM",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x0e3b2d0c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xafb0fa1f,
    to_list = function() {
      list("_" = "InlineQueryPeerTypeBotPM")
    },
    bytes = function() {
      rawToBits(as.raw(c(0x0c, 0x2d, 0x3b, 0x0e)))
    }
  )
)

#  @title InlineQueryPeerTypeBroadcast
#  @description Telegram API type InlineQueryPeerTypeBroadcast
#  @export
#  @noRd
#  @noRd
InlineQueryPeerTypeBroadcast <- R6::R6Class(
  "InlineQueryPeerTypeBroadcast",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x6334ee9a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xafb0fa1f,
    to_list = function() {
      list("_" = "InlineQueryPeerTypeBroadcast")
    },
    bytes = function() {
      rawToBits(as.raw(c(0x9a, 0xee, 0x34, 0x63)))
    }
  )
)

#  @title InlineQueryPeerTypeChat
#  @description Telegram API type InlineQueryPeerTypeChat
#  @export
#  @noRd
#  @noRd
InlineQueryPeerTypeChat <- R6::R6Class(
  "InlineQueryPeerTypeChat",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd766c50a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xafb0fa1f,
    to_list = function() {
      list("_" = "InlineQueryPeerTypeChat")
    },
    bytes = function() {
      rawToBits(as.raw(c(0x0a, 0xc5, 0x66, 0xd7)))
    }
  )
)

#  @title InlineQueryPeerTypeMegagroup
#  @description Telegram API type InlineQueryPeerTypeMegagroup
#  @export
#  @noRd
#  @noRd
InlineQueryPeerTypeMegagroup <- R6::R6Class(
  "InlineQueryPeerTypeMegagroup",
  inherit = TLObject,
  public = list(
    to_list = function() {
      list("_" = "InlineQueryPeerTypeMegagroup")
    },
    bytes = function() {
      as.raw(c(0x43, 0xbe, 0xc4, 0x5e))
    }
  )
)

#  @title InlineQueryPeerTypePM
#  @description Telegram API type InlineQueryPeerTypePM
#  @export
#  @noRd
#  @noRd
InlineQueryPeerTypePM <- R6::R6Class(
  "InlineQueryPeerTypePM",
  inherit = TLObject,
  public = list(
    to_list = function() {
      list("_" = "InlineQueryPeerTypePM")
    },
    bytes = function() {
      as.raw(c(0xac, 0x0f, 0x3c, 0x83))
    }
  )
)

#  @title InlineQueryPeerTypeSameBotPM
#  @description Telegram API type InlineQueryPeerTypeSameBotPM
#  @export
#  @noRd
#  @noRd
InlineQueryPeerTypeSameBotPM <- R6::R6Class(
  "InlineQueryPeerTypeSameBotPM",
  inherit = TLObject,
  public = list(
    to_list = function() {
      list("_" = "InlineQueryPeerTypeSameBotPM")
    },
    bytes = function() {
      as.raw(c(0x9d, 0xed, 0x81, 0x30))
    }
  )
)

#  @title InputAppEvent
#  @description Telegram API type InputAppEvent
#  @export
#  @noRd
#  @noRd
InputAppEvent <- R6::R6Class(
  "InputAppEvent",
  public = list(
    #  @field time Field.
    time = NULL,
    #  @field type Field.
    type = NULL,
    #  @field peer Field.
    peer = NULL,
    #  @field data Field.
    data = NULL,
    initialize = function(time, type, peer, data) {
      self$time <- time
      self$type <- type
      self$peer <- peer
      self$data <- data
    },
    to_list = function() {
      list(
        "_" = "InputAppEvent",
        time = self$time,
        type = self$type,
        peer = self$peer,
        data = if (inherits(self$data, "TLObject")) self$data$to_list() else self$data
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x1d, 0x1b, 0x12, 0x45)),
        writeBin(self$time, raw(), size = 8),
        serialize_bytes(self$type),
        writeBin(self$peer, raw(), size = 8),
        self$data$bytes()
      )
    }
  )
)

#  @title InputBotAppID
#  @description Telegram API type InputBotAppID
#  @export
#  @noRd
#  @noRd
InputBotAppID <- R6::R6Class(
  "InputBotAppID",
  public = list(
    #  @field id Field.
    id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    initialize = function(id, access_hash) {
      self$id <- id
      self$access_hash <- access_hash
    },
    to_list = function() {
      list(
        "_" = "InputBotAppID",
        id = self$id,
        access_hash = self$access_hash
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xa9, 0x20, 0xbd, 0x7a)),
        writeBin(self$id, raw(), size = 8),
        writeBin(self$access_hash, raw(), size = 8)
      )
    }
  )
)

#  @title InputBotAppShortName
#  @description Telegram API type InputBotAppShortName
#  @export
#  @noRd
#  @noRd
InputBotAppShortName <- R6::R6Class(
  "InputBotAppShortName",
  inherit = TLObject,
  public = list(
    #  @field bot_id Field.
    bot_id = NULL,
    #  @field short_name Field.
    short_name = NULL,
    initialize = function(bot_id, short_name) {
      self$bot_id <- bot_id
      self$short_name <- short_name
    },
    to_dict = function() {
      list(
        "_" = "InputBotAppShortName",
        bot_id = if (inherits(self$bot_id, "TLObject")) self$bot_id$to_dict() else self$bot_id,
        short_name = self$short_name
      )
    },
    bytes = function() {
      paste0(
        "\x07\x04\x8c\x90",
        self$bot_id$bytes(),
        serialize_bytes(self$short_name)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      bot_id <- reader$tgread_object()
      short_name <- reader$tgread_string()
      self$new(bot_id = bot_id, short_name = short_name)
    }
  )
)

#  @title InputBotInlineMessageGame
#  @description Telegram API type InputBotInlineMessageGame
#  @export
#  @noRd
#  @noRd
InputBotInlineMessageGame <- R6::R6Class(
  "InputBotInlineMessageGame",
  inherit = TLObject,
  public = list(
    #  @field reply_markup Field.
    reply_markup = NULL,
    initialize = function(reply_markup = NULL) {
      self$reply_markup <- reply_markup
    },
    to_dict = function() {
      list(
        "_" = "InputBotInlineMessageGame",
        reply_markup = if (inherits(self$reply_markup, "TLObject")) self$reply_markup$to_dict() else self$reply_markup
      )
    },
    bytes = function() {
      paste0(
        "dXBK",
        as.character(if (is.null(self$reply_markup) || !self$reply_markup) 0 else 4),
        if (is.null(self$reply_markup) || !self$reply_markup) "" else self$reply_markup$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      reply_markup <- if (bitwAnd(flags, 4)) reader$tgread_object() else NULL
      self$new(reply_markup = reply_markup)
    }
  )
)

#  @title InputBotInlineMessageID
#  @description Telegram API type InputBotInlineMessageID
#  @export
#  @noRd
#  @noRd
InputBotInlineMessageID <- R6::R6Class(
  "InputBotInlineMessageID",
  inherit = TLObject,
  public = list(
    #  @field dc_id Field.
    dc_id = NULL,
    #  @field id Field.
    id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    initialize = function(dc_id, id, access_hash) {
      self$dc_id <- dc_id
      self$id <- id
      self$access_hash <- access_hash
    },
    to_list = function() {
      list(
        "_" = "InputBotInlineMessageID",
        dc_id = self$dc_id,
        id = self$id,
        access_hash = self$access_hash
      )
    },
    bytes = function() {
      rawToBits(c(
        as.raw(0x89), as.raw(0x3d), as.raw(0x0c), as.raw(0x89),
        writeBin(as.integer(self$dc_id), raw(), size = 4, endian = "little"),
        writeBin(as.integer(self$id), raw(), size = 8, endian = "little"),
        writeBin(as.integer(self$access_hash), raw(), size = 8, endian = "little")
      ))
    }
  )
)

#  @title InputBotInlineMessageID64
#  @description Telegram API type InputBotInlineMessageID64
#  @export
#  @noRd
#  @noRd
InputBotInlineMessageID64 <- R6::R6Class(
  "InputBotInlineMessageID64",
  inherit = TLObject,
  public = list(
    #  @field dc_id Field.
    dc_id = NULL,
    #  @field owner_id Field.
    owner_id = NULL,
    #  @field id Field.
    id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    initialize = function(dc_id, owner_id, id, access_hash) {
      self$dc_id <- dc_id
      self$owner_id <- owner_id
      self$id <- id
      self$access_hash <- access_hash
    },
    to_list = function() {
      list(
        "_" = "InputBotInlineMessageID64",
        dc_id = self$dc_id,
        owner_id = self$owner_id,
        id = self$id,
        access_hash = self$access_hash
      )
    },
    bytes = function() {
      rawToBits(c(
        as.raw(0xd7), as.raw(0x15), as.raw(0xd9), as.raw(0xb6),
        writeBin(as.integer(self$dc_id), raw(), size = 4, endian = "little"),
        writeBin(as.integer(self$owner_id), raw(), size = 8, endian = "little"),
        writeBin(as.integer(self$id), raw(), size = 4, endian = "little"),
        writeBin(as.integer(self$access_hash), raw(), size = 8, endian = "little")
      ))
    }
  )
)

#  @title InputBotInlineMessageMediaAuto
#  @description Telegram API type InputBotInlineMessageMediaAuto
#  @export
#  @noRd
#  @noRd
InputBotInlineMessageMediaAuto <- R6::R6Class(
  "InputBotInlineMessageMediaAuto",
  inherit = TLObject,
  public = list(
    #  @field message Field.
    message = NULL,
    #  @field invert_media Field.
    invert_media = NULL,
    #  @field entities Field.
    entities = NULL,
    #  @field reply_markup Field.
    reply_markup = NULL,
    initialize = function(message, invert_media = NULL, entities = NULL, reply_markup = NULL) {
      self$message <- message
      self$invert_media <- invert_media
      self$entities <- entities
      self$reply_markup <- reply_markup
    },
    to_list = function() {
      list(
        "_" = "InputBotInlineMessageMediaAuto",
        message = self$message,
        invert_media = self$invert_media,
        entities = if (is.null(self$entities)) list() else lapply(self$entities, function(x) if (inherits(x, "TLObject")) x$to_list() else x),
        reply_markup = if (inherits(self$reply_markup, "TLObject")) self$reply_markup$to_list() else self$reply_markup
      )
    },
    bytes = function() {
      flags <- Reduce(bitwOr, as.integer(c(
        if (is.null(self$invert_media) || !self$invert_media) 0 else 8,
        if (is.null(self$entities) || length(self$entities) == 0) 0 else 2,
        if (is.null(self$reply_markup)) 0 else 4
      )), init = 0L)

      c(
        as.raw(c(0x86, 0xc7, 0x80, 0x33)),
        as.raw(flags),
        serialize_bytes(self$message),
        if (is.null(self$entities) || length(self$entities) == 0) {
          raw()
        } else {
          c(
            as.raw(c(0x15, 0xc4, 0xb5, 0x1c)),
            writeBin(length(self$entities), raw(), size = 4),
            unlist(lapply(self$entities, function(x) x$bytes()))
          )
        },
        if (is.null(self$reply_markup)) raw() else self$reply_markup$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      invert_media <- as.logical(bitwAnd(flags, 8))
      message <- reader$tgread_string()
      entities <- if (bitwAnd(flags, 2)) {
        reader$read_int()
        lapply(seq_len(reader$read_int()), function(.) reader$tgread_object())
      } else {
        NULL
      }
      reply_markup <- if (bitwAnd(flags, 4)) reader$tgread_object() else NULL

      self$new(message = message, invert_media = invert_media, entities = entities, reply_markup = reply_markup)
    }
  )
)

#  @title InputBotInlineMessageMediaContact
#  @description Telegram API type InputBotInlineMessageMediaContact
#  @export
#  @noRd
#  @noRd
InputBotInlineMessageMediaContact <- R6::R6Class(
  "InputBotInlineMessageMediaContact",
  inherit = TLObject,
  public = list(
    #  @field phone_number Field.
    phone_number = NULL,
    #  @field first_name Field.
    first_name = NULL,
    #  @field last_name Field.
    last_name = NULL,
    #  @field vcard Field.
    vcard = NULL,
    #  @field reply_markup Field.
    reply_markup = NULL,
    initialize = function(phone_number, first_name, last_name, vcard, reply_markup = NULL) {
      self$phone_number <- phone_number
      self$first_name <- first_name
      self$last_name <- last_name
      self$vcard <- vcard
      self$reply_markup <- reply_markup
    },
    to_list = function() {
      list(
        "_" = "InputBotInlineMessageMediaContact",
        phone_number = self$phone_number,
        first_name = self$first_name,
        last_name = self$last_name,
        vcard = self$vcard,
        reply_markup = if (!is.null(self$reply_markup) && inherits(self$reply_markup, "TLObject")) self$reply_markup$to_list() else self$reply_markup
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xfd, 0xbf, 0xed, 0xa6)),
        as.raw(if (is.null(self$reply_markup)) 0 else 4),
        serialize_bytes(self$phone_number),
        serialize_bytes(self$first_name),
        serialize_bytes(self$last_name),
        serialize_bytes(self$vcard),
        if (!is.null(self$reply_markup)) self$reply_markup$bytes() else raw(0)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      phone_number <- reader$tgread_string()
      first_name <- reader$tgread_string()
      last_name <- reader$tgread_string()
      vcard <- reader$tgread_string()
      reply_markup <- if (bitwAnd(flags, 4) != 0) reader$tgread_object() else NULL
      self$new(phone_number, first_name, last_name, vcard, reply_markup)
    }
  )
)

#  @title InputBotInlineMessageMediaGeo
#  @description Telegram API type InputBotInlineMessageMediaGeo
#  @export
#  @noRd
#  @noRd
InputBotInlineMessageMediaGeo <- R6::R6Class(
  "InputBotInlineMessageMediaGeo",
  inherit = TLObject,
  public = list(
    #  @field geo_point Field.
    geo_point = NULL,
    #  @field heading Field.
    heading = NULL,
    #  @field period Field.
    period = NULL,
    #  @field proximity_notification_radius Field.
    proximity_notification_radius = NULL,
    #  @field reply_markup Field.
    reply_markup = NULL,
    initialize = function(geo_point, heading = NULL, period = NULL, proximity_notification_radius = NULL, reply_markup = NULL) {
      self$geo_point <- geo_point
      self$heading <- heading
      self$period <- period
      self$proximity_notification_radius <- proximity_notification_radius
      self$reply_markup <- reply_markup
    },
    to_list = function() {
      list(
        "_" = "InputBotInlineMessageMediaGeo",
        geo_point = if (inherits(self$geo_point, "TLObject")) self$geo_point$to_list() else self$geo_point,
        heading = self$heading,
        period = self$period,
        proximity_notification_radius = self$proximity_notification_radius,
        reply_markup = if (inherits(self$reply_markup, "TLObject")) self$reply_markup$to_list() else self$reply_markup
      )
    },
    bytes = function() {
      flags <- Reduce(bitwOr, as.integer(c(
        if (is.null(self$heading) || !self$heading) 0 else 1,
        if (is.null(self$period) || !self$period) 0 else 2,
        if (is.null(self$proximity_notification_radius) || !self$proximity_notification_radius) 0 else 8,
        if (is.null(self$reply_markup) || !self$reply_markup) 0 else 4
      )), init = 0L)

      c(
        as.raw(c(0x85, 0x9a, 0x92, 0x96)),
        as.raw(flags),
        self$geo_point$bytes(),
        if (is.null(self$heading) || !self$heading) raw() else writeBin(as.integer(self$heading), raw(), size = 4),
        if (is.null(self$period) || !self$period) raw() else writeBin(as.integer(self$period), raw(), size = 4),
        if (is.null(self$proximity_notification_radius) || !self$proximity_notification_radius) raw() else writeBin(as.integer(self$proximity_notification_radius), raw(), size = 4),
        if (is.null(self$reply_markup) || !self$reply_markup) raw() else self$reply_markup$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      geo_point <- reader$tgread_object()
      heading <- if (bitwAnd(flags, 1)) reader$read_int() else NULL
      period <- if (bitwAnd(flags, 2)) reader$read_int() else NULL
      proximity_notification_radius <- if (bitwAnd(flags, 8)) reader$read_int() else NULL
      reply_markup <- if (bitwAnd(flags, 4)) reader$tgread_object() else NULL

      self$new(geo_point = geo_point, heading = heading, period = period, proximity_notification_radius = proximity_notification_radius, reply_markup = reply_markup)
    }
  )
)

#  @title InputBotInlineMessageMediaInvoice
#  @description Telegram API type InputBotInlineMessageMediaInvoice
#  @export
#  @noRd
#  @noRd
InputBotInlineMessageMediaInvoice <- R6::R6Class(
  "InputBotInlineMessageMediaInvoice",
  inherit = TLObject,
  public = list(
    #  @field title Field.
    title = NULL,
    #  @field description Field.
    description = NULL,
    #  @field invoice Field.
    invoice = NULL,
    #  @field payload Field.
    payload = NULL,
    #  @field provider Field.
    provider = NULL,
    #  @field provider_data Field.
    provider_data = NULL,
    #  @field photo Field.
    photo = NULL,
    #  @field reply_markup Field.
    reply_markup = NULL,
    initialize = function(title, description, invoice, payload, provider, provider_data, photo = NULL, reply_markup = NULL) {
      self$title <- title
      self$description <- description
      self$invoice <- invoice
      self$payload <- payload
      self$provider <- provider
      self$provider_data <- provider_data
      self$photo <- photo
      self$reply_markup <- reply_markup
    },
    to_list = function() {
      list(
        "_" = "InputBotInlineMessageMediaInvoice",
        title = self$title,
        description = self$description,
        invoice = if (inherits(self$invoice, "TLObject")) self$invoice$to_list() else self$invoice,
        payload = self$payload,
        provider = self$provider,
        provider_data = if (inherits(self$provider_data, "TLObject")) self$provider_data$to_list() else self$provider_data,
        photo = if (!is.null(self$photo) && inherits(self$photo, "TLObject")) self$photo$to_list() else self$photo,
        reply_markup = if (!is.null(self$reply_markup) && inherits(self$reply_markup, "TLObject")) self$reply_markup$to_list() else self$reply_markup
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x25, 0x82, 0xE7, 0xD7)),
        as.raw(bitwOr(
          if (is.null(self$photo) || !self$photo) 0 else 1,
          if (is.null(self$reply_markup) || !self$reply_markup) 0 else 4
        )),
        serialize_bytes(self$title),
        serialize_bytes(self$description),
        if (is.null(self$photo) || !self$photo) raw() else self$photo$bytes(),
        self$invoice$bytes(),
        serialize_bytes(self$payload),
        serialize_bytes(self$provider),
        self$provider_data$bytes(),
        if (is.null(self$reply_markup) || !self$reply_markup) raw() else self$reply_markup$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      title <- reader$tgread_string()
      description <- reader$tgread_string()
      photo <- if (bitwAnd(flags, 1)) reader$tgread_object() else NULL
      invoice <- reader$tgread_object()
      payload <- reader$tgread_bytes()
      provider <- reader$tgread_string()
      provider_data <- reader$tgread_object()
      reply_markup <- if (bitwAnd(flags, 4)) reader$tgread_object() else NULL

      self$new(
        title = title,
        description = description,
        invoice = invoice,
        payload = payload,
        provider = provider,
        provider_data = provider_data,
        photo = photo,
        reply_markup = reply_markup
      )
    }
  )
)

#  @title InputBotInlineMessageMediaVenue
#  @description Telegram API type InputBotInlineMessageMediaVenue
#  @export
#  @noRd
#  @noRd
InputBotInlineMessageMediaVenue <- R6::R6Class(
  "InputBotInlineMessageMediaVenue",
  inherit = TLObject,
  public = list(
    #  @field geo_point Field.
    geo_point = NULL,
    #  @field title Field.
    title = NULL,
    #  @field address Field.
    address = NULL,
    #  @field provider Field.
    provider = NULL,
    #  @field venue_id Field.
    venue_id = NULL,
    #  @field venue_type Field.
    venue_type = NULL,
    #  @field reply_markup Field.
    reply_markup = NULL,
    initialize = function(geo_point, title, address, provider, venue_id, venue_type, reply_markup = NULL) {
      self$geo_point <- geo_point
      self$title <- title
      self$address <- address
      self$provider <- provider
      self$venue_id <- venue_id
      self$venue_type <- venue_type
      self$reply_markup <- reply_markup
    },
    to_list = function() {
      list(
        "_" = "InputBotInlineMessageMediaVenue",
        geo_point = if (inherits(self$geo_point, "TLObject")) self$geo_point$to_list() else self$geo_point,
        title = self$title,
        address = self$address,
        provider = self$provider,
        venue_id = self$venue_id,
        venue_type = self$venue_type,
        reply_markup = if (inherits(self$reply_markup, "TLObject")) self$reply_markup$to_list() else self$reply_markup
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x11, 0xbf, 0x7b, 0x41)),
        as.raw(if (is.null(self$reply_markup) || !self$reply_markup) 0 else 4),
        self$geo_point$bytes(),
        serialize_bytes(self$title),
        serialize_bytes(self$address),
        serialize_bytes(self$provider),
        serialize_bytes(self$venue_id),
        serialize_bytes(self$venue_type),
        if (is.null(self$reply_markup) || !self$reply_markup) raw() else self$reply_markup$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      geo_point <- reader$tgread_object()
      title <- reader$tgread_string()
      address <- reader$tgread_string()
      provider <- reader$tgread_string()
      venue_id <- reader$tgread_string()
      venue_type <- reader$tgread_string()
      reply_markup <- if (bitwAnd(flags, 4)) reader$tgread_object() else NULL

      self$new(
        geo_point = geo_point,
        title = title,
        address = address,
        provider = provider,
        venue_id = venue_id,
        venue_type = venue_type,
        reply_markup = reply_markup
      )
    }
  )
)

#  @title InputBotInlineMessageMediaWebPage
#  @description Telegram API type InputBotInlineMessageMediaWebPage
#  @export
#  @noRd
#  @noRd
InputBotInlineMessageMediaWebPage <- R6::R6Class(
  "InputBotInlineMessageMediaWebPage",
  inherit = TLObject,
  public = list(
    #  @field message Field.
    message = NULL,
    #  @field url Field.
    url = NULL,
    #  @field invert_media Field.
    invert_media = NULL,
    #  @field force_large_media Field.
    force_large_media = NULL,
    #  @field force_small_media Field.
    force_small_media = NULL,
    #  @field optional Field.
    optional = NULL,
    #  @field entities Field.
    entities = NULL,
    #  @field reply_markup Field.
    reply_markup = NULL,
    initialize = function(message, url, invert_media = NULL, force_large_media = NULL,
                          force_small_media = NULL, optional = NULL, entities = NULL,
                          reply_markup = NULL) {
      self$message <- message
      self$url <- url
      self$invert_media <- invert_media
      self$force_large_media <- force_large_media
      self$force_small_media <- force_small_media
      self$optional <- optional
      self$entities <- entities
      self$reply_markup <- reply_markup
    },
    to_list = function() {
      list(
        "_" = "InputBotInlineMessageMediaWebPage",
        message = self$message,
        url = self$url,
        invert_media = self$invert_media,
        force_large_media = self$force_large_media,
        force_small_media = self$force_small_media,
        optional = self$optional,
        entities = if (is.null(self$entities)) list() else lapply(self$entities, function(x) if (inherits(x, "TLObject")) x$to_list() else x),
        reply_markup = if (inherits(self$reply_markup, "TLObject")) self$reply_markup$to_list() else self$reply_markup
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x10, 0xc5, 0xdc, 0xbd)),
        pack_flags(
          invert_media = self$invert_media,
          force_large_media = self$force_large_media,
          force_small_media = self$force_small_media,
          optional = self$optional,
          entities = !is.null(self$entities),
          reply_markup = !is.null(self$reply_markup)
        ),
        serialize_bytes(self$message),
        if (!is.null(self$entities)) {
          c(
            as.raw(c(0x15, 0xc4, 0xb5, 0x1c)),
            serialize_int(length(self$entities)),
            unlist(lapply(self$entities, function(x) x$bytes()), recursive = FALSE)
          )
        } else {
          raw()
        },
        serialize_bytes(self$url),
        if (!is.null(self$reply_markup)) self$reply_markup$bytes() else raw()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      invert_media <- bitwAnd(flags, 8) != 0
      force_large_media <- bitwAnd(flags, 16) != 0
      force_small_media <- bitwAnd(flags, 32) != 0
      optional <- bitwAnd(flags, 64) != 0
      message <- reader$tgread_string()

      if (bitwAnd(flags, 2) != 0) {
        reader$read_int()
        entities <- vector("list", reader$read_int())
        for (i in seq_along(entities)) {
          entities[[i]] <- reader$tgread_object()
        }
      } else {
        entities <- NULL
      }

      url <- reader$tgread_string()

      if (bitwAnd(flags, 4) != 0) {
        reply_markup <- reader$tgread_object()
      } else {
        reply_markup <- NULL
      }

      self$new(
        message = message, url = url, invert_media = invert_media,
        force_large_media = force_large_media, force_small_media = force_small_media,
        optional = optional, entities = entities, reply_markup = reply_markup
      )
    }
  )
)

#  @title InputBotInlineMessageText
#  @description Telegram API type InputBotInlineMessageText
#  @export
#  @noRd
#  @noRd
InputBotInlineMessageText <- R6::R6Class(
  "InputBotInlineMessageText",
  inherit = TLObject,
  public = list(
    #  @field message Field.
    message = NULL,
    #  @field no_webpage Field.
    no_webpage = NULL,
    #  @field invert_media Field.
    invert_media = NULL,
    #  @field entities Field.
    entities = NULL,
    #  @field reply_markup Field.
    reply_markup = NULL,
    initialize = function(message, no_webpage = NULL, invert_media = NULL, entities = NULL, reply_markup = NULL) {
      self$message <- message
      self$no_webpage <- no_webpage
      self$invert_media <- invert_media
      self$entities <- entities
      self$reply_markup <- reply_markup
    },
    to_list = function() {
      list(
        "_" = "InputBotInlineMessageText",
        message = self$message,
        no_webpage = self$no_webpage,
        invert_media = self$invert_media,
        entities = if (is.null(self$entities)) list() else lapply(self$entities, function(x) if (inherits(x, "TLObject")) x$to_list() else x),
        reply_markup = if (inherits(self$reply_markup, "TLObject")) self$reply_markup$to_list() else self$reply_markup
      )
    },
    bytes = function() {
      flags <- Reduce(bitwOr, as.integer(c(
        if (is.null(self$no_webpage) || !self$no_webpage) 0 else 1,
        if (is.null(self$invert_media) || !self$invert_media) 0 else 8,
        if (is.null(self$entities) || length(self$entities) == 0) 0 else 2,
        if (is.null(self$reply_markup)) 0 else 4
      )), init = 0L)

      c(
        as.raw(c(0x87, 0x7a, 0xcd, 0x3d)),
        as.raw(flags),
        serialize_bytes(self$message),
        if (is.null(self$entities) || length(self$entities) == 0) {
          raw()
        } else {
          c(
            as.raw(c(0x15, 0xc4, 0xb5, 0x1c)),
            writeBin(length(self$entities), raw(), size = 4),
            unlist(lapply(self$entities, function(x) x$bytes()))
          )
        },
        if (is.null(self$reply_markup)) raw() else self$reply_markup$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      no_webpage <- bitwAnd(flags, 1) != 0
      invert_media <- bitwAnd(flags, 8) != 0
      message <- reader$tgread_string()

      if (bitwAnd(flags, 2) != 0) {
        reader$read_int()
        entities <- vector("list", reader$read_int())
        for (i in seq_along(entities)) {
          entities[[i]] <- reader$tgread_object()
        }
      } else {
        entities <- NULL
      }

      if (bitwAnd(flags, 4) != 0) {
        reply_markup <- reader$tgread_object()
      } else {
        reply_markup <- NULL
      }

      self$new(message = message, no_webpage = no_webpage, invert_media = invert_media, entities = entities, reply_markup = reply_markup)
    }
  )
)

#  @title InputBotInlineResult
#  @description Telegram API type InputBotInlineResult
#  @export
#  @noRd
#  @noRd
InputBotInlineResult <- R6::R6Class(
  "InputBotInlineResult",
  inherit = TLObject,
  public = list(
    #  @field id Field.
    id = NULL,
    #  @field type Field.
    type = NULL,
    #  @field send_message Field.
    send_message = NULL,
    #  @field title Field.
    title = NULL,
    #  @field description Field.
    description = NULL,
    #  @field url Field.
    url = NULL,
    #  @field thumb Field.
    thumb = NULL,
    #  @field content Field.
    content = NULL,
    initialize = function(id, type, send_message, title = NULL, description = NULL, url = NULL, thumb = NULL, content = NULL) {
      self$id <- id
      self$type <- type
      self$send_message <- send_message
      self$title <- title
      self$description <- description
      self$url <- url
      self$thumb <- thumb
      self$content <- content
    },
    to_list = function() {
      list(
        "_" = "InputBotInlineResult",
        id = self$id,
        type = self$type,
        send_message = if (inherits(self$send_message, "TLObject")) self$send_message$to_list() else self$send_message,
        title = self$title,
        description = self$description,
        url = self$url,
        thumb = if (inherits(self$thumb, "TLObject")) self$thumb$to_list() else self$thumb,
        content = if (inherits(self$content, "TLObject")) self$content$to_list() else self$content
      )
    },
    bytes = function() {
      flags <- Reduce(bitwOr, as.integer(c(
        if (is.null(self$title) || !self$title) 0 else 2,
        if (is.null(self$description) || !self$description) 0 else 4,
        if (is.null(self$url) || !self$url) 0 else 8,
        if (is.null(self$thumb) || !self$thumb) 0 else 16,
        if (is.null(self$content) || !self$content) 0 else 32
      )), init = 0L)

      c(
        as.raw(c(0x19, 0x93, 0xbf, 0x88)),
        as.raw(flags),
        serialize_bytes(self$id),
        serialize_bytes(self$type),
        if (is.null(self$title) || !self$title) raw() else serialize_bytes(self$title),
        if (is.null(self$description) || !self$description) raw() else serialize_bytes(self$description),
        if (is.null(self$url) || !self$url) raw() else serialize_bytes(self$url),
        if (is.null(self$thumb) || !self$thumb) raw() else self$thumb$bytes(),
        if (is.null(self$content) || !self$content) raw() else self$content$bytes(),
        self$send_message$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      id <- reader$tgread_string()
      type <- reader$tgread_string()
      title <- if (bitwAnd(flags, 2)) reader$tgread_string() else NULL
      description <- if (bitwAnd(flags, 4)) reader$tgread_string() else NULL
      url <- if (bitwAnd(flags, 8)) reader$tgread_string() else NULL
      thumb <- if (bitwAnd(flags, 16)) reader$tgread_object() else NULL
      content <- if (bitwAnd(flags, 32)) reader$tgread_object() else NULL
      send_message <- reader$tgread_object()

      self$new(id = id, type = type, send_message = send_message, title = title, description = description, url = url, thumb = thumb, content = content)
    }
  )
)

#  @title InputBotInlineResultDocument
#  @description Telegram API type InputBotInlineResultDocument
#  @export
#  @noRd
#  @noRd
InputBotInlineResultDocument <- R6::R6Class(
  "InputBotInlineResultDocument",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xfff8fdc4,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x80a4a3de,
    #  @field id Field.
    id = NULL,
    #  @field type Field.
    type = NULL,
    #  @field document Field.
    document = NULL,
    #  @field send_message Field.
    send_message = NULL,
    #  @field title Field.
    title = NULL,
    #  @field description Field.
    description = NULL,
    initialize = function(id, type, document, send_message, title = NULL, description = NULL) {
      self$id <- id
      self$type <- type
      self$document <- document
      self$send_message <- send_message
      self$title <- title
      self$description <- description
    },
    to_list = function() {
      list(
        "_" = "InputBotInlineResultDocument",
        id = self$id,
        type = self$type,
        document = if (inherits(self$document, "TLObject")) self$document$to_list() else self$document,
        send_message = if (inherits(self$send_message, "TLObject")) self$send_message$to_list() else self$send_message,
        title = self$title,
        description = self$description
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xc4, 0xfd, 0xf8, 0xff)),
        as.raw(bitwOr(
          if (is.null(self$title) || self$title == FALSE) 0 else 2,
          if (is.null(self$description) || self$description == FALSE) 0 else 4
        )),
        self$serialize_bytes(self$id),
        self$serialize_bytes(self$type),
        if (is.null(self$title) || self$title == FALSE) raw() else self$serialize_bytes(self$title),
        if (is.null(self$description) || self$description == FALSE) raw() else self$serialize_bytes(self$description),
        self$document$bytes(),
        self$send_message$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      id <- reader$tgread_string()
      type <- reader$tgread_string()
      title <- if (bitwAnd(flags, 2) != 0) reader$tgread_string() else NULL
      description <- if (bitwAnd(flags, 4) != 0) reader$tgread_string() else NULL
      document <- reader$tgread_object()
      send_message <- reader$tgread_object()

      self$new(id = id, type = type, document = document, send_message = send_message, title = title, description = description)
    }
  )
)

#  @title InputBotInlineResultGame
#  @description Telegram API type InputBotInlineResultGame
#  @export
#  @noRd
#  @noRd
InputBotInlineResultGame <- R6::R6Class(
  "InputBotInlineResultGame",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4fa417f2,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x80a4a3de,
    #  @field id Field.
    id = NULL,
    #  @field short_name Field.
    short_name = NULL,
    #  @field send_message Field.
    send_message = NULL,
    initialize = function(id, short_name, send_message) {
      self$id <- id
      self$short_name <- short_name
      self$send_message <- send_message
    },
    to_list = function() {
      list(
        "_" = "InputBotInlineResultGame",
        id = self$id,
        short_name = self$short_name,
        send_message = if (inherits(self$send_message, "TLObject")) self$send_message$to_list() else self$send_message
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xf2, 0x17, 0xa4, 0x4f)),
        serialize_bytes(self$id),
        serialize_bytes(self$short_name),
        self$send_message$bytes()
      )
    }
  )
)

#  @title InputBotInlineResultPhoto
#  @description Telegram API type InputBotInlineResultPhoto
#  @export
#  @noRd
#  @noRd
InputBotInlineResultPhoto <- R6::R6Class(
  "InputBotInlineResultPhoto",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa8d864a7,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x80a4a3de,
    #  @field id Field.
    id = NULL,
    #  @field type Field.
    type = NULL,
    #  @field photo Field.
    photo = NULL,
    #  @field send_message Field.
    send_message = NULL,
    initialize = function(id, type, photo, send_message) {
      self$id <- id
      self$type <- type
      self$photo <- photo
      self$send_message <- send_message
    },
    to_list = function() {
      list(
        "_" = "InputBotInlineResultPhoto",
        id = self$id,
        type = self$type,
        photo = if (inherits(self$photo, "TLObject")) self$photo$to_list() else self$photo,
        send_message = if (inherits(self$send_message, "TLObject")) self$send_message$to_list() else self$send_message
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xa7, 0x64, 0xd8, 0xa8)),
        serialize_bytes(self$id),
        serialize_bytes(self$type),
        self$photo$bytes(),
        self$send_message$bytes()
      )
    }
  )
)

#  @title InputBusinessAwayMessage
#  @description Telegram API type InputBusinessAwayMessage
#  @export
#  @noRd
#  @noRd
InputBusinessAwayMessage <- R6::R6Class(
  "InputBusinessAwayMessage",
  public = list(
    #  @field shortcut_id Field.
    shortcut_id = NULL,
    #  @field schedule Field.
    schedule = NULL,
    #  @field recipients Field.
    recipients = NULL,
    #  @field offline_only Field.
    offline_only = NULL,
    initialize = function(shortcut_id, schedule, recipients, offline_only = NULL) {
      self$shortcut_id <- shortcut_id
      self$schedule <- schedule
      self$recipients <- recipients
      self$offline_only <- offline_only
    },
    to_list = function() {
      list(
        "_" = "InputBusinessAwayMessage",
        shortcut_id = self$shortcut_id,
        schedule = if (inherits(self$schedule, "R6")) self$schedule$to_list() else self$schedule,
        recipients = if (inherits(self$recipients, "R6")) self$recipients$to_list() else self$recipients,
        offline_only = self$offline_only
      )
    },
    bytes = function() {
      c(
        as.raw(0xe0), as.raw(0x75), as.raw(0x21), as.raw(0x83),
        as.raw(ifelse(is.null(self$offline_only) || !self$offline_only, 0, 1)),
        writeBin(as.integer(self$shortcut_id), raw(), size = 4),
        self$schedule$bytes(),
        self$recipients$bytes()
      )
    }
  )
)

#  @title InputBusinessBotRecipients
#  @description Telegram API type InputBusinessBotRecipients
#  @export
#  @noRd
#  @noRd
InputBusinessBotRecipients <- R6::R6Class(
  "InputBusinessBotRecipients",
  public = list(
    #  @field existing_chats Field.
    existing_chats = NULL,
    #  @field new_chats Field.
    new_chats = NULL,
    #  @field contacts Field.
    contacts = NULL,
    #  @field non_contacts Field.
    non_contacts = NULL,
    #  @field exclude_selected Field.
    exclude_selected = NULL,
    #  @field users Field.
    users = NULL,
    #  @field exclude_users Field.
    exclude_users = NULL,
    initialize = function(existing_chats = NULL, new_chats = NULL, contacts = NULL, non_contacts = NULL, exclude_selected = NULL, users = NULL, exclude_users = NULL) {
      self$existing_chats <- existing_chats
      self$new_chats <- new_chats
      self$contacts <- contacts
      self$non_contacts <- non_contacts
      self$exclude_selected <- exclude_selected
      self$users <- users
      self$exclude_users <- exclude_users
    },
    to_list = function() {
      list(
        "_" = "InputBusinessBotRecipients",
        existing_chats = self$existing_chats,
        new_chats = self$new_chats,
        contacts = self$contacts,
        non_contacts = self$non_contacts,
        exclude_selected = self$exclude_selected,
        users = if (is.null(self$users)) list() else lapply(self$users, function(x) if (inherits(x, "R6")) x$to_list() else x),
        exclude_users = if (is.null(self$exclude_users)) list() else lapply(self$exclude_users, function(x) if (inherits(x, "R6")) x$to_list() else x)
      )
    },
    bytes = function() {
      flags <- 0
      if (!is.null(self$existing_chats) && self$existing_chats) flags <- bitwOr(flags, 1)
      if (!is.null(self$new_chats) && self$new_chats) flags <- bitwOr(flags, 2)
      if (!is.null(self$contacts) && self$contacts) flags <- bitwOr(flags, 4)
      if (!is.null(self$non_contacts) && self$non_contacts) flags <- bitwOr(flags, 8)
      if (!is.null(self$exclude_selected) && self$exclude_selected) flags <- bitwOr(flags, 32)
      if (!is.null(self$users)) flags <- bitwOr(flags, 16)
      if (!is.null(self$exclude_users)) flags <- bitwOr(flags, 64)

      c(
        as.raw(0x1e), as.raw(0x92), as.raw(0xe5), as.raw(0xc4),
        writeBin(as.integer(flags), raw(), size = 4),
        if (!is.null(self$users)) {
          c(
            as.raw(0x15), as.raw(0xc4), as.raw(0xb5), as.raw(0x1c),
            writeBin(as.integer(length(self$users)), raw(), size = 4),
            unlist(lapply(self$users, function(x) x$bytes()))
          )
        } else {
          raw()
        },
        if (!is.null(self$exclude_users)) {
          c(
            as.raw(0x15), as.raw(0xc4), as.raw(0xb5), as.raw(0x1c),
            writeBin(as.integer(length(self$exclude_users)), raw(), size = 4),
            unlist(lapply(self$exclude_users, function(x) x$bytes()))
          )
        } else {
          raw()
        }
      )
    }
  )
)

#  @title InputBusinessChatLink
#  @description Telegram API type InputBusinessChatLink
#  @export
#  @noRd
#  @noRd
InputBusinessChatLink <- R6::R6Class(
  "InputBusinessChatLink",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x11679fa7,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xab670513,
    #  @field message Field.
    message = NULL,
    #  @field entities Field.
    entities = NULL,
    #  @field title Field.
    title = NULL,
    initialize = function(message, entities = NULL, title = NULL) {
      self$message <- message
      self$entities <- entities
      self$title <- title
    },
    to_dict = function() {
      list(
        "_" = "InputBusinessChatLink",
        message = self$message,
        entities = if (is.null(self$entities)) list() else lapply(self$entities, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        title = self$title
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xa7, 0x9f, 0x67, 0x11)),
        as.raw(bitwOr(if (is.null(self$entities)) 0 else 1, if (is.null(self$title)) 0 else 2)),
        serialize_bytes(self$message),
        if (is.null(self$entities)) raw() else c(as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), writeBin(length(self$entities), raw(), size = 4), unlist(lapply(self$entities, function(x) x$bytes()))),
        if (is.null(self$title)) raw() else serialize_bytes(self$title)
      )
    }
  )
)

#  @title InputBusinessGreetingMessage
#  @description Telegram API type InputBusinessGreetingMessage
#  @export
#  @noRd
#  @noRd
InputBusinessGreetingMessage <- R6::R6Class(
  "InputBusinessGreetingMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x194cb3b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x6278dcdd,
    #  @field shortcut_id Field.
    shortcut_id = NULL,
    #  @field recipients Field.
    recipients = NULL,
    #  @field no_activity_days Field.
    no_activity_days = NULL,
    initialize = function(shortcut_id, recipients, no_activity_days) {
      self$shortcut_id <- shortcut_id
      self$recipients <- recipients
      self$no_activity_days <- no_activity_days
    },
    to_dict = function() {
      list(
        "_" = "InputBusinessGreetingMessage",
        shortcut_id = self$shortcut_id,
        recipients = if (inherits(self$recipients, "TLObject")) self$recipients$to_dict() else self$recipients,
        no_activity_days = self$no_activity_days
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x3b, 0xcb, 0x94, 0x01)),
        writeBin(self$shortcut_id, raw(), size = 4),
        self$recipients$bytes(),
        writeBin(self$no_activity_days, raw(), size = 4)
      )
    }
  )
)

#  @title InputBusinessIntro
#  @description Telegram API type InputBusinessIntro
#  @export
#  @noRd
#  @noRd
InputBusinessIntro <- R6::R6Class(
  "InputBusinessIntro",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9c469cd,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x645a767d,
    #  @field title Field.
    title = NULL,
    #  @field description Field.
    description = NULL,
    #  @field sticker Field.
    sticker = NULL,
    initialize = function(title, description, sticker = NULL) {
      self$title <- title
      self$description <- description
      self$sticker <- sticker
    },
    to_dict = function() {
      list(
        "_" = "InputBusinessIntro",
        title = self$title,
        description = self$description,
        sticker = if (inherits(self$sticker, "TLObject")) self$sticker$to_list() else self$sticker
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xcd, 0x69, 0xc4, 0x09)),
        as.raw(if (is.null(self$sticker) || self$sticker == FALSE) 0 else 1),
        self$serialize_bytes(self$title),
        self$serialize_bytes(self$description),
        if (is.null(self$sticker) || self$sticker == FALSE) raw() else self$sticker$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      title <- reader$tgread_string()
      description <- reader$tgread_string()
      sticker <- if (bitwAnd(flags, 1)) reader$tgread_object() else NULL

      self$new(title = title, description = description, sticker = sticker)
    }
  )
)

#  @title InputBusinessRecipients
#  @description Telegram API type InputBusinessRecipients
#  @export
#  @noRd
#  @noRd
InputBusinessRecipients <- R6::R6Class(
  "InputBusinessRecipients",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x6f8b32aa,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd7ee53f,
    #  @field existing_chats Field.
    existing_chats = NULL,
    #  @field new_chats Field.
    new_chats = NULL,
    #  @field contacts Field.
    contacts = NULL,
    #  @field non_contacts Field.
    non_contacts = NULL,
    #  @field exclude_selected Field.
    exclude_selected = NULL,
    #  @field users Field.
    users = NULL,
    initialize = function(existing_chats = NULL, new_chats = NULL, contacts = NULL, non_contacts = NULL, exclude_selected = NULL, users = NULL) {
      self$existing_chats <- existing_chats
      self$new_chats <- new_chats
      self$contacts <- contacts
      self$non_contacts <- non_contacts
      self$exclude_selected <- exclude_selected
      self$users <- users
    },
    to_dict = function() {
      list(
        "_" = "InputBusinessRecipients",
        existing_chats = self$existing_chats,
        new_chats = self$new_chats,
        contacts = self$contacts,
        non_contacts = self$non_contacts,
        exclude_selected = self$exclude_selected,
        users = if (is.null(self$users)) list() else lapply(self$users, function(x) if (inherits(x, "TLObject")) x$to_list() else x)
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xaa, 0x32, 0x8b, 0x6f)),
        as.raw(
          (if (is.null(self$existing_chats) || self$existing_chats == FALSE) 0 else 1) +
            (if (is.null(self$new_chats) || self$new_chats == FALSE) 0 else 2) +
            (if (is.null(self$contacts) || self$contacts == FALSE) 0 else 4) +
            (if (is.null(self$non_contacts) || self$non_contacts == FALSE) 0 else 8) +
            (if (is.null(self$exclude_selected) || self$exclude_selected == FALSE) 0 else 32) +
            (if (is.null(self$users) || self$users == FALSE) 0 else 16)
        ),
        if (is.null(self$users) || self$users == FALSE) {
          raw()
        } else {
          c(
            as.raw(c(0x15, 0xc4, 0xb5, 0x1c)),
            as.raw(length(self$users)),
            unlist(lapply(self$users, function(x) x$bytes()))
          )
        }
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      existing_chats <- bitwAnd(flags, 1) > 0
      new_chats <- bitwAnd(flags, 2) > 0
      contacts <- bitwAnd(flags, 4) > 0
      non_contacts <- bitwAnd(flags, 8) > 0
      exclude_selected <- bitwAnd(flags, 32) > 0

      users <- if (bitwAnd(flags, 16)) {
        reader$read_int()
        lapply(seq_len(reader$read_int()), function(.) reader$tgread_object())
      } else {
        NULL
      }

      self$new(
        existing_chats = existing_chats,
        new_chats = new_chats,
        contacts = contacts,
        non_contacts = non_contacts,
        exclude_selected = exclude_selected,
        users = users
      )
    }
  )
)

#  @title InputChannel
#  @description Telegram API type InputChannel
#  @export
#  @noRd
#  @noRd
InputChannel <- R6::R6Class(
  "InputChannel",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf35aec28,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x40f202fd,
    #  @field channel_id Field.
    channel_id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    initialize = function(channel_id, access_hash) {
      self$channel_id <- channel_id
      self$access_hash <- access_hash
    },
    to_dict = function() {
      list(
        "_" = "InputChannel",
        channel_id = self$channel_id,
        access_hash = self$access_hash
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x28, 0xec, 0x5a, 0xf3)),
        pack("q", self$channel_id),
        pack("q", self$access_hash)
      )
    }
  )
)

#  @title InputChannelEmpty
#  @description Telegram API type InputChannelEmpty
#  @export
#  @noRd
#  @noRd
InputChannelEmpty <- R6::R6Class(
  "InputChannelEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xee8c1e86,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x40f202fd,
    to_dict = function() {
      list("_" = "InputChannelEmpty")
    },
    bytes = function() {
      as.raw(c(0x86, 0x1e, 0x8c, 0xee))
    }
  )
)

#  @title InputChannelFromMessage
#  @description Telegram API type InputChannelFromMessage
#  @export
#  @noRd
#  @noRd
InputChannelFromMessage <- R6::R6Class(
  "InputChannelFromMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5b934f9d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x40f202fd,
    #  @field peer Field.
    peer = NULL,
    #  @field msg_id Field.
    msg_id = NULL,
    #  @field channel_id Field.
    channel_id = NULL,
    initialize = function(peer, msg_id, channel_id) {
      self$peer <- peer
      self$msg_id <- msg_id
      self$channel_id <- channel_id
    },
    to_dict = function() {
      list(
        "_" = "InputChannelFromMessage",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_list() else self$peer,
        msg_id = self$msg_id,
        channel_id = self$channel_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x9d, 0x4f, 0x93, 0x5b)),
        self$peer$bytes(),
        writeBin(as.integer(self$msg_id), raw(), size = 4, endian = "little"),
        writeBin(as.numeric(self$channel_id), raw(), size = 8, endian = "little")
      )
    }
  )
)

#  @title InputChatPhoto
#  @description Telegram API type InputChatPhoto
#  @export
#  @noRd
#  @noRd
InputChatPhoto <- R6::R6Class(
  "InputChatPhoto",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8953ad37,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd4eb2d74,
    #  @field id Field.
    id = NULL,
    initialize = function(id) {
      self$id <- id
    },
    to_dict = function() {
      list(
        "_" = "InputChatPhoto",
        id = if (inherits(self$id, "TLObject")) self$id$to_list() else self$id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x37, 0xad, 0x53, 0x89)),
        self$id$bytes()
      )
    }
  )
)

#  @title InputChatPhotoEmpty
#  @description Telegram API type InputChatPhotoEmpty
#  @export
#  @noRd
#  @noRd
InputChatPhotoEmpty <- R6::R6Class(
  "InputChatPhotoEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1ca48f57,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd4eb2d74,
    to_dict = function() {
      list("_" = "InputChatPhotoEmpty")
    },
    bytes = function() {
      as.raw(c(0x57, 0x8f, 0xa4, 0x1c))
    }
  )
)

#  @title InputChatTheme
#  @description Telegram API type InputChatTheme
#  @export
#  @noRd
#  @noRd
InputChatTheme <- R6::R6Class(
  "InputChatTheme",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc93de95c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x57294e64,
    #  @field emoticon Field.
    emoticon = NULL,
    initialize = function(emoticon) {
      self$emoticon <- emoticon
    },
    to_dict = function() {
      list("_" = "InputChatTheme", emoticon = self$emoticon)
    },
    bytes = function() {
      c(as.raw(c(0x5c, 0xe9, 0x3d, 0xc9)), charToRaw(self$emoticon))
    }
  )
)

#  @title InputChatThemeEmpty
#  @description Telegram API type InputChatThemeEmpty
#  @export
#  @noRd
#  @noRd
InputChatThemeEmpty <- R6::R6Class(
  "InputChatThemeEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x83268483,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x57294e64,
    to_dict = function() {
      list("_" = "InputChatThemeEmpty")
    },
    bytes = function() {
      as.raw(c(0x83, 0x84, 0x26, 0x83))
    }
  )
)

#  @title InputChatThemeUniqueGift
#  @description Telegram API type InputChatThemeUniqueGift
#  @export
#  @noRd
#  @noRd
InputChatThemeUniqueGift <- R6::R6Class(
  "InputChatThemeUniqueGift",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x87e5dfe4,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x57294e64,
    #  @field slug Field.
    slug = NULL,
    initialize = function(slug) {
      self$slug <- slug
    },
    to_dict = function() {
      list(
        "_" = "InputChatThemeUniqueGift",
        slug = self$slug
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xe4, 0xdf, 0xe5, 0x87)),
        serialize_bytes(self$slug)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      slug <- reader$tgread_string()
      self$new(slug = slug)
    }
  )
)

#  @title InputChatUploadedPhoto
#  @description Telegram API type InputChatUploadedPhoto
#  @export
#  @noRd
#  @noRd
InputChatUploadedPhoto <- R6::R6Class(
  "InputChatUploadedPhoto",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbdcdaec0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd4eb2d74,
    #  @field file Field.
    file = NULL,
    #  @field video Field.
    video = NULL,
    #  @field video_start_ts Field.
    video_start_ts = NULL,
    #  @field video_emoji_markup Field.
    video_emoji_markup = NULL,
    initialize = function(file = NULL, video = NULL, video_start_ts = NULL, video_emoji_markup = NULL) {
      self$file <- file
      self$video <- video
      self$video_start_ts <- video_start_ts
      self$video_emoji_markup <- video_emoji_markup
    },
    to_dict = function() {
      list(
        "_" = "InputChatUploadedPhoto",
        file = if (!is.null(self$file) && inherits(self$file, "TLObject")) self$file$to_dict() else self$file,
        video = if (!is.null(self$video) && inherits(self$video, "TLObject")) self$video$to_dict() else self$video,
        video_start_ts = self$video_start_ts,
        video_emoji_markup = if (!is.null(self$video_emoji_markup) && inherits(self$video_emoji_markup, "TLObject")) self$video_emoji_markup$to_dict() else self$video_emoji_markup
      )
    },
    bytes = function() {
      flags <- (if (!is.null(self$file)) 1 else 0) |
        (if (!is.null(self$video)) 2 else 0) |
        (if (!is.null(self$video_start_ts)) 4 else 0) |
        (if (!is.null(self$video_emoji_markup)) 8 else 0)

      c(
        as.raw(c(0xc0, 0xae, 0xcd, 0xbd)),
        pack_int(flags),
        if (!is.null(self$file)) self$file$bytes() else raw(0),
        if (!is.null(self$video)) self$video$bytes() else raw(0),
        if (!is.null(self$video_start_ts)) pack_double(self$video_start_ts) else raw(0),
        if (!is.null(self$video_emoji_markup)) self$video_emoji_markup$bytes() else raw(0)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      file <- if (bitwAnd(flags, 1)) reader$tgread_object() else NULL
      video <- if (bitwAnd(flags, 2)) reader$tgread_object() else NULL
      video_start_ts <- if (bitwAnd(flags, 4)) reader$read_double() else NULL
      video_emoji_markup <- if (bitwAnd(flags, 8)) reader$tgread_object() else NULL

      self$new(file = file, video = video, video_start_ts = video_start_ts, video_emoji_markup = video_emoji_markup)
    }
  )
)

#  @title InputChatlistDialogFilter
#  @description Telegram API type InputChatlistDialogFilter
#  @export
#  @noRd
#  @noRd
InputChatlistDialogFilter <- R6::R6Class(
  "InputChatlistDialogFilter",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf3e0da33,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x23f9659,
    #  @field filter_id Field.
    filter_id = NULL,
    initialize = function(filter_id) {
      self$filter_id <- filter_id
    },
    to_dict = function() {
      list(
        "_" = "InputChatlistDialogFilter",
        filter_id = self$filter_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x33, 0xda, 0xe0, 0xf3)),
        writeBin(as.integer(self$filter_id), raw(), size = 4, endian = "little")
      )
    }
  )
)

#  @title InputCheckPasswordEmpty
#  @description Telegram API type InputCheckPasswordEmpty
#  @export
#  @noRd
#  @noRd
InputCheckPasswordEmpty <- R6::R6Class(
  "InputCheckPasswordEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9880f658,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd41af560,
    to_dict = function() {
      list("_" = "InputCheckPasswordEmpty")
    },
    bytes = function() {
      as.raw(c(0x58, 0xf6, 0x80, 0x98))
    }
  )
)

#  @title InputCheckPasswordSRP
#  @description Telegram API type InputCheckPasswordSRP
#  @export
#  @noRd
#  @noRd
InputCheckPasswordSRP <- R6::R6Class(
  "InputCheckPasswordSRP",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd27ff082,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd41af560,
    #  @field srp_id Field.
    srp_id = NULL,
    #  @field A Field.
    A = NULL,
    #  @field M1 Field.
    M1 = NULL,
    initialize = function(srp_id, A, M1) {
      self$srp_id <- srp_id
      self$A <- A
      self$M1 <- M1
    },
    to_dict = function() {
      list(
        "_" = "InputCheckPasswordSRP",
        srp_id = self$srp_id,
        A = self$A,
        M1 = self$M1
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x82, 0xf0, 0x7f, 0xd2)),
        writeBin(as.numeric(self$srp_id), raw(), size = 8, endian = "little"),
        serialize_bytes(self$A),
        serialize_bytes(self$M1)
      )
    }
  )
)

#  @title InputClientProxy
#  @description Telegram API type InputClientProxy
#  @export
#  @noRd
#  @noRd
InputClientProxy <- R6::R6Class(
  "InputClientProxy",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x75588b3f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x91a4346,
    #  @field address Field.
    address = NULL,
    #  @field port Field.
    port = NULL,
    initialize = function(address, port) {
      self$address <- address
      self$port <- port
    },
    to_list = function() {
      list(
        "_" = "InputClientProxy",
        address = self$address,
        port = self$port
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x3f, 0x8b, 0x58, 0x75)),
        serialize_bytes(self$address),
        writeBin(as.integer(self$port), raw(), size = 4, endian = "little")
      )
    }
  )
)

#  @title InputCollectiblePhone
#  @description Telegram API type InputCollectiblePhone
#  @export
#  @noRd
#  @noRd
InputCollectiblePhone <- R6::R6Class(
  "InputCollectiblePhone",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa2e214a4,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x2a0f81eb,
    #  @field phone Field.
    phone = NULL,
    initialize = function(phone) {
      self$phone <- phone
    },
    to_list = function() {
      list(
        "_" = "InputCollectiblePhone",
        phone = self$phone
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xa4, 0x14, 0xe2, 0xa2)),
        serialize_bytes(self$phone)
      )
    }
  )
)

#  @title InputCollectibleUsername
#  @description Telegram API type InputCollectibleUsername
#  @export
#  @noRd
#  @noRd
InputCollectibleUsername <- R6::R6Class(
  "InputCollectibleUsername",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe39460a9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x2a0f81eb,
    #  @field username Field.
    username = NULL,
    initialize = function(username) {
      self$username <- username
    },
    to_list = function() {
      list(
        "_" = "InputCollectibleUsername",
        username = self$username
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xa9, 0x60, 0x94, 0xe3)),
        serialize_bytes(self$username)
      )
    }
  )
)

#  @title InputDialogPeer
#  @description Telegram API type InputDialogPeer
#  @export
#  @noRd
#  @noRd
InputDialogPeer <- R6::R6Class(
  "InputDialogPeer",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xfcaafeb7,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xa21c9795,
    #  @field peer Field.
    peer = NULL,
    initialize = function(peer) {
      self$peer <- peer
    },
    to_dict = function() {
      list(
        "_" = "InputDialogPeer",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xb7, 0xfe, 0xaa, 0xfc)),
        self$peer$bytes()
      )
    }
  )
)

#  @title InputDialogPeerFolder
#  @description Telegram API type InputDialogPeerFolder
#  @export
#  @noRd
#  @noRd
InputDialogPeerFolder <- R6::R6Class(
  "InputDialogPeerFolder",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x64600527,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xa21c9795,
    #  @field folder_id Field.
    folder_id = NULL,
    initialize = function(folder_id) {
      self$folder_id <- folder_id
    },
    to_dict = function() {
      list(
        "_" = "InputDialogPeerFolder",
        folder_id = self$folder_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x27, 0x05, 0x60, 0x64)),
        writeBin(as.integer(self$folder_id), raw(), size = 4, endian = "little")
      )
    }
  )
)

#  @title InputDocument
#  @description Telegram API type InputDocument
#  @export
#  @noRd
#  @noRd
InputDocument <- R6::R6Class(
  "InputDocument",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1abfb575,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf33fdb68,
    #  @field id Field.
    id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    #  @field file_reference Field.
    file_reference = NULL,
    initialize = function(id, access_hash, file_reference) {
      self$id <- id
      self$access_hash <- access_hash
      self$file_reference <- file_reference
    },
    to_list = function() {
      list(
        "_" = "InputDocument",
        id = self$id,
        access_hash = self$access_hash,
        file_reference = self$file_reference
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x75, 0xb5, 0xbf, 0x1a)),
        writeBin(self$id, raw(), size = 8, endian = "little"),
        writeBin(self$access_hash, raw(), size = 8, endian = "little"),
        self$serialize_bytes(self$file_reference)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      id <- reader$read_long()
      access_hash <- reader$read_long()
      file_reference <- reader$tgread_bytes()
      self$new(id = id, access_hash = access_hash, file_reference = file_reference)
    }
  )
)

#  @title InputDocumentEmpty
#  @description Telegram API type InputDocumentEmpty
#  @export
#  @noRd
#  @noRd
InputDocumentEmpty <- R6::R6Class(
  "InputDocumentEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x72f0eaae,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf33fdb68,
    to_list = function() {
      list("_" = "InputDocumentEmpty")
    },
    bytes = function() {
      as.raw(c(0xae, 0xea, 0xf0, 0x72))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$new()
    }
  )
)

#  @title InputDocumentFileLocation
#  @description Telegram API type InputDocumentFileLocation
#  @export
#  @noRd
#  @noRd
InputDocumentFileLocation <- R6::R6Class(
  "InputDocumentFileLocation",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbad07584,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1523d462,
    #  @field id Field.
    id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    #  @field file_reference Field.
    file_reference = NULL,
    #  @field thumb_size Field.
    thumb_size = NULL,
    initialize = function(id, access_hash, file_reference, thumb_size) {
      self$id <- id
      self$access_hash <- access_hash
      self$file_reference <- file_reference
      self$thumb_size <- thumb_size
    },
    to_list = function() {
      list(
        "_" = "InputDocumentFileLocation",
        id = self$id,
        access_hash = self$access_hash,
        file_reference = self$file_reference,
        thumb_size = self$thumb_size
      )
    },
    bytes = function() {
      coerce_raw <- function(x) {
        if (is.null(x)) return(raw(0))
        if (inherits(x, "raw_bytes")) return(as.raw(x))
        if (is.raw(x)) return(x)
        if (is.list(x)) {
          if (length(x) == 1) return(coerce_raw(x[[1]]))
          if (all(vapply(x, is.raw, logical(1)))) return(do.call(c, x))
          if (all(vapply(x, is.integer, logical(1)))) return(as.raw(unlist(x, use.names = FALSE)))
          if (all(vapply(x, is.numeric, logical(1)))) return(as.raw(as.integer(unlist(x, use.names = FALSE))))
        }
        if (is.character(x)) return(charToRaw(x))
        if (is.integer(x)) return(as.raw(x))
        if (is.numeric(x)) return(as.raw(as.integer(x)))
        stop("file_reference must be raw or character")
      }
      ref <- coerce_raw(self$file_reference)
      thumb <- if (is.null(self$thumb_size)) "" else self$thumb_size
      c(
        as.raw(c(0x84, 0x75, 0xd0, 0xba)),
        pack("q", self$id),
        pack("q", self$access_hash),
        self$serialize_bytes(ref),
        self$serialize_bytes(thumb)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      id <- reader$read_long()
      access_hash <- reader$read_long()
      file_reference <- reader$tgread_bytes()
      thumb_size <- reader$tgread_string()
      self$new(id = id, access_hash = access_hash, file_reference = file_reference, thumb_size = thumb_size)
    }
  )
)

#  @title InputEmojiStatusCollectible
#  @description Telegram API type InputEmojiStatusCollectible
#  @export
#  @noRd
#  @noRd
InputEmojiStatusCollectible <- R6::R6Class(
  "InputEmojiStatusCollectible",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7141dbf,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf930b138,
    #  @field collectible_id Field.
    collectible_id = NULL,
    #  @field until Field.
    until = NULL,
    initialize = function(collectible_id, until = NULL) {
      self$collectible_id <- collectible_id
      self$until <- until
    },
    to_dict = function() {
      list(
        "_" = "InputEmojiStatusCollectible",
        collectible_id = self$collectible_id,
        until = self$until
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xbf, 0x1d, 0x14, 0x07)),
        as.raw(if (is.null(self$until) || !self$until) 0 else 1),
        writeBin(as.integer64(self$collectible_id), raw(), size = 8),
        if (is.null(self$until) || !self$until) raw() else self$serialize_datetime(self$until)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      collectible_id <- reader$read_long()
      until <- if (bitwAnd(flags, 1) == 1) reader$tgread_date() else NULL
      self$new(collectible_id = collectible_id, until = until)
    }
  )
)


#  @title InputEncryptedChat
#  @description Telegram API type InputEncryptedChat
#  @export
#  @noRd
#  @noRd
InputEncryptedChat <- R6::R6Class(
  "InputEncryptedChat",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf141b5e1,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x6c7606c0,
    #  @field chat_id Field.
    chat_id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    initialize = function(chat_id, access_hash) {
      self$chat_id <- chat_id
      self$access_hash <- access_hash
    },
    to_list = function() {
      list(
        "_" = "InputEncryptedChat",
        chat_id = self$chat_id,
        access_hash = self$access_hash
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xe1, 0xb5, 0x41, 0xf1)),
        writeBin(as.integer(self$chat_id), raw(), size = 4, endian = "little"),
        writeBin(as.numeric(self$access_hash), raw(), size = 8, endian = "little")
      )
    }
  )
)

#  @title InputEncryptedFile
#  @description Telegram API type InputEncryptedFile
#  @export
#  @noRd
#  @noRd
InputEncryptedFile <- R6::R6Class(
  "InputEncryptedFile",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5a17b5e5,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8574c27a,
    #  @field id Field.
    id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    initialize = function(id, access_hash) {
      self$id <- id
      self$access_hash <- access_hash
    },
    to_list = function() {
      list(
        "_" = "InputEncryptedFile",
        id = self$id,
        access_hash = self$access_hash
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xe5, 0xb5, 0x17, 0x5a)),
        writeBin(as.numeric(self$id), raw(), size = 8, endian = "little"),
        writeBin(as.numeric(self$access_hash), raw(), size = 8, endian = "little")
      )
    }
  )
)

#  @title InputEncryptedFileBigUploaded
#  @description Telegram API type InputEncryptedFileBigUploaded
#  @export
#  @noRd
#  @noRd
InputEncryptedFileBigUploaded <- R6::R6Class(
  "InputEncryptedFileBigUploaded",
  public = list(
    #  @field id Field.
    id = NULL,
    #  @field parts Field.
    parts = NULL,
    #  @field key_fingerprint Field.
    key_fingerprint = NULL,
    initialize = function(id, parts, key_fingerprint) {
      self$id <- id
      self$parts <- parts
      self$key_fingerprint <- key_fingerprint
    },
    to_list = function() {
      list(
        "_" = "InputEncryptedFileBigUploaded",
        id = self$id,
        parts = self$parts,
        key_fingerprint = self$key_fingerprint
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xc8, 0x73, 0xc1, 0x2d)),
        writeBin(as.integer(self$id), raw(), size = 8, endian = "little"),
        writeBin(as.integer(self$parts), raw(), size = 4, endian = "little"),
        writeBin(as.integer(self$key_fingerprint), raw(), size = 4, endian = "little")
      )
    }
  )
)

#  @title InputEncryptedFileEmpty
#  @description Telegram API type InputEncryptedFileEmpty
#  @export
#  @noRd
#  @noRd
InputEncryptedFileEmpty <- R6::R6Class(
  "InputEncryptedFileEmpty",
  public = list(
    to_list = function() {
      list("_" = "InputEncryptedFileEmpty")
    },
    bytes = function() {
      as.raw(c(0x64, 0xc3, 0x37, 0x18))
    }
  )
)

#  @title InputEncryptedFileLocation
#  @description Telegram API type InputEncryptedFileLocation
#  @export
#  @noRd
#  @noRd
InputEncryptedFileLocation <- R6::R6Class(
  "InputEncryptedFileLocation",
  public = list(
    #  @field id Field.
    id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    initialize = function(id, access_hash) {
      self$id <- id
      self$access_hash <- access_hash
    },
    to_list = function() {
      list(
        "_" = "InputEncryptedFileLocation",
        id = self$id,
        access_hash = self$access_hash
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xf5, 0x23, 0x5d, 0x55)),
        writeBin(as.integer(self$id), raw(), size = 8, endian = "little"),
        writeBin(as.integer(self$access_hash), raw(), size = 8, endian = "little")
      )
    }
  )
)

#  @title InputEncryptedFileUploaded
#  @description Telegram API type InputEncryptedFileUploaded
#  @export
#  @noRd
#  @noRd
InputEncryptedFileUploaded <- R6::R6Class(
  "InputEncryptedFileUploaded",
  public = list(
    #  @field id Field.
    id = NULL,
    #  @field parts Field.
    parts = NULL,
    #  @field md5_checksum Field.
    md5_checksum = NULL,
    #  @field key_fingerprint Field.
    key_fingerprint = NULL,
    initialize = function(id, parts, md5_checksum, key_fingerprint) {
      self$id <- id
      self$parts <- parts
      self$md5_checksum <- md5_checksum
      self$key_fingerprint <- key_fingerprint
    },
    to_list = function() {
      list(
        "_" = "InputEncryptedFileUploaded",
        id = self$id,
        parts = self$parts,
        md5_checksum = self$md5_checksum,
        key_fingerprint = self$key_fingerprint
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x64, 0xbd, 0x03, 0x06)),
        writeBin(as.integer(self$id), raw(), size = 8, endian = "little"),
        writeBin(as.integer(self$parts), raw(), size = 4, endian = "little"),
        charToRaw(self$md5_checksum),
        writeBin(as.integer(self$key_fingerprint), raw(), size = 4, endian = "little")
      )
    }
  )
)

#  @title InputFile
#  @description Telegram API type InputFile
#  @export
#  @noRd
#  @noRd
InputFile <- R6::R6Class(
  "InputFile",
  public = list(
    #  @field id Field.
    id = NULL,
    #  @field parts Field.
    parts = NULL,
    #  @field name Field.
    name = NULL,
    #  @field md5_checksum Field.
    md5_checksum = NULL,
    initialize = function(id, parts, name, md5_checksum) {
      self$id <- id
      self$parts <- parts
      self$name <- name
      self$md5_checksum <- md5_checksum
    },
    to_list = function() {
      list(
        "_" = "InputFile",
        id = self$id,
        parts = self$parts,
        name = self$name,
        md5_checksum = self$md5_checksum
      )
    },
    bytes = function() {
      paste0(
        as.raw(c(0x7f, 0xf2, 0x2f, 0xf5)),
        serialize(self$id, NULL),
        serialize(self$parts, NULL),
        serialize(self$name, NULL),
        serialize(self$md5_checksum, NULL)
      )
    }
  )
)

#  @title InputFileBig
#  @description Telegram API type InputFileBig
#  @export
#  @noRd
#  @noRd
InputFileBig <- R6::R6Class(
  "InputFileBig",
  public = list(
    #  @field id Field.
    id = NULL,
    #  @field parts Field.
    parts = NULL,
    #  @field name Field.
    name = NULL,
    initialize = function(id, parts, name) {
      self$id <- id
      self$parts <- parts
      self$name <- name
    },
    to_list = function() {
      list(
        "_" = "InputFileBig",
        id = self$id,
        parts = self$parts,
        name = self$name
      )
    },
    bytes = function() {
      paste0(
        as.raw(c(0xb5, 0x0b, 0x4f, 0xfa)),
        serialize(self$id, NULL),
        serialize(self$parts, NULL),
        serialize(self$name, NULL)
      )
    }
  )
)

#  @title InputFileLocation
#  @description Telegram API type InputFileLocation
#  @export
#  @noRd
#  @noRd
InputFileLocation <- R6::R6Class(
  "InputFileLocation",
  public = list(
    #  @field volume_id Field.
    volume_id = NULL,
    #  @field local_id Field.
    local_id = NULL,
    #  @field secret Field.
    secret = NULL,
    #  @field file_reference Field.
    file_reference = NULL,
    initialize = function(volume_id, local_id, secret, file_reference) {
      self$volume_id <- volume_id
      self$local_id <- local_id
      self$secret <- secret
      self$file_reference <- file_reference
    },
    to_list = function() {
      list(
        "_" = "InputFileLocation",
        volume_id = self$volume_id,
        local_id = self$local_id,
        secret = self$secret,
        file_reference = self$file_reference
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xdf, 0xda, 0xab, 0xe1)),
        writeBin(as.integer(self$volume_id), raw(), size = 8),
        writeBin(as.integer(self$local_id), raw(), size = 4),
        writeBin(as.integer(self$secret), raw(), size = 8),
        charToRaw(self$file_reference)
      )
    }
  )
)

#  @title InputFileStoryDocument
#  @description Telegram API type InputFileStoryDocument
#  @export
#  @noRd
#  @noRd
InputFileStoryDocument <- R6::R6Class(
  "InputFileStoryDocument",
  public = list(
    #  @field id Field.
    id = NULL,
    initialize = function(id) {
      self$id <- id
    },
    to_list = function() {
      list(
        "_" = "InputFileStoryDocument",
        id = if (inherits(self$id, "R6")) self$id$to_list() else self$id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x62, 0xdc, 0x8b, 0x48)),
        self$id$bytes()
      )
    }
  )
)

#  @title InputFolderPeer
#  @description Telegram API type InputFolderPeer
#  @export
#  @noRd
#  @noRd
InputFolderPeer <- R6::R6Class(
  "InputFolderPeer",
  public = list(
    #  @field peer Field.
    peer = NULL,
    #  @field folder_id Field.
    folder_id = NULL,
    initialize = function(peer, folder_id) {
      self$peer <- peer
      self$folder_id <- folder_id
    },
    to_list = function() {
      list(
        "_" = "InputFolderPeer",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_list() else self$peer,
        folder_id = self$folder_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x96, 0xc2, 0xd2, 0xfb)),
        self$peer$bytes(),
        writeBin(as.integer(self$folder_id), raw(), size = 4, endian = "little")
      )
    }
  )
)

#  @title InputGameID
#  @description Telegram API type InputGameID
#  @export
#  @noRd
#  @noRd
InputGameID <- R6::R6Class(
  "InputGameID",
  public = list(
    #  @field id Field.
    id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    initialize = function(id, access_hash) {
      self$id <- id
      self$access_hash <- access_hash
    },
    to_list = function() {
      list(
        "_" = "InputGameID",
        id = self$id,
        access_hash = self$access_hash
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x77, 0x3e, 0x2c, 0x03)),
        writeBin(as.numeric(self$id), raw(), size = 8, endian = "little"),
        writeBin(as.numeric(self$access_hash), raw(), size = 8, endian = "little")
      )
    }
  )
)

#  @title InputGameShortName
#  @description Telegram API type InputGameShortName
#  @export
#  @noRd
#  @noRd
InputGameShortName <- R6::R6Class(
  "InputGameShortName",
  public = list(
    #  @field bot_id Field.
    bot_id = NULL,
    #  @field short_name Field.
    short_name = NULL,
    initialize = function(bot_id, short_name) {
      self$bot_id <- bot_id
      self$short_name <- short_name
    },
    to_list = function() {
      list(
        "_" = "InputGameShortName",
        bot_id = if (inherits(self$bot_id, "TLObject")) self$bot_id$to_list() else self$bot_id,
        short_name = self$short_name
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x0a, 0xe8, 0x31, 0xc3)),
        self$bot_id$bytes(),
        charToRaw(self$short_name)
      )
    }
  )
)

#  @title InputGeoPoint
#  @description Telegram API type InputGeoPoint
#  @export
#  @noRd
#  @noRd
InputGeoPoint <- R6::R6Class(
  "InputGeoPoint",
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x48222faf,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x430d225,
    #  @field lat Field.
    lat = NULL,
    #  @field long Field.
    long = NULL,
    #  @field accuracy_radius Field.
    accuracy_radius = NULL,
    initialize = function(lat, long, accuracy_radius = NULL) {
      self$lat <- lat
      self$long <- long
      self$accuracy_radius <- accuracy_radius
    },
    to_dict = function() {
      list(
        "_" = "InputGeoPoint",
        lat = self$lat,
        long = self$long,
        accuracy_radius = self$accuracy_radius
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xaf, 0x2f, 0x22, 0x48)),
        writeBin(as.integer(ifelse(is.null(self$accuracy_radius) || !self$accuracy_radius, 0, 1)), raw(), size = 4),
        writeBin(as.double(self$lat), raw(), size = 8),
        writeBin(as.double(self$long), raw(), size = 8),
        if (!is.null(self$accuracy_radius) && self$accuracy_radius) {
          writeBin(as.integer(self$accuracy_radius), raw(), size = 4)
        } else {
          raw()
        }
      )
    }
  )
)

#  @title InputGeoPointEmpty
#  @description Telegram API type InputGeoPointEmpty
#  @export
#  @noRd
#  @noRd
InputGeoPointEmpty <- R6::R6Class(
  "InputGeoPointEmpty",
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe4c123d6,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x430d225,
    to_dict = function() {
      list("_" = "InputGeoPointEmpty")
    },
    bytes = function() {
      as.raw(c(0xd6, 0x23, 0xc1, 0xe4))
    }
  )
)

#  @noRd
#  @noRd
InputGroupCall <- R6::R6Class(
  "InputGroupCall",
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd8aa840f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x58611ab1,
    #  @field id Field.
    id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    initialize = function(id, access_hash) {
      self$id <- id
      self$access_hash <- access_hash
    },
    to_dict = function() {
      list(
        "_" = "InputGroupCall",
        id = self$id,
        access_hash = self$access_hash
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x0f, 0x84, 0xaa, 0xd8)),
        writeBin(as.integer64(self$id), raw(), size = 8),
        writeBin(as.integer64(self$access_hash), raw(), size = 8)
      )
    }
  )
)

#  @title InputGroupCallInviteMessage
#  @description Telegram API type InputGroupCallInviteMessage
#  @export
#  @noRd
#  @noRd
InputGroupCallInviteMessage <- R6::R6Class(
  "InputGroupCallInviteMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8c10603f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x58611ab1,
    #  @field msg_id Field.
    msg_id = NULL,
    initialize = function(msg_id) {
      self$msg_id <- msg_id
    },
    to_dict = function() {
      list(
        "_" = "InputGroupCallInviteMessage",
        msg_id = self$msg_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x3f, 0x60, 0x10, 0x8c)),
        writeBin(as.integer(self$msg_id), raw(), size = 4, endian = "little")
      )
    }
  )
)

#  @title InputGroupCallSlug
#  @description Telegram API type InputGroupCallSlug
#  @export
#  @noRd
#  @noRd
InputGroupCallSlug <- R6::R6Class(
  "InputGroupCallSlug",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xfe06823f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x58611ab1,
    #  @field slug Field.
    slug = NULL,
    initialize = function(slug) {
      self$slug <- slug
    },
    to_dict = function() {
      list(
        "_" = "InputGroupCallSlug",
        slug = self$slug
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x3f, 0x82, 0x06, 0xfe)),
        charToRaw(self$slug)
      )
    }
  )
)

#  @title InputGroupCallStream
#  @description Telegram API type InputGroupCallStream
#  @export
#  @noRd
#  @noRd
InputGroupCallStream <- R6::R6Class(
  "InputGroupCallStream",
  public = list(
    #  @field call Field.
    call = NULL,
    #  @field time_ms Field.
    time_ms = NULL,
    #  @field scale Field.
    scale = NULL,
    #  @field video_channel Field.
    video_channel = NULL,
    #  @field video_quality Field.
    video_quality = NULL,
    initialize = function(call, time_ms, scale, video_channel = NULL, video_quality = NULL) {
      self$call <- call
      self$time_ms <- time_ms
      self$scale <- scale
      self$video_channel <- video_channel
      self$video_quality <- video_quality
    },
    to_list = function() {
      list(
        "_" = "InputGroupCallStream",
        call = if (inherits(self$call, "TLObject")) self$call$to_list() else self$call,
        time_ms = self$time_ms,
        scale = self$scale,
        video_channel = self$video_channel,
        video_quality = self$video_quality
      )
    },
    bytes = function() {
      stopifnot(
        (is.null(self$video_channel) && is.null(self$video_quality)) ||
          (!is.null(self$video_channel) && !is.null(self$video_quality))
      )
      c(
        as.raw(c(0x05, 0xA9, 0x98, 0x2A)),
        as.raw(ifelse(is.null(self$video_channel), 0, 1) | ifelse(is.null(self$video_quality), 0, 1)),
        self$call$bytes(),
        writeBin(self$time_ms, raw(), size = 8, endian = "little"),
        writeBin(self$scale, raw(), size = 4, endian = "little"),
        if (!is.null(self$video_channel)) writeBin(self$video_channel, raw(), size = 4, endian = "little") else raw(),
        if (!is.null(self$video_quality)) writeBin(self$video_quality, raw(), size = 4, endian = "little") else raw()
      )
    }
  )
)

#  @title InputInvoiceBusinessBotTransferStars
#  @description Telegram API type InputInvoiceBusinessBotTransferStars
#  @export
#  @noRd
#  @noRd
InputInvoiceBusinessBotTransferStars <- R6::R6Class(
  "InputInvoiceBusinessBotTransferStars",
  public = list(
    #  @field bot Field.
    bot = NULL,
    #  @field stars Field.
    stars = NULL,
    initialize = function(bot, stars) {
      self$bot <- bot
      self$stars <- stars
    },
    to_list = function() {
      list(
        "_" = "InputInvoiceBusinessBotTransferStars",
        bot = if (inherits(self$bot, "TLObject")) self$bot$to_list() else self$bot,
        stars = self$stars
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xF4, 0x99, 0x7E, 0x42)),
        self$bot$bytes(),
        writeBin(self$stars, raw(), size = 8, endian = "little")
      )
    }
  )
)

#  @title InputInvoiceChatInviteSubscription
#  @description Telegram API type InputInvoiceChatInviteSubscription
#  @export
#  @noRd
#  @noRd
InputInvoiceChatInviteSubscription <- R6::R6Class(
  "InputInvoiceChatInviteSubscription",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x34e793f1,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x726e9bfe,
    #  @field hash Field.
    hash = NULL,
    initialize = function(hash) {
      self$hash <- hash
    },
    to_dict = function() {
      list(
        "_" = "InputInvoiceChatInviteSubscription",
        hash = self$hash
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xf1, 0x93, 0xe7, 0x34)),
        serialize_bytes(self$hash)
      )
    }
  )
)

#  @title InputInvoiceMessage
#  @description Telegram API type InputInvoiceMessage
#  @export
#  @noRd
#  @noRd
InputInvoiceMessage <- R6::R6Class(
  "InputInvoiceMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc5b56859,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x726e9bfe,
    #  @field peer Field.
    peer = NULL,
    #  @field msg_id Field.
    msg_id = NULL,
    initialize = function(peer, msg_id) {
      self$peer <- peer
      self$msg_id <- msg_id
    },
    to_dict = function() {
      list(
        "_" = "InputInvoiceMessage",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        msg_id = self$msg_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x59, 0x68, 0xb5, 0xc5)),
        self$peer$bytes(),
        writeBin(as.integer(self$msg_id), raw(), size = 4, endian = "little")
      )
    }
  )
)

#  @title InputInvoicePremiumGiftCode
#  @description Telegram API type InputInvoicePremiumGiftCode
#  @export
#  @noRd
#  @noRd
InputInvoicePremiumGiftCode <- R6::R6Class(
  "InputInvoicePremiumGiftCode",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x98986c0d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x726e9bfe,
    #  @field purpose Field.
    purpose = NULL,
    #  @field option Field.
    option = NULL,
    initialize = function(purpose, option) {
      self$purpose <- purpose
      self$option <- option
    },
    to_dict = function() {
      list(
        "_" = "InputInvoicePremiumGiftCode",
        purpose = if (inherits(self$purpose, "TLObject")) self$purpose$to_dict() else self$purpose,
        option = if (inherits(self$option, "TLObject")) self$option$to_dict() else self$option
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x0d, 0x6c, 0x98, 0x98)),
        self$purpose$bytes(),
        self$option$bytes()
      )
    }
  )
)

#  @title InputInvoicePremiumGiftStars
#  @description Telegram API type InputInvoicePremiumGiftStars
#  @export
#  @noRd
#  @noRd
InputInvoicePremiumGiftStars <- R6::R6Class(
  "InputInvoicePremiumGiftStars",
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xdabab2ef,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x726e9bfe,
    #  @field user_id Field.
    user_id = NULL,
    #  @field months Field.
    months = NULL,
    #  @field message Field.
    message = NULL,
    initialize = function(user_id, months, message = NULL) {
      self$user_id <- user_id
      self$months <- months
      self$message <- message
    },
    to_dict = function() {
      list(
        "_" = "InputInvoicePremiumGiftStars",
        user_id = if (inherits(self$user_id, "TLObject")) self$user_id$to_dict() else self$user_id,
        months = self$months,
        message = if (inherits(self$message, "TLObject")) self$message$to_dict() else self$message
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xef, 0xb2, 0xba, 0xda)),
        as.raw(packBits(intToBits(if (is.null(self$message) || self$message == FALSE) 0 else 1))),
        self$user_id$bytes(),
        as.raw(packBits(intToBits(self$months))),
        if (is.null(self$message) || self$message == FALSE) raw() else self$message$bytes()
      )
    }
  )
)

#  @title InputInvoiceSlug
#  @description Telegram API type InputInvoiceSlug
#  @export
#  @noRd
#  @noRd
InputInvoiceSlug <- R6::R6Class(
  "InputInvoiceSlug",
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc326caef,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x726e9bfe,
    #  @field slug Field.
    slug = NULL,
    initialize = function(slug) {
      self$slug <- slug
    },
    to_dict = function() {
      list(
        "_" = "InputInvoiceSlug",
        slug = self$slug
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xef, 0xca, 0x26, 0xc3)),
        serialize_bytes(self$slug)
      )
    }
  )
)

#  @title InputInvoiceStarGift
#  @description Telegram API type InputInvoiceStarGift
#  @export
#  @noRd
#  @noRd
InputInvoiceStarGift <- R6::R6Class(
  "InputInvoiceStarGift",
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe8625e92,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x726e9bfe,
    #  @field peer Field.
    peer = NULL,
    #  @field gift_id Field.
    gift_id = NULL,
    #  @field hide_name Field.
    hide_name = NULL,
    #  @field include_upgrade Field.
    include_upgrade = NULL,
    #  @field message Field.
    message = NULL,
    initialize = function(peer, gift_id, hide_name = NULL, include_upgrade = NULL, message = NULL) {
      self$peer <- peer
      self$gift_id <- gift_id
      self$hide_name <- hide_name
      self$include_upgrade <- include_upgrade
      self$message <- message
    },
    to_list = function() {
      list(
        "_" = "InputInvoiceStarGift",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_list() else self$peer,
        gift_id = self$gift_id,
        hide_name = self$hide_name,
        include_upgrade = self$include_upgrade,
        message = if (inherits(self$message, "TLObject")) self$message$to_list() else self$message
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x92, 0x5e, 0x62, 0xe8)),
        as.raw(Reduce(bitwOr, c(
          ifelse(is.null(self$hide_name) || !self$hide_name, 0, 1),
          ifelse(is.null(self$include_upgrade) || !self$include_upgrade, 0, 4),
          ifelse(is.null(self$message), 0, 2)
        ))),
        self$peer$bytes(),
        writeBin(as.integer64(self$gift_id), raw(), size = 8),
        if (!is.null(self$message)) self$message$bytes() else raw()
      )
    }
  )
)

#  @title InputInvoiceStarGiftPrepaidUpgrade
#  @description Telegram API type InputInvoiceStarGiftPrepaidUpgrade
#  @export
#  @noRd
#  @noRd
InputInvoiceStarGiftPrepaidUpgrade <- R6::R6Class(
  "InputInvoiceStarGiftPrepaidUpgrade",
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9a0b48b8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x726e9bfe,
    #  @field peer Field.
    peer = NULL,
    #  @field hash Field.
    hash = NULL,
    initialize = function(peer, hash) {
      self$peer <- peer
      self$hash <- hash
    },
    to_list = function() {
      list(
        "_" = "InputInvoiceStarGiftPrepaidUpgrade",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_list() else self$peer,
        hash = self$hash
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xb8, 0x48, 0x0b, 0x9a)),
        self$peer$bytes(),
        serialize_bytes(self$hash)
      )
    }
  )
)

#  @title InputInvoiceStarGiftResale
#  @description Telegram API type InputInvoiceStarGiftResale
#  @export
#  @noRd
#  @noRd
InputInvoiceStarGiftResale <- R6::R6Class(
  "InputInvoiceStarGiftResale",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc39f5324,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x726e9bfe,
    #  @field slug Field.
    slug = NULL,
    #  @field to_id Field.
    to_id = NULL,
    #  @field ton Field.
    ton = NULL,
    initialize = function(slug, to_id, ton = NULL) {
      self$slug <- slug
      self$to_id <- to_id
      self$ton <- ton
    },
    to_dict = function() {
      list(
        "_" = "InputInvoiceStarGiftResale",
        slug = self$slug,
        to_id = if (inherits(self$to_id, "TLObject")) self$to_id$to_dict() else self$to_id,
        ton = self$ton
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x24, 0x53, 0x9f, 0xc3)),
        as.raw(if (is.null(self$ton) || !self$ton) 0 else 1),
        serialize_bytes(self$slug),
        self$to_id$bytes()
      )
    }
  )
)

#  @title InputInvoiceStarGiftTransfer
#  @description Telegram API type InputInvoiceStarGiftTransfer
#  @export
#  @noRd
#  @noRd
InputInvoiceStarGiftTransfer <- R6::R6Class(
  "InputInvoiceStarGiftTransfer",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4a5f5bd9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x726e9bfe,
    #  @field stargift Field.
    stargift = NULL,
    #  @field to_id Field.
    to_id = NULL,
    initialize = function(stargift, to_id) {
      self$stargift <- stargift
      self$to_id <- to_id
    },
    to_dict = function() {
      list(
        "_" = "InputInvoiceStarGiftTransfer",
        stargift = if (inherits(self$stargift, "TLObject")) self$stargift$to_dict() else self$stargift,
        to_id = if (inherits(self$to_id, "TLObject")) self$to_id$to_dict() else self$to_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xd9, 0x5b, 0x5f, 0x4a)),
        self$stargift$bytes(),
        self$to_id$bytes()
      )
    }
  )
)

#  @title InputInvoiceStarGiftUpgrade
#  @description Telegram API type InputInvoiceStarGiftUpgrade
#  @export
#  @noRd
#  @noRd
InputInvoiceStarGiftUpgrade <- R6::R6Class(
  "InputInvoiceStarGiftUpgrade",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4d818d5d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x726e9bfe,
    #  @field stargift Field.
    stargift = NULL,
    #  @field keep_original_details Field.
    keep_original_details = NULL,
    initialize = function(stargift, keep_original_details = NULL) {
      self$stargift <- stargift
      self$keep_original_details <- keep_original_details
    },
    to_dict = function() {
      list(
        "_" = "InputInvoiceStarGiftUpgrade",
        stargift = if (inherits(self$stargift, "TLObject")) self$stargift$to_dict() else self$stargift,
        keep_original_details = self$keep_original_details
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x5d, 0x8d, 0x81, 0x4d)),
        as.raw(if (is.null(self$keep_original_details) || !self$keep_original_details) 0 else 1),
        self$stargift$bytes()
      )
    }
  )
)

#  @title InputInvoiceStars
#  @description Telegram API type InputInvoiceStars
#  @export
#  @noRd
#  @noRd
InputInvoiceStars <- R6::R6Class(
  "InputInvoiceStars",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x65f00ce3,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x726e9bfe,
    #  @field purpose Field.
    purpose = NULL,
    initialize = function(purpose) {
      self$purpose <- purpose
    },
    to_dict = function() {
      list(
        "_" = "InputInvoiceStars",
        purpose = if (inherits(self$purpose, "TLObject")) self$purpose$to_dict() else self$purpose
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xe3, 0x0c, 0xf0, 0x65)),
        self$purpose$bytes()
      )
    }
  )
)

#  @title InputKeyboardButtonRequestPeer
#  @description Telegram API type InputKeyboardButtonRequestPeer
#  @export
#  @noRd
#  @noRd
InputKeyboardButtonRequestPeer <- R6::R6Class(
  "InputKeyboardButtonRequestPeer",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc9662d05,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    #  @field text Field.
    text = NULL,
    #  @field button_id Field.
    button_id = NULL,
    #  @field peer_type Field.
    peer_type = NULL,
    #  @field max_quantity Field.
    max_quantity = NULL,
    #  @field name_requested Field.
    name_requested = NULL,
    #  @field username_requested Field.
    username_requested = NULL,
    #  @field photo_requested Field.
    photo_requested = NULL,
    initialize = function(text, button_id, peer_type, max_quantity, name_requested = NULL, username_requested = NULL, photo_requested = NULL) {
      self$text <- text
      self$button_id <- button_id
      self$peer_type <- peer_type
      self$max_quantity <- max_quantity
      self$name_requested <- name_requested
      self$username_requested <- username_requested
      self$photo_requested <- photo_requested
    },
    to_list = function() {
      list(
        "_" = "InputKeyboardButtonRequestPeer",
        text = self$text,
        button_id = self$button_id,
        peer_type = if (inherits(self$peer_type, "TLObject")) self$peer_type$to_list() else self$peer_type,
        max_quantity = self$max_quantity,
        name_requested = self$name_requested,
        username_requested = self$username_requested,
        photo_requested = self$photo_requested
      )
    },
    bytes = function() {
      c(
        as.raw(0x05), as.raw(0x2d), as.raw(0x66), as.raw(0xc9),
        as.raw((if (is.null(self$name_requested) || !self$name_requested) 0 else 1) |
          (if (is.null(self$username_requested) || !self$username_requested) 0 else 2) |
          (if (is.null(self$photo_requested) || !self$photo_requested) 0 else 4)),
        serialize_bytes(self$text),
        writeBin(as.integer(self$button_id), raw(), size = 4),
        self$peer_type$bytes(),
        writeBin(as.integer(self$max_quantity), raw(), size = 4)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      name_requested <- as.logical(bitwAnd(flags, 1))
      username_requested <- as.logical(bitwAnd(flags, 2))
      photo_requested <- as.logical(bitwAnd(flags, 4))
      text <- reader$tgread_string()
      button_id <- reader$read_int()
      peer_type <- reader$tgread_object()
      max_quantity <- reader$read_int()

      self$new(
        text = text,
        button_id = button_id,
        peer_type = peer_type,
        max_quantity = max_quantity,
        name_requested = name_requested,
        username_requested = username_requested,
        photo_requested = photo_requested
      )
    }
  )
)

#  @title InputKeyboardButtonUrlAuth
#  @description Telegram API type InputKeyboardButtonUrlAuth
#  @export
#  @noRd
#  @noRd
InputKeyboardButtonUrlAuth <- R6::R6Class(
  "InputKeyboardButtonUrlAuth",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd02e7fd4,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    #  @field text Field.
    text = NULL,
    #  @field url Field.
    url = NULL,
    #  @field bot Field.
    bot = NULL,
    #  @field request_write_access Field.
    request_write_access = NULL,
    #  @field fwd_text Field.
    fwd_text = NULL,
    initialize = function(text, url, bot, request_write_access = NULL, fwd_text = NULL) {
      self$text <- text
      self$url <- url
      self$bot <- bot
      self$request_write_access <- request_write_access
      self$fwd_text <- fwd_text
    },
    to_dict = function() {
      list(
        "_" = "InputKeyboardButtonUrlAuth",
        text = self$text,
        url = self$url,
        bot = if (inherits(self$bot, "TLObject")) self$bot$to_dict() else self$bot,
        request_write_access = self$request_write_access,
        fwd_text = self$fwd_text
      )
    },
    bytes = function() {
      # Placeholder for byte serialization logic
      NULL
    }
  )
)

#  @title InputKeyboardButtonUserProfile
#  @description Telegram API type InputKeyboardButtonUserProfile
#  @export
#  @noRd
#  @noRd
InputKeyboardButtonUserProfile <- R6::R6Class(
  "InputKeyboardButtonUserProfile",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe988037b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    #  @field text Field.
    text = NULL,
    #  @field user_id Field.
    user_id = NULL,
    initialize = function(text, user_id) {
      self$text <- text
      self$user_id <- user_id
    },
    to_dict = function() {
      list(
        "_" = "InputKeyboardButtonUserProfile",
        text = self$text,
        user_id = if (inherits(self$user_id, "TLObject")) self$user_id$to_dict() else self$user_id
      )
    },
    bytes = function() {
      # Placeholder for byte serialization logic
      NULL
    }
  )
)

#  @title InputMediaAreaChannelPost
#  @description Telegram API type InputMediaAreaChannelPost
#  @export
#  @noRd
#  @noRd
InputMediaAreaChannelPost <- R6::R6Class(
  "InputMediaAreaChannelPost",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x2271f2bf,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf36d7bf2,
    #  @field coordinates Field.
    coordinates = NULL,
    #  @field channel Field.
    channel = NULL,
    #  @field msg_id Field.
    msg_id = NULL,
    initialize = function(coordinates, channel, msg_id) {
      self$coordinates <- coordinates
      self$channel <- channel
      self$msg_id <- msg_id
    },
    to_dict = function() {
      list(
        "_" = "InputMediaAreaChannelPost",
        coordinates = if (inherits(self$coordinates, "TLObject")) self$coordinates$to_dict() else self$coordinates,
        channel = if (inherits(self$channel, "TLObject")) self$channel$to_dict() else self$channel,
        msg_id = self$msg_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xbf, 0xf2, 0x71, 0x22)),
        self$coordinates$bytes(),
        self$channel$bytes(),
        writeBin(as.integer(self$msg_id), raw(), size = 4, endian = "little")
      )
    }
  )
)

#  @title InputMediaAreaVenue
#  @description Telegram API type InputMediaAreaVenue
#  @export
#  @noRd
#  @noRd
InputMediaAreaVenue <- R6::R6Class(
  "InputMediaAreaVenue",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb282217f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf36d7bf2,
    #  @field coordinates Field.
    coordinates = NULL,
    #  @field query_id Field.
    query_id = NULL,
    #  @field result_id Field.
    result_id = NULL,
    initialize = function(coordinates, query_id, result_id) {
      self$coordinates <- coordinates
      self$query_id <- query_id
      self$result_id <- result_id
    },
    to_dict = function() {
      list(
        "_" = "InputMediaAreaVenue",
        coordinates = if (inherits(self$coordinates, "TLObject")) self$coordinates$to_dict() else self$coordinates,
        query_id = self$query_id,
        result_id = self$result_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x7f, 0x21, 0x82, 0xb2)),
        self$coordinates$bytes(),
        writeBin(as.integer(self$query_id), raw(), size = 8, endian = "little"),
        serialize(self$result_id, NULL)
      )
    }
  )
)

#  @title InputMediaContact
#  @description Telegram API type InputMediaContact
#  @export
#  @noRd
#  @noRd
InputMediaContact <- R6::R6Class(
  "InputMediaContact",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf8ab7dfb,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xfaf846f4,
    #  @field phone_number Field.
    phone_number = NULL,
    #  @field first_name Field.
    first_name = NULL,
    #  @field last_name Field.
    last_name = NULL,
    #  @field vcard Field.
    vcard = NULL,
    initialize = function(phone_number, first_name, last_name, vcard) {
      self$phone_number <- phone_number
      self$first_name <- first_name
      self$last_name <- last_name
      self$vcard <- vcard
    },
    to_dict = function() {
      list(
        "_" = "InputMediaContact",
        phone_number = self$phone_number,
        first_name = self$first_name,
        last_name = self$last_name,
        vcard = self$vcard
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xfb, 0x7d, 0xab, 0xf8)),
        serialize_bytes(self$phone_number),
        serialize_bytes(self$first_name),
        serialize_bytes(self$last_name),
        serialize_bytes(self$vcard)
      )
    }
  )
)

#  @title InputMediaDice
#  @description Telegram API type InputMediaDice
#  @export
#  @noRd
#  @noRd
InputMediaDice <- R6::R6Class(
  "InputMediaDice",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe66fbf7b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xfaf846f4,
    #  @field emoticon Field.
    emoticon = NULL,
    initialize = function(emoticon) {
      self$emoticon <- emoticon
    },
    to_dict = function() {
      list(
        "_" = "InputMediaDice",
        emoticon = self$emoticon
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x7b, 0xbf, 0x6f, 0xe6)),
        serialize_bytes(self$emoticon)
      )
    }
  )
)

#  @title InputMediaDocument
#  @description Telegram API type InputMediaDocument
#  @export
#  @noRd
#  @noRd
InputMediaDocument <- R6::R6Class(
  "InputMediaDocument",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa8763ab5,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xfaf846f4,
    #  @field id Field.
    id = NULL,
    #  @field spoiler Field.
    spoiler = NULL,
    #  @field video_cover Field.
    video_cover = NULL,
    #  @field video_timestamp Field.
    video_timestamp = NULL,
    #  @field ttl_seconds Field.
    ttl_seconds = NULL,
    #  @field query Field.
    query = NULL,
    initialize = function(id, spoiler = NULL, video_cover = NULL, video_timestamp = NULL, ttl_seconds = NULL, query = NULL) {
      self$id <- id
      self$spoiler <- spoiler
      self$video_cover <- video_cover
      self$video_timestamp <- video_timestamp
      self$ttl_seconds <- ttl_seconds
      self$query <- query
    },
    to_dict = function() {
      list(
        "_" = "InputMediaDocument",
        id = if (inherits(self$id, "TLObject")) self$id$to_dict() else self$id,
        spoiler = self$spoiler,
        video_cover = if (inherits(self$video_cover, "TLObject")) self$video_cover$to_dict() else self$video_cover,
        video_timestamp = self$video_timestamp,
        ttl_seconds = self$ttl_seconds,
        query = self$query
      )
    },
    bytes = function() {
      flags <- (if (is.null(self$spoiler) || !self$spoiler) 0 else 4) |
        (if (is.null(self$video_cover) || !self$video_cover) 0 else 8) |
        (if (is.null(self$video_timestamp) || !self$video_timestamp) 0 else 16) |
        (if (is.null(self$ttl_seconds) || !self$ttl_seconds) 0 else 1) |
        (if (is.null(self$query) || !self$query) 0 else 2)

      c(
        as.raw(c(0xb5, 0x3a, 0x76, 0xa8)),
        writeBin(as.integer(flags), raw(), size = 4, endian = "little"),
        self$id$bytes(),
        if (!is.null(self$video_cover) && self$video_cover) self$video_cover$bytes() else raw(),
        if (!is.null(self$video_timestamp) && self$video_timestamp) writeBin(as.integer(self$video_timestamp), raw(), size = 4, endian = "little") else raw(),
        if (!is.null(self$ttl_seconds) && self$ttl_seconds) writeBin(as.integer(self$ttl_seconds), raw(), size = 4, endian = "little") else raw(),
        if (!is.null(self$query) && self$query) serialize_bytes(self$query) else raw()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      spoiler <- as.logical(bitwAnd(flags, 4))
      id <- reader$tgread_object()
      video_cover <- if (bitwAnd(flags, 8)) reader$tgread_object() else NULL
      video_timestamp <- if (bitwAnd(flags, 16)) reader$read_int() else NULL
      ttl_seconds <- if (bitwAnd(flags, 1)) reader$read_int() else NULL
      query <- if (bitwAnd(flags, 2)) reader$tgread_string() else NULL

      self$new(id = id, spoiler = spoiler, video_cover = video_cover, video_timestamp = video_timestamp, ttl_seconds = ttl_seconds, query = query)
    }
  )
)

#  @title InputMediaDocumentExternal
#  @description Telegram API type InputMediaDocumentExternal
#  @export
#  @noRd
#  @noRd
InputMediaDocumentExternal <- R6::R6Class(
  "InputMediaDocumentExternal",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x779600f9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xfaf846f4,
    #  @field url Field.
    url = NULL,
    #  @field spoiler Field.
    spoiler = NULL,
    #  @field ttl_seconds Field.
    ttl_seconds = NULL,
    #  @field video_cover Field.
    video_cover = NULL,
    #  @field video_timestamp Field.
    video_timestamp = NULL,
    initialize = function(url, spoiler = NULL, ttl_seconds = NULL, video_cover = NULL, video_timestamp = NULL) {
      self$url <- url
      self$spoiler <- spoiler
      self$ttl_seconds <- ttl_seconds
      self$video_cover <- video_cover
      self$video_timestamp <- video_timestamp
    },
    to_dict = function() {
      list(
        "_" = "InputMediaDocumentExternal",
        url = self$url,
        spoiler = self$spoiler,
        ttl_seconds = self$ttl_seconds,
        video_cover = if (is.null(self$video_cover)) NULL else (if (inherits(self$video_cover, "TLObject")) self$video_cover$to_list() else self$video_cover),
        video_timestamp = self$video_timestamp
      )
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  )
)

#  @title InputMediaEmpty
#  @description Telegram API type InputMediaEmpty
#  @export
#  @noRd
#  @noRd
InputMediaEmpty <- R6::R6Class(
  "InputMediaEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9664f57f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xfaf846f4,
    initialize = function() {
      # no fields
    },
    to_dict = function() {
      list("_" = "InputMediaEmpty")
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  )
)

#  @title InputMediaGame
#  @description Telegram API type InputMediaGame
#  @export
#  @noRd
#  @noRd
InputMediaGame <- R6::R6Class(
  "InputMediaGame",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd33f43f3,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xfaf846f4,
    #  @field id Field.
    id = NULL,
    initialize = function(id) {
      self$id <- id
    },
    to_dict = function() {
      list("_" = "InputMediaGame", id = if (inherits(self$id, "TLObject")) self$id$to_list() else self$id)
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  )
)

#  @title InputMediaGeoLive
#  @description Telegram API type InputMediaGeoLive
#  @export
#  @noRd
#  @noRd
InputMediaGeoLive <- R6::R6Class(
  "InputMediaGeoLive",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x971fa843,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xfaf846f4,
    #  @field geo_point Field.
    geo_point = NULL,
    #  @field stopped Field.
    stopped = NULL,
    #  @field heading Field.
    heading = NULL,
    #  @field period Field.
    period = NULL,
    #  @field proximity_notification_radius Field.
    proximity_notification_radius = NULL,
    initialize = function(geo_point, stopped = NULL, heading = NULL, period = NULL, proximity_notification_radius = NULL) {
      self$geo_point <- geo_point
      self$stopped <- stopped
      self$heading <- heading
      self$period <- period
      self$proximity_notification_radius <- proximity_notification_radius
    },
    to_dict = function() {
      list(
        "_" = "InputMediaGeoLive",
        geo_point = if (inherits(self$geo_point, "TLObject")) self$geo_point$to_list() else self$geo_point,
        stopped = self$stopped,
        heading = self$heading,
        period = self$period,
        proximity_notification_radius = self$proximity_notification_radius
      )
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  )
)

#  @title InputMediaGeoPoint
#  @description Telegram API type InputMediaGeoPoint
#  @export
#  @noRd
#  @noRd
InputMediaGeoPoint <- R6::R6Class(
  "InputMediaGeoPoint",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf9c44144,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xfaf846f4,
    #  @field geo_point Field.
    geo_point = NULL,
    initialize = function(geo_point) {
      self$geo_point <- geo_point
    },
    to_dict = function() {
      list(
        "_" = "InputMediaGeoPoint",
        geo_point = if (inherits(self$geo_point, "TLObject")) self$geo_point$to_list() else self$geo_point
      )
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  )
)

#  @title InputMediaInvoice
#  @description Telegram API type InputMediaInvoice
#  @export
#  @noRd
#  @noRd
InputMediaInvoice <- R6::R6Class(
  "InputMediaInvoice",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x405fef0d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xfaf846f4,
    #  @field title Field.
    title = NULL,
    #  @field description Field.
    description = NULL,
    #  @field invoice Field.
    invoice = NULL,
    #  @field payload Field.
    payload = NULL,
    #  @field providerdata Field.
    providerdata = NULL,
    #  @field photo Field.
    photo = NULL,
    #  @field provider Field.
    provider = NULL,
    #  @field start_param Field.
    start_param = NULL,
    #  @field extended_media Field.
    extended_media = NULL,
    initialize = function(title, description, invoice, payload, providerdata, photo = NULL, provider = NULL, start_param = NULL, extended_media = NULL) {
      self$title <- title
      self$description <- description
      self$invoice <- invoice
      self$payload <- payload
      self$providerdata <- providerdata
      self$photo <- photo
      self$provider <- provider
      self$start_param <- start_param
      self$extended_media <- extended_media
    },
    to_dict = function() {
      list(
        "_" = "InputMediaInvoice",
        title = self$title,
        description = self$description,
        invoice = if (inherits(self$invoice, "TLObject")) self$invoice$to_list() else self$invoice,
        payload = self$payload,
        providerdata = if (inherits(self$providerdata, "TLObject")) self$providerdata$to_list() else self$providerdata,
        photo = if (is.null(self$photo)) NULL else (if (inherits(self$photo, "TLObject")) self$photo$to_list() else self$photo),
        provider = self$provider,
        start_param = self$start_param,
        extended_media = if (is.null(self$extended_media)) NULL else (if (inherits(self$extended_media, "TLObject")) self$extended_media$to_list() else self$extended_media)
      )
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  )
)

#  @title InputMediaPaidMedia
#  @description Telegram API type InputMediaPaidMedia
#  @export
#  @noRd
#  @noRd
InputMediaPaidMedia <- R6::R6Class(
  "InputMediaPaidMedia",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc4103386,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xfaf846f4,
    #  @field stars_amount Field.
    stars_amount = NULL,
    #  @field extended_media Field.
    extended_media = NULL,
    #  @field payload Field.
    payload = NULL,
    initialize = function(stars_amount, extended_media, payload = NULL) {
      self$stars_amount <- stars_amount
      self$extended_media <- extended_media
      self$payload <- payload
    },
    to_dict = function() {
      list(
        "_" = "InputMediaPaidMedia",
        stars_amount = self$stars_amount,
        extended_media = if (is.null(self$extended_media)) NULL else lapply(self$extended_media, function(x) if (inherits(x, "TLObject")) x$to_list() else x),
        payload = self$payload
      )
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  )
)

#  @title InputMediaPhoto
#  @description Telegram API type InputMediaPhoto
#  @export
#  @noRd
#  @noRd
InputMediaPhoto <- R6::R6Class(
  "InputMediaPhoto",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb3ba0635,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xfaf846f4,
    #  @field id Field.
    id = NULL,
    #  @field spoiler Field.
    spoiler = NULL,
    #  @field ttl_seconds Field.
    ttl_seconds = NULL,
    initialize = function(id, spoiler = NULL, ttl_seconds = NULL) {
      self$id <- id
      self$spoiler <- spoiler
      self$ttl_seconds <- ttl_seconds
    },
    to_dict = function() {
      list(
        "_" = "InputMediaPhoto",
        id = if (inherits(self$id, "TLObject")) self$id$to_list() else self$id,
        spoiler = self$spoiler,
        ttl_seconds = self$ttl_seconds
      )
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  )
)

#  @title InputMediaPhotoExternal
#  @description Telegram API type InputMediaPhotoExternal
#  @export
#  @noRd
#  @noRd
InputMediaPhotoExternal <- R6::R6Class(
  "InputMediaPhotoExternal",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe5bbfe1a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xfaf846f4,
    #  @field url Field.
    url = NULL,
    #  @field spoiler Field.
    spoiler = NULL,
    #  @field ttl_seconds Field.
    ttl_seconds = NULL,
    initialize = function(url, spoiler = NULL, ttl_seconds = NULL) {
      self$url <- url
      self$spoiler <- spoiler
      self$ttl_seconds <- ttl_seconds
    },
    to_dict = function() {
      list(
        "_" = "InputMediaPhotoExternal",
        url = self$url,
        spoiler = self$spoiler,
        ttl_seconds = self$ttl_seconds
      )
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  )
)

#  @title InputMediaPoll
#  @description Telegram API type InputMediaPoll
#  @export
#  @noRd
#  @noRd
InputMediaPoll <- R6::R6Class(
  "InputMediaPoll",
  inherit = TLObject,
  public = list(
    CONSTRUCTOR_ID = 0x0f94e5f1, # keep as numeric constant (hex shown in python)
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xfaf846f4,
    #  @field poll Field.
    poll = NULL,
    #  @field correct_answers Field.
    correct_answers = NULL,
    #  @field solution Field.
    solution = NULL,
    #  @field solution_entities Field.
    solution_entities = NULL,
    initialize = function(poll, correct_answers = NULL, solution = NULL, solution_entities = NULL) {
      self$poll <- poll
      self$correct_answers <- correct_answers
      self$solution <- solution
      self$solution_entities <- solution_entities
    },
    to_dict = function() {
      list(
        "_" = "InputMediaPoll",
        poll = if (inherits(self$poll, "TLObject")) self$poll$to_list() else self$poll,
        correct_answers = if (is.null(self$correct_answers)) NULL else self$correct_answers,
        solution = self$solution,
        solution_entities = if (is.null(self$solution_entities)) NULL else lapply(self$solution_entities, function(x) if (inherits(x, "TLObject")) x$to_list() else x)
      )
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  )
)

#  @title InputMediaStory
#  @description Telegram API type InputMediaStory
#  @export
#  @noRd
#  @noRd
InputMediaStory <- R6::R6Class(
  "InputMediaStory",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x89fdd778,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xfaf846f4,
    #  @field peer Field.
    peer = NULL,
    #  @field id Field.
    id = NULL,
    initialize = function(peer, id) {
      self$peer <- peer
      self$id <- id
    },
    to_dict = function() {
      list(
        "_" = "InputMediaStory",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_list() else self$peer,
        id = self$id
      )
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  ),
  class = TRUE
)

#  @title InputMediaTodo
#  @description Telegram API type InputMediaTodo
#  @export
#  @noRd
#  @noRd
InputMediaTodo <- R6::R6Class(
  "InputMediaTodo",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9fc55fde,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xfaf846f4,
    #  @field todo Field.
    todo = NULL,
    initialize = function(todo) {
      self$todo <- todo
    },
    to_dict = function() {
      list(
        "_" = "InputMediaTodo",
        todo = if (inherits(self$todo, "TLObject")) self$todo$to_list() else self$todo
      )
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  ),
  class = TRUE
)

#  @title InputMediaUploadedDocument
#  @description Telegram API type InputMediaUploadedDocument
#  @export
#  @noRd
#  @noRd
InputMediaUploadedDocument <- R6::R6Class(
  "InputMediaUploadedDocument",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x037c9330,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xfaf846f4,
    #  @field file Field.
    file = NULL,
    #  @field mime_type Field.
    mime_type = NULL,
    #  @field attributes Field.
    attributes = NULL,
    #  @field nosound_video Field.
    nosound_video = NULL,
    #  @field force_file Field.
    force_file = NULL,
    #  @field spoiler Field.
    spoiler = NULL,
    #  @field thumb Field.
    thumb = NULL,
    #  @field stickers Field.
    stickers = NULL,
    #  @field video_cover Field.
    video_cover = NULL,
    #  @field video_timestamp Field.
    video_timestamp = NULL,
    #  @field ttl_seconds Field.
    ttl_seconds = NULL,
    initialize = function(file, mime_type, attributes,
                          nosound_video = NULL, force_file = NULL, spoiler = NULL,
                          thumb = NULL, stickers = NULL, video_cover = NULL,
                          video_timestamp = NULL, ttl_seconds = NULL) {
      self$file <- file
      self$mime_type <- mime_type
      self$attributes <- attributes
      self$nosound_video <- nosound_video
      self$force_file <- force_file
      self$spoiler <- spoiler
      self$thumb <- thumb
      self$stickers <- stickers
      self$video_cover <- video_cover
      self$video_timestamp <- video_timestamp
      self$ttl_seconds <- ttl_seconds
    },
    to_dict = function() {
      list(
        "_" = "InputMediaUploadedDocument",
        file = if (inherits(self$file, "TLObject")) self$file$to_list() else self$file,
        mime_type = self$mime_type,
        attributes = if (is.null(self$attributes)) list() else lapply(self$attributes, function(x) if (inherits(x, "TLObject")) x$to_list() else x),
        nosound_video = self$nosound_video,
        force_file = self$force_file,
        spoiler = self$spoiler,
        thumb = if (inherits(self$thumb, "TLObject")) self$thumb$to_list() else self$thumb,
        stickers = if (is.null(self$stickers)) list() else lapply(self$stickers, function(x) if (inherits(x, "TLObject")) x$to_list() else x),
        video_cover = if (inherits(self$video_cover, "TLObject")) self$video_cover$to_list() else self$video_cover,
        video_timestamp = self$video_timestamp,
        ttl_seconds = self$ttl_seconds
      )
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  ),
  class = TRUE
)

#  @title InputMediaUploadedPhoto
#  @description Telegram API type InputMediaUploadedPhoto
#  @export
#  @noRd
#  @noRd
InputMediaUploadedPhoto <- R6::R6Class(
  "InputMediaUploadedPhoto",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1e287d04,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xfaf846f4,
    #  @field file Field.
    file = NULL,
    #  @field spoiler Field.
    spoiler = NULL,
    #  @field stickers Field.
    stickers = NULL,
    #  @field ttl_seconds Field.
    ttl_seconds = NULL,
    initialize = function(file, spoiler = NULL, stickers = NULL, ttl_seconds = NULL) {
      self$file <- file
      self$spoiler <- spoiler
      self$stickers <- stickers
      self$ttl_seconds <- ttl_seconds
    },
    to_dict = function() {
      list(
        "_" = "InputMediaUploadedPhoto",
        file = if (inherits(self$file, "TLObject")) self$file$to_list() else self$file,
        spoiler = self$spoiler,
        stickers = if (is.null(self$stickers)) list() else lapply(self$stickers, function(x) if (inherits(x, "TLObject")) x$to_list() else x),
        ttl_seconds = self$ttl_seconds
      )
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  ),
  class = TRUE
)


#  @title InputMediaVenue
#  @description Telegram API type InputMediaVenue
#  @export
#  @noRd
#  @noRd
InputMediaVenue <- R6::R6Class("InputMediaVenue",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc13d1c11,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xfaf846f4,
    #  @field geo_point Field.
    geo_point = NULL,
    #  @field title Field.
    title = NULL,
    #  @field address Field.
    address = NULL,
    #  @field provider Field.
    provider = NULL,
    #  @field venue_id Field.
    venue_id = NULL,
    #  @field venue_type Field.
    venue_type = NULL,
    initialize = function(geo_point, title, address, provider, venue_id, venue_type) {
      self$geo_point <- geo_point
      self$title <- title
      self$address <- address
      self$provider <- provider
      self$venue_id <- venue_id
      self$venue_type <- venue_type
    },
    to_dict = function() {
      list(
        "_" = "InputMediaVenue",
        geo_point = if (inherits(self$geo_point, "TLObject")) self$geo_point$to_list() else self$geo_point,
        title = self$title,
        address = self$address,
        provider = self$provider,
        venue_id = self$venue_id,
        venue_type = self$venue_type
      )
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  ),
  class = TRUE
)

#  @title InputMediaWebPage
#  @description Telegram API type InputMediaWebPage
#  @export
#  @noRd
#  @noRd
InputMediaWebPage <- R6::R6Class("InputMediaWebPage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc21b8849,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xfaf846f4,
    #  @field url Field.
    url = NULL,
    #  @field force_large_media Field.
    force_large_media = NULL,
    #  @field force_small_media Field.
    force_small_media = NULL,
    #  @field optional Field.
    optional = NULL,
    initialize = function(url, force_large_media = NULL, force_small_media = NULL, optional = NULL) {
      self$url <- url
      self$force_large_media <- force_large_media
      self$force_small_media <- force_small_media
      self$optional <- optional
    },
    to_dict = function() {
      list(
        "_" = "InputMediaWebPage",
        url = self$url,
        force_large_media = self$force_large_media,
        force_small_media = self$force_small_media,
        optional = self$optional
      )
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  ),
  class = TRUE
)

#  @title InputMessageCallbackQuery
#  @description Telegram API type InputMessageCallbackQuery
#  @export
#  @noRd
#  @noRd
InputMessageCallbackQuery <- R6::R6Class("InputMessageCallbackQuery",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xacfa1a7e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x54b6bcc5,
    #  @field id Field.
    id = NULL,
    #  @field query_id Field.
    query_id = NULL,
    initialize = function(id, query_id) {
      self$id <- id
      self$query_id <- query_id
    },
    to_dict = function() {
      list("_" = "InputMessageCallbackQuery", id = self$id, query_id = self$query_id)
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  )
)

#  @title InputMessageEntityMentionName
#  @description Telegram API type InputMessageEntityMentionName
#  @export
#  @noRd
#  @noRd
InputMessageEntityMentionName <- R6::R6Class("InputMessageEntityMentionName",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x208e68c9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xcf6419dc,
    #  @field offset Field.
    offset = NULL,
    #  @field length Field.
    length = NULL,
    #  @field user_id Field.
    user_id = NULL,
    initialize = function(offset, length, user_id) {
      self$offset <- offset
      self$length <- length
      self$user_id <- user_id
    },
    to_dict = function() {
      list(
        "_" = "InputMessageEntityMentionName",
        offset = self$offset,
        length = self$length,
        user_id = if (inherits(self$user_id, "TLObject")) self$user_id$to_list() else self$user_id
      )
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  )
)

#  @title InputMessageID
#  @description Telegram API type InputMessageID
#  @export
#  @noRd
#  @noRd
InputMessageID <- R6::R6Class("InputMessageID",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa676a322,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x54b6bcc5,
    #  @field id Field.
    id = NULL,
    initialize = function(id) {
      self$id <- id
    },
    to_dict = function() {
      list("_" = "InputMessageID", id = self$id)
    },
    bytes = function() {
      c(
        as.raw(c(0x22, 0xa3, 0x76, 0xa6)),
        writeBin(as.integer(self$id), raw(), size = 4, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  )
)

#  @title InputMessagePinned
#  @description Telegram API type InputMessagePinned
#  @export
#  @noRd
#  @noRd
InputMessagePinned <- R6::R6Class("InputMessagePinned",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x86872538,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x54b6bcc5,
    initialize = function() {
      # no fields
    },
    to_dict = function() {
      list("_" = "InputMessagePinned")
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  )
)

#  @title InputMessageReplyTo
#  @description Telegram API type InputMessageReplyTo
#  @export
#  @noRd
#  @noRd
InputMessageReplyTo <- R6::R6Class("InputMessageReplyTo",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbad88395,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x54b6bcc5,
    #  @field id Field.
    id = NULL,
    initialize = function(id) {
      self$id <- id
    },
    to_dict = function() {
      list("_" = "InputMessageReplyTo", id = self$id)
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  )
)

#  @title InputMessagesFilterChatPhotos
#  @description Telegram API type InputMessagesFilterChatPhotos
#  @export
#  @noRd
#  @noRd
InputMessagesFilterChatPhotos <- R6::R6Class("InputMessagesFilterChatPhotos",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x3a20ecb8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8a36ec14,
    initialize = function() {},
    to_dict = function() {
      list("_" = "InputMessagesFilterChatPhotos")
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  )
)

#  @title InputMessagesFilterContacts
#  @description Telegram API type InputMessagesFilterContacts
#  @export
#  @noRd
#  @noRd
InputMessagesFilterContacts <- R6::R6Class("InputMessagesFilterContacts",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe062db83,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8a36ec14,
    initialize = function() {},
    to_dict = function() {
      list("_" = "InputMessagesFilterContacts")
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  )
)

#  @title InputMessagesFilterDocument
#  @description Telegram API type InputMessagesFilterDocument
#  @export
#  @noRd
#  @noRd
InputMessagesFilterDocument <- R6::R6Class("InputMessagesFilterDocument",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9eddf188,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8a36ec14,
    initialize = function() {},
    to_dict = function() {
      list("_" = "InputMessagesFilterDocument")
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  )
)

#  @title InputMessagesFilterEmpty
#  @description Telegram API type InputMessagesFilterEmpty
#  @export
#  @noRd
#  @noRd
InputMessagesFilterEmpty <- R6::R6Class("InputMessagesFilterEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x57e2f66c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8a36ec14,
    initialize = function() {},
    to_dict = function() {
      list("_" = "InputMessagesFilterEmpty")
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  )
)

#  @title InputMessagesFilterGeo
#  @description Telegram API type InputMessagesFilterGeo
#  @export
#  @noRd
#  @noRd
InputMessagesFilterGeo <- R6::R6Class("InputMessagesFilterGeo",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe7026d0d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8a36ec14,
    initialize = function() {},
    to_dict = function() {
      list("_" = "InputMessagesFilterGeo")
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  )
)

#  @title InputMessagesFilterGif
#  @description Telegram API type InputMessagesFilterGif
#  @export
#  @noRd
#  @noRd
InputMessagesFilterGif <- R6::R6Class("InputMessagesFilterGif",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xffc86587,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8a36ec14,
    initialize = function() {},
    to_dict = function() {
      list("_" = "InputMessagesFilterGif")
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  )
)

#  @title InputMessagesFilterMusic
#  @description Telegram API type InputMessagesFilterMusic
#  @export
#  @noRd
#  @noRd
InputMessagesFilterMusic <- R6::R6Class("InputMessagesFilterMusic",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x3751b49e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8a36ec14,
    initialize = function() {},
    to_dict = function() {
      list("_" = "InputMessagesFilterMusic")
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  )
)

#  @title InputMessagesFilterMyMentions
#  @description Telegram API type InputMessagesFilterMyMentions
#  @export
#  @noRd
#  @noRd
InputMessagesFilterMyMentions <- R6::R6Class("InputMessagesFilterMyMentions",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc1f8e69a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8a36ec14,
    initialize = function() {},
    to_dict = function() {
      list("_" = "InputMessagesFilterMyMentions")
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      NULL
    }
  )
)

#  @title InputMessagesFilterPhoneCalls
#  @description Telegram API type InputMessagesFilterPhoneCalls
#  @export
#  @noRd
#  @noRd
InputMessagesFilterPhoneCalls <- R6::R6Class(
  "InputMessagesFilterPhoneCalls",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x80c99768,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8a36ec14,
    #  @field missed Field.
    missed = NULL,
    initialize = function(missed = NULL) {
      self$missed <- missed
    },
    to_dict = function() {
      list("_" = "InputMessagesFilterPhoneCalls", missed = self$missed)
    },
    bytes = function() {
      NULL
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      missed <- bitwAnd(flags, 1) != 0
      return(self$initialize(missed = missed))
    }
  )
)

#  @title InputMessagesFilterPhotoVideo
#  @description Telegram API type InputMessagesFilterPhotoVideo
#  @export
#  @noRd
#  @noRd
InputMessagesFilterPhotoVideo <- R6::R6Class(
  "InputMessagesFilterPhotoVideo",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x56e9f0e4,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8a36ec14,
    to_dict = function() {
      list("_" = "InputMessagesFilterPhotoVideo")
    },
    bytes = function() {
      # Represent bytes as a raw vector
      raw_vector <- as.raw(c(0xe4, 0xf0, 0xe9, 0x56))
      return(raw_vector)
    }
  ),
  private = list(
    from_reader = function(reader) {
      return(self)
    }
  )
)

#  @title InputMessagesFilterPhotos
#  @description Telegram API type InputMessagesFilterPhotos
#  @export
#  @noRd
#  @noRd
InputMessagesFilterPhotos <- R6::R6Class(
  "InputMessagesFilterPhotos",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9609a51c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8a36ec14,
    to_dict = function() {
      list("_" = "InputMessagesFilterPhotos")
    },
    bytes = function() {
      as.raw(c(0x1c, 0xa5, 0x09, 0x96))
    }
  ),
  private = list(
    from_reader = function(reader) {
      return(self)
    }
  )
)

#  @title InputMessagesFilterPinned
#  @description Telegram API type InputMessagesFilterPinned
#  @export
#  @noRd
#  @noRd
InputMessagesFilterPinned <- R6::R6Class(
  "InputMessagesFilterPinned",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1bb00451,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8a36ec14,
    to_dict = function() {
      list("_" = "InputMessagesFilterPinned")
    },
    bytes = function() {
      as.raw(c(0x51, 0x04, 0xb0, 0x1b))
    }
  ),
  private = list(
    from_reader = function(reader) {
      return(self)
    }
  )
)

#  @title InputMessagesFilterRoundVideo
#  @description Telegram API type InputMessagesFilterRoundVideo
#  @export
#  @noRd
#  @noRd
InputMessagesFilterRoundVideo <- R6::R6Class(
  "InputMessagesFilterRoundVideo",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb549da53,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8a36ec14,
    to_dict = function() {
      list("_" = "InputMessagesFilterRoundVideo")
    },
    bytes = function() {
      as.raw(c(0x53, 0xda, 0x49, 0xb5))
    }
  ),
  private = list(
    from_reader = function(reader) {
      return(self)
    }
  )
)

#  @title InputMessagesFilterRoundVoice
#  @description Telegram API type InputMessagesFilterRoundVoice
#  @export
#  @noRd
#  @noRd
InputMessagesFilterRoundVoice <- R6::R6Class(
  "InputMessagesFilterRoundVoice",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7a7c17a4,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8a36ec14,
    to_dict = function() {
      list("_" = "InputMessagesFilterRoundVoice")
    },
    bytes = function() {
      as.raw(c(0xa4, 0x17, 0x7c, 0x7a))
    }
  ),
  private = list(
    from_reader = function(reader) {
      return(self)
    }
  )
)

#  @title InputMessagesFilterUrl
#  @description Telegram API type InputMessagesFilterUrl
#  @export
#  @noRd
#  @noRd
InputMessagesFilterUrl <- R6::R6Class(
  "InputMessagesFilterUrl",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7ef0dd87,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8a36ec14,
    to_dict = function() {
      list("_" = "InputMessagesFilterUrl")
    },
    bytes = function() {
      as.raw(c(0x87, 0xdd, 0xf0, 0x7e))
    }
  ),
  private = list(
    from_reader = function(reader) {
      return(self)
    }
  )
)

#  @title InputMessagesFilterVideo
#  @description Telegram API type InputMessagesFilterVideo
#  @export
#  @noRd
#  @noRd
InputMessagesFilterVideo <- R6::R6Class(
  "InputMessagesFilterVideo",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9fc00e65,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8a36ec14,
    to_dict = function() {
      list("_" = "InputMessagesFilterVideo")
    },
    bytes = function() {
      as.raw(c(0x65, 0x0e, 0xc0, 0x9f))
    }
  ),
  private = list(
    from_reader = function(reader) {
      return(self)
    }
  )
)

#  @title InputMessagesFilterVoice
#  @description Telegram API type InputMessagesFilterVoice
#  @export
#  @noRd
#  @noRd
InputMessagesFilterVoice <- R6::R6Class(
  "InputMessagesFilterVoice",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x50f5c392,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8a36ec14,
    to_dict = function() {
      list("_" = "InputMessagesFilterVoice")
    },
    bytes = function() {
      as.raw(c(0x92, 0xc3, 0xf5, 0x50))
    }
  ),
  private = list(
    from_reader = function(reader) {
      return(self)
    }
  )
)

#  @title InputNotifyBroadcasts
#  @description Telegram API type InputNotifyBroadcasts
#  @export
#  @noRd
#  @noRd
InputNotifyBroadcasts <- R6::R6Class(
  "InputNotifyBroadcasts",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb1db7c7e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x58981615,
    to_dict = function() {
      list("_" = "InputNotifyBroadcasts")
    },
    bytes = function() {
      as.raw(c(0x7e, 0x7c, 0xdb, 0xb1))
    }
  ),
  private = list(
    from_reader = function(reader) {
      return(self)
    }
  )
)

#  @title InputNotifyChats
#  @description Telegram API type InputNotifyChats
#  @export
#  @noRd
#  @noRd
InputNotifyChats <- R6::R6Class(
  "InputNotifyChats",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4a95e84e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x58981615,
    to_dict = function() {
      list("_" = "InputNotifyChats")
    },
    bytes = function() {
      as.raw(c(0x4e, 0xe8, 0x95, 0x4a))
    }
  ),
  private = list(
    from_reader = function(reader) {
      return(self)
    }
  )
)

#  @title InputNotifyForumTopic
#  @description Telegram API type InputNotifyForumTopic
#  @export
#  @noRd
#  @noRd
InputNotifyForumTopic <- R6::R6Class(
  "InputNotifyForumTopic",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5c467992,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x58981615,
    #  @field peer Field.
    peer = NULL,
    #  @field top_msg_id Field.
    top_msg_id = NULL,
    initialize = function(peer, top_msg_id) {
      self$peer <- peer
      self$top_msg_id <- top_msg_id
    },
    to_dict = function() {
      list("_" = "InputNotifyForumTopic", peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer, top_msg_id = self$top_msg_id)
    },
    bytes = function() {
      c(
        as.raw(c(0x92, 0x79, 0x46, 0x5C)),
        self$peer$bytes(),
        writeBin(as.integer(self$top_msg_id), raw(), size = 4, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      top_msg_id <- reader$read_int()
      return(self$initialize(peer = peer, top_msg_id = top_msg_id))
    }
  )
)

#  @title InputNotifyPeer
#  @description Telegram API type InputNotifyPeer
#  @export
#  @noRd
#  @noRd
InputNotifyPeer <- R6::R6Class(
  "InputNotifyPeer",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb8bc5b0c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x58981615,
    #  @field peer Field.
    peer = NULL,
    initialize = function(peer) {
      self$peer <- peer
    },
    to_dict = function() {
      list("_" = "InputNotifyPeer", peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer)
    },
    bytes = function() {
      c(
        as.raw(c(0x0c, 0x5b, 0xbc, 0xb8)),
        self$peer$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      return(self$initialize(peer = peer))
    }
  )
)

#  @title InputNotifyUsers
#  @description Telegram API type InputNotifyUsers
#  @export
#  @noRd
#  @noRd
InputNotifyUsers <- R6::R6Class(
  "InputNotifyUsers",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x193b4417,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x58981615,
    to_dict = function() {
      list("_" = "InputNotifyUsers")
    },
    bytes = function() {
      as.raw(c(0x17, 0x44, 0x3B, 0x19))
    }
  ),
  private = list(
    from_reader = function(reader) {
      return(self)
    }
  )
)

#  @title InputPaymentCredentials
#  @description Telegram API type InputPaymentCredentials
#  @export
#  @noRd
#  @noRd
InputPaymentCredentials <- R6::R6Class(
  "InputPaymentCredentials",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x3417d728,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x2899a53d,
    #  @field data Field.
    data = NULL,
    #  @field save Field.
    save = NULL,
    initialize = function(data, save = NULL) {
      self$data <- data
      self$save <- save
    },
    to_dict = function() {
      list("_" = "InputPaymentCredentials", data = if (inherits(self$data, "TLObject")) self$data$to_dict() else self$data, save = self$save)
    },
    bytes = function() {
      c(
        as.raw(0x28), as.raw(0xd7), as.raw(0x17), as.raw(0x34),
        as.raw(if (is.null(self$save) || !self$save) 0 else 1),
        self$data$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      save <- bitwAnd(flags, 1) != 0
      data <- reader$tgread_object()
      return(self$initialize(data = data, save = save))
    }
  )
)

#  @title InputPaymentCredentialsApplePay
#  @description Telegram API type InputPaymentCredentialsApplePay
#  @export
#  @noRd
#  @noRd
InputPaymentCredentialsApplePay <- R6::R6Class(
  "InputPaymentCredentialsApplePay",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xaa1c39f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x2899a53d,
    #  @field paymentdata Field.
    paymentdata = NULL,
    initialize = function(paymentdata) {
      self$paymentdata <- paymentdata
    },
    to_dict = function() {
      list("_" = "InputPaymentCredentialsApplePay", paymentdata = if (inherits(self$paymentdata, "TLObject")) self$paymentdata$to_dict() else self$paymentdata)
    },
    bytes = function() {
      c(
        as.raw(c(0x9f, 0xc3, 0xa1, 0x0a)),
        self$paymentdata$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      paymentdata <- reader$tgread_object()
      return(self$initialize(paymentdata = paymentdata))
    }
  )
)

#  @title InputPaymentCredentialsGooglePay
#  @description Telegram API type InputPaymentCredentialsGooglePay
#  @export
#  @noRd
#  @noRd
InputPaymentCredentialsGooglePay <- R6::R6Class(
  "InputPaymentCredentialsGooglePay",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8ac32801,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x2899a53d,
    #  @field payment_token Field.
    payment_token = NULL,
    initialize = function(payment_token) {
      self$payment_token <- payment_token
    },
    to_dict = function() {
      list("_" = "InputPaymentCredentialsGooglePay", payment_token = if (inherits(self$payment_token, "TLObject")) self$payment_token$to_dict() else self$payment_token)
    },
    bytes = function() {
      c(
        as.raw(0x01), as.raw(0x28), as.raw(0xc3), as.raw(0x8a),
        self$payment_token$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      payment_token <- reader$tgread_object()
      return(self$initialize(payment_token = payment_token))
    }
  )
)

#  @title InputPaymentCredentialsSaved
#  @description Telegram API type InputPaymentCredentialsSaved
#  @export
#  @noRd
#  @noRd
InputPaymentCredentialsSaved <- R6::R6Class(
  "InputPaymentCredentialsSaved",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc10eb2cf,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x2899a53d,
    #  @field id Field.
    id = NULL,
    #  @field tmp_password Field.
    tmp_password = NULL,
    initialize = function(id, tmp_password) {
      self$id <- id
      self$tmp_password <- tmp_password
    },
    to_dict = function() {
      list("_" = "InputPaymentCredentialsSaved", id = self$id, tmp_password = self$tmp_password)
    },
    bytes = function() {
      c(
        as.raw(0xcf), as.raw(0xb2), as.raw(0x0e), as.raw(0xc1),
        self$serializebytes(self$id),
        self$serializebytes(self$tmp_password)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      id <- reader$tgread_string()
      tmp_password <- reader$tgreadbytes()
      return(self$initialize(id = id, tmp_password = tmp_password))
    }
  )
)

#  @title InputPeerChannel
#  @description Telegram API type InputPeerChannel
#  @export
#  @noRd
#  @noRd
InputPeerChannel <- R6::R6Class(
  "InputPeerChannel",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x27bcbbfc,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc91c90b6,
    #  @field channel_id Field.
    channel_id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    initialize = function(channel_id, access_hash) {
      self$channel_id <- channel_id
      self$access_hash <- access_hash
    },
    to_dict = function() {
      list("_" = "InputPeerChannel", channel_id = self$channel_id, access_hash = self$access_hash)
    },
    bytes = function() {
      c(
        as.raw(0xfc), as.raw(0xbb), as.raw(0xbc), as.raw(0x27),
        pack("<q", self$channel_id),
        pack("<q", self$access_hash)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      channel_id <- reader$read_long()
      access_hash <- reader$read_long()
      return(self$initialize(channel_id = channel_id, access_hash = access_hash))
    }
  )
)

#  @title InputPeerChannelFromMessage
#  @description Telegram API type InputPeerChannelFromMessage
#  @export
#  @noRd
#  @noRd
InputPeerChannelFromMessage <- R6::R6Class(
  "InputPeerChannelFromMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbd2a0840,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc91c90b6,
    #  @field peer Field.
    peer = NULL,
    #  @field msg_id Field.
    msg_id = NULL,
    #  @field channel_id Field.
    channel_id = NULL,
    initialize = function(peer, msg_id, channel_id) {
      self$peer <- peer
      self$msg_id <- msg_id
      self$channel_id <- channel_id
    },
    to_dict = function() {
      list("_" = "InputPeerChannelFromMessage", peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer, msg_id = self$msg_id, channel_id = self$channel_id)
    },
    bytes = function() {
      c(
        as.raw(c(0x40, 0x08, 0x2A, 0xBD)),
        self$peer$bytes(),
        writeBin(as.integer(self$msg_id), raw(), size = 4, endian = "little"),
        writeBin(as.numeric(self$channel_id), raw(), size = 8, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      msg_id <- reader$read_int()
      channel_id <- reader$read_long()
      return(self$initialize(peer = peer, msg_id = msg_id, channel_id = channel_id))
    }
  )
)

#  @title InputPeerChat
#  @description Telegram API type InputPeerChat
#  @export
#  @noRd
#  @noRd
InputPeerChat <- R6::R6Class(
  "InputPeerChat",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x35a95cb9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc91c90b6,
    #  @field chat_id Field.
    chat_id = NULL,
    initialize = function(chat_id) {
      self$chat_id <- chat_id
    },
    to_dict = function() {
      list("_" = "InputPeerChat", chat_id = self$chat_id)
    },
    bytes = function() {
      c(
        as.raw(0xb9), as.raw(0x5c), as.raw(0xa9), as.raw(0x35),
        pack("<q", self$chat_id)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      chat_id <- reader$read_long()
      return(self$initialize(chat_id = chat_id))
    }
  )
)

#  @title InputPeerEmpty
#  @description Telegram API type InputPeerEmpty
#  @export
#  @noRd
#  @noRd
InputPeerEmpty <- R6::R6Class(
  "InputPeerEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7f3b18ea,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc91c90b6,
    to_dict = function() {
      list("_" = "InputPeerEmpty")
    },
    bytes = function() {
      as.raw(c(0xea, 0x18, 0x3b, 0x7f))
    }
  ),
  private = list(
    from_reader = function(reader) {
      return(self)
    }
  )
)

#  @title InputPeerNotifySettings
#  @description Telegram API type InputPeerNotifySettings
#  @export
#  @noRd
#  @noRd
InputPeerNotifySettings <- R6::R6Class(
  "InputPeerNotifySettings",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xcacb6ae2,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x90db0b0d,
    #  @field show_previews Field.
    show_previews = NULL,
    #  @field silent Field.
    silent = NULL,
    #  @field mute_until Field.
    mute_until = NULL,
    #  @field sound Field.
    sound = NULL,
    #  @field stories_muted Field.
    stories_muted = NULL,
    #  @field stories_hide_sender Field.
    stories_hide_sender = NULL,
    #  @field stories_sound Field.
    stories_sound = NULL,
    initialize = function(show_previews = NULL, silent = NULL, mute_until = NULL, sound = NULL, stories_muted = NULL, stories_hide_sender = NULL, stories_sound = NULL) {
      self$show_previews <- show_previews
      self$silent <- silent
      self$mute_until <- mute_until
      self$sound <- sound
      self$stories_muted <- stories_muted
      self$stories_hide_sender <- stories_hide_sender
      self$stories_sound <- stories_sound
    },
    to_dict = function() {
      list("_" = "InputPeerNotifySettings", show_previews = self$show_previews, silent = self$silent, mute_until = self$mute_until, sound = if (inherits(self$sound, "TLObject")) self$sound$to_dict() else self$sound, stories_muted = self$stories_muted, stories_hide_sender = self$stories_hide_sender, stories_sound = if (inherits(self$stories_sound, "TLObject")) self$stories_sound$to_dict() else self$stories_sound)
    },
    bytes = function() {
      rawdata <- c(
        as.raw(0xca), as.raw(0xcb), as.raw(0x6a), as.raw(0xe2),
        as.raw((ifelse(is.null(self$show_previews), 0, 1)) |
          (ifelse(is.null(self$silent), 0, 2)) |
          (ifelse(is.null(self$mute_until) || self$mute_until == FALSE, 0, 4)) |
          (ifelse(is.null(self$sound) || self$sound == FALSE, 0, 8)) |
          (ifelse(is.null(self$stories_muted), 0, 64)) |
          (ifelse(is.null(self$stories_hide_sender), 0, 128)) |
          (ifelse(is.null(self$stories_sound) || self$stories_sound == FALSE, 0, 256)))
      )

      if (!is.null(self$show_previews)) {
        rawdata <- c(rawdata, if (self$show_previews) as.raw(0x99) else as.raw(0xbc))
      }
      if (!is.null(self$silent)) {
        rawdata <- c(rawdata, if (self$silent) as.raw(0x99) else as.raw(0xbc))
      }
      if (!is.null(self$mute_until) && self$mute_until != FALSE) {
        rawdata <- c(rawdata, self$serialize_datetime(self$mute_until))
      }
      if (!is.null(self$sound) && self$sound != FALSE) {
        rawdata <- c(rawdata, self$sound$bytes())
      }
      if (!is.null(self$stories_muted)) {
        rawdata <- c(rawdata, if (self$stories_muted) as.raw(0x99) else as.raw(0xbc))
      }
      if (!is.null(self$stories_hide_sender)) {
        rawdata <- c(rawdata, if (self$stories_hide_sender) as.raw(0x99) else as.raw(0xbc))
      }
      if (!is.null(self$stories_sound) && self$stories_sound != FALSE) {
        rawdata <- c(rawdata, self$stories_sound$bytes())
      }

      rawdata
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      if (bitwAnd(flags, 1)) show_previews <- reader$tgread_bool() else show_previews <- NULL
      if (bitwAnd(flags, 2)) silent <- reader$tgread_bool() else silent <- NULL
      if (bitwAnd(flags, 4)) mute_until <- reader$tgread_date() else mute_until <- NULL
      if (bitwAnd(flags, 8)) sound <- reader$tgread_object() else sound <- NULL
      if (bitwAnd(flags, 64)) stories_muted <- reader$tgread_bool() else stories_muted <- NULL
      if (bitwAnd(flags, 128)) stories_hide_sender <- reader$tgread_bool() else stories_hide_sender <- NULL
      if (bitwAnd(flags, 256)) stories_sound <- reader$tgread_object() else stories_sound <- NULL
      return(self$initialize(show_previews = show_previews, silent = silent, mute_until = mute_until, sound = sound, stories_muted = stories_muted, stories_hide_sender = stories_hide_sender, stories_sound = stories_sound))
    }
  )
)

#  @title InputPeerPhotoFileLocation
#  @description Telegram API type InputPeerPhotoFileLocation
#  @export
#  @noRd
#  @noRd
InputPeerPhotoFileLocation <- R6::R6Class(
  "InputPeerPhotoFileLocation",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x37257e99,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1523d462,
    #  @field peer Field.
    peer = NULL,
    #  @field photo_id Field.
    photo_id = NULL,
    #  @field big Field.
    big = NULL,
    initialize = function(peer, photo_id, big = NULL) {
      self$peer <- peer
      self$photo_id <- photo_id
      self$big <- big
    },
    to_dict = function() {
      list("_" = "InputPeerPhotoFileLocation", peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer, photo_id = self$photo_id, big = self$big)
    },
    bytes = function() {
      c(
        as.raw(0x99), as.raw(0x7e), as.raw(0x25), as.raw(0x37),
        as.raw(if (is.null(self$big) || !self$big) 0 else 1),
        self$peer$bytes(),
        as.raw(bitwAnd(self$photo_id, 0xFF)),
        as.raw(bitwAnd(bitwShiftR(self$photo_id, 8), 0xFF)),
        as.raw(bitwAnd(bitwShiftR(self$photo_id, 16), 0xFF)),
        as.raw(bitwAnd(bitwShiftR(self$photo_id, 24), 0xFF)),
        as.raw(bitwAnd(bitwShiftR(self$photo_id, 32), 0xFF)),
        as.raw(bitwAnd(bitwShiftR(self$photo_id, 40), 0xFF)),
        as.raw(bitwAnd(bitwShiftR(self$photo_id, 48), 0xFF)),
        as.raw(bitwAnd(bitwShiftR(self$photo_id, 56), 0xFF))
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      big <- bitwAnd(flags, 1) != 0
      peer <- reader$tgread_object()
      photo_id <- reader$read_long()
      return(self$initialize(peer = peer, photo_id = photo_id, big = big))
    }
  )
)

#  @title InputPeerSelf
#  @description Telegram API type InputPeerSelf
#  @export
#  @noRd
#  @noRd
InputPeerSelf <- R6::R6Class(
  "InputPeerSelf",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7da07ec9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc91c90b6,
    to_dict = function() {
      list("_" = "InputPeerSelf")
    },
    bytes = function() {
      as.raw(c(0xc9, 0x7e, 0xa0, 0x7d))
    }
  ),
  private = list(
    from_reader = function(reader) {
      return(self)
    }
  )
)

#  @title InputPeerUser
#  @description Telegram API type InputPeerUser
#  @export
#  @noRd
#  @noRd
InputPeerUser <- R6::R6Class(
  "InputPeerUser",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xdde8a54c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc91c90b6,
    #  @field user_id Field.
    user_id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    initialize = function(user_id, access_hash) {
      self$user_id <- user_id
      self$access_hash <- access_hash
    },
    to_dict = function() {
      list("_" = "InputPeerUser", user_id = self$user_id, access_hash = self$access_hash)
    },
    bytes = function() {
      c(
        as.raw(0xdd), as.raw(0xe8), as.raw(0xa5), as.raw(0x4c),
        pack("<q", self$user_id),
        pack("<q", self$access_hash)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      user_id <- reader$read_long()
      access_hash <- reader$read_long()
      return(self$initialize(user_id = user_id, access_hash = access_hash))
    }
  )
)

#  @title InputPeerUserFromMessage
#  @description Telegram API type InputPeerUserFromMessage
#  @export
#  @noRd
#  @noRd
InputPeerUserFromMessage <- R6::R6Class(
  "InputPeerUserFromMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa87b0a1c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc91c90b6,
    initialize = function(peer, msg_id, user_id) {
      self$peer <- peer
      self$msg_id <- msg_id
      self$user_id <- user_id
    },
    to_dict = function() {
      list(
        "_" = "InputPeerUserFromMessage",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        msg_id = self$msg_id,
        user_id = self$user_id
      )
    },
    bytes = function() {
      c(as.raw(c(0x1c, 0x0a, 0x7b, 0xa8)), self$peer$bytes(), struct$pack("<i", self$msg_id), struct$pack("<q", self$user_id))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$peer <- reader$tgread_object()
      self$msg_id <- reader$read_int()
      self$user_id <- reader$read_long()
    }
  )
)

#  @title InputPhoneCall
#  @description Telegram API type InputPhoneCall
#  @export
#  @noRd
#  @noRd
InputPhoneCall <- R6::R6Class(
  "InputPhoneCall",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1e36fded,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbcaaf240,
    initialize = function(id, access_hash) {
      self$id <- id
      self$access_hash <- access_hash
    },
    to_dict = function() {
      list(
        "_" = "InputPhoneCall",
        id = self$id,
        access_hash = self$access_hash
      )
    },
    bytes = function() {
      c(as.raw(c(0xed, 0xfd, 0x36, 0x1e)), struct$pack("<q", self$id), struct$pack("<q", self$access_hash))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$id <- reader$read_long()
      self$access_hash <- reader$read_long()
    }
  )
)

#  @title InputPhoneContact
#  @description Telegram API type InputPhoneContact
#  @export
#  @noRd
#  @noRd
InputPhoneContact <- R6::R6Class(
  "InputPhoneContact",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf392b7f4,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xae696a82,
    initialize = function(client_id, phone, first_name, last_name) {
      self$client_id <- client_id
      self$phone <- phone
      self$first_name <- first_name
      self$last_name <- last_name
    },
    to_dict = function() {
      list(
        "_" = "InputPhoneContact",
        client_id = self$client_id,
        phone = self$phone,
        first_name = self$first_name,
        last_name = self$last_name
      )
    },
    bytes = function() {
      c(as.raw(c(0xf4, 0xb7, 0x92, 0xf3)), struct$pack("<q", self$client_id), self$serializebytes(self$phone), self$serializebytes(self$first_name), self$serializebytes(self$last_name))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$client_id <- reader$read_long()
      self$phone <- reader$tgread_string()
      self$first_name <- reader$tgread_string()
      self$last_name <- reader$tgread_string()
    }
  )
)

#  @title InputPhoto
#  @description Telegram API type InputPhoto
#  @export
#  @noRd
#  @noRd
InputPhoto <- R6::R6Class(
  "InputPhoto",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x3bb3b94a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x846363e0,
    initialize = function(id, access_hash, file_reference) {
      self$id <- id
      self$access_hash <- access_hash
      self$file_reference <- file_reference
    },
    to_dict = function() {
      list(
        "_" = "InputPhoto",
        id = self$id,
        access_hash = self$access_hash,
        file_reference = self$file_reference
      )
    },
    bytes = function() {
      c(as.raw(c(0x4a, 0xb9, 0xb3, 0x3b)), struct$pack("<q", self$id), struct$pack("<q", self$access_hash), self$serializebytes(self$file_reference))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$id <- reader$read_long()
      self$access_hash <- reader$read_long()
      self$file_reference <- reader$tgreadbytes()
    }
  )
)

#  @title InputPhotoEmpty
#  @description Telegram API type InputPhotoEmpty
#  @export
#  @noRd
#  @noRd
InputPhotoEmpty <- R6::R6Class(
  "InputPhotoEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1cd7bf0d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x846363e0,
    to_dict = function() {
      list("_" = "InputPhotoEmpty")
    },
    bytes = function() {
      as.raw(c(0x0d, 0xbf, 0xd7, 0x1c))
    }
  ),
  private = list(
    from_reader = function(reader) {
      # no fields
    }
  )
)

#  @title InputPhotoFileLocation
#  @description Telegram API type InputPhotoFileLocation
#  @export
#  @noRd
#  @noRd
InputPhotoFileLocation <- R6::R6Class(
  "InputPhotoFileLocation",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x40181ffe,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1523d462,
    #  @field id Field.
    id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    #  @field file_reference Field.
    file_reference = NULL,
    #  @field thumb_size Field.
    thumb_size = NULL,
    initialize = function(id, access_hash, file_reference, thumb_size) {
      self$id <- id
      self$access_hash <- access_hash
      self$file_reference <- file_reference
      self$thumb_size <- thumb_size
    },
    to_dict = function() {
      list(
        "_" = "InputPhotoFileLocation",
        id = self$id,
        access_hash = self$access_hash,
        file_reference = self$file_reference,
        thumb_size = self$thumb_size
      )
    },
    bytes = function() {
      coerce_raw <- function(x) {
        if (is.null(x)) return(raw(0))
        if (inherits(x, "raw_bytes")) return(as.raw(x))
        if (is.raw(x)) return(x)
        if (is.list(x)) {
          if (length(x) == 1) return(coerce_raw(x[[1]]))
          if (all(vapply(x, is.raw, logical(1)))) return(do.call(c, x))
          if (all(vapply(x, is.integer, logical(1)))) return(as.raw(unlist(x, use.names = FALSE)))
          if (all(vapply(x, is.numeric, logical(1)))) return(as.raw(as.integer(unlist(x, use.names = FALSE))))
        }
        if (is.character(x)) return(charToRaw(x))
        if (is.integer(x)) return(as.raw(x))
        if (is.numeric(x)) return(as.raw(as.integer(x)))
        stop("file_reference must be raw or character")
      }
      ref <- coerce_raw(self$file_reference)
      thumb <- if (is.null(self$thumb_size)) "" else self$thumb_size
      c(
        as.raw(c(0xfe, 0x1f, 0x18, 0x40)),
        pack("q", self$id),
        pack("q", self$access_hash),
        self$serialize_bytes(ref),
        self$serialize_bytes(thumb)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$id <- reader$read_long()
      self$access_hash <- reader$read_long()
      self$file_reference <- reader$tgreadbytes()
      self$thumb_size <- reader$tgread_string()
    }
  )
)

#  @title InputPhotoLegacyFileLocation
#  @description Telegram API type InputPhotoLegacyFileLocation
#  @export
#  @noRd
#  @noRd
InputPhotoLegacyFileLocation <- R6::R6Class(
  "InputPhotoLegacyFileLocation",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd83466f3,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1523d462,
    initialize = function(id, access_hash, file_reference, volume_id, local_id, secret) {
      self$id <- id
      self$access_hash <- access_hash
      self$file_reference <- file_reference
      self$volume_id <- volume_id
      self$local_id <- local_id
      self$secret <- secret
    },
    to_dict = function() {
      list(
        "_" = "InputPhotoLegacyFileLocation",
        id = self$id,
        access_hash = self$access_hash,
        file_reference = self$file_reference,
        volume_id = self$volume_id,
        local_id = self$local_id,
        secret = self$secret
      )
    },
    bytes = function() {
      c(as.raw(c(0xf3, 0x66, 0x34, 0xd8)), struct$pack("<q", self$id), struct$pack("<q", self$access_hash), self$serializebytes(self$file_reference), struct$pack("<q", self$volume_id), struct$pack("<i", self$local_id), struct$pack("<q", self$secret))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$id <- reader$read_long()
      self$access_hash <- reader$read_long()
      self$file_reference <- reader$tgreadbytes()
      self$volume_id <- reader$read_long()
      self$local_id <- reader$read_int()
      self$secret <- reader$read_long()
    }
  )
)

#  @title InputPrivacyKeyAbout
#  @description Telegram API type InputPrivacyKeyAbout
#  @export
#  @noRd
#  @noRd
InputPrivacyKeyAbout <- R6::R6Class(
  "InputPrivacyKeyAbout",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x3823cc40,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x53627f8,
    to_dict = function() {
      list("_" = "InputPrivacyKeyAbout")
    },
    bytes = function() {
      as.raw(c(0x40, 0xcc, 0x23, 0x38))
    }
  ),
  private = list(
    from_reader = function(reader) {
      # no fields
    }
  )
)

#  @title InputPrivacyKeyAddedByPhone
#  @description Telegram API type InputPrivacyKeyAddedByPhone
#  @export
#  @noRd
#  @noRd
InputPrivacyKeyAddedByPhone <- R6::R6Class(
  "InputPrivacyKeyAddedByPhone",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd1219bdd,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x53627f8,
    to_dict = function() {
      list("_" = "InputPrivacyKeyAddedByPhone")
    },
    bytes = function() {
      as.raw(c(0xdd, 0x9b, 0x21, 0xd1))
    }
  ),
  private = list(
    from_reader = function(reader) {
      # no fields
    }
  )
)

#  @title InputPrivacyKeyBirthday
#  @description Telegram API type InputPrivacyKeyBirthday
#  @export
#  @noRd
#  @noRd
InputPrivacyKeyBirthday <- R6::R6Class(
  "InputPrivacyKeyBirthday",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd65a11cc,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x53627f8,
    to_dict = function() {
      list("_" = "InputPrivacyKeyBirthday")
    },
    bytes = function() {
      as.raw(c(0xcc, 0x11, 0x5a, 0xd6))
    }
  ),
  private = list(
    from_reader = function(reader) {
      # no fields
    }
  )
)

#  @title InputPrivacyKeyChatInvite
#  @description Telegram API type InputPrivacyKeyChatInvite
#  @export
#  @noRd
#  @noRd
InputPrivacyKeyChatInvite <- R6::R6Class(
  "InputPrivacyKeyChatInvite",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbfdfb0426,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x53627f8,
    to_dict = function() {
      list("_" = "InputPrivacyKeyChatInvite")
    },
    bytes = function() {
      as.raw(c(0x26, 0x04, 0xfb, 0xbd))
    }
  ),
  private = list(
    from_reader = function(reader) {
      # no fields
    }
  )
)

#  @title InputPrivacyKeyForwards
#  @description Telegram API type InputPrivacyKeyForwards
#  @export
#  @noRd
#  @noRd
InputPrivacyKeyForwards <- R6::R6Class(
  "InputPrivacyKeyForwards",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa4dd4c08,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x53627f8,
    to_dict = function() {
      list("_" = "InputPrivacyKeyForwards")
    },
    bytes = function() {
      as.raw(c(0x08, 0x4c, 0xdd, 0xa4))
    }
  ),
  private = list(
    from_reader = function(reader) {
      # no fields
    }
  )
)

#  @title InputPrivacyKeyNoPaidMessages
#  @description Telegram API type InputPrivacyKeyNoPaidMessages
#  @export
#  @noRd
#  @noRd
InputPrivacyKeyNoPaidMessages <- R6::R6Class(
  "InputPrivacyKeyNoPaidMessages",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbdc597b4,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x53627f8,
    to_dict = function() {
      list("_" = "InputPrivacyKeyNoPaidMessages")
    },
    bytes = function() {
      as.raw(c(0xb4, 0x97, 0xc5, 0xbd))
    }
  ),
  private = list(
    from_reader = function(reader) {
      # no fields
    }
  )
)

#  @title InputPrivacyKeyPhoneCall
#  @description Telegram API type InputPrivacyKeyPhoneCall
#  @export
#  @noRd
#  @noRd
InputPrivacyKeyPhoneCall <- R6::R6Class(
  "InputPrivacyKeyPhoneCall",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xfabadc5f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x53627f8,
    to_dict = function() {
      list("_" = "InputPrivacyKeyPhoneCall")
    },
    bytes = function() {
      as.raw(c(0x5f, 0xdc, 0xba, 0xfa))
    }
  ),
  private = list(
    from_reader = function(reader) {
      # no fields
    }
  )
)

#  @title InputPrivacyKeyPhoneNumber
#  @description Telegram API type InputPrivacyKeyPhoneNumber
#  @export
#  @noRd
#  @noRd
InputPrivacyKeyPhoneNumber <- R6::R6Class(
  "InputPrivacyKeyPhoneNumber",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x352dafa,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x53627f8,
    to_dict = function() {
      list("_" = "InputPrivacyKeyPhoneNumber")
    },
    bytes = function() {
      as.raw(c(0xfa, 0xda, 0x52, 0x03))
    }
  ),
  private = list(
    from_reader = function(reader) {
      # no fields
    }
  )
)

#  @title InputPrivacyKeyPhoneP2P
#  @description Telegram API type InputPrivacyKeyPhoneP2P
#  @export
#  @noRd
#  @noRd
InputPrivacyKeyPhoneP2P <- R6::R6Class(
  "InputPrivacyKeyPhoneP2P",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xdb9e70d2,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x53627f8,
    to_dict = function() {
      list("_" = "InputPrivacyKeyPhoneP2P")
    },
    bytes = function() {
      as.raw(c(0xd2, 0x70, 0x9e, 0xdb))
    }
  ),
  private = list(
    from_reader = function(reader) {
      # no fields
    }
  )
)

#  @title InputPrivacyKeyProfilePhoto
#  @description Telegram API type InputPrivacyKeyProfilePhoto
#  @export
#  @noRd
#  @noRd
InputPrivacyKeyProfilePhoto <- R6::R6Class(
  "InputPrivacyKeyProfilePhoto",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5719bacc,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x53627f8,
    to_dict = function() {
      list("_" = "InputPrivacyKeyProfilePhoto")
    },
    bytes = function() {
      as.raw(c(0xcc, 0xba, 0x19, 0x57))
    }
  ),
  private = list(
    from_reader = function(reader) {
      # no fields
    }
  )
)

#  @title InputPrivacyKeyStarGiftsAutoSave
#  @description Telegram API type InputPrivacyKeyStarGiftsAutoSave
#  @export
#  @noRd
#  @noRd
InputPrivacyKeyStarGiftsAutoSave <- R6::R6Class(
  "InputPrivacyKeyStarGiftsAutoSave",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe1732341,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x53627f8,
    to_dict = function() {
      list("_" = "InputPrivacyKeyStarGiftsAutoSave")
    },
    bytes = function() {
      as.raw(c(0x41, 0x23, 0x73, 0xe1))
    }
  ),
  private = list(
    from_reader = function(reader) {
      # no fields
    }
  )
)

#  @title InputPrivacyKeyStatusTimestamp
#  @description Telegram API type InputPrivacyKeyStatusTimestamp
#  @export
#  @noRd
#  @noRd
InputPrivacyKeyStatusTimestamp <- R6::R6Class(
  "InputPrivacyKeyStatusTimestamp",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4f96cb18,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x53627f8,
    to_dict = function() {
      list("_" = "InputPrivacyKeyStatusTimestamp")
    },
    bytes = function() {
      as.raw(c(0x18, 0xcb, 0x96, 0x4f))
    }
  ),
  private = list(
    from_reader = function(reader) {
      # no fields
    }
  )
)

#  @title InputPrivacyKeyVoiceMessages
#  @description Telegram API type InputPrivacyKeyVoiceMessages
#  @export
#  @noRd
#  @noRd
InputPrivacyKeyVoiceMessages <- R6::R6Class(
  "InputPrivacyKeyVoiceMessages",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xaee69d68,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x53627f8,
    to_dict = function() {
      list("_" = "InputPrivacyKeyVoiceMessages")
    },
    bytes = function() {
      as.raw(c(0x68, 0x9d, 0xe6, 0xae))
    }
  ),
  private = list(
    from_reader = function(reader) {
      # no fields
    }
  )
)

#  @title InputPrivacyValueAllowAll
#  @description Telegram API type InputPrivacyValueAllowAll
#  @export
#  @noRd
#  @noRd
InputPrivacyValueAllowAll <- R6::R6Class(
  "InputPrivacyValueAllowAll",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x184b35ce,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5a3b6b22,
    to_dict = function() {
      list("_" = "InputPrivacyValueAllowAll")
    },
    bytes = function() {
      as.raw(c(0xce, 0x35, 0x4b, 0x18))
    }
  ),
  private = list(
    from_reader = function(reader) {
      # no fields
    }
  )
)

#  @title InputPrivacyValueAllowBots
#  @description Telegram API type InputPrivacyValueAllowBots
#  @export
#  @noRd
#  @noRd
InputPrivacyValueAllowBots <- R6::R6Class(
  "InputPrivacyValueAllowBots",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5a4fcce5,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5a3b6b22,
    to_dict = function() {
      list("_" = "InputPrivacyValueAllowBots")
    },
    bytes = function() {
      as.raw(c(0xe5, 0xcc, 0x4f, 0x5a))
    }
  ),
  private = list(
    from_reader = function(reader) {
      # no fields
    }
  )
)

#  @title InputPrivacyValueAllowChatParticipants
#  @description Telegram API type InputPrivacyValueAllowChatParticipants
#  @export
#  @noRd
#  @noRd
InputPrivacyValueAllowChatParticipants <- R6::R6Class(
  "InputPrivacyValueAllowChatParticipants",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x840649cf,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5a3b6b22,
    initialize = function(chats) {
      self$chats <- chats
    },
    to_dict = function() {
      list(
        "_" = "InputPrivacyValueAllowChatParticipants",
        chats = self$chats
      )
    },
    bytes = function() {
      c(as.raw(c(0xcf, 0x49, 0x06, 0x84)), struct$pack("<i", length(self$chats)), do.call(c, lapply(self$chats, function(x) struct$pack("<q", x))))
    }
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      self$chats <- lapply(seq_len(reader$read_int()), function(i) reader$read_long())
    }
  )
)

#  @title InputPrivacyValueAllowCloseFriends
#  @description Telegram API type InputPrivacyValueAllowCloseFriends
#  @export
#  @noRd
#  @noRd
InputPrivacyValueAllowCloseFriends <- R6::R6Class(
  "InputPrivacyValueAllowCloseFriends",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x2f453e49,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5a3b6b22,
    to_dict = function() {
      list("_" = "InputPrivacyValueAllowCloseFriends")
    },
    bytes = function() {
      as.raw(c(0x49, 0x3e, 0x45, 0x2f))
    }
  ),
  private = list(
    from_reader = function(reader) {
      # no fields
    }
  )
)

#  @title InputPrivacyValueAllowContacts
#  @description Telegram API type InputPrivacyValueAllowContacts
#  @export
#  @noRd
#  @noRd
InputPrivacyValueAllowContacts <- R6::R6Class(
  "InputPrivacyValueAllowContacts",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd09e07b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5a3b6b22,
    to_dict = function() {
      list("_" = "InputPrivacyValueAllowContacts")
    },
    bytes = function() {
      as.raw(c(0x7b, 0xe0, 0x09, 0x0d))
    }
  ),
  private = list(
    from_reader = function(reader) {
      # no fields
    }
  )
)

#  @title InputPrivacyValueAllowPremium
#  @description Telegram API type InputPrivacyValueAllowPremium
#  @export
#  @noRd
#  @noRd
InputPrivacyValueAllowPremium <- R6::R6Class(
  "InputPrivacyValueAllowPremium",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x77cdc9f1,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5a3b6b22,
    to_dict = function() {
      list("_" = "InputPrivacyValueAllowPremium")
    },
    bytes = function() {
      as.raw(c(0xf1, 0xc9, 0xcd, 0x77))
    }
  ),
  private = list(
    from_reader = function(reader) {
      # no fields
    }
  )
)

#  @title InputPrivacyValueAllowUsers
#  @description Telegram API type InputPrivacyValueAllowUsers
#  @export
#  @noRd
#  @noRd
InputPrivacyValueAllowUsers <- R6::R6Class(
  "InputPrivacyValueAllowUsers",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x131cc67f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5a3b6b22,
    initialize = function(users) {
      self$users <- users
    },
    to_dict = function() {
      list(
        "_" = "InputPrivacyValueAllowUsers",
        users = lapply(self$users, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      )
    },
    bytes = function() {
      c(as.raw(c(0x7f, 0xc6, 0x1c, 0x13)), struct$pack("<i", length(self$users)), do.call(c, lapply(self$users, function(x) x$bytes())))
    }
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      self$users <- lapply(seq_len(reader$read_int()), function(i) reader$tgread_object())
    }
  )
)

#  @title InputPrivacyValueDisallowAll
#  @description Telegram API type InputPrivacyValueDisallowAll
#  @export
#  @noRd
#  @noRd
InputPrivacyValueDisallowAll <- R6::R6Class(
  "InputPrivacyValueDisallowAll",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd66b66c9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5a3b6b22,
    to_dict = function() {
      list("_" = "InputPrivacyValueDisallowAll")
    },
    bytes = function() {
      as.raw(c(0xc9, 0x66, 0x6b, 0xd6))
    }
  ),
  private = list(
    from_reader = function(reader) {
      # no fields
    }
  )
)

#  @title InputPrivacyValueDisallowBots
#  @description Telegram API type InputPrivacyValueDisallowBots
#  @export
#  @noRd
#  @noRd
InputPrivacyValueDisallowBots <- R6::R6Class(
  "InputPrivacyValueDisallowBots",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc4e57915,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5a3b6b22,
    to_dict = function() {
      list("_" = "InputPrivacyValueDisallowBots")
    },
    bytes = function() {
      as.raw(c(0x15, 0x79, 0xe5, 0xc4))
    }
  ),
  private = list(
    from_reader = function(reader) {
      # no fields
    }
  )
)

#  @title InputPrivacyValueDisallowChatParticipants
#  @description Telegram API type InputPrivacyValueDisallowChatParticipants
#  @export
#  @noRd
#  @noRd
InputPrivacyValueDisallowChatParticipants <- R6::R6Class(
  "InputPrivacyValueDisallowChatParticipants",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe94f0f86,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5a3b6b22,
    initialize = function(chats) {
      self$chats <- chats
    },
    to_dict = function() {
      list(
        "_" = "InputPrivacyValueDisallowChatParticipants",
        chats = self$chats
      )
    },
    bytes = function() {
      c(as.raw(c(0x86, 0x0f, 0x4f, 0xe9)), struct$pack("<i", length(self$chats)), do.call(c, lapply(self$chats, function(x) struct$pack("<q", x))))
    }
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      self$chats <- lapply(seq_len(reader$read_int()), function(i) reader$read_long())
    }
  )
)

#  @title InputPrivacyValueDisallowContacts
#  @description Telegram API type InputPrivacyValueDisallowContacts
#  @export
#  @noRd
#  @noRd
InputPrivacyValueDisallowContacts <- R6::R6Class(
  "InputPrivacyValueDisallowContacts",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xba52007,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5a3b6b22,
    to_dict = function() {
      list("_" = "InputPrivacyValueDisallowContacts")
    },
    bytes = function() {
      as.raw(c(0x07, 0x20, 0xa5, 0x0b))
    }
  ),
  private = list(
    from_reader = function(reader) {
      # no fields
    }
  )
)

#  @title InputPrivacyValueDisallowUsers
#  @description Telegram API type InputPrivacyValueDisallowUsers
#  @export
#  @noRd
#  @noRd
InputPrivacyValueDisallowUsers <- R6::R6Class(
  "InputPrivacyValueDisallowUsers",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x90110467,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5a3b6b22,
    initialize = function(users) {
      self$users <- users
    },
    to_dict = function() {
      list(
        "_" = "InputPrivacyValueDisallowUsers",
        users = lapply(self$users, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      )
    },
    bytes = function() {
      c(as.raw(c(0x67, 0x04, 0x11, 0x90)), struct$pack("<i", length(self$users)), do.call(c, lapply(self$users, function(x) x$bytes())))
    }
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      self$users <- lapply(seq_len(reader$read_int()), function(i) reader$tgread_object())
    }
  )
)

#  @title InputQuickReplyShortcut
#  @description Telegram API type InputQuickReplyShortcut
#  @export
#  @noRd
#  @noRd
InputQuickReplyShortcut <- R6::R6Class(
  "InputQuickReplyShortcut",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x24596d41,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xa5687c57,
    initialize = function(shortcut) {
      self$shortcut <- shortcut
    },
    to_dict = function() {
      list(
        "_" = "InputQuickReplyShortcut",
        shortcut = self$shortcut
      )
    },
    bytes = function() {
      c(as.raw(c(0x41, 0x6d, 0x59, 0x24)), self$serializebytes(self$shortcut))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$shortcut <- reader$tgread_string()
    }
  )
)

#  @title InputQuickReplyShortcutId
#  @description Telegram API type InputQuickReplyShortcutId
#  @export
#  @noRd
#  @noRd
InputQuickReplyShortcutId <- R6::R6Class(
  "InputQuickReplyShortcutId",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1190cf1,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xa5687c57,
    initialize = function(shortcut_id) {
      self$shortcut_id <- shortcut_id
    },
    to_dict = function() {
      list(
        "_" = "InputQuickReplyShortcutId",
        shortcut_id = self$shortcut_id
      )
    },
    bytes = function() {
      c(as.raw(c(0xf1, 0x0c, 0x19, 0x01)), struct$pack("<i", self$shortcut_id))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$shortcut_id <- reader$read_int()
    }
  )
)

#  @title InputReplyToMessage
#  @description Telegram API type InputReplyToMessage
#  @export
#  @noRd
#  @noRd
InputReplyToMessage <- R6::R6Class(
  "InputReplyToMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x869fbe10,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8c71131d,
    initialize = function(reply_to_msg_id, top_msg_id = NULL, reply_topeer_id = NULL, quote_text = NULL, quote_entities = NULL, quote_offset = NULL, monoforumpeer_id = NULL, todo_item_id = NULL) {
      self$reply_to_msg_id <- reply_to_msg_id
      self$top_msg_id <- top_msg_id
      self$reply_topeer_id <- reply_topeer_id
      self$quote_text <- quote_text
      self$quote_entities <- quote_entities
      self$quote_offset <- quote_offset
      self$monoforumpeer_id <- monoforumpeer_id
      self$todo_item_id <- todo_item_id
    },
    to_dict = function() {
      list(
        "_" = "InputReplyToMessage",
        reply_to_msg_id = self$reply_to_msg_id,
        top_msg_id = self$top_msg_id,
        reply_topeer_id = if (inherits(self$reply_topeer_id, "TLObject")) self$reply_topeer_id$to_dict() else self$reply_topeer_id,
        quote_text = self$quote_text,
        quote_entities = if (is.null(self$quote_entities)) NULL else lapply(self$quote_entities, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        quote_offset = self$quote_offset,
        monoforumpeer_id = if (inherits(self$monoforumpeer_id, "TLObject")) self$monoforumpeer_id$to_dict() else self$monoforumpeer_id,
        todo_item_id = self$todo_item_id
      )
    },
    bytes = function() {
      flags <- (if (is.null(self$top_msg_id)) 0 else 1) | (if (is.null(self$reply_topeer_id)) 0 else 2) | (if (is.null(self$quote_text)) 0 else 4) | (if (is.null(self$quote_entities)) 0 else 8) | (if (is.null(self$quote_offset)) 0 else 16) | (if (is.null(self$monoforumpeer_id)) 0 else 32) | (if (is.null(self$todo_item_id)) 0 else 64)
      c(
        as.raw(c(0x10, 0xbe, 0x9f, 0x86)), struct$pack("<I", flags), struct$pack("<i", self$reply_to_msg_id),
        if (!is.null(self$top_msg_id)) struct$pack("<i", self$top_msg_id) else raw(),
        if (!is.null(self$reply_topeer_id)) self$reply_topeer_id$bytes() else raw(),
        if (!is.null(self$quote_text)) self$serializebytes(self$quote_text) else raw(),
        if (!is.null(self$quote_entities)) c(struct$pack("<i", length(self$quote_entities)), do.call(c, lapply(self$quote_entities, function(x) x$bytes()))) else raw(),
        if (!is.null(self$quote_offset)) struct$pack("<i", self$quote_offset) else raw(),
        if (!is.null(self$monoforumpeer_id)) self$monoforumpeer_id$bytes() else raw(),
        if (!is.null(self$todo_item_id)) struct$pack("<i", self$todo_item_id) else raw()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      self$reply_to_msg_id <- reader$read_int()
      if (bitwAnd(flags, 1)) self$top_msg_id <- reader$read_int()
      if (bitwAnd(flags, 2)) self$reply_topeer_id <- reader$tgread_object()
      if (bitwAnd(flags, 4)) self$quote_text <- reader$tgread_string()
      if (bitwAnd(flags, 8)) {
        reader$read_int()
        self$quote_entities <- lapply(seq_len(reader$read_int()), function(i) reader$tgread_object())
      }
      if (bitwAnd(flags, 16)) self$quote_offset <- reader$read_int()
      if (bitwAnd(flags, 32)) self$monoforumpeer_id <- reader$tgread_object()
      if (bitwAnd(flags, 64)) self$todo_item_id <- reader$read_int()
    }
  )
)

#  @title InputReplyToMonoForum
#  @description Telegram API type InputReplyToMonoForum
#  @export
#  @noRd
#  @noRd
InputReplyToMonoForum <- R6::R6Class(
  "InputReplyToMonoForum",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x69d66c45,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8c71131d,
    initialize = function(monoforumpeer_id) {
      self$monoforumpeer_id <- monoforumpeer_id
    },
    to_dict = function() {
      list(
        "_" = "InputReplyToMonoForum",
        monoforumpeer_id = if (inherits(self$monoforumpeer_id, "TLObject")) self$monoforumpeer_id$to_dict() else self$monoforumpeer_id
      )
    },
    bytes = function() {
      c(as.raw(c(0x45, 0x6c, 0xd6, 0x69)), self$monoforumpeer_id$bytes())
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$monoforumpeer_id <- reader$tgread_object()
    }
  )
)

#  @title InputReplyToStory
#  @description Telegram API type InputReplyToStory
#  @export
#  @noRd
#  @noRd
InputReplyToStory <- R6::R6Class(
  "InputReplyToStory",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5881323a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8c71131d,
    initialize = function(peer, story_id) {
      self$peer <- peer
      self$story_id <- story_id
    },
    to_dict = function() {
      list("_" = "InputReplyToStory", peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer, story_id = self$story_id)
    },
    bytes = function() {
      c(as.raw(c(0x3a, 0x32, 0x81, 0x58)), self$peer$bytes(), packBits(intToBits(self$story_id), type = "raw")[1:4])
    }
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      story_id <- reader$read_int()
      self$initialize(peer = peer, story_id = story_id)
    }
  )
)

#  @title InputReportReasonChildAbuse
#  @description Telegram API type InputReportReasonChildAbuse
#  @export
#  @noRd
#  @noRd
InputReportReasonChildAbuse <- R6::R6Class(
  "InputReportReasonChildAbuse",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xadf44ee3,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8401bd27,
    to_dict = function() {
      list("_" = "InputReportReasonChildAbuse")
    },
    bytes = function() {
      as.raw(c(0xe3, 0x4e, 0xf4, 0xad))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  )
)

#  @title InputReportReasonCopyright
#  @description Telegram API type InputReportReasonCopyright
#  @export
#  @noRd
#  @noRd
InputReportReasonCopyright <- R6::R6Class(
  "InputReportReasonCopyright",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9b89f93a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8401bd27,
    to_dict = function() {
      list("_" = "InputReportReasonCopyright")
    },
    bytes = function() {
      as.raw(c(0x3a, 0xf9, 0x89, 0x9b))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  )
)

#  @title InputReportReasonFake
#  @description Telegram API type InputReportReasonFake
#  @export
#  @noRd
#  @noRd
InputReportReasonFake <- R6::R6Class(
  "InputReportReasonFake",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf5ddd6e7,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8401bd27,
    to_dict = function() {
      list("_" = "InputReportReasonFake")
    },
    bytes = function() {
      as.raw(c(0xe7, 0xd6, 0xdd, 0xf5))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  )
)

#  @title InputReportReasonGeoIrrelevant
#  @description Telegram API type InputReportReasonGeoIrrelevant
#  @export
#  @noRd
#  @noRd
InputReportReasonGeoIrrelevant <- R6::R6Class(
  "InputReportReasonGeoIrrelevant",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xdbd4feed,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8401bd27,
    to_dict = function() {
      list("_" = "InputReportReasonGeoIrrelevant")
    },
    bytes = function() {
      as.raw(c(0xed, 0xfe, 0xd4, 0xdb))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  )
)

#  @title InputReportReasonIllegalDrugs
#  @description Telegram API type InputReportReasonIllegalDrugs
#  @export
#  @noRd
#  @noRd
InputReportReasonIllegalDrugs <- R6::R6Class(
  "InputReportReasonIllegalDrugs",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa8eb2be,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8401bd27,
    to_dict = function() {
      list("_" = "InputReportReasonIllegalDrugs")
    },
    bytes = function() {
      as.raw(c(0xbe, 0x2b, 0x8e, 0x0a))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  )
)

#  @title InputReportReasonOther
#  @description Telegram API type InputReportReasonOther
#  @export
#  @noRd
#  @noRd
InputReportReasonOther <- R6::R6Class(
  "InputReportReasonOther",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc1e4a2b1,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8401bd27,
    to_dict = function() {
      list("_" = "InputReportReasonOther")
    },
    bytes = function() {
      as.raw(c(0xb1, 0xa2, 0xe4, 0xc1))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  )
)

#  @title InputReportReasonPersonalDetails
#  @description Telegram API type InputReportReasonPersonalDetails
#  @export
#  @noRd
#  @noRd
InputReportReasonPersonalDetails <- R6::R6Class(
  "InputReportReasonPersonalDetails",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9ec7863d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8401bd27,
    to_dict = function() {
      list("_" = "InputReportReasonPersonalDetails")
    },
    bytes = function() {
      as.raw(c(0x3d, 0x86, 0xc7, 0x9e))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  )
)

#  @title InputReportReasonPornography
#  @description Telegram API type InputReportReasonPornography
#  @export
#  @noRd
#  @noRd
InputReportReasonPornography <- R6::R6Class(
  "InputReportReasonPornography",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x2e59d922,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8401bd27,
    to_dict = function() {
      list("_" = "InputReportReasonPornography")
    },
    bytes = function() {
      as.raw(c(0x22, 0xd9, 0x59, 0x2e))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  )
)

#  @title InputReportReasonSpam
#  @description Telegram API type InputReportReasonSpam
#  @export
#  @noRd
#  @noRd
InputReportReasonSpam <- R6::R6Class(
  "InputReportReasonSpam",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x58dbcab8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8401bd27,
    to_dict = function() {
      list("_" = "InputReportReasonSpam")
    },
    bytes = function() {
      as.raw(c(0xb8, 0xca, 0xdb, 0x58))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  )
)

#  @title InputReportReasonViolence
#  @description Telegram API type InputReportReasonViolence
#  @export
#  @noRd
#  @noRd
InputReportReasonViolence <- R6::R6Class(
  "InputReportReasonViolence",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1e22c78d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8401bd27,
    to_dict = function() {
      list("_" = "InputReportReasonViolence")
    },
    bytes = function() {
      as.raw(c(0x8d, 0xc7, 0x22, 0x1e))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  )
)

#  @title InputSavedStarGiftChat
#  @description Telegram API type InputSavedStarGiftChat
#  @export
#  @noRd
#  @noRd
InputSavedStarGiftChat <- R6::R6Class(
  "InputSavedStarGiftChat",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf101aa7f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8f7599ae,
    initialize = function(peer, saved_id) {
      self$peer <- peer
      self$saved_id <- saved_id
    },
    to_dict = function() {
      list("_" = "InputSavedStarGiftChat", peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer, saved_id = self$saved_id)
    },
    bytes = function() {
      c(as.raw(c(0x7f, 0xaa, 0x01, 0xf1)), self$peer$bytes(), packBits(intToBits(self$saved_id), type = "raw")[1:8])
    }
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      saved_id <- reader$read_long()
      self$initialize(peer = peer, saved_id = saved_id)
    }
  )
)

#  @title InputSavedStarGiftSlug
#  @description Telegram API type InputSavedStarGiftSlug
#  @export
#  @noRd
#  @noRd
InputSavedStarGiftSlug <- R6::R6Class(
  "InputSavedStarGiftSlug",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x2085c238,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8f7599ae,
    initialize = function(slug) {
      self$slug <- slug
    },
    to_dict = function() {
      list("_" = "InputSavedStarGiftSlug", slug = self$slug)
    },
    bytes = function() {
      c(as.raw(c(0x38, 0xc2, 0x85, 0x20)), charToRaw(self$slug))
    }
  ),
  private = list(
    from_reader = function(reader) {
      slug <- reader$tgread_string()
      self$initialize(slug = slug)
    }
  )
)

#  @title InputSavedStarGiftUser
#  @description Telegram API type InputSavedStarGiftUser
#  @export
#  @noRd
#  @noRd
InputSavedStarGiftUser <- R6::R6Class(
  "InputSavedStarGiftUser",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x69279795,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8f7599ae,
    initialize = function(msg_id) {
      self$msg_id <- msg_id
    },
    to_dict = function() {
      list("_" = "InputSavedStarGiftUser", msg_id = self$msg_id)
    },
    bytes = function() {
      c(as.raw(c(0x95, 0x97, 0x27, 0x69)), packBits(intToBits(self$msg_id), type = "raw")[1:4])
    }
  ),
  private = list(
    from_reader = function(reader) {
      msg_id <- reader$read_int()
      self$initialize(msg_id = msg_id)
    }
  )
)

#  @title InputSecureFile
#  @description Telegram API type InputSecureFile
#  @export
#  @noRd
#  @noRd
InputSecureFile <- R6::R6Class(
  "InputSecureFile",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5367e5be,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xdac8adfc,
    initialize = function(id, access_hash) {
      self$id <- id
      self$access_hash <- access_hash
    },
    to_dict = function() {
      list("_" = "InputSecureFile", id = self$id, access_hash = self$access_hash)
    },
    bytes = function() {
      c(as.raw(c(0xbe, 0xe5, 0x67, 0x53)), packBits(intToBits(self$id), type = "raw")[1:8], packBits(intToBits(self$access_hash), type = "raw")[1:8])
    }
  ),
  private = list(
    from_reader = function(reader) {
      id <- reader$read_long()
      access_hash <- reader$read_long()
      self$initialize(id = id, access_hash = access_hash)
    }
  )
)

#  @title InputSecureFileLocation
#  @description Telegram API type InputSecureFileLocation
#  @export
#  @noRd
#  @noRd
InputSecureFileLocation <- R6::R6Class(
  "InputSecureFileLocation",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xcbc7ee28,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1523d462,
    initialize = function(id, access_hash) {
      self$id <- id
      self$access_hash <- access_hash
    },
    to_dict = function() {
      list("_" = "InputSecureFileLocation", id = self$id, access_hash = self$access_hash)
    },
    bytes = function() {
      c(as.raw(c(0x28, 0xee, 0xc7, 0xcb)), packBits(intToBits(self$id), type = "raw")[1:8], packBits(intToBits(self$access_hash), type = "raw")[1:8])
    }
  ),
  private = list(
    from_reader = function(reader) {
      id <- reader$read_long()
      access_hash <- reader$read_long()
      self$initialize(id = id, access_hash = access_hash)
    }
  )
)

#  @title InputSecureFileUploaded
#  @description Telegram API type InputSecureFileUploaded
#  @export
#  @noRd
#  @noRd
InputSecureFileUploaded <- R6::R6Class(
  "InputSecureFileUploaded",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x3334b0f0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xdac8adfc,
    initialize = function(id, parts, md5_checksum, file_hash, secret) {
      self$id <- id
      self$parts <- parts
      self$md5_checksum <- md5_checksum
      self$file_hash <- file_hash
      self$secret <- secret
    },
    to_dict = function() {
      list("_" = "InputSecureFileUploaded", id = self$id, parts = self$parts, md5_checksum = self$md5_checksum, file_hash = self$file_hash, secret = self$secret)
    },
    bytes = function() {
      c(as.raw(c(0xf0, 0xb0, 0x34, 0x33)), packBits(intToBits(self$id), type = "raw")[1:8], packBits(intToBits(self$parts), type = "raw")[1:4], charToRaw(self$md5_checksum), self$file_hash, self$secret)
    }
  ),
  private = list(
    from_reader = function(reader) {
      id <- reader$read_long()
      parts <- reader$read_int()
      md5_checksum <- reader$tgread_string()
      file_hash <- reader$tgreadbytes()
      secret <- reader$tgreadbytes()
      self$initialize(id = id, parts = parts, md5_checksum = md5_checksum, file_hash = file_hash, secret = secret)
    }
  )
)

#  @title InputSecureValue
#  @description Telegram API type InputSecureValue
#  @export
#  @noRd
#  @noRd
InputSecureValue <- R6::R6Class(
  "InputSecureValue",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xdb21d0a7,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb49da1fc,
    initialize = function(type, data = NULL, front_side = NULL, reverse_side = NULL, selfie = NULL, translation = NULL, files = NULL, plaindata = NULL) {
      self$type <- type
      self$data <- data
      self$front_side <- front_side
      self$reverse_side <- reverse_side
      self$selfie <- selfie
      self$translation <- translation
      self$files <- files
      self$plaindata <- plaindata
    },
    to_dict = function() {
      list("_" = "InputSecureValue", type = if (inherits(self$type, "TLObject")) self$type$to_dict() else self$type, data = if (inherits(self$data, "TLObject")) self$data$to_dict() else self$data, front_side = if (inherits(self$front_side, "TLObject")) self$front_side$to_dict() else self$front_side, reverse_side = if (inherits(self$reverse_side, "TLObject")) self$reverse_side$to_dict() else self$reverse_side, selfie = if (inherits(self$selfie, "TLObject")) self$selfie$to_dict() else self$selfie, translation = lapply(self$translation, function(x) if (inherits(x, "TLObject")) x$to_dict() else x), files = lapply(self$files, function(x) if (inherits(x, "TLObject")) x$to_dict() else x), plaindata = if (inherits(self$plaindata, "TLObject")) self$plaindata$to_dict() else self$plaindata)
    },
    bytes = function() {
      flags <- (if (is.null(self$data) || self$data == FALSE) 0 else 1) | (if (is.null(self$front_side) || self$front_side == FALSE) 0 else 2) | (if (is.null(self$reverse_side) || self$reverse_side == FALSE) 0 else 4) | (if (is.null(self$selfie) || self$selfie == FALSE) 0 else 8) | (if (is.null(self$translation) || self$translation == FALSE) 0 else 64) | (if (is.null(self$files) || self$files == FALSE) 0 else 16) | (if (is.null(self$plaindata) || self$plaindata == FALSE) 0 else 32)
      c(as.raw(c(0xa7, 0xd0, 0x21, 0xdb)), packBits(intToBits(flags), type = "raw")[1:4], self$type$bytes(), if (!is.null(self$data)) self$data$bytes() else raw(0), if (!is.null(self$front_side)) self$front_side$bytes() else raw(0), if (!is.null(self$reverse_side)) self$reverse_side$bytes() else raw(0), if (!is.null(self$selfie)) self$selfie$bytes() else raw(0), if (!is.null(self$translation)) c(as.raw(c(0x1c, 0xb5, 0xc4, 0x15)), packBits(intToBits(length(self$translation)), type = "raw")[1:4], do.call(c, lapply(self$translation, function(x) x$bytes()))) else raw(0), if (!is.null(self$files)) c(as.raw(c(0x1c, 0xb5, 0xc4, 0x15)), packBits(intToBits(length(self$files)), type = "raw")[1:4], do.call(c, lapply(self$files, function(x) x$bytes()))) else raw(0), if (!is.null(self$plaindata)) self$plaindata$bytes() else raw(0))
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      type <- reader$tgread_object()
      data <- if (bitwAnd(flags, 1)) reader$tgread_object() else NULL
      front_side <- if (bitwAnd(flags, 2)) reader$tgread_object() else NULL
      reverse_side <- if (bitwAnd(flags, 4)) reader$tgread_object() else NULL
      selfie <- if (bitwAnd(flags, 8)) reader$tgread_object() else NULL
      translation <- if (bitwAnd(flags, 64)) {
        reader$read_int()
        lapply(1:reader$read_int(), function(i) reader$tgread_object())
      } else {
        NULL
      }
      files <- if (bitwAnd(flags, 16)) {
        reader$read_int()
        lapply(1:reader$read_int(), function(i) reader$tgread_object())
      } else {
        NULL
      }
      plaindata <- if (bitwAnd(flags, 32)) reader$tgread_object() else NULL
      self$initialize(type = type, data = data, front_side = front_side, reverse_side = reverse_side, selfie = selfie, translation = translation, files = files, plaindata = plaindata)
    }
  )
)

#  @title InputSingleMedia
#  @description Telegram API type InputSingleMedia
#  @export
#  @noRd
#  @noRd
InputSingleMedia <- R6::R6Class(
  "InputSingleMedia",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1cc6e91f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x21ca8ed8,
    initialize = function(media, message, random_id = NULL, entities = NULL) {
      self$media <- media
      self$message <- message
      self$random_id <- if (is.null(random_id)) as.integer(runif(1, min = -2^63, max = 2^63 - 1)) else random_id
      self$entities <- entities
    },
    to_dict = function() {
      list("_" = "InputSingleMedia", media = if (inherits(self$media, "TLObject")) self$media$to_dict() else self$media, message = self$message, random_id = self$random_id, entities = lapply(self$entities, function(x) if (inherits(x, "TLObject")) x$to_dict() else x))
    },
    bytes = function() {
      flags <- if (is.null(self$entities) || self$entities == FALSE) 0 else 1
      c(as.raw(c(0x1f, 0xe9, 0xc6, 0x1c)), packBits(intToBits(flags), type = "raw")[1:4], self$media$bytes(), packBits(intToBits(self$random_id), type = "raw")[1:8], charToRaw(self$message), if (!is.null(self$entities)) c(as.raw(c(0x1c, 0xb5, 0xc4, 0x15)), packBits(intToBits(length(self$entities)), type = "raw")[1:4], do.call(c, lapply(self$entities, function(x) x$bytes()))) else raw(0))
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      media <- reader$tgread_object()
      random_id <- reader$read_long()
      message <- reader$tgread_string()
      entities <- if (bitwAnd(flags, 1)) {
        reader$read_int()
        lapply(1:reader$read_int(), function(i) reader$tgread_object())
      } else {
        NULL
      }
      self$initialize(media = media, message = message, random_id = random_id, entities = entities)
    }
  )
)

#  @title InputStarsTransaction
#  @description Telegram API type InputStarsTransaction
#  @export
#  @noRd
#  @noRd
InputStarsTransaction <- R6::R6Class(
  "InputStarsTransaction",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x206ae6d1,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x11e208ea,
    initialize = function(id, refund = NULL) {
      self$id <- id
      self$refund <- refund
    },
    to_dict = function() {
      list("_" = "InputStarsTransaction", id = self$id, refund = self$refund)
    },
    bytes = function() {
      flags <- if (is.null(self$refund) || self$refund == FALSE) 0 else 1
      c(as.raw(c(0xd1, 0xe6, 0x6a, 0x20)), packBits(intToBits(flags), type = "raw")[1:4], charToRaw(self$id))
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      refund <- bitwAnd(flags, 1) != 0
      id <- reader$tgread_string()
      self$initialize(id = id, refund = refund)
    }
  )
)

#  @title InputStickerSetAnimatedEmoji
#  @description Telegram API type InputStickerSetAnimatedEmoji
#  @export
#  @noRd
#  @noRd
InputStickerSetAnimatedEmoji <- R6::R6Class(
  "InputStickerSetAnimatedEmoji",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x28703c8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x3da389aa,
    to_dict = function() {
      list("_" = "InputStickerSetAnimatedEmoji")
    },
    bytes = function() {
      as.raw(c(0xc8, 0x03, 0x87, 0x02))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  )
)

#  @title InputStickerSetAnimatedEmojiAnimations
#  @description Telegram API type InputStickerSetAnimatedEmojiAnimations
#  @export
#  @noRd
#  @noRd
InputStickerSetAnimatedEmojiAnimations <- R6::R6Class(
  "InputStickerSetAnimatedEmojiAnimations",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xcde3739,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x3da389aa,
    to_dict = function() {
      list("_" = "InputStickerSetAnimatedEmojiAnimations")
    },
    bytes = function() {
      as.raw(c(0x39, 0x73, 0xde, 0x0c))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  )
)

#  @title InputStickerSetDice
#  @description Telegram API type InputStickerSetDice
#  @export
#  @noRd
#  @noRd
InputStickerSetDice <- R6::R6Class(
  "InputStickerSetDice",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe67f520e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x3da389aa,
    initialize = function(emoticon) {
      self$emoticon <- emoticon
    },
    to_dict = function() {
      list("_" = "InputStickerSetDice", emoticon = self$emoticon)
    },
    bytes = function() {
      c(as.raw(c(0x0e, 0x52, 0x7f, 0xe6)), charToRaw(self$emoticon))
    }
  ),
  private = list(
    from_reader = function(reader) {
      emoticon <- reader$tgread_string()
      self$initialize(emoticon = emoticon)
    }
  )
)

#  @title InputStickerSetEmojiChannelDefaultStatuses
#  @description Telegram API type InputStickerSetEmojiChannelDefaultStatuses
#  @export
#  @noRd
#  @noRd
InputStickerSetEmojiChannelDefaultStatuses <- R6::R6Class(
  "InputStickerSetEmojiChannelDefaultStatuses",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x49748553,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x3da389aa,
    to_dict = function() {
      list("_" = "InputStickerSetEmojiChannelDefaultStatuses")
    },
    bytes = function() {
      as.raw(c(0x53, 0x85, 0x74, 0x49))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  )
)

#  @title InputStickerSetEmojiDefaultStatuses
#  @description Telegram API type InputStickerSetEmojiDefaultStatuses
#  @export
#  @noRd
#  @noRd
InputStickerSetEmojiDefaultStatuses <- R6::R6Class(
  "InputStickerSetEmojiDefaultStatuses",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x29d0f5ee,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x3da389aa,
    to_dict = function() {
      list("_" = "InputStickerSetEmojiDefaultStatuses")
    },
    bytes = function() {
      as.raw(c(0xee, 0xf5, 0xd0, 0x29))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  )
)

#  @title InputStickerSetEmojiDefaultTopicIcons
#  @description Telegram API type InputStickerSetEmojiDefaultTopicIcons
#  @export
#  @noRd
#  @noRd
InputStickerSetEmojiDefaultTopicIcons <- R6::R6Class(
  "InputStickerSetEmojiDefaultTopicIcons",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x44c1f8e9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x3da389aa,
    to_dict = function() {
      list("_" = "InputStickerSetEmojiDefaultTopicIcons")
    },
    bytes = function() {
      as.raw(c(0xe9, 0xf8, 0xc1, 0x44))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  )
)

#  @title InputStickerSetEmojiGenericAnimations
#  @description Telegram API type InputStickerSetEmojiGenericAnimations
#  @export
#  @noRd
#  @noRd
InputStickerSetEmojiGenericAnimations <- R6::R6Class(
  "InputStickerSetEmojiGenericAnimations",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4c4d4ce,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x3da389aa,
    to_dict = function() {
      list("_" = "InputStickerSetEmojiGenericAnimations")
    },
    bytes = function() {
      as.raw(c(0xce, 0xd4, 0xc4, 0x04))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  )
)

#  @title InputStickerSetEmpty
#  @description Telegram API type InputStickerSetEmpty
#  @export
#  @noRd
#  @noRd
InputStickerSetEmpty <- R6::R6Class(
  "InputStickerSetEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xffb62b95,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x3da389aa,
    to_dict = function() {
      list("_" = "InputStickerSetEmpty")
    },
    bytes = function() {
      as.raw(c(0x95, 0x2b, 0xb6, 0xff))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  )
)

#  @title InputStickerSetID
#  @description Telegram API type InputStickerSetID
#  @export
#  @noRd
#  @noRd
InputStickerSetID <- R6::R6Class(
  "InputStickerSetID",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9de7a269,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x3da389aa,
    initialize = function(id, access_hash) {
      self$id <- id
      self$access_hash <- access_hash
    },
    to_dict = function() {
      list("_" = "InputStickerSetID", id = self$id, access_hash = self$access_hash)
    },
    bytes = function() {
      c(as.raw(c(0x69, 0xa2, 0xe7, 0x9d)), packBits(intToBits(self$id), type = "raw")[1:8], packBits(intToBits(self$access_hash), type = "raw")[1:8])
    }
  ),
  private = list(
    from_reader = function(reader) {
      id <- reader$read_long()
      access_hash <- reader$read_long()
      self$initialize(id = id, access_hash = access_hash)
    }
  )
)

#  @title InputStickerSetItem
#  @description Telegram API type InputStickerSetItem
#  @export
#  @noRd
#  @noRd
InputStickerSetItem <- R6::R6Class(
  "InputStickerSetItem",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x32da9e9c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xae59f075,
    initialize = function(document, emoji, mask_coords = NULL, keywords = NULL) {
      self$document <- document
      self$emoji <- emoji
      self$mask_coords <- mask_coords
      self$keywords <- keywords
    },
    to_dict = function() {
      list("_" = "InputStickerSetItem", document = if (inherits(self$document, "TLObject")) self$document$to_dict() else self$document, emoji = self$emoji, mask_coords = if (inherits(self$mask_coords, "TLObject")) self$mask_coords$to_dict() else self$mask_coords, keywords = self$keywords)
    },
    bytes = function() {
      flags <- (if (is.null(self$mask_coords) || self$mask_coords == FALSE) 0 else 1) | (if (is.null(self$keywords) || self$keywords == FALSE) 0 else 2)
      c(as.raw(c(0x9c, 0x9e, 0xda, 0x32)), packBits(intToBits(flags), type = "raw")[1:4], self$document$bytes(), charToRaw(self$emoji), if (!is.null(self$mask_coords)) self$mask_coords$bytes() else raw(0), if (!is.null(self$keywords)) charToRaw(self$keywords) else raw(0))
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      document <- reader$tgread_object()
      emoji <- reader$tgread_string()
      mask_coords <- if (bitwAnd(flags, 1)) reader$tgread_object() else NULL
      keywords <- if (bitwAnd(flags, 2)) reader$tgread_string() else NULL
      self$initialize(document = document, emoji = emoji, mask_coords = mask_coords, keywords = keywords)
    }
  )
)

#  @title InputStickerSetPremiumGifts
#  @description Telegram API type InputStickerSetPremiumGifts
#  @export
#  @noRd
#  @noRd
InputStickerSetPremiumGifts <- R6::R6Class(
  "InputStickerSetPremiumGifts",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc88b3b02,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x3da389aa,
    to_dict = function() {
      list("_" = "InputStickerSetPremiumGifts")
    },
    bytes = function() {
      as.raw(c(0x02, 0x3b, 0x8b, 0xc8))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  )
)

#  @title InputStickerSetShortName
#  @description Telegram API type InputStickerSetShortName
#  @export
#  @noRd
#  @noRd
InputStickerSetShortName <- R6::R6Class(
  "InputStickerSetShortName",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x861cc8a0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x3da389aa,
    initialize = function(short_name) {
      self$short_name <- short_name
    },
    to_dict = function() {
      list("_" = "InputStickerSetShortName", short_name = self$short_name)
    },
    bytes = function() {
      c(as.raw(c(0xa0, 0xc8, 0x1c, 0x86)), charToRaw(self$short_name))
    }
  ),
  private = list(
    from_reader = function(reader) {
      short_name <- reader$tgread_string()
      self$initialize(short_name = short_name)
    }
  )
)

#  @title InputStickerSetThumb
#  @description Telegram API type InputStickerSetThumb
#  @export
#  @noRd
#  @noRd
InputStickerSetThumb <- R6::R6Class(
  "InputStickerSetThumb",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9d84f3db,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1523d462,
    initialize = function(stickerset, thumb_version) {
      self$stickerset <- stickerset
      self$thumb_version <- thumb_version
    },
    to_dict = function() {
      list("_" = "InputStickerSetThumb", stickerset = if (inherits(self$stickerset, "TLObject")) self$stickerset$to_dict() else self$stickerset, thumb_version = self$thumb_version)
    },
    bytes = function() {
      c(as.raw(c(0xdb, 0xf3, 0x84, 0x9d)), self$stickerset$bytes(), packBits(intToBits(self$thumb_version), type = "raw")[1:4])
    }
  ),
  private = list(
    from_reader = function(reader) {
      stickerset <- reader$tgread_object()
      thumb_version <- reader$read_int()
      self$initialize(stickerset = stickerset, thumb_version = thumb_version)
    }
  )
)

#  @title InputStickerSetTonGifts
#  @description Telegram API type InputStickerSetTonGifts
#  @export
#  @noRd
#  @noRd
InputStickerSetTonGifts <- R6::R6Class(
  "InputStickerSetTonGifts",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1cf671a0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x3da389aa,
    to_dict = function() {
      list("_" = "InputStickerSetTonGifts")
    },
    bytes = function() {
      as.raw(c(0xa0, 0x71, 0xf6, 0x1c))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  )
)

#  @title InputStickeredMediaDocument
#  @description Telegram API type InputStickeredMediaDocument
#  @export
#  @noRd
#  @noRd
InputStickeredMediaDocument <- R6::R6Class(
  "InputStickeredMediaDocument",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x438865b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5146d99e,
    initialize = function(id) {
      self$id <- id
    },
    to_dict = function() {
      list("_" = "InputStickeredMediaDocument", id = if (inherits(self$id, "TLObject")) self$id$to_dict() else self$id)
    },
    bytes = function() {
      c(as.raw(c(0x5b, 0x86, 0x38, 0x04)), self$id$bytes())
    }
  ),
  private = list(
    from_reader = function(reader) {
      id <- reader$tgread_object()
      self$initialize(id = id)
    }
  )
)

#  @title InputStickeredMediaPhoto
#  @description Telegram API type InputStickeredMediaPhoto
#  @export
#  @noRd
#  @noRd
InputStickeredMediaPhoto <- R6::R6Class(
  "InputStickeredMediaPhoto",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4a992157,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5146d99e,
    initialize = function(id) {
      self$id <- id
    },
    to_dict = function() {
      list("_" = "InputStickeredMediaPhoto", id = if (inherits(self$id, "TLObject")) self$id$to_dict() else self$id)
    },
    bytes = function() {
      c(as.raw(c(0x57, 0x21, 0x99, 0x4a)), self$id$bytes())
    }
  ),
  private = list(
    from_reader = function(reader) {
      id <- reader$tgread_object()
      self$initialize(id = id)
    }
  )
)

#  @title InputStorePaymentAuthCode
#  @description Telegram API type InputStorePaymentAuthCode
#  @export
#  @noRd
#  @noRd
InputStorePaymentAuthCode <- R6::R6Class(
  "InputStorePaymentAuthCode",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9bb2636d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xe7a4174d,
    initialize = function(phone_number, phone_code_hash, currency, amount, restore = NULL) {
      self$phone_number <- phone_number
      self$phone_code_hash <- phone_code_hash
      self$currency <- currency
      self$amount <- amount
      self$restore <- restore
    },
    to_dict = function() {
      list("_" = "InputStorePaymentAuthCode", phone_number = self$phone_number, phone_code_hash = self$phone_code_hash, currency = self$currency, amount = self$amount, restore = self$restore)
    },
    bytes = function() {
      flags <- if (is.null(self$restore) || self$restore == FALSE) 0 else 1
      c(as.raw(c(0x6d, 0x63, 0xb2, 0x9b)), packBits(intToBits(flags), type = "raw")[1:4], charToRaw(self$phone_number), charToRaw(self$phone_code_hash), charToRaw(self$currency), packBits(intToBits(self$amount), type = "raw")[1:8])
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      restore <- bitwAnd(flags, 1) != 0
      phone_number <- reader$tgread_string()
      phone_code_hash <- reader$tgread_string()
      currency <- reader$tgread_string()
      amount <- reader$read_long()
      self$initialize(phone_number = phone_number, phone_code_hash = phone_code_hash, currency = currency, amount = amount, restore = restore)
    }
  )
)

#  @title InputStorePaymentGiftPremium
#  @description Telegram API type InputStorePaymentGiftPremium
#  @export
#  @noRd
#  @noRd
InputStorePaymentGiftPremium <- R6::R6Class(
  "InputStorePaymentGiftPremium",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x616f7fe8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xe7a4174d,
    #  @field user_id Field.
    user_id = NULL,
    #  @field currency Field.
    currency = NULL,
    #  @field amount Field.
    amount = NULL,
    initialize = function(user_id, currency, amount) {
      self$user_id <- user_id
      self$currency <- currency
      self$amount <- amount
    },
    to_dict = function() {
      list(
        "_" = "InputStorePaymentGiftPremium",
        user_id = if (inherits(self$user_id, "TLObject")) self$user_id$to_dict() else self$user_id,
        currency = self$currency,
        amount = self$amount
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xe8, 0x7f, 0x6f, 0x61)),
        self$user_id$bytes(),
        serialize_bytes(self$currency),
        writeBin(as.integer64(self$amount), raw(), size = 8, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      user_id <- reader$tgread_object()
      currency <- reader$tgread_string()
      amount <- reader$read_long()
      self$new(user_id = user_id, currency = currency, amount = amount)
    }
  )
)

#  @title InputStorePaymentPremiumGiftCode
#  @description Telegram API type InputStorePaymentPremiumGiftCode
#  @export
#  @noRd
#  @noRd
InputStorePaymentPremiumGiftCode <- R6::R6Class(
  "InputStorePaymentPremiumGiftCode",
  inherit = TLObject,
  public = list(
    #  @field users Field.
    users = NULL,
    #  @field currency Field.
    currency = NULL,
    #  @field amount Field.
    amount = NULL,
    #  @field boost_peer Field.
    boost_peer = NULL,
    #  @field message Field.
    message = NULL,
    initialize = function(users, currency, amount, boost_peer = NULL, message = NULL) {
      self$users <- users
      self$currency <- currency
      self$amount <- amount
      self$boost_peer <- boost_peer
      self$message <- message
    },
    to_dict = function() {
      list(
        "_" = "InputStorePaymentPremiumGiftCode",
        users = lapply(self$users, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        currency = self$currency,
        amount = self$amount,
        boost_peer = if (inherits(self$boost_peer, "TLObject")) self$boost_peer$to_dict() else self$boost_peer,
        message = if (inherits(self$message, "TLObject")) self$message$to_dict() else self$message
      )
    }
  )
)

#  @title InputStorePaymentPremiumGiveaway
#  @description Telegram API type InputStorePaymentPremiumGiveaway
#  @export
#  @noRd
#  @noRd
InputStorePaymentPremiumGiveaway <- R6::R6Class(
  "InputStorePaymentPremiumGiveaway",
  inherit = TLObject,
  public = list(
    #  @field boost_peer Field.
    boost_peer = NULL,
    #  @field until_date Field.
    until_date = NULL,
    #  @field currency Field.
    currency = NULL,
    #  @field amount Field.
    amount = NULL,
    #  @field only_new_subscribers Field.
    only_new_subscribers = NULL,
    #  @field winners_are_visible Field.
    winners_are_visible = NULL,
    #  @field additional_peers Field.
    additional_peers = NULL,
    #  @field countries_iso2 Field.
    countries_iso2 = NULL,
    #  @field prize_description Field.
    prize_description = NULL,
    #  @field random_id Field.
    random_id = NULL,
    initialize = function(boost_peer, until_date, currency, amount, only_new_subscribers = NULL,
                          winners_are_visible = NULL, additional_peers = NULL, countries_iso2 = NULL,
                          prize_description = NULL, random_id = NULL) {
      self$boost_peer <- boost_peer
      self$until_date <- until_date
      self$currency <- currency
      self$amount <- amount
      self$only_new_subscribers <- only_new_subscribers
      self$winners_are_visible <- winners_are_visible
      self$additional_peers <- additional_peers
      self$countries_iso2 <- countries_iso2
      self$prize_description <- prize_description
      self$random_id <- if (is.null(random_id)) as.integer64(sample.int(1e9, 1)) else random_id
    },
    to_dict = function() {
      list(
        "_" = "InputStorePaymentPremiumGiveaway",
        boost_peer = if (inherits(self$boost_peer, "TLObject")) self$boost_peer$to_dict() else self$boost_peer,
        until_date = self$until_date,
        currency = self$currency,
        amount = self$amount,
        only_new_subscribers = self$only_new_subscribers,
        winners_are_visible = self$winners_are_visible,
        additional_peers = lapply(self$additional_peers, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        countries_iso2 = self$countries_iso2,
        prize_description = self$prize_description,
        random_id = self$random_id
      )
    }
  )
)

#  @title InputStorePaymentPremiumSubscription
#  @description Telegram API type InputStorePaymentPremiumSubscription
#  @export
#  @noRd
#  @noRd
InputStorePaymentPremiumSubscription <- R6::R6Class(
  "InputStorePaymentPremiumSubscription",
  inherit = TLObject,
  public = list(
    #  @field restore Field.
    restore = NULL,
    #  @field upgrade Field.
    upgrade = NULL,
    initialize = function(restore = NULL, upgrade = NULL) {
      self$restore <- restore
      self$upgrade <- upgrade
    },
    to_dict = function() {
      list(
        "_" = "InputStorePaymentPremiumSubscription",
        restore = self$restore,
        upgrade = self$upgrade
      )
    },
    bytes = function() {
      flags <- (if (is.null(self$restore) || !self$restore) 0 else 1) |
        (if (is.null(self$upgrade) || !self$upgrade) 0 else 2)
      c(as.raw(c(0xa6, 0x75, 0x1e, 0xf)), as.raw(flags))
    }
  )
)

#  @title InputStorePaymentStarsGift
#  @description Telegram API type InputStorePaymentStarsGift
#  @export
#  @noRd
#  @noRd
InputStorePaymentStarsGift <- R6::R6Class(
  "InputStorePaymentStarsGift",
  inherit = TLObject,
  public = list(
    #  @field user_id Field.
    user_id = NULL,
    #  @field stars Field.
    stars = NULL,
    #  @field currency Field.
    currency = NULL,
    #  @field amount Field.
    amount = NULL,
    initialize = function(user_id, stars, currency, amount) {
      self$user_id <- user_id
      self$stars <- stars
      self$currency <- currency
      self$amount <- amount
    },
    to_dict = function() {
      list(
        "_" = "InputStorePaymentStarsGift",
        user_id = if (inherits(self$user_id, "TLObject")) self$user_id$to_dict() else self$user_id,
        stars = self$stars,
        currency = self$currency,
        amount = self$amount
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xf7, 0x1e, 0x74, 0x1d)),
        self$user_id$bytes(),
        writeBin(as.integer64(self$stars), raw(), size = 8),
        charToRaw(self$currency),
        writeBin(as.integer64(self$amount), raw(), size = 8)
      )
    }
  )
)

#  @title InputStorePaymentStarsGiveaway
#  @description Telegram API type InputStorePaymentStarsGiveaway
#  @export
#  @noRd
#  @noRd
InputStorePaymentStarsGiveaway <- R6::R6Class(
  "InputStorePaymentStarsGiveaway",
  inherit = TLObject,
  public = list(
    #  @field stars Field.
    stars = NULL,
    #  @field boost_peer Field.
    boost_peer = NULL,
    #  @field until_date Field.
    until_date = NULL,
    #  @field currency Field.
    currency = NULL,
    #  @field amount Field.
    amount = NULL,
    #  @field users Field.
    users = NULL,
    #  @field only_new_subscribers Field.
    only_new_subscribers = NULL,
    #  @field winners_are_visible Field.
    winners_are_visible = NULL,
    #  @field additional_peers Field.
    additional_peers = NULL,
    #  @field countries_iso2 Field.
    countries_iso2 = NULL,
    #  @field prize_description Field.
    prize_description = NULL,
    #  @field random_id Field.
    random_id = NULL,
    initialize = function(stars, boost_peer, until_date, currency, amount, users,
                          only_new_subscribers = NULL, winners_are_visible = NULL,
                          additional_peers = NULL, countries_iso2 = NULL,
                          prize_description = NULL, random_id = NULL) {
      self$stars <- stars
      self$boost_peer <- boost_peer
      self$until_date <- until_date
      self$currency <- currency
      self$amount <- amount
      self$users <- users
      self$only_new_subscribers <- only_new_subscribers
      self$winners_are_visible <- winners_are_visible
      self$additional_peers <- additional_peers
      self$countries_iso2 <- countries_iso2
      self$prize_description <- prize_description
      self$random_id <- if (is.null(random_id)) as.integer64(sample.int(1e9, 1)) else random_id
    },
    to_dict = function() {
      list(
        "_" = "InputStorePaymentStarsGiveaway",
        stars = self$stars,
        boost_peer = if (inherits(self$boost_peer, "TLObject")) self$boost_peer$to_dict() else self$boost_peer,
        until_date = self$until_date,
        currency = self$currency,
        amount = self$amount,
        users = self$users,
        only_new_subscribers = self$only_new_subscribers,
        winners_are_visible = self$winners_are_visible,
        additional_peers = if (is.null(self$additional_peers)) list() else lapply(self$additional_peers, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        countries_iso2 = if (is.null(self$countries_iso2)) list() else self$countries_iso2,
        prize_description = self$prize_description,
        random_id = self$random_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xfa, 0x08, 0x1f, 0x75)),
        as.raw(Reduce(bitwOr, c(
          ifelse(is.null(self$only_new_subscribers) || !self$only_new_subscribers, 0, 1),
          ifelse(is.null(self$winners_are_visible) || !self$winners_are_visible, 0, 8),
          ifelse(is.null(self$additional_peers), 0, 2),
          ifelse(is.null(self$countries_iso2), 0, 4),
          ifelse(is.null(self$prize_description), 0, 16)
        ))),
        serialize_int64(self$stars),
        self$boost_peer$bytes(),
        if (!is.null(self$additional_peers)) serialize_list(self$additional_peers) else raw(0),
        if (!is.null(self$countries_iso2)) serialize_list(self$countries_iso2) else raw(0),
        if (!is.null(self$prize_description)) serialize_string(self$prize_description) else raw(0),
        serialize_int64(self$random_id),
        serialize_datetime(self$until_date),
        serialize_string(self$currency),
        serialize_int64(self$amount),
        serialize_int(self$users)
      )
    }
  )
)

#  @title InputStorePaymentStarsTopup
#  @description Telegram API type InputStorePaymentStarsTopup
#  @export
#  @noRd
#  @noRd
InputStorePaymentStarsTopup <- R6::R6Class(
  "InputStorePaymentStarsTopup",
  inherit = TLObject,
  public = list(
    #  @field stars Field.
    stars = NULL,
    #  @field currency Field.
    currency = NULL,
    #  @field amount Field.
    amount = NULL,
    #  @field spend_purpose_peer Field.
    spend_purpose_peer = NULL,
    initialize = function(stars, currency, amount, spend_purpose_peer = NULL) {
      self$stars <- stars
      self$currency <- currency
      self$amount <- amount
      self$spend_purpose_peer <- spend_purpose_peer
    },
    to_dict = function() {
      list(
        "_" = "InputStorePaymentStarsTopup",
        stars = self$stars,
        currency = self$currency,
        amount = self$amount,
        spend_purpose_peer = if (inherits(self$spend_purpose_peer, "TLObject")) self$spend_purpose_peer$to_dict() else self$spend_purpose_peer
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xcb, 0xa6, 0xa2, 0xf9)),
        as.raw(ifelse(is.null(self$spend_purpose_peer), 0, 1)),
        serialize_int64(self$stars),
        serialize_string(self$currency),
        serialize_int64(self$amount),
        if (!is.null(self$spend_purpose_peer)) self$spend_purpose_peer$bytes() else raw(0)
      )
    }
  )
)

#  @title InputStorePaymentPremiumSubscription
#  @description Telegram API type InputStorePaymentPremiumSubscription
#  @export
#  @noRd
#  @noRd
InputStorePaymentPremiumSubscription <- R6::R6Class(
  "InputStorePaymentPremiumSubscription",
  inherit = TLObject,
  public = list(
    #  @field restore Field.
    restore = NULL,
    #  @field upgrade Field.
    upgrade = NULL,
    initialize = function(restore = NULL, upgrade = NULL) {
      self$restore <- restore
      self$upgrade <- upgrade
    },
    to_dict = function() {
      list(
        "_" = "InputStorePaymentPremiumSubscription",
        restore = self$restore,
        upgrade = self$upgrade
      )
    },
    bytes = function() {
      flags <- (if (is.null(self$restore) || !self$restore) 0 else 1) |
        (if (is.null(self$upgrade) || !self$upgrade) 0 else 2)
      c(as.raw(c(0xa6, 0x75, 0x1e, 0x66)), writeBin(as.integer(flags), raw(), size = 4, endian = "little"))
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      restore <- as.logical(bitwAnd(flags, 1))
      upgrade <- as.logical(bitwAnd(flags, 2))
      self$new(restore = restore, upgrade = upgrade)
    }
  )
)

#  @title InputStorePaymentGiftPremium
#  @description Telegram API type InputStorePaymentGiftPremium
#  @export
#  @noRd
#  @noRd
InputStorePaymentGiftPremium <- R6::R6Class(
  "InputStorePaymentGiftPremium",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x616f7fe8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xe7a4174d,
    initialize = function(user_id, currency, amount) {
      self$user_id <- user_id
      self$currency <- currency
      self$amount <- amount
    },
    to_dict = function() {
      list("_" = "InputStorePaymentGiftPremium", user_id = if (inherits(self$user_id, "TLObject")) self$user_id$to_dict() else self$user_id, currency = self$currency, amount = self$amount)
    },
    bytes = function() {
      c(as.raw(c(0xe8, 0x7f, 0x6f, 0x61)), self$user_id$bytes(), charToRaw(self$currency), packBits(intToBits(self$amount), type = "raw")[1:8])
    }
  ),
  private = list(
    from_reader = function(reader) {
      user_id <- reader$tgread_object()
      currency <- reader$tgread_string()
      amount <- reader$read_long()
      self$initialize(user_id = user_id, currency = currency, amount = amount)
    }
  )
)

#  @title InputTakeoutFileLocation
#  @description Telegram API type InputTakeoutFileLocation
#  @export
#  @noRd
#  @noRd
InputTakeoutFileLocation <- R6::R6Class(
  "InputTakeoutFileLocation",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x29be5899,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1523d462,
    to_dict = function() {
      list("_" = "InputTakeoutFileLocation")
    },
    bytes = function() {
      as.raw(c(0x99, 0x58, 0xBE, 0x29))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$new()
    }
  )
)

#  @title InputTheme
#  @description Telegram API type InputTheme
#  @export
#  @noRd
#  @noRd
InputTheme <- R6::R6Class(
  "InputTheme",
  public = list(
    #  @field id Field.
    id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    initialize = function(id, access_hash) {
      self$id <- id
      self$access_hash <- access_hash
    },
    to_dict = function() {
      list(
        "_" = "InputTheme",
        id = self$id,
        access_hash = self$access_hash
      )
    }
  )
)

#  @title InputThemeSettings
#  @description Telegram API type InputThemeSettings
#  @export
#  @noRd
#  @noRd
InputThemeSettings <- R6::R6Class(
  "InputThemeSettings",
  public = list(
    #  @field base_theme Field.
    base_theme = NULL,
    #  @field accent_color Field.
    accent_color = NULL,
    #  @field message_colors_animated Field.
    message_colors_animated = NULL,
    #  @field outbox_accent_color Field.
    outbox_accent_color = NULL,
    #  @field message_colors Field.
    message_colors = NULL,
    #  @field wallpaper Field.
    wallpaper = NULL,
    #  @field wallpaper_settings Field.
    wallpaper_settings = NULL,
    initialize = function(base_theme, accent_color, message_colors_animated = NULL,
                          outbox_accent_color = NULL, message_colors = NULL,
                          wallpaper = NULL, wallpaper_settings = NULL) {
      self$base_theme <- base_theme
      self$accent_color <- accent_color
      self$message_colors_animated <- message_colors_animated
      self$outbox_accent_color <- outbox_accent_color
      self$message_colors <- message_colors
      self$wallpaper <- wallpaper
      self$wallpaper_settings <- wallpaper_settings
    },
    to_dict = function() {
      list(
        "_" = "InputThemeSettings",
        base_theme = if (inherits(self$base_theme, "R6")) self$base_theme$to_dict() else self$base_theme,
        accent_color = self$accent_color,
        message_colors_animated = self$message_colors_animated,
        outbox_accent_color = self$outbox_accent_color,
        message_colors = if (is.null(self$message_colors)) list() else self$message_colors,
        wallpaper = if (inherits(self$wallpaper, "R6")) self$wallpaper$to_dict() else self$wallpaper,
        wallpaper_settings = if (inherits(self$wallpaper_settings, "R6")) self$wallpaper_settings$to_dict() else self$wallpaper_settings
      )
    }
  )
)

#  @title InputThemeSlug
#  @description Telegram API type InputThemeSlug
#  @export
#  @noRd
#  @noRd
InputThemeSlug <- R6::R6Class(
  "InputThemeSlug",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf5890df1,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x7a100f0,
    #  @field slug Field.
    slug = NULL,
    initialize = function(slug) {
      self$slug <- slug
    },
    to_dict = function() {
      list("_" = "InputThemeSlug", slug = self$slug)
    },
    bytes = function() {
      c(as.raw(0xf1), as.raw(0x0d), as.raw(0x89), as.raw(0xf5), charToRaw(self$slug))
    }
  ),
  private = list(
    from_reader = function(reader) {
      slug <- reader$tgread_string()
      self$new(slug = slug)
    }
  )
)

#  @title InputUser
#  @description Telegram API type InputUser
#  @export
#  @noRd
#  @noRd
InputUser <- R6::R6Class(
  "InputUser",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf21158c6,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xe669bf46,
    #  @field user_id Field.
    user_id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    initialize = function(user_id, access_hash) {
      self$user_id <- user_id
      self$access_hash <- access_hash
    },
    to_dict = function() {
      list("_" = "InputUser", user_id = self$user_id, access_hash = self$access_hash)
    },
    bytes = function() {
      c(
        as.raw(0xc6), as.raw(0x58), as.raw(0x11), as.raw(0xf2),
        writeBin(self$user_id, raw(), size = 8),
        writeBin(self$access_hash, raw(), size = 8)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      user_id <- reader$read_long()
      access_hash <- reader$read_long()
      self$new(user_id = user_id, access_hash = access_hash)
    }
  )
)

#  @title InputUserEmpty
#  @description Telegram API type InputUserEmpty
#  @export
#  @noRd
#  @noRd
InputUserEmpty <- R6::R6Class(
  "InputUserEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb98886cf,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xe669bf46,
    to_dict = function() {
      list("_" = "InputUserEmpty")
    },
    bytes = function() {
      as.raw(c(0xcf, 0x86, 0x88, 0xb9))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$new()
    }
  )
)

#  @title InputUserFromMessage
#  @description Telegram API type InputUserFromMessage
#  @export
#  @noRd
#  @noRd
InputUserFromMessage <- R6::R6Class(
  "InputUserFromMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1da448e2,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xe669bf46,
    #  @field peer Field.
    peer = NULL,
    #  @field msg_id Field.
    msg_id = NULL,
    #  @field user_id Field.
    user_id = NULL,
    initialize = function(peer, msg_id, user_id) {
      self$peer <- peer
      self$msg_id <- msg_id
      self$user_id <- user_id
    },
    to_dict = function() {
      list(
        "_" = "InputUserFromMessage",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        msg_id = self$msg_id,
        user_id = self$user_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xe2, 0x48, 0xa4, 0x1d)),
        self$peer$bytes(),
        intToRaw(self$msg_id),
        intToRaw(self$user_id, 8)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      msg_id <- reader$read_int()
      user_id <- reader$read_long()
      self$new(peer = peer, msg_id = msg_id, user_id = user_id)
    }
  )
)

#  @title InputUserSelf
#  @description Telegram API type InputUserSelf
#  @export
#  @noRd
#  @noRd
InputUserSelf <- R6::R6Class(
  "InputUserSelf",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf7c1b13f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xe669bf46,
    to_dict = function() {
      list("_" = "InputUserSelf")
    },
    bytes = function() {
      as.raw(c(0x3f, 0xb1, 0xc1, 0xf7))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$new()
    }
  )
)

#  @title InputWallPaper
#  @description Telegram API type InputWallPaper
#  @export
#  @noRd
#  @noRd
InputWallPaper <- R6::R6Class(
  "InputWallPaper",
  inherit = TLObject,
  public = list(
    #  @field id Field.
    id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    initialize = function(id, access_hash) {
      self$id <- id
      self$access_hash <- access_hash
    },
    to_dict = function() {
      list(
        "_" = "InputWallPaper",
        id = self$id,
        access_hash = self$access_hash
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xe6, 0x30, 0xb9, 0x79)),
        writeBin(as.integer(self$id), raw(), size = 8, endian = "little"),
        writeBin(as.integer(self$access_hash), raw(), size = 8, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      id <- reader$read_long()
      access_hash <- reader$read_long()
      self$new(id = id, access_hash = access_hash)
    }
  )
)

#  @title InputWallPaperNoFile
#  @description Telegram API type InputWallPaperNoFile
#  @export
#  @noRd
#  @noRd
InputWallPaperNoFile <- R6::R6Class(
  "InputWallPaperNoFile",
  inherit = TLObject,
  public = list(
    #  @field id Field.
    id = NULL,
    initialize = function(id) {
      self$id <- id
    },
    to_dict = function() {
      list(
        "_" = "InputWallPaperNoFile",
        id = self$id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x96, 0x7a, 0x46, 0x2e)),
        writeBin(as.integer(self$id), raw(), size = 8, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      id <- reader$read_long()
      self$new(id = id)
    }
  )
)

#  @title InputWallPaperSlug
#  @description Telegram API type InputWallPaperSlug
#  @export
#  @noRd
#  @noRd
InputWallPaperSlug <- R6::R6Class(
  "InputWallPaperSlug",
  inherit = TLObject,
  public = list(
    #  @field slug Field.
    slug = NULL,
    initialize = function(slug) {
      self$slug <- slug
    },
    to_dict = function() {
      list(
        "_" = "InputWallPaperSlug",
        slug = self$slug
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x72, 0x09, 0x1c, 0x80)),
        serialize_bytes(self$slug)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      slug <- reader$tgread_string()
      self$new(slug = slug)
    }
  )
)

#  @title InputWebDocument
#  @description Telegram API type InputWebDocument
#  @export
#  @noRd
#  @noRd
InputWebDocument <- R6::R6Class(
  "InputWebDocument",
  inherit = TLObject,
  public = list(
    #  @field url Field.
    url = NULL,
    #  @field size Field.
    size = NULL,
    #  @field mime_type Field.
    mime_type = NULL,
    #  @field attributes Field.
    attributes = NULL,
    initialize = function(url, size, mime_type, attributes) {
      self$url <- url
      self$size <- size
      self$mime_type <- mime_type
      self$attributes <- attributes
    },
    to_dict = function() {
      list(
        "_" = "InputWebDocument",
        url = self$url,
        size = self$size,
        mime_type = self$mime_type,
        attributes = if (is.null(self$attributes)) list() else lapply(self$attributes, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      )
    },
    bytes = function() {
      raw()
    }
  ),
  private = list(
    from_reader = function(reader) {
      url <- reader$tgread_string()
      size <- reader$read_int()
      mime_type <- reader$tgread_string()
      reader$read_int()
      attributes <- list()
      for (i in seq_len(reader$read_int())) {
        attributes[[i]] <- reader$tgread_object()
      }
      self$new(url = url, size = size, mime_type = mime_type, attributes = attributes)
    }
  )
)

#  @title InputWebFileAudioAlbumThumbLocation
#  @description Telegram API type InputWebFileAudioAlbumThumbLocation
#  @export
#  @noRd
#  @noRd
InputWebFileAudioAlbumThumbLocation <- R6::R6Class(
  "InputWebFileAudioAlbumThumbLocation",
  inherit = TLObject,
  public = list(
    #  @field small Field.
    small = NULL,
    #  @field document Field.
    document = NULL,
    #  @field title Field.
    title = NULL,
    #  @field performer Field.
    performer = NULL,
    initialize = function(small = NULL, document = NULL, title = NULL, performer = NULL) {
      self$small <- small
      self$document <- document
      self$title <- title
      self$performer <- performer
    },
    to_dict = function() {
      list(
        "_" = "InputWebFileAudioAlbumThumbLocation",
        small = self$small,
        document = if (inherits(self$document, "TLObject")) self$document$to_dict() else self$document,
        title = self$title,
        performer = self$performer
      )
    },
    bytes = function() {
      raw()
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      small <- as.logical(bitwAnd(flags, 4))
      document <- if (bitwAnd(flags, 1)) reader$tgread_object() else NULL
      title <- if (bitwAnd(flags, 2)) reader$tgread_string() else NULL
      performer <- if (bitwAnd(flags, 2)) reader$tgread_string() else NULL

      self$new(small = small, document = document, title = title, performer = performer)
    }
  )
)

#  @title InputWebFileGeoPointLocation
#  @description Telegram API type InputWebFileGeoPointLocation
#  @export
#  @noRd
#  @noRd
InputWebFileGeoPointLocation <- R6::R6Class(
  "InputWebFileGeoPointLocation",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9f2221c9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf72ed8d9,
    #  @field geo_point Field.
    geo_point = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    #  @field w Field.
    w = NULL,
    #  @field h Field.
    h = NULL,
    #  @field zoom Field.
    zoom = NULL,
    #  @field scale Field.
    scale = NULL,
    initialize = function(geo_point, access_hash, w, h, zoom, scale) {
      self$geo_point <- geo_point
      self$access_hash <- access_hash
      self$w <- w
      self$h <- h
      self$zoom <- zoom
      self$scale <- scale
    },
    to_dict = function() {
      list(
        "_" = "InputWebFileGeoPointLocation",
        geo_point = if (inherits(self$geo_point, "TLObject")) self$geo_point$to_dict() else self$geo_point,
        access_hash = self$access_hash,
        w = self$w,
        h = self$h,
        zoom = self$zoom,
        scale = self$scale
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xc9, 0x21, 0x22, 0x9f)),
        self$geo_point$bytes(),
        writeBin(self$access_hash, raw(), size = 8, endian = "little"),
        writeBin(self$w, raw(), size = 4, endian = "little"),
        writeBin(self$h, raw(), size = 4, endian = "little"),
        writeBin(self$zoom, raw(), size = 4, endian = "little"),
        writeBin(self$scale, raw(), size = 4, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      geo_point <- reader$tgread_object()
      access_hash <- reader$read_long()
      w <- reader$read_int()
      h <- reader$read_int()
      zoom <- reader$read_int()
      scale <- reader$read_int()
      self$new(geo_point = geo_point, access_hash = access_hash, w = w, h = h, zoom = zoom, scale = scale)
    }
  )
)

#  @title InputWebFileLocation
#  @description Telegram API type InputWebFileLocation
#  @export
#  @noRd
#  @noRd
InputWebFileLocation <- R6::R6Class(
  "InputWebFileLocation",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc239d686,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf72ed8d9,
    #  @field url Field.
    url = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    initialize = function(url, access_hash) {
      self$url <- url
      self$access_hash <- access_hash
    },
    to_dict = function() {
      list(
        "_" = "InputWebFileLocation",
        url = self$url,
        access_hash = self$access_hash
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x86, 0xd6, 0x39, 0xc2)),
        serialize_bytes(self$url),
        writeBin(self$access_hash, raw(), size = 8, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      url <- reader$tgread_string()
      access_hash <- reader$read_long()
      self$new(url = url, access_hash = access_hash)
    }
  )
)

#  @title Invoice
#  @description Telegram API type Invoice
#  @export
#  @noRd
#  @noRd
Invoice <- R6::R6Class(
  "Invoice",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x49ee584,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5fd82ed8,
    #  @field currency Field.
    currency = NULL,
    #  @field prices Field.
    prices = NULL,
    #  @field test Field.
    test = NULL,
    #  @field name_requested Field.
    name_requested = NULL,
    #  @field phone_requested Field.
    phone_requested = NULL,
    #  @field email_requested Field.
    email_requested = NULL,
    #  @field shipping_address_requested Field.
    shipping_address_requested = NULL,
    #  @field flexible Field.
    flexible = NULL,
    #  @field phone_to_provider Field.
    phone_to_provider = NULL,
    #  @field email_to_provider Field.
    email_to_provider = NULL,
    #  @field recurring Field.
    recurring = NULL,
    #  @field max_tip_amount Field.
    max_tip_amount = NULL,
    #  @field suggested_tip_amounts Field.
    suggested_tip_amounts = NULL,
    #  @field terms_url Field.
    terms_url = NULL,
    #  @field subscription_period Field.
    subscription_period = NULL,
    initialize = function(currency, prices, test = NULL, name_requested = NULL, phone_requested = NULL,
                          email_requested = NULL, shipping_address_requested = NULL, flexible = NULL,
                          phone_to_provider = NULL, email_to_provider = NULL, recurring = NULL,
                          max_tip_amount = NULL, suggested_tip_amounts = NULL, terms_url = NULL,
                          subscription_period = NULL) {
      self$currency <- currency
      self$prices <- prices
      self$test <- test
      self$name_requested <- name_requested
      self$phone_requested <- phone_requested
      self$email_requested <- email_requested
      self$shipping_address_requested <- shipping_address_requested
      self$flexible <- flexible
      self$phone_to_provider <- phone_to_provider
      self$email_to_provider <- email_to_provider
      self$recurring <- recurring
      self$max_tip_amount <- max_tip_amount
      self$suggested_tip_amounts <- suggested_tip_amounts
      self$terms_url <- terms_url
      self$subscription_period <- subscription_period
    },
    to_dict = function() {
      list(
        "_" = "Invoice",
        currency = self$currency,
        prices = if (is.null(self$prices)) list() else lapply(self$prices, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        test = self$test,
        name_requested = self$name_requested,
        phone_requested = self$phone_requested,
        email_requested = self$email_requested,
        shipping_address_requested = self$shipping_address_requested,
        flexible = self$flexible,
        phone_to_provider = self$phone_to_provider,
        email_to_provider = self$email_to_provider,
        recurring = self$recurring,
        max_tip_amount = self$max_tip_amount,
        suggested_tip_amounts = if (is.null(self$suggested_tip_amounts)) list() else self$suggested_tip_amounts,
        terms_url = self$terms_url,
        subscription_period = self$subscription_period
      )
    },
    bytes = function() {
      stopifnot((!is.null(self$max_tip_amount) && !is.null(self$suggested_tip_amounts)) ||
        (is.null(self$max_tip_amount) && is.null(self$suggested_tip_amounts)))
      raw()
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      test <- as.logical(bitwAnd(flags, 1))
      name_requested <- as.logical(bitwAnd(flags, 2))
      phone_requested <- as.logical(bitwAnd(flags, 4))
      email_requested <- as.logical(bitwAnd(flags, 8))
      shipping_address_requested <- as.logical(bitwAnd(flags, 16))
      flexible <- as.logical(bitwAnd(flags, 32))
      phone_to_provider <- as.logical(bitwAnd(flags, 64))
      email_to_provider <- as.logical(bitwAnd(flags, 128))
      recurring <- as.logical(bitwAnd(flags, 512))
      currency <- reader$tgread_string()
      reader$read_int()
      prices <- list()
      for (i in seq_len(reader$read_int())) {
        prices[[i]] <- reader$tgread_object()
      }

      max_tip_amount <- if (bitwAnd(flags, 256)) reader$read_long() else NULL
      suggested_tip_amounts <- if (bitwAnd(flags, 256)) {
        reader$read_int()
        lapply(seq_len(reader$read_int()), function(i) reader$read_long())
      } else {
        NULL
      }
      terms_url <- if (bitwAnd(flags, 1024)) reader$tgread_string() else NULL
      subscription_period <- if (bitwAnd(flags, 2048)) reader$read_int() else NULL

      self$new(
        currency = currency, prices = prices, test = test, name_requested = name_requested,
        phone_requested = phone_requested, email_requested = email_requested,
        shipping_address_requested = shipping_address_requested, flexible = flexible,
        phone_to_provider = phone_to_provider, email_to_provider = email_to_provider,
        recurring = recurring, max_tip_amount = max_tip_amount,
        suggested_tip_amounts = suggested_tip_amounts, terms_url = terms_url,
        subscription_period = subscription_period
      )
    }
  )
)

#  @title IpPort
#  @description Telegram API type IpPort
#  @export
#  @noRd
#  @noRd
IpPort <- R6::R6Class(
  "IpPort",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd433ad73,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xa2a03726,
    #  @field ipv4 Field.
    ipv4 = NULL,
    #  @field port Field.
    port = NULL,
    initialize = function(ipv4, port) {
      self$ipv4 <- ipv4
      self$port <- port
    },
    to_dict = function() {
      list(
        "_" = "IpPort",
        ipv4 = self$ipv4,
        port = self$port
      )
    },
    bytes = function() {
      raw()
    }
  ),
  private = list(
    from_reader = function(reader) {
      ipv4 <- reader$read_int()
      port <- reader$read_int()
      self$new(ipv4 = ipv4, port = port)
    }
  )
)

#  @title IpPortSecret
#  @description Telegram API type IpPortSecret
#  @export
#  @noRd
#  @noRd
IpPortSecret <- R6::R6Class(
  "IpPortSecret",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x37982646,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xa2a03726,
    #  @field ipv4 Field.
    ipv4 = NULL,
    #  @field port Field.
    port = NULL,
    #  @field secret Field.
    secret = NULL,
    initialize = function(ipv4, port, secret) {
      self$ipv4 <- ipv4
      self$port <- port
      self$secret <- secret
    },
    to_dict = function() {
      list(
        "_" = "IpPortSecret",
        ipv4 = self$ipv4,
        port = self$port,
        secret = self$secret
      )
    },
    bytes = function() {
      raw(0) # Placeholder for byte serialization logic
    }
  ),
  private = list(
    from_reader = function(reader) {
      ipv4 <- reader$read_int()
      port <- reader$read_int()
      secret <- reader$tgread_bytes()
      self$new(ipv4 = ipv4, port = port, secret = secret)
    }
  )
)

#  @title JsonArray
#  @description Telegram API type JsonArray
#  @export
#  @noRd
#  @noRd
JsonArray <- R6::R6Class(
  "JsonArray",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf7444763,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xeb9987b3,
    #  @field value Field.
    value = NULL,
    initialize = function(value) {
      self$value <- value
    },
    to_dict = function() {
      list(
        "_" = "JsonArray",
        value = if (is.null(self$value)) {
          list()
        } else {
          lapply(self$value, function(x) {
            if (inherits(x, "TLObject")) x$to_dict() else x
          })
        }
      )
    },
    bytes = function() {
      raw(0) # Placeholder for byte serialization logic
    }
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      value <- list()
      for (i in seq_len(reader$read_int())) {
        x <- reader$tgread_object()
        value[[i]] <- x
      }
      self$new(value = value)
    }
  )
)

#  @title JsonBool
#  @description Telegram API type JsonBool
#  @export
#  @noRd
#  @noRd
JsonBool <- R6::R6Class(
  "JsonBool",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc7345e6a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xeb9987b3,
    #  @field value Field.
    value = NULL,
    initialize = function(value) {
      self$value <- value
    },
    to_dict = function() {
      list(
        "_" = "JsonBool",
        value = self$value
      )
    },
    bytes = function() {
      if (self$value) {
        as.raw(c(0x6a, 0x5e, 0x34, 0xc7, 0xb5, 0x75, 0x72, 0x99))
      } else {
        as.raw(c(0x6a, 0x5e, 0x34, 0xc7, 0x37, 0x97, 0x79, 0xbc))
      }
    }
  ),
  private = list(
    from_reader = function(reader) {
      value <- reader$tgread_bool()
      self$new(value = value)
    }
  )
)

#  @title JsonNull
#  @description Telegram API type JsonNull
#  @export
#  @noRd
#  @noRd
JsonNull <- R6::R6Class(
  "JsonNull",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x3f6d7b68,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xeb9987b3,
    to_dict = function() {
      list("_" = "JsonNull")
    },
    bytes = function() {
      as.raw(c(0x68, 0x7b, 0x6d, 0x3f))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$new()
    }
  )
)

#  @title JsonNumber
#  @description Telegram API type JsonNumber
#  @export
#  @noRd
#  @noRd
JsonNumber <- R6::R6Class(
  "JsonNumber",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x2be0dfa4,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xeb9987b3,
    #  @field value Field.
    value = NULL,
    initialize = function(value) {
      self$value <- value
    },
    to_dict = function() {
      list(
        "_" = "JsonNumber",
        value = self$value
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xa4, 0xdf, 0xe0, 0x2b)),
        writeBin(self$value, raw(), size = 8, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      value <- reader$read_double()
      self$new(value = value)
    }
  )
)

#  @title JsonObject
#  @description Telegram API type JsonObject
#  @export
#  @noRd
#  @noRd
JsonObject <- R6::R6Class(
  "JsonObject",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x99c1d49d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xeb9987b3,
    #  @field value Field.
    value = NULL,
    initialize = function(value) {
      self$value <- value
    },
    to_dict = function() {
      list(
        "_" = "JsonObject",
        value = if (is.null(self$value)) {
          list()
        } else {
          lapply(self$value, function(x) {
            if (inherits(x, "TLObject")) x$to_dict() else x
          })
        }
      )
    },
    bytes = function() {
      raw_data <- c(
        as.raw(c(0x9d, 0xd4, 0xc1, 0x99)),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)),
        writeBin(length(self$value), raw(), size = 4, endian = "little"),
        unlist(lapply(self$value, function(x) x$bytes()), recursive = FALSE)
      )
      do.call(c, raw_data)
    }
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      value_list <- vector("list", reader$read_int())
      for (i in seq_along(value_list)) {
        value_list[[i]] <- reader$tgread_object()
      }
      self$new(value = value_list)
    }
  )
)

#  @title JsonObjectValue
#  @description Telegram API type JsonObjectValue
#  @export
#  @noRd
#  @noRd
JsonObjectValue <- R6::R6Class(
  "JsonObjectValue",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc0de1bd9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x937fceb9,
    #  @field key Field.
    key = NULL,
    #  @field value Field.
    value = NULL,
    initialize = function(key, value) {
      self$key <- key
      self$value <- value
    },
    to_dict = function() {
      list(
        "_" = "JsonObjectValue",
        key = self$key,
        value = if (inherits(self$value, "TLObject")) self$value$to_dict() else self$value
      )
    },
    bytes = function() {
      raw_data <- c(
        as.raw(c(0xd9, 0x1b, 0xde, 0xc0)),
        serialize_bytes(self$key),
        self$value$bytes()
      )
      do.call(c, raw_data)
    }
  ),
  private = list(
    from_reader = function(reader) {
      key <- reader$tgread_string()
      value <- reader$tgread_object()
      self$new(key = key, value = value)
    }
  )
)

#  @title JsonString
#  @description Telegram API type JsonString
#  @export
#  @noRd
#  @noRd
JsonString <- R6::R6Class(
  "JsonString",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb71e767a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xeb9987b3,
    #  @field value Field.
    value = NULL,
    initialize = function(value) {
      self$value <- value
    },
    to_dict = function() {
      list(
        "_" = "JsonString",
        value = self$value
      )
    },
    bytes = function() {
      raw(0) # Placeholder for byte serialization
    }
  ),
  private = list(
    from_reader = function(reader) {
      value <- reader$tgread_string()
      self$new(value = value)
    }
  )
)

#  @title KeyboardButton
#  @description Telegram API type KeyboardButton
#  @export
#  @noRd
#  @noRd
KeyboardButton <- R6::R6Class(
  "KeyboardButton",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa2fa4880,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    #  @field text Field.
    text = NULL,
    initialize = function(text) {
      self$text <- text
    },
    to_dict = function() {
      list(
        "_" = "KeyboardButton",
        text = self$text
      )
    },
    bytes = function() {
      raw(0) # Placeholder for byte serialization
    }
  ),
  private = list(
    from_reader = function(reader) {
      text <- reader$tgread_string()
      self$new(text = text)
    }
  )
)

#  @title KeyboardButtonBuy
#  @description Telegram API type KeyboardButtonBuy
#  @export
#  @noRd
#  @noRd
KeyboardButtonBuy <- R6::R6Class(
  "KeyboardButtonBuy",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xafd93fbb,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    #  @field text Field.
    text = NULL,
    initialize = function(text) {
      self$text <- text
    },
    to_dict = function() {
      list(
        "_" = "KeyboardButtonBuy",
        text = self$text
      )
    },
    bytes = function() {
      raw(0) # Placeholder for byte serialization
    }
  ),
  private = list(
    from_reader = function(reader) {
      text <- reader$tgread_string()
      self$new(text = text)
    }
  )
)

#  @title KeyboardButtonCallback
#  @description Telegram API type KeyboardButtonCallback
#  @export
#  @noRd
#  @noRd
KeyboardButtonCallback <- R6::R6Class(
  "KeyboardButtonCallback",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x35bbdb6b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    #  @field text Field.
    text = NULL,
    #  @field data Field.
    data = NULL,
    #  @field requires_password Field.
    requires_password = NULL,
    initialize = function(text, data, requires_password = NULL) {
      self$text <- text
      self$data <- data
      self$requires_password <- requires_password
    },
    to_dict = function() {
      list(
        "_" = "KeyboardButtonCallback",
        text = self$text,
        data = self$data,
        requires_password = self$requires_password
      )
    },
    bytes = function() {
      raw(0) # Placeholder for byte serialization
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      requires_password <- as.logical(flags & 1)
      text <- reader$tgread_string()
      data <- reader$tgread_bytes()
      self$new(text = text, data = data, requires_password = requires_password)
    }
  )
)

#  @title KeyboardButtonCopy
#  @description Telegram API type KeyboardButtonCopy
#  @export
#  @noRd
#  @noRd
KeyboardButtonCopy <- R6::R6Class("KeyboardButtonCopy",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x75d2698e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    initialize = function(text, copy_text) {
      self$text <- text
      self$copy_text <- copy_text
    },
    to_dict = function() {
      list("_" = "KeyboardButtonCopy", text = self$text, copy_text = self$copy_text)
    },
    bytes = function() {
      c(as.raw(c(0x8e, 0x69, 0xd2, 0x75)), self$serializebytes(self$text), self$serializebytes(self$copy_text))
    }
  ),
  private = list(
    from_reader = function(reader) {
      text <- reader$tgread_string()
      copy_text <- reader$tgread_string()
      self$initialize(text = text, copy_text = copy_text)
      self
    }
  )
)

#  @title KeyboardButtonGame
#  @description Telegram API type KeyboardButtonGame
#  @export
#  @noRd
#  @noRd
KeyboardButtonGame <- R6::R6Class("KeyboardButtonGame",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x50f41ccf,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    initialize = function(text) {
      self$text <- text
    },
    to_dict = function() {
      list("_" = "KeyboardButtonGame", text = self$text)
    },
    bytes = function() {
      c(as.raw(c(0xcf, 0x1c, 0xf4, 0x50)), self$serializebytes(self$text))
    }
  ),
  private = list(
    from_reader = function(reader) {
      text <- reader$tgread_string()
      self$initialize(text = text)
      self
    }
  )
)

#  @title KeyboardButtonRequestGeoLocation
#  @description Telegram API type KeyboardButtonRequestGeoLocation
#  @export
#  @noRd
#  @noRd
KeyboardButtonRequestGeoLocation <- R6::R6Class("KeyboardButtonRequestGeoLocation",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xfc796b3f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    initialize = function(text) {
      self$text <- text
    },
    to_dict = function() {
      list("_" = "KeyboardButtonRequestGeoLocation", text = self$text)
    },
    bytes = function() {
      c(as.raw(c(0x3f, 0x6b, 0x79, 0xfc)), self$serializebytes(self$text))
    }
  ),
  private = list(
    from_reader = function(reader) {
      text <- reader$tgread_string()
      self$initialize(text = text)
      self
    }
  )
)

#  @title KeyboardButtonRequestPeer
#  @description Telegram API type KeyboardButtonRequestPeer
#  @export
#  @noRd
#  @noRd
KeyboardButtonRequestPeer <- R6::R6Class("KeyboardButtonRequestPeer",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x53d7bfd8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    initialize = function(text, button_id, peer_type, max_quantity) {
      self$text <- text
      self$button_id <- button_id
      self$peer_type <- peer_type
      self$max_quantity <- max_quantity
    },
    to_dict = function() {
      list("_" = "KeyboardButtonRequestPeer", text = self$text, button_id = self$button_id, peer_type = if (inherits(self$peer_type, "TLObject")) self$peer_type$to_dict() else self$peer_type, max_quantity = self$max_quantity)
    },
    bytes = function() {
      c(as.raw(c(0xd8, 0xbf, 0xd7, 0x53)), self$serializebytes(self$text), writeBin(self$button_id, raw(), size = 4, endian = "little"), self$peer_type$bytes(), writeBin(self$max_quantity, raw(), size = 4, endian = "little"))
    }
  ),
  private = list(
    from_reader = function(reader) {
      text <- reader$tgread_string()
      button_id <- reader$read_int()
      peer_type <- reader$tgread_object()
      max_quantity <- reader$read_int()
      self$initialize(text = text, button_id = button_id, peer_type = peer_type, max_quantity = max_quantity)
      self
    }
  )
)

#  @title KeyboardButtonRequestPhone
#  @description Telegram API type KeyboardButtonRequestPhone
#  @export
#  @noRd
#  @noRd
KeyboardButtonRequestPhone <- R6::R6Class("KeyboardButtonRequestPhone",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb16a6c29,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    initialize = function(text) {
      self$text <- text
    },
    to_dict = function() {
      list("_" = "KeyboardButtonRequestPhone", text = self$text)
    },
    bytes = function() {
      c(as.raw(c(0x29, 0x6c, 0x6a, 0xb1)), self$serializebytes(self$text))
    }
  ),
  private = list(
    from_reader = function(reader) {
      text <- reader$tgread_string()
      self$initialize(text = text)
      self
    }
  )
)

#  @title KeyboardButtonRequestPoll
#  @description Telegram API type KeyboardButtonRequestPoll
#  @export
#  @noRd
#  @noRd
KeyboardButtonRequestPoll <- R6::R6Class("KeyboardButtonRequestPoll",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbbc7515d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    initialize = function(text, quiz = NULL) {
      self$text <- text
      self$quiz <- quiz
    },
    to_dict = function() {
      list("_" = "KeyboardButtonRequestPoll", text = self$text, quiz = self$quiz)
    },
    bytes = function() {
      flags <- if (is.null(self$quiz)) 0 else 1
      c(as.raw(c(0x5d, 0x51, 0xc7, 0xbb)), writeBin(flags, raw(), size = 4, endian = "little"), if (is.null(self$quiz)) raw() else (if (self$quiz) as.raw(c(0xb5, 0x75, 0x72, 0x99)) else as.raw(c(0x37, 0x97, 0x79, 0xbc))), self$serializebytes(self$text))
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      if (bitwAnd(flags, 1)) {
        quiz <- reader$tgread_bool()
      } else {
        quiz <- NULL
      }
      text <- reader$tgread_string()
      self$initialize(text = text, quiz = quiz)
      self
    }
  )
)

#  @title KeyboardButtonRow
#  @description Telegram API type KeyboardButtonRow
#  @export
#  @noRd
#  @noRd
KeyboardButtonRow <- R6::R6Class("KeyboardButtonRow",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x77608b83,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x847730ae,
    initialize = function(buttons) {
      self$buttons <- buttons
    },
    to_dict = function() {
      list("_" = "KeyboardButtonRow", buttons = lapply(self$buttons, function(x) if (inherits(x, "TLObject")) x$to_dict() else x))
    },
    bytes = function() {
      c(as.raw(c(0x83, 0x8b, 0x60, 0x77)), as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), writeBin(length(self$buttons), raw(), size = 4, endian = "little"), do.call(c, lapply(self$buttons, function(x) x$bytes())))
    }
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      buttons <- list()
      for (i in 1:reader$read_int()) {
        x <- reader$tgread_object()
        buttons <- c(buttons, list(x))
      }
      self$initialize(buttons = buttons)
      self
    }
  )
)

#  @title KeyboardButtonSimpleWebView
#  @description Telegram API type KeyboardButtonSimpleWebView
#  @export
#  @noRd
#  @noRd
KeyboardButtonSimpleWebView <- R6::R6Class("KeyboardButtonSimpleWebView",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa0c0505c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    initialize = function(text, url) {
      self$text <- text
      self$url <- url
    },
    to_dict = function() {
      list("_" = "KeyboardButtonSimpleWebView", text = self$text, url = self$url)
    },
    bytes = function() {
      c(as.raw(c(0x5c, 0x50, 0xc0, 0xa0)), self$serializebytes(self$text), self$serializebytes(self$url))
    }
  ),
  private = list(
    from_reader = function(reader) {
      text <- reader$tgread_string()
      url <- reader$tgread_string()
      self$initialize(text = text, url = url)
      self
    }
  )
)

#  @title KeyboardButtonSwitchInline
#  @description Telegram API type KeyboardButtonSwitchInline
#  @export
#  @noRd
#  @noRd
KeyboardButtonSwitchInline <- R6::R6Class("KeyboardButtonSwitchInline",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x93b9fbb5,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    initialize = function(text, query, samepeer = NULL, peer_types = NULL) {
      self$text <- text
      self$query <- query
      self$samepeer <- samepeer
      self$peer_types <- peer_types
    },
    to_dict = function() {
      list("_" = "KeyboardButtonSwitchInline", text = self$text, query = self$query, samepeer = self$samepeer, peer_types = lapply(self$peer_types, function(x) if (inherits(x, "TLObject")) x$to_dict() else x))
    },
    bytes = function() {
      flags <- (if (is.null(self$samepeer) || !self$samepeer) 0 else 1) | (if (is.null(self$peer_types)) 0 else 2)
      peer_typesbytes <- if (is.null(self$peer_types)) raw() else c(as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), writeBin(length(self$peer_types), raw(), size = 4, endian = "little"), do.call(c, lapply(self$peer_types, function(x) x$bytes())))
      c(as.raw(c(0xb5, 0xfb, 0xb9, 0x93)), writeBin(flags, raw(), size = 4, endian = "little"), if (is.null(self$samepeer)) raw() else raw(), self$serializebytes(self$text), self$serializebytes(self$query), peer_typesbytes)
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      samepeer <- bitwAnd(flags, 1) != 0
      text <- reader$tgread_string()
      query <- reader$tgread_string()
      if (bitwAnd(flags, 2)) {
        reader$read_int()
        peer_types <- list()
        for (i in 1:reader$read_int()) {
          x <- reader$tgread_object()
          peer_types <- c(peer_types, list(x))
        }
      } else {
        peer_types <- NULL
      }
      self$initialize(text = text, query = query, samepeer = samepeer, peer_types = peer_types)
      self
    }
  )
)

#  @title KeyboardButtonUrl
#  @description Telegram API type KeyboardButtonUrl
#  @export
#  @noRd
#  @noRd
KeyboardButtonUrl <- R6::R6Class("KeyboardButtonUrl",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x258aff05,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    initialize = function(text, url) {
      self$text <- text
      self$url <- url
    },
    to_dict = function() {
      list("_" = "KeyboardButtonUrl", text = self$text, url = self$url)
    },
    bytes = function() {
      c(as.raw(c(0x05, 0xff, 0x8a, 0x25)), self$serializebytes(self$text), self$serializebytes(self$url))
    }
  ),
  private = list(
    from_reader = function(reader) {
      text <- reader$tgread_string()
      url <- reader$tgread_string()
      self$initialize(text = text, url = url)
      self
    }
  )
)

#  @title KeyboardButtonUrlAuth
#  @description Telegram API type KeyboardButtonUrlAuth
#  @export
#  @noRd
#  @noRd
KeyboardButtonUrlAuth <- R6::R6Class("KeyboardButtonUrlAuth",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x10b78d29,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    initialize = function(text, url, button_id, fwd_text = NULL) {
      self$text <- text
      self$url <- url
      self$button_id <- button_id
      self$fwd_text <- fwd_text
    },
    to_dict = function() {
      list("_" = "KeyboardButtonUrlAuth", text = self$text, url = self$url, button_id = self$button_id, fwd_text = self$fwd_text)
    },
    bytes = function() {
      flags <- if (is.null(self$fwd_text)) 0 else 1
      c(as.raw(c(0x29, 0x8d, 0xb7, 0x10)), writeBin(flags, raw(), size = 4, endian = "little"), self$serializebytes(self$text), if (is.null(self$fwd_text)) raw() else self$serializebytes(self$fwd_text), self$serializebytes(self$url), writeBin(self$button_id, raw(), size = 4, endian = "little"))
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      text <- reader$tgread_string()
      if (bitwAnd(flags, 1)) {
        fwd_text <- reader$tgread_string()
      } else {
        fwd_text <- NULL
      }
      url <- reader$tgread_string()
      button_id <- reader$read_int()
      self$initialize(text = text, url = url, button_id = button_id, fwd_text = fwd_text)
      self
    }
  )
)

#  @title KeyboardButtonUserProfile
#  @description Telegram API type KeyboardButtonUserProfile
#  @export
#  @noRd
#  @noRd
KeyboardButtonUserProfile <- R6::R6Class("KeyboardButtonUserProfile",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x308660c1,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    initialize = function(text, user_id) {
      self$text <- text
      self$user_id <- user_id
    },
    to_dict = function() {
      list("_" = "KeyboardButtonUserProfile", text = self$text, user_id = self$user_id)
    },
    bytes = function() {
      c(as.raw(c(0xc1, 0x60, 0x86, 0x30)), self$serializebytes(self$text), writeBin(self$user_id, raw(), size = 8, endian = "little"))
    }
  ),
  private = list(
    from_reader = function(reader) {
      text <- reader$tgread_string()
      user_id <- reader$read_long()
      self$initialize(text = text, user_id = user_id)
      self
    }
  )
)

#  @title KeyboardButtonWebView
#  @description Telegram API type KeyboardButtonWebView
#  @export
#  @noRd
#  @noRd
KeyboardButtonWebView <- R6::R6Class("KeyboardButtonWebView",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x13767230,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    initialize = function(text, url) {
      self$text <- text
      self$url <- url
    },
    to_dict = function() {
      list("_" = "KeyboardButtonWebView", text = self$text, url = self$url)
    },
    bytes = function() {
      c(as.raw(c(0x30, 0x72, 0x76, 0x13)), self$serializebytes(self$text), self$serializebytes(self$url))
    }
  ),
  private = list(
    from_reader = function(reader) {
      text <- reader$tgread_string()
      url <- reader$tgread_string()
      self$initialize(text = text, url = url)
      self
    }
  )
)

#  @title KeyboardButton
#  @description Telegram API type KeyboardButton
#  @export
#  @noRd
#  @noRd
KeyboardButton <- R6::R6Class("KeyboardButton",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa2fa4880,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    initialize = function(text) {
      self$text <- text
    },
    to_dict = function() {
      list("_" = "KeyboardButton", text = self$text)
    },
    bytes = function() {
      c(as.raw(c(0x80, 0x48, 0xfa, 0xa2)), self$serializebytes(self$text))
    }
  ),
  private = list(
    from_reader = function(reader) {
      text <- reader$tgread_string()
      self$initialize(text = text)
      self
    }
  )
)

#  @title KeyboardButtonBuy
#  @description Telegram API type KeyboardButtonBuy
#  @export
#  @noRd
#  @noRd
KeyboardButtonBuy <- R6::R6Class("KeyboardButtonBuy",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xafd93fbb,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    initialize = function(text) {
      self$text <- text
    },
    to_dict = function() {
      list("_" = "KeyboardButtonBuy", text = self$text)
    },
    bytes = function() {
      c(as.raw(c(0xbb, 0x3f, 0xd9, 0xaf)), self$serializebytes(self$text))
    }
  ),
  private = list(
    from_reader = function(reader) {
      text <- reader$tgread_string()
      self$initialize(text = text)
      self
    }
  )
)

#  @title KeyboardButtonCallback
#  @description Telegram API type KeyboardButtonCallback
#  @export
#  @noRd
#  @noRd
KeyboardButtonCallback <- R6::R6Class("KeyboardButtonCallback",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x35bbdb6b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    initialize = function(text, data, requires_password = NULL) {
      self$text <- text
      self$data <- data
      self$requires_password <- requires_password
    },
    to_dict = function() {
      list("_" = "KeyboardButtonCallback", text = self$text, data = self$data, requires_password = self$requires_password)
    },
    bytes = function() {
      flags <- if (is.null(self$requires_password) || !self$requires_password) 0 else 1
      c(as.raw(c(0x6b, 0xdb, 0xbb, 0x35)), writeBin(flags, raw(), size = 4, endian = "little"), self$serializebytes(self$text), self$serializebytes(self$data))
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      requires_password <- bitwAnd(flags, 1) != 0
      text <- reader$tgread_string()
      data <- reader$tgreadbytes()
      self$initialize(text = text, data = data, requires_password = requires_password)
      self
    }
  )
)

#  @title KeyboardButtonCopy
#  @description Telegram API type KeyboardButtonCopy
#  @export
#  @noRd
#  @noRd
KeyboardButtonCopy <- R6::R6Class(
  "KeyboardButtonCopy",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x75d2698e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    #  @field text Field.
    text = NULL,
    #  @field copy_text Field.
    copy_text = NULL,
    initialize = function(text, copy_text) {
      self$text <- text
      self$copy_text <- copy_text
    },
    to_dict = function() {
      list("_" = "KeyboardButtonCopy", text = self$text, copy_text = self$copy_text)
    },
    bytes = function() {
      c(
        pack("<I", self$CONSTRUCTOR_ID),
        self$serializebytes(self$text),
        self$serializebytes(self$copy_text)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$text <- reader$tgread_string()
      self$copy_text <- reader$tgread_string()
      self
    }
  )
)

#  @title KeyboardButtonGame
#  @description Telegram API type KeyboardButtonGame
#  @export
#  @noRd
#  @noRd
KeyboardButtonGame <- R6::R6Class(
  "KeyboardButtonGame",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x50f41ccf,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    #  @field text Field.
    text = NULL,
    initialize = function(text) {
      self$text <- text
    },
    to_dict = function() {
      list("_" = "KeyboardButtonGame", text = self$text)
    },
    bytes = function() {
      c(
        pack("<I", self$CONSTRUCTOR_ID),
        self$serializebytes(self$text)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$text <- reader$tgread_string()
      self
    }
  )
)

#  @title KeyboardButtonRequestGeoLocation
#  @description Telegram API type KeyboardButtonRequestGeoLocation
#  @export
#  @noRd
#  @noRd
KeyboardButtonRequestGeoLocation <- R6::R6Class(
  "KeyboardButtonRequestGeoLocation",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xfc796b3f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    #  @field text Field.
    text = NULL,
    initialize = function(text) {
      self$text <- text
    },
    to_dict = function() {
      list("_" = "KeyboardButtonRequestGeoLocation", text = self$text)
    },
    bytes = function() {
      c(
        pack("<I", self$CONSTRUCTOR_ID),
        self$serializebytes(self$text)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$text <- reader$tgread_string()
      self
    }
  )
)

#  @title KeyboardButtonRequestPeer
#  @description Telegram API type KeyboardButtonRequestPeer
#  @export
#  @noRd
#  @noRd
KeyboardButtonRequestPeer <- R6::R6Class(
  "KeyboardButtonRequestPeer",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x53d7bfd8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    #  @field text Field.
    text = NULL,
    #  @field button_id Field.
    button_id = NULL,
    #  @field peer_type Field.
    peer_type = NULL,
    #  @field max_quantity Field.
    max_quantity = NULL,
    initialize = function(text, button_id, peer_type, max_quantity) {
      self$text <- text
      self$button_id <- button_id
      self$peer_type <- peer_type
      self$max_quantity <- max_quantity
    },
    to_dict = function() {
      list("_" = "KeyboardButtonRequestPeer", text = self$text, button_id = self$button_id, peer_type = if (inherits(self$peer_type, "TLObject")) self$peer_type$to_dict() else self$peer_type, max_quantity = self$max_quantity)
    },
    bytes = function() {
      c(
        pack("<I", self$CONSTRUCTOR_ID),
        self$serializebytes(self$text),
        pack("<i", self$button_id),
        self$peer_type$bytes(),
        pack("<i", self$max_quantity)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$text <- reader$tgread_string()
      self$button_id <- reader$read_int()
      self$peer_type <- reader$tgread_object()
      self$max_quantity <- reader$read_int()
      self
    }
  )
)

#  @title KeyboardButtonRequestPhone
#  @description Telegram API type KeyboardButtonRequestPhone
#  @export
#  @noRd
#  @noRd
KeyboardButtonRequestPhone <- R6::R6Class(
  "KeyboardButtonRequestPhone",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb16a6c29,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    #  @field text Field.
    text = NULL,
    initialize = function(text) {
      self$text <- text
    },
    to_dict = function() {
      list("_" = "KeyboardButtonRequestPhone", text = self$text)
    },
    bytes = function() {
      c(
        pack("<I", self$CONSTRUCTOR_ID),
        self$serializebytes(self$text)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$text <- reader$tgread_string()
      self
    }
  )
)

#  @title KeyboardButtonRequestPoll
#  @description Telegram API type KeyboardButtonRequestPoll
#  @export
#  @noRd
#  @noRd
KeyboardButtonRequestPoll <- R6::R6Class(
  "KeyboardButtonRequestPoll",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbbc7515d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    #  @field text Field.
    text = NULL,
    #  @field quiz Field.
    quiz = NULL,
    initialize = function(text, quiz = NULL) {
      self$text <- text
      self$quiz <- quiz
    },
    to_dict = function() {
      list("_" = "KeyboardButtonRequestPoll", text = self$text, quiz = self$quiz)
    },
    bytes = function() {
      flags <- if (is.null(self$quiz)) 0L else 1L
      c(
        pack("<I", self$CONSTRUCTOR_ID),
        pack("<I", flags),
        if (!is.null(self$quiz)) if (self$quiz) pack("<I", 0x9975b5) else pack("<I", 0xbc799737) else NULL,
        self$serializebytes(self$text)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      if (bitwAnd(flags, 1L)) {
        self$quiz <- reader$tgread_bool()
      } else {
        self$quiz <- NULL
      }
      self$text <- reader$tgread_string()
      self
    }
  )
)

#  @title KeyboardButtonRow
#  @description Telegram API type KeyboardButtonRow
#  @export
#  @noRd
#  @noRd
KeyboardButtonRow <- R6::R6Class(
  "KeyboardButtonRow",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x77608b83,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x847730ae,
    #  @field buttons Field.
    buttons = NULL,
    initialize = function(buttons) {
      self$buttons <- buttons
    },
    to_dict = function() {
      list("_" = "KeyboardButtonRow", buttons = lapply(self$buttons, function(x) if (inherits(x, "TLObject")) x$to_dict() else x))
    },
    bytes = function() {
      c(
        pack("<I", self$CONSTRUCTOR_ID),
        pack("<I", 0x1cb5c415L),
        pack("<i", length(self$buttons)),
        unlist(lapply(self$buttons, function(x) x$bytes()))
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      self$buttons <- list()
      for (i in 1:reader$read_int()) {
        self$buttons[[i]] <- reader$tgread_object()
      }
      self
    }
  ),
  class = TRUE
)

#  @title KeyboardButtonSimpleWebView
#  @description Telegram API type KeyboardButtonSimpleWebView
#  @export
#  @noRd
#  @noRd
KeyboardButtonSimpleWebView <- R6::R6Class(
  "KeyboardButtonSimpleWebView",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa0c0505c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    #  @field text Field.
    text = NULL,
    #  @field url Field.
    url = NULL,
    initialize = function(text, url) {
      self$text <- text
      self$url <- url
    },
    to_dict = function() {
      list("_" = "KeyboardButtonSimpleWebView", text = self$text, url = self$url)
    },
    bytes = function() {
      c(
        pack("<I", self$CONSTRUCTOR_ID),
        self$serializebytes(self$text),
        self$serializebytes(self$url)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$text <- reader$tgread_string()
      self$url <- reader$tgread_string()
      self
    }
  )
)

#  @title KeyboardButtonSwitchInline
#  @description Telegram API type KeyboardButtonSwitchInline
#  @export
#  @noRd
#  @noRd
KeyboardButtonSwitchInline <- R6::R6Class(
  "KeyboardButtonSwitchInline",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x93b9fbb5,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    #  @field text Field.
    text = NULL,
    #  @field query Field.
    query = NULL,
    #  @field samepeer Field.
    samepeer = NULL,
    #  @field peer_types Field.
    peer_types = NULL,
    initialize = function(text, query, samepeer = NULL, peer_types = NULL) {
      self$text <- text
      self$query <- query
      self$samepeer <- samepeer
      self$peer_types <- peer_types
    },
    to_dict = function() {
      list("_" = "KeyboardButtonSwitchInline", text = self$text, query = self$query, samepeer = self$samepeer, peer_types = lapply(self$peer_types, function(x) if (inherits(x, "TLObject")) x$to_dict() else x))
    },
    bytes = function() {
      flags <- (if (is.null(self$samepeer) || !self$samepeer) 0L else 1L) | (if (is.null(self$peer_types)) 0L else 2L)
      c(
        pack("<I", self$CONSTRUCTOR_ID),
        pack("<I", flags),
        self$serializebytes(self$text),
        self$serializebytes(self$query),
        if (!is.null(self$peer_types)) c(pack("<I", 0x1cb5c415L), pack("<i", length(self$peer_types)), unlist(lapply(self$peer_types, function(x) x$bytes()))) else NULL
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      self$samepeer <- bitwAnd(flags, 1L) != 0L
      self$text <- reader$tgread_string()
      self$query <- reader$tgread_string()
      if (bitwAnd(flags, 2L)) {
        reader$read_int()
        self$peer_types <- list()
        for (i in 1:reader$read_int()) {
          self$peer_types[[i]] <- reader$tgread_object()
        }
      } else {
        self$peer_types <- NULL
      }
      self
    }
  )
)

#  @title KeyboardButtonUrl
#  @description Telegram API type KeyboardButtonUrl
#  @export
#  @noRd
#  @noRd
KeyboardButtonUrl <- R6::R6Class(
  "KeyboardButtonUrl",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x258aff05,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    #  @field text Field.
    text = NULL,
    #  @field url Field.
    url = NULL,
    initialize = function(text, url) {
      self$text <- text
      self$url <- url
    },
    to_dict = function() {
      list("_" = "KeyboardButtonUrl", text = self$text, url = self$url)
    },
    bytes = function() {
      c(
        pack("<I", self$CONSTRUCTOR_ID),
        self$serializebytes(self$text),
        self$serializebytes(self$url)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$text <- reader$tgread_string()
      self$url <- reader$tgread_string()
      self
    }
  )
)

#  @title KeyboardButtonUrlAuth
#  @description Telegram API type KeyboardButtonUrlAuth
#  @export
#  @noRd
#  @noRd
KeyboardButtonUrlAuth <- R6::R6Class(
  "KeyboardButtonUrlAuth",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x10b78d29,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    #  @field text Field.
    text = NULL,
    #  @field url Field.
    url = NULL,
    #  @field button_id Field.
    button_id = NULL,
    #  @field fwd_text Field.
    fwd_text = NULL,
    initialize = function(text, url, button_id, fwd_text = NULL) {
      self$text <- text
      self$url <- url
      self$button_id <- button_id
      self$fwd_text <- fwd_text
    },
    to_dict = function() {
      list("_" = "KeyboardButtonUrlAuth", text = self$text, url = self$url, button_id = self$button_id, fwd_text = self$fwd_text)
    },
    bytes = function() {
      flags <- if (is.null(self$fwd_text)) 0L else 1L
      c(
        pack("<I", self$CONSTRUCTOR_ID),
        pack("<I", flags),
        self$serializebytes(self$text),
        if (!is.null(self$fwd_text)) self$serializebytes(self$fwd_text) else NULL,
        self$serializebytes(self$url),
        pack("<i", self$button_id)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      self$text <- reader$tgread_string()
      if (bitwAnd(flags, 1L)) {
        self$fwd_text <- reader$tgread_string()
      } else {
        self$fwd_text <- NULL
      }
      self$url <- reader$tgread_string()
      self$button_id <- reader$read_int()
      self
    }
  )
)

#  @title KeyboardButtonUserProfile
#  @description Telegram API type KeyboardButtonUserProfile
#  @export
#  @noRd
#  @noRd
KeyboardButtonUserProfile <- R6::R6Class(
  "KeyboardButtonUserProfile",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x308660c1,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    #  @field text Field.
    text = NULL,
    #  @field user_id Field.
    user_id = NULL,
    initialize = function(text, user_id) {
      self$text <- text
      self$user_id <- user_id
    },
    to_dict = function() {
      list("_" = "KeyboardButtonUserProfile", text = self$text, user_id = self$user_id)
    },
    bytes = function() {
      c(
        pack("<I", self$CONSTRUCTOR_ID),
        self$serializebytes(self$text),
        pack("<q", self$user_id)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$text <- reader$tgread_string()
      self$user_id <- reader$read_long()
      self
    }
  )
)

#  @title KeyboardButtonWebView
#  @description Telegram API type KeyboardButtonWebView
#  @export
#  @noRd
#  @noRd
KeyboardButtonWebView <- R6::R6Class(
  "KeyboardButtonWebView",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x13767230,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbad74a3,
    #  @field text Field.
    text = NULL,
    #  @field url Field.
    url = NULL,
    initialize = function(text, url) {
      self$text <- text
      self$url <- url
    },
    to_dict = function() {
      list("_" = "KeyboardButtonWebView", text = self$text, url = self$url)
    },
    bytes = function() {
      c(
        pack("<I", self$CONSTRUCTOR_ID),
        self$serializebytes(self$text),
        self$serializebytes(self$url)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$text <- reader$tgread_string()
      self$url <- reader$tgread_string()
      self
    }
  )
)

#  @title LabeledPrice
#  @description Telegram API type LabeledPrice
#  @export
#  @noRd
#  @noRd
LabeledPrice <- R6::R6Class(
  "LabeledPrice",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xcb296bf8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1c84047a,
    #  @field label Field.
    label = NULL,
    #  @field amount Field.
    amount = NULL,
    initialize = function(label, amount) {
      self$label <- label
      self$amount <- amount
    },
    to_dict = function() {
      list("_" = "LabeledPrice", label = self$label, amount = self$amount)
    },
    bytes = function() {
      c(
        pack("<I", self$CONSTRUCTOR_ID),
        self$serializebytes(self$label),
        pack("<q", self$amount)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$label <- reader$tgread_string()
      self$amount <- reader$read_long()
      self
    }
  )
)

#  @title LangPackDifference
#  @description Telegram API type LangPackDifference
#  @export
#  @noRd
#  @noRd
LangPackDifference <- R6::R6Class(
  "LangPackDifference",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf385c1f6,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x52662d55,
    #  @field lang_code Field.
    lang_code = NULL,
    #  @field from_version Field.
    from_version = NULL,
    #  @field version Field.
    version = NULL,
    #  @field strings Field.
    strings = NULL,
    initialize = function(lang_code, from_version, version, strings) {
      self$lang_code <- lang_code
      self$from_version <- from_version
      self$version <- version
      self$strings <- strings
    },
    to_dict = function() {
      list("_" = "LangPackDifference", lang_code = self$lang_code, from_version = self$from_version, version = self$version, strings = lapply(self$strings, function(x) if (inherits(x, "TLObject")) x$to_dict() else x))
    },
    bytes = function() {
      # Implementation needed
    }
  ),
  private = list(
    from_reader = function(reader) {
      # Implementation needed
    }
  )
)

#  @title LangPackLanguage
#  @description Telegram API type LangPackLanguage
#  @export
#  @noRd
#  @noRd
LangPackLanguage <- R6::R6Class(
  "LangPackLanguage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xeeca5ce3,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xabac89b7,
    #  @field name Field.
    name = NULL,
    #  @field native_name Field.
    native_name = NULL,
    #  @field lang_code Field.
    lang_code = NULL,
    #  @field plural_code Field.
    plural_code = NULL,
    #  @field strings_count Field.
    strings_count = NULL,
    #  @field translated_count Field.
    translated_count = NULL,
    #  @field translations_url Field.
    translations_url = NULL,
    #  @field official Field.
    official = NULL,
    #  @field rtl Field.
    rtl = NULL,
    #  @field beta Field.
    beta = NULL,
    #  @field base_lang_code Field.
    base_lang_code = NULL,
    initialize = function(name, native_name, lang_code, plural_code, strings_count, translated_count, translations_url, official = NULL, rtl = NULL, beta = NULL, base_lang_code = NULL) {
      self$name <- name
      self$native_name <- native_name
      self$lang_code <- lang_code
      self$plural_code <- plural_code
      self$strings_count <- strings_count
      self$translated_count <- translated_count
      self$translations_url <- translations_url
      self$official <- official
      self$rtl <- rtl
      self$beta <- beta
      self$base_lang_code <- base_lang_code
    },
    to_dict = function() {
      list("_" = "LangPackLanguage", name = self$name, native_name = self$native_name, lang_code = self$lang_code, plural_code = self$plural_code, strings_count = self$strings_count, translated_count = self$translated_count, translations_url = self$translations_url, official = self$official, rtl = self$rtl, beta = self$beta, base_lang_code = self$base_lang_code)
    },
    bytes = function() {
      # Implementation needed
    }
  ),
  private = list(
    from_reader = function(reader) {
      # Implementation needed
    }
  )
)

#  @title LangPackString
#  @description Telegram API type LangPackString
#  @export
#  @noRd
#  @noRd
LangPackString <- R6::R6Class(
  "LangPackString",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xcad181f6,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xdc179ab9,
    #  @field key Field.
    key = NULL,
    #  @field value Field.
    value = NULL,
    initialize = function(key, value) {
      self$key <- key
      self$value <- value
    },
    to_dict = function() {
      list("_" = "LangPackString", key = self$key, value = self$value)
    },
    bytes = function() {
      # Implementation needed
    }
  ),
  private = list(
    from_reader = function(reader) {
      # Implementation needed
    }
  )
)

#  @title LangPackStringDeleted
#  @description Telegram API type LangPackStringDeleted
#  @export
#  @noRd
#  @noRd
LangPackStringDeleted <- R6::R6Class(
  "LangPackStringDeleted",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x2979eeb2,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xdc179ab9,
    #  @field key Field.
    key = NULL,
    initialize = function(key) {
      self$key <- key
    },
    to_dict = function() {
      list("_" = "LangPackStringDeleted", key = self$key)
    },
    bytes = function() {
      # Implementation needed
    }
  ),
  private = list(
    from_reader = function(reader) {
      # Implementation needed
    }
  )
)

#  @title LangPackStringPluralized
#  @description Telegram API type LangPackStringPluralized
#  @export
#  @noRd
#  @noRd
LangPackStringPluralized <- R6::R6Class(
  "LangPackStringPluralized",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x6c47ac9f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xdc179ab9,
    #  @field key Field.
    key = NULL,
    #  @field other_value Field.
    other_value = NULL,
    #  @field zero_value Field.
    zero_value = NULL,
    #  @field one_value Field.
    one_value = NULL,
    #  @field two_value Field.
    two_value = NULL,
    #  @field few_value Field.
    few_value = NULL,
    #  @field many_value Field.
    many_value = NULL,
    initialize = function(key, other_value, zero_value = NULL, one_value = NULL, two_value = NULL, few_value = NULL, many_value = NULL) {
      self$key <- key
      self$other_value <- other_value
      self$zero_value <- zero_value
      self$one_value <- one_value
      self$two_value <- two_value
      self$few_value <- few_value
      self$many_value <- many_value
    },
    to_dict = function() {
      list("_" = "LangPackStringPluralized", key = self$key, other_value = self$other_value, zero_value = self$zero_value, one_value = self$one_value, two_value = self$two_value, few_value = self$few_value, many_value = self$many_value)
    },
    bytes = function() {
      # Implementation needed
    }
  ),
  private = list(
    from_reader = function(reader) {
      # Implementation needed
    }
  )
)

#  @title MaskCoords
#  @description Telegram API type MaskCoords
#  @export
#  @noRd
#  @noRd
MaskCoords <- R6::R6Class(
  "MaskCoords",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xaed6dbb2,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x6bbb2fd,
    #  @field n Field.
    n = NULL,
    #  @field x Field.
    x = NULL,
    #  @field y Field.
    y = NULL,
    #  @field zoom Field.
    zoom = NULL,
    initialize = function(n, x, y, zoom) {
      self$n <- n
      self$x <- x
      self$y <- y
      self$zoom <- zoom
    },
    to_dict = function() {
      list("_" = "MaskCoords", n = self$n, x = self$x, y = self$y, zoom = self$zoom)
    },
    bytes = function() {
      # Implementation needed
    }
  ),
  private = list(
    from_reader = function(reader) {
      # Implementation needed
    }
  )
)

#  @title MediaAreaChannelPost
#  @description Telegram API type MediaAreaChannelPost
#  @export
#  @noRd
#  @noRd
MediaAreaChannelPost <- R6::R6Class(
  "MediaAreaChannelPost",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x770416af,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf36d7bf2,
    #  @field coordinates Field.
    coordinates = NULL,
    #  @field channel_id Field.
    channel_id = NULL,
    #  @field msg_id Field.
    msg_id = NULL,
    initialize = function(coordinates, channel_id, msg_id) {
      self$coordinates <- coordinates
      self$channel_id <- channel_id
      self$msg_id <- msg_id
    },
    to_dict = function() {
      list("_" = "MediaAreaChannelPost", coordinates = if (inherits(self$coordinates, "TLObject")) self$coordinates$to_dict() else self$coordinates, channel_id = self$channel_id, msg_id = self$msg_id)
    },
    bytes = function() {
      # Implementation needed
    }
  ),
  private = list(
    from_reader = function(reader) {
      # Implementation needed
    }
  )
)

#  @title MediaAreaCoordinates
#  @description Telegram API type MediaAreaCoordinates
#  @export
#  @noRd
#  @noRd
MediaAreaCoordinates <- R6::R6Class(
  "MediaAreaCoordinates",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xcfc9e002,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1d448c39,
    #  @field x Field.
    x = NULL,
    #  @field y Field.
    y = NULL,
    #  @field w Field.
    w = NULL,
    #  @field h Field.
    h = NULL,
    #  @field rotation Field.
    rotation = NULL,
    #  @field radius Field.
    radius = NULL,
    initialize = function(x, y, w, h, rotation, radius = NULL) {
      self$x <- x
      self$y <- y
      self$w <- w
      self$h <- h
      self$rotation <- rotation
      self$radius <- radius
    },
    to_dict = function() {
      list("_" = "MediaAreaCoordinates", x = self$x, y = self$y, w = self$w, h = self$h, rotation = self$rotation, radius = self$radius)
    },
    bytes = function() {
      # Implementation needed
    }
  ),
  private = list(
    from_reader = function(reader) {
      # Implementation needed
    }
  )
)

#  @title MediaAreaGeoPoint
#  @description Telegram API type MediaAreaGeoPoint
#  @export
#  @noRd
#  @noRd
MediaAreaGeoPoint <- R6::R6Class("MediaAreaGeoPoint",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xcad5452d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf36d7bf2,
    #  @field coordinates Field.
    coordinates = NULL,
    #  @field geo Field.
    geo = NULL,
    #  @field address Field.
    address = NULL,
    initialize = function(coordinates, geo, address = NULL) {
      self$coordinates <- coordinates
      self$geo <- geo
      self$address <- address
    },
    to_dict = function() {
      list(
        `_` = "MediaAreaGeoPoint",
        coordinates = if (inherits(self$coordinates, "TLObject")) self$coordinates$to_dict() else self$coordinates,
        geo = if (inherits(self$geo, "TLObject")) self$geo$to_dict() else self$geo,
        address = if (is.null(self$address)) NULL else (if (inherits(self$address, "TLObject")) self$address$to_dict() else self$address)
      )
    },
    bytes = function() {
      # TODO: implement proper serialization
      raw(0)
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      coords <- reader$tgread_object()
      geo <- reader$tgread_object()
      address <- if (bitwAnd(flags, 1L) != 0L) reader$tgread_object() else NULL
      list(coordinates = coords, geo = geo, address = address)
    }
  ),
  class = TRUE
)

#  @title MediaAreaStarGift
#  @description Telegram API type MediaAreaStarGift
#  @export
#  @noRd
#  @noRd
MediaAreaStarGift <- R6::R6Class("MediaAreaStarGift",
  inherit = TLObject,
  public = list(
    CONSTRUCTOR_ID = 0x77879f6d, # placeholder; original had bytes, no explicit hex in R snippet
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf36d7bf2,
    #  @field coordinates Field.
    coordinates = NULL,
    #  @field slug Field.
    slug = NULL,
    initialize = function(coordinates, slug) {
      self$coordinates <- coordinates
      self$slug <- slug
    },
    to_dict = function() {
      list(
        `_` = "MediaAreaStarGift",
        coordinates = if (inherits(self$coordinates, "TLObject")) self$coordinates$to_dict() else self$coordinates,
        slug = self$slug
      )
    },
    bytes = function() {
      raw(0)
    }
  ),
  private = list(
    from_reader = function(reader) {
      coords <- reader$tgread_object()
      slug <- reader$tgread_string()
      list(coordinates = coords, slug = slug)
    }
  ),
  class = TRUE
)

#  @title MediaAreaSuggestedReaction
#  @description Telegram API type MediaAreaSuggestedReaction
#  @export
#  @noRd
#  @noRd
MediaAreaSuggestedReaction <- R6::R6Class("MediaAreaSuggestedReaction",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x14455871,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf36d7bf2,
    #  @field coordinates Field.
    coordinates = NULL,
    #  @field reaction Field.
    reaction = NULL,
    #  @field dark Field.
    dark = NULL,
    #  @field flipped Field.
    flipped = NULL,
    initialize = function(coordinates, reaction, dark = NULL, flipped = NULL) {
      self$coordinates <- coordinates
      self$reaction <- reaction
      self$dark <- dark
      self$flipped <- flipped
    },
    to_dict = function() {
      list(
        `_` = "MediaAreaSuggestedReaction",
        coordinates = if (inherits(self$coordinates, "TLObject")) self$coordinates$to_dict() else self$coordinates,
        reaction = if (inherits(self$reaction, "TLObject")) self$reaction$to_dict() else self$reaction,
        dark = self$dark,
        flipped = self$flipped
      )
    },
    bytes = function() {
      raw(0)
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      dark <- bitwAnd(flags, 1L) != 0L
      flipped <- bitwAnd(flags, 2L) != 0L
      coords <- reader$tgread_object()
      reaction <- reader$tgread_object()
      list(coordinates = coords, reaction = reaction, dark = dark, flipped = flipped)
    }
  ),
  class = TRUE
)

#  @title MediaAreaUrl
#  @description Telegram API type MediaAreaUrl
#  @export
#  @noRd
#  @noRd
MediaAreaUrl <- R6::R6Class("MediaAreaUrl",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x37381085,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf36d7bf2,
    #  @field coordinates Field.
    coordinates = NULL,
    #  @field url Field.
    url = NULL,
    initialize = function(coordinates, url) {
      self$coordinates <- coordinates
      self$url <- url
    },
    to_dict = function() {
      list(
        `_` = "MediaAreaUrl",
        coordinates = if (inherits(self$coordinates, "TLObject")) self$coordinates$to_dict() else self$coordinates,
        url = self$url
      )
    },
    bytes = function() {
      raw(0)
    }
  ),
  private = list(
    from_reader = function(reader) {
      coords <- reader$tgread_object()
      url <- reader$tgread_string()
      list(coordinates = coords, url = url)
    }
  ),
  class = TRUE
)

#  @title MediaAreaVenue
#  @description Telegram API type MediaAreaVenue
#  @export
#  @noRd
#  @noRd
MediaAreaVenue <- R6::R6Class("MediaAreaVenue",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbe82db9c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf36d7bf2,
    #  @field coordinates Field.
    coordinates = NULL,
    #  @field geo Field.
    geo = NULL,
    #  @field title Field.
    title = NULL,
    #  @field address Field.
    address = NULL,
    #  @field provider Field.
    provider = NULL,
    #  @field venue_id Field.
    venue_id = NULL,
    #  @field venue_type Field.
    venue_type = NULL,
    initialize = function(coordinates, geo, title, address, provider, venue_id, venue_type) {
      self$coordinates <- coordinates
      self$geo <- geo
      self$title <- title
      self$address <- address
      self$provider <- provider
      self$venue_id <- venue_id
      self$venue_type <- venue_type
    },
    to_dict = function() {
      list(
        `_` = "MediaAreaVenue",
        coordinates = if (inherits(self$coordinates, "TLObject")) self$coordinates$to_dict() else self$coordinates,
        geo = if (inherits(self$geo, "TLObject")) self$geo$to_dict() else self$geo,
        title = self$title,
        address = self$address,
        provider = self$provider,
        venue_id = self$venue_id,
        venue_type = self$venue_type
      )
    },
    bytes = function() {
      raw(0)
    }
  ),
  private = list(
    from_reader = function(reader) {
      coords <- reader$tgread_object()
      geo <- reader$tgread_object()
      title <- reader$tgread_string()
      address <- reader$tgread_string()
      provider <- reader$tgread_string()
      venue_id <- reader$tgread_string()
      venue_type <- reader$tgread_string()
      list(
        coordinates = coords, geo = geo, title = title,
        address = address, provider = provider, venue_id = venue_id, venue_type = venue_type
      )
    }
  ),
  class = TRUE
)

#  @title MediaAreaWeather
#  @description Telegram API type MediaAreaWeather
#  @export
#  @noRd
#  @noRd
MediaAreaWeather <- R6::R6Class("MediaAreaWeather",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x49a6549c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf36d7bf2,
    #  @field coordinates Field.
    coordinates = NULL,
    #  @field emoji Field.
    emoji = NULL,
    #  @field temperature_c Field.
    temperature_c = NULL,
    #  @field color Field.
    color = NULL,
    initialize = function(coordinates, emoji, temperature_c, color) {
      self$coordinates <- coordinates
      self$emoji <- emoji
      self$temperature_c <- temperature_c
      self$color <- color
    },
    to_dict = function() {
      list(
        `_` = "MediaAreaWeather",
        coordinates = if (inherits(self$coordinates, "TLObject")) self$coordinates$to_dict() else self$coordinates,
        emoji = self$emoji,
        temperature_c = self$temperature_c,
        color = self$color
      )
    },
    bytes = function() {
      raw(0)
    }
  ),
  private = list(
    from_reader = function(reader) {
      coords <- reader$tgread_object()
      emoji <- reader$tgread_string()
      temperature_c <- reader$read_double()
      color <- reader$read_int()
      list(coordinates = coords, emoji = emoji, temperature_c = temperature_c, color = color)
    }
  ),
  class = TRUE
)

#  @title Message
#  @description Telegram API type Message
#  @export
#  @noRd
#  @noRd
Message <- R6::R6Class(
  "Message",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9815cec8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x790009e3,
    #  @field id Field.
    id = NULL,
    #  @field peer_id Field.
    peer_id = NULL,
    #  @field date Field.
    date = NULL,
    #  @field message Field.
    message = NULL,
    #  @field out Field.
    out = NULL,
    #  @field mentioned Field.
    mentioned = NULL,
    #  @field media_unread Field.
    media_unread = NULL,
    #  @field silent Field.
    silent = NULL,
    #  @field post Field.
    post = NULL,
    #  @field from_scheduled Field.
    from_scheduled = NULL,
    #  @field legacy Field.
    legacy = NULL,
    #  @field edit_hide Field.
    edit_hide = NULL,
    #  @field pinned Field.
    pinned = NULL,
    #  @field noforwards Field.
    noforwards = NULL,
    #  @field invert_media Field.
    invert_media = NULL,
    #  @field offline Field.
    offline = NULL,
    #  @field video_processing_pending Field.
    video_processing_pending = NULL,
    #  @field paid_suggested_post_stars Field.
    paid_suggested_post_stars = NULL,
    #  @field paid_suggested_post_ton Field.
    paid_suggested_post_ton = NULL,
    #  @field from_id Field.
    from_id = NULL,
    #  @field from_boosts_applied Field.
    from_boosts_applied = NULL,
    #  @field saved_peer_id Field.
    saved_peer_id = NULL,
    #  @field fwd_from Field.
    fwd_from = NULL,
    #  @field via_bot_id Field.
    via_bot_id = NULL,
    #  @field via_business_bot_id Field.
    via_business_bot_id = NULL,
    #  @field reply_to Field.
    reply_to = NULL,
    #  @field media Field.
    media = NULL,
    #  @field reply_markup Field.
    reply_markup = NULL,
    #  @field entities Field.
    entities = NULL,
    #  @field views Field.
    views = NULL,
    #  @field forwards Field.
    forwards = NULL,
    #  @field replies Field.
    replies = NULL,
    #  @field edit_date Field.
    edit_date = NULL,
    #  @field post_author Field.
    post_author = NULL,
    #  @field grouped_id Field.
    grouped_id = NULL,
    #  @field reactions Field.
    reactions = NULL,
    #  @field restriction_reason Field.
    restriction_reason = NULL,
    #  @field ttl_period Field.
    ttl_period = NULL,
    #  @field quick_reply_shortcut_id Field.
    quick_reply_shortcut_id = NULL,
    #  @field effect Field.
    effect = NULL,
    #  @field factcheck Field.
    factcheck = NULL,
    #  @field report_delivery_until_date Field.
    report_delivery_until_date = NULL,
    #  @field paid_message_stars Field.
    paid_message_stars = NULL,
    #  @field suggested_post Field.
    suggested_post = NULL,
    initialize = function(id, peer_id, date, message, out = NULL, mentioned = NULL, media_unread = NULL, silent = NULL,
                          post = NULL, from_scheduled = NULL, legacy = NULL, edit_hide = NULL, pinned = NULL,
                          noforwards = NULL, invert_media = NULL, offline = NULL, video_processing_pending = NULL,
                          paid_suggested_post_stars = NULL, paid_suggested_post_ton = NULL, from_id = NULL,
                          from_boosts_applied = NULL, saved_peer_id = NULL, fwd_from = NULL, via_bot_id = NULL,
                          via_business_bot_id = NULL, reply_to = NULL, media = NULL, reply_markup = NULL,
                          entities = NULL, views = NULL, forwards = NULL, replies = NULL, edit_date = NULL,
                          post_author = NULL, grouped_id = NULL, reactions = NULL, restriction_reason = NULL,
                          ttl_period = NULL, quick_reply_shortcut_id = NULL, effect = NULL, factcheck = NULL,
                          report_delivery_until_date = NULL, paid_message_stars = NULL, suggested_post = NULL) {
      self$id <- id
      self$peer_id <- peer_id
      self$date <- date
      self$message <- message
      self$out <- out
      self$mentioned <- mentioned
      self$media_unread <- media_unread
      self$silent <- silent
      self$post <- post
      self$from_scheduled <- from_scheduled
      self$legacy <- legacy
      self$edit_hide <- edit_hide
      self$pinned <- pinned
      self$noforwards <- noforwards
      self$invert_media <- invert_media
      self$offline <- offline
      self$video_processing_pending <- video_processing_pending
      self$paid_suggested_post_stars <- paid_suggested_post_stars
      self$paid_suggested_post_ton <- paid_suggested_post_ton
      self$from_id <- from_id
      self$from_boosts_applied <- from_boosts_applied
      self$saved_peer_id <- saved_peer_id
      self$fwd_from <- fwd_from
      self$via_bot_id <- via_bot_id
      self$via_business_bot_id <- via_business_bot_id
      self$reply_to <- reply_to
      self$media <- media
      self$reply_markup <- reply_markup
      self$entities <- entities
      self$views <- views
      self$forwards <- forwards
      self$replies <- replies
      self$edit_date <- edit_date
      self$post_author <- post_author
      self$grouped_id <- grouped_id
      self$reactions <- reactions
      self$restriction_reason <- restriction_reason
      self$ttl_period <- ttl_period
      self$quick_reply_shortcut_id <- quick_reply_shortcut_id
      self$effect <- effect
      self$factcheck <- factcheck
      self$report_delivery_until_date <- report_delivery_until_date
      self$paid_message_stars <- paid_message_stars
      self$suggested_post <- suggested_post
    },
    to_dict = function() {
      list(
        `_` = "Message",
        id = self$id,
        peer_id = if (inherits(self$peer_id, "TLObject")) self$peer_id$to_dict() else self$peer_id,
        date = self$date,
        message = self$message,
        out = self$out,
        mentioned = self$mentioned,
        media_unread = self$media_unread,
        silent = self$silent,
        post = self$post,
        from_scheduled = self$from_scheduled,
        legacy = self$legacy,
        edit_hide = self$edit_hide,
        pinned = self$pinned,
        noforwards = self$noforwards,
        invert_media = self$invert_media,
        offline = self$offline,
        video_processing_pending = self$video_processing_pending,
        paid_suggested_post_stars = self$paid_suggested_post_stars,
        paid_suggested_post_ton = self$paid_suggested_post_ton,
        from_id = if (inherits(self$from_id, "TLObject")) self$from_id$to_dict() else self$from_id,
        from_boosts_applied = self$from_boosts_applied,
        saved_peer_id = if (inherits(self$saved_peer_id, "TLObject")) self$saved_peer_id$to_dict() else self$saved_peer_id,
        fwd_from = if (inherits(self$fwd_from, "TLObject")) self$fwd_from$to_dict() else self$fwd_from,
        via_bot_id = self$via_bot_id,
        via_business_bot_id = self$via_business_bot_id,
        reply_to = if (inherits(self$reply_to, "TLObject")) self$reply_to$to_dict() else self$reply_to,
        media = if (inherits(self$media, "TLObject")) self$media$to_dict() else self$media,
        reply_markup = if (inherits(self$reply_markup, "TLObject")) self$reply_markup$to_dict() else self$reply_markup,
        entities = if (is.null(self$entities)) list() else lapply(self$entities, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        views = self$views,
        forwards = self$forwards,
        replies = if (inherits(self$replies, "TLObject")) self$replies$to_dict() else self$replies,
        edit_date = self$edit_date,
        post_author = self$post_author,
        grouped_id = self$grouped_id,
        reactions = if (inherits(self$reactions, "TLObject")) self$reactions$to_dict() else self$reactions,
        restriction_reason = if (is.null(self$restriction_reason)) list() else lapply(self$restriction_reason, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        ttl_period = self$ttl_period,
        quick_reply_shortcut_id = self$quick_reply_shortcut_id,
        effect = self$effect,
        factcheck = if (inherits(self$factcheck, "TLObject")) self$factcheck$to_dict() else self$factcheck,
        report_delivery_until_date = self$report_delivery_until_date,
        paid_message_stars = self$paid_message_stars,
        suggested_post = if (inherits(self$suggested_post, "TLObject")) self$suggested_post$to_dict() else self$suggested_post
      )
    },
    bytes = function() {
      stop("Serialization to bytes is not implemented")
    }
  ),
  private = list(
    from_reader = function(reader) {
      remaining <- function() {
        length(reader$get_bytes()) - reader$tell_position()
      }
      can_read <- function(n) remaining() >= n
      flags <- reader$read_int()
      flags2 <- reader$read_int()

      out <- bitwAnd(flags, 2) != 0
      mentioned <- bitwAnd(flags, 16) != 0
      media_unread <- bitwAnd(flags, 32) != 0
      silent <- bitwAnd(flags, 8192) != 0
      post <- bitwAnd(flags, 16384) != 0
      from_scheduled <- bitwAnd(flags, 262144) != 0
      legacy <- bitwAnd(flags, 524288) != 0
      edit_hide <- bitwAnd(flags, 2097152) != 0
      pinned <- bitwAnd(flags, 16777216) != 0
      noforwards <- bitwAnd(flags, 67108864) != 0
      invert_media <- bitwAnd(flags, 134217728) != 0

      offline <- bitwAnd(flags2, 2) != 0
      video_processing_pending <- bitwAnd(flags2, 16) != 0
      paid_suggested_post_stars <- bitwAnd(flags2, 256) != 0
      paid_suggested_post_ton <- bitwAnd(flags2, 512) != 0

      id <- reader$read_int()
      from_id <- if (bitwAnd(flags, 256) != 0) reader$tgread_object() else NULL
      from_boosts_applied <- if (bitwAnd(flags, 536870912) != 0) reader$read_int() else NULL
      peer_id <- reader$tgread_object()
      saved_peer_id <- if (bitwAnd(flags, 268435456) != 0) reader$tgread_object() else NULL
      fwd_from <- if (bitwAnd(flags, 4) != 0) reader$tgread_object() else NULL
      via_bot_id <- if (bitwAnd(flags, 2048) != 0) reader$read_long() else NULL
      via_business_bot_id <- if (bitwAnd(flags2, 1) != 0) reader$read_long() else NULL
      reply_to <- if (bitwAnd(flags, 8) != 0) reader$tgread_object() else NULL
      date <- reader$tgread_date()
      message <- reader$tgread_string()
      media <- if (bitwAnd(flags, 512) != 0 && can_read(4)) reader$tgread_object() else NULL
      reply_markup <- NULL
      entities <- NULL
      views <- NULL
      forwards <- NULL
      replies <- NULL
      edit_date <- NULL
      post_author <- NULL
      grouped_id <- NULL
      reactions <- NULL
      restriction_reason <- NULL
      ttl_period <- NULL
      quick_reply_shortcut_id <- NULL
      effect <- NULL
      factcheck <- NULL
      report_delivery_until_date <- NULL
      paid_message_stars <- NULL
      suggested_post <- NULL

      if (remaining() > 0) {
        reply_markup <- if (bitwAnd(flags, 64) != 0 && can_read(4)) reader$tgread_object() else NULL
        if (bitwAnd(flags, 128) != 0 && can_read(8)) {
          reader$read_int()
          n_entities <- reader$read_int()
          entities <- if (n_entities > 0) lapply(seq_len(n_entities), function(x) reader$tgread_object()) else list()
        }
        if (bitwAnd(flags, 1024) != 0 && can_read(4)) views <- reader$read_int()
        if (bitwAnd(flags, 1024) != 0 && can_read(4)) forwards <- reader$read_int()
        if (bitwAnd(flags, 8388608) != 0 && can_read(4)) replies <- reader$tgread_object()
        if (bitwAnd(flags, 32768) != 0 && can_read(4)) edit_date <- reader$tgread_date()
        if (bitwAnd(flags, 65536) != 0 && can_read(1)) post_author <- reader$tgread_string()
        if (bitwAnd(flags, 131072) != 0 && can_read(8)) grouped_id <- reader$read_long()
        if (bitwAnd(flags, 1048576) != 0 && can_read(4)) reactions <- reader$tgread_object()
        if (bitwAnd(flags, 4194304) != 0 && can_read(8)) {
          reader$read_int()
          n_restrict <- reader$read_int()
          restriction_reason <- if (n_restrict > 0) lapply(seq_len(n_restrict), function(x) reader$tgread_object()) else list()
        }
        if (bitwAnd(flags, 33554432) != 0 && can_read(4)) ttl_period <- reader$read_int()
        if (bitwAnd(flags, 1073741824) != 0 && can_read(4)) quick_reply_shortcut_id <- reader$read_int()
        if (bitwAnd(flags2, 4) != 0 && can_read(8)) effect <- reader$read_long()
        if (bitwAnd(flags2, 8) != 0 && can_read(4)) factcheck <- reader$tgread_object()
        if (bitwAnd(flags2, 32) != 0 && can_read(4)) report_delivery_until_date <- reader$tgread_date()
        if (bitwAnd(flags2, 64) != 0 && can_read(8)) paid_message_stars <- reader$read_long()
        if (bitwAnd(flags2, 128) != 0 && can_read(4)) suggested_post <- reader$tgread_object()
      }

      list(
        id = id,
        peer_id = peer_id,
        date = date,
        message = message,
        out = out,
        mentioned = mentioned,
        media_unread = media_unread,
        silent = silent,
        post = post,
        from_scheduled = from_scheduled,
        legacy = legacy,
        edit_hide = edit_hide,
        pinned = pinned,
        noforwards = noforwards,
        invert_media = invert_media,
        offline = offline,
        video_processing_pending = video_processing_pending,
        paid_suggested_post_stars = paid_suggested_post_stars,
        paid_suggested_post_ton = paid_suggested_post_ton,
        from_id = from_id,
        from_boosts_applied = from_boosts_applied,
        saved_peer_id = saved_peer_id,
        fwd_from = fwd_from,
        via_bot_id = via_bot_id,
        via_business_bot_id = via_business_bot_id,
        reply_to = reply_to,
        media = media,
        reply_markup = reply_markup,
        entities = entities,
        views = views,
        forwards = forwards,
        replies = replies,
        edit_date = edit_date,
        post_author = post_author,
        grouped_id = grouped_id,
        reactions = reactions,
        restriction_reason = restriction_reason,
        ttl_period = ttl_period,
        quick_reply_shortcut_id = quick_reply_shortcut_id,
        effect = effect,
        factcheck = factcheck,
        report_delivery_until_date = report_delivery_until_date,
        paid_message_stars = paid_message_stars,
        suggested_post = suggested_post
      )
    }
  )
)

#  @title MessageActionBoostApply
#  @description Telegram API type MessageActionBoostApply
#  @export
#  @noRd
#  @noRd
MessageActionBoostApply <- R6::R6Class(
  "MessageActionBoostApply",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xcc02aa6d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field boosts Field.
    boosts = NULL,
    initialize = function(boosts) {
      self$boosts <- boosts
    },
    to_dict = function() {
      list(`_` = "MessageActionBoostApply", boosts = self$boosts)
    },
    bytes = function() {
      raw(0) # Placeholder for byte serialization
    }
  ),
  private = list(
    from_reader = function(reader) {
      boosts <- reader$read_int()
      self$new(boosts = boosts)
    }
  )
)

#  @title MessageActionBotAllowed
#  @description Telegram API type MessageActionBotAllowed
#  @export
#  @noRd
#  @noRd
MessageActionBotAllowed <- R6::R6Class(
  "MessageActionBotAllowed",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc516d679,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field attach_menu Field.
    attach_menu = NULL,
    #  @field from_request Field.
    from_request = NULL,
    #  @field domain Field.
    domain = NULL,
    #  @field app Field.
    app = NULL,
    initialize = function(attach_menu = NULL, from_request = NULL, domain = NULL, app = NULL) {
      self$attach_menu <- attach_menu
      self$from_request <- from_request
      self$domain <- domain
      self$app <- app
    },
    to_dict = function() {
      list(
        `_` = "MessageActionBotAllowed",
        attach_menu = self$attach_menu,
        from_request = self$from_request,
        domain = self$domain,
        app = if (inherits(self$app, "TLObject")) self$app$to_dict() else self$app
      )
    },
    bytes = function() {
      raw(0) # Placeholder for byte serialization
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      attach_menu <- as.logical(bitwAnd(flags, 2))
      from_request <- as.logical(bitwAnd(flags, 8))
      domain <- if (bitwAnd(flags, 1)) reader$tgread_string() else NULL
      app <- if (bitwAnd(flags, 4)) reader$tgread_object() else NULL

      self$new(attach_menu = attach_menu, from_request = from_request, domain = domain, app = app)
    }
  )
)

#  @title MessageActionChannelCreate
#  @description Telegram API type MessageActionChannelCreate
#  @export
#  @noRd
#  @noRd
MessageActionChannelCreate <- R6::R6Class(
  "MessageActionChannelCreate",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x95d2ac92,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field title Field.
    title = NULL,
    initialize = function(title) {
      self$title <- title
    },
    to_dict = function() {
      list(`_` = "MessageActionChannelCreate", title = self$title)
    },
    bytes = function() {
      c(
        as.raw(c(0x92, 0xac, 0xd2, 0x95)),
        serialize_bytes(self$title)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      title <- reader$tgread_string()
      self$new(title = title)
    }
  )
)

#  @title MessageActionChannelMigrateFrom
#  @description Telegram API type MessageActionChannelMigrateFrom
#  @export
#  @noRd
#  @noRd
MessageActionChannelMigrateFrom <- R6::R6Class(
  "MessageActionChannelMigrateFrom",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xea3948e9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field title Field.
    title = NULL,
    #  @field chat_id Field.
    chat_id = NULL,
    initialize = function(title, chat_id) {
      self$title <- title
      self$chat_id <- chat_id
    },
    to_dict = function() {
      list(`_` = "MessageActionChannelMigrateFrom", title = self$title, chat_id = self$chat_id)
    },
    bytes = function() {
      c(
        as.raw(c(0xe9, 0x48, 0x39, 0xea)),
        serialize_bytes(self$title),
        writeBin(self$chat_id, raw(), size = 8, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      title <- reader$tgread_string()
      chat_id <- reader$read_long()
      self$new(title = title, chat_id = chat_id)
    }
  )
)

#  @title MessageActionChatAddUser
#  @description Telegram API type MessageActionChatAddUser
#  @export
#  @noRd
#  @noRd
MessageActionChatAddUser <- R6::R6Class(
  "MessageActionChatAddUser",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x15cefd00,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field users Field.
    users = NULL,
    initialize = function(users) {
      self$users <- users
    },
    to_dict = function() {
      list(`_` = "MessageActionChatAddUser", users = if (is.null(self$users)) list() else self$users)
    },
    bytes = function() {
      c(
        as.raw(c(0x00, 0xfd, 0xce, 0x15)),
        writeBin(length(self$users), raw(), size = 4, endian = "little"),
        unlist(lapply(self$users, function(x) writeBin(x, raw(), size = 8, endian = "little")))
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      users <- vector("list", reader$read_int())
      for (i in seq_along(users)) {
        users[[i]] <- reader$read_long()
      }
      self$new(users = users)
    }
  )
)

#  @title MessageActionChatCreate
#  @description Telegram API type MessageActionChatCreate
#  @export
#  @noRd
#  @noRd
MessageActionChatCreate <- R6::R6Class(
  "MessageActionChatCreate",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbd47cbad,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field title Field.
    title = NULL,
    #  @field users Field.
    users = NULL,
    initialize = function(title, users) {
      self$title <- title
      self$users <- users
    },
    to_dict = function() {
      list(
        `_` = "MessageActionChatCreate",
        title = self$title,
        users = if (is.null(self$users)) list() else self$users
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xad, 0xcb, 0x47, 0xbd)),
        serialize_bytes(self$title),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)),
        writeBin(length(self$users), raw(), size = 4, endian = "little"),
        unlist(lapply(self$users, function(x) writeBin(x, raw(), size = 8, endian = "little")))
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      title <- reader$tgread_string()
      reader$read_int()
      users <- vector("list", reader$read_int())
      for (i in seq_along(users)) {
        users[[i]] <- reader$read_long()
      }
      self$new(title = title, users = users)
    }
  )
)

#  @title MessageActionChatDeletePhoto
#  @description Telegram API type MessageActionChatDeletePhoto
#  @export
#  @noRd
#  @noRd
MessageActionChatDeletePhoto <- R6::R6Class(
  "MessageActionChatDeletePhoto",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x95e3fbef,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    to_dict = function() {
      list(`_` = "MessageActionChatDeletePhoto")
    },
    bytes = function() {
      as.raw(c(0xef, 0xfb, 0xe3, 0x95))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$new()
    }
  )
)

#  @title MessageActionChatDeleteUser
#  @description Telegram API type MessageActionChatDeleteUser
#  @export
#  @noRd
#  @noRd
MessageActionChatDeleteUser <- R6::R6Class(
  "MessageActionChatDeleteUser",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa43f30cc,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field user_id Field.
    user_id = NULL,
    initialize = function(user_id) {
      self$user_id <- user_id
    },
    to_dict = function() {
      list(
        `_` = "MessageActionChatDeleteUser",
        user_id = self$user_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xcc, 0x30, 0x3f, 0xa4)),
        writeBin(as.integer64(self$user_id), raw(), size = 8, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      user_id <- reader$read_long()
      self$new(user_id = user_id)
    }
  )
)

#  @title MessageActionChatEditPhoto
#  @description Telegram API type MessageActionChatEditPhoto
#  @export
#  @noRd
#  @noRd
MessageActionChatEditPhoto <- R6::R6Class(
  "MessageActionChatEditPhoto",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7fcb13a8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field photo Field.
    photo = NULL,
    initialize = function(photo) {
      self$photo <- photo
    },
    to_dict = function() {
      list(
        `_` = "MessageActionChatEditPhoto",
        photo = if (inherits(self$photo, "TLObject")) self$photo$to_dict() else self$photo
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xa8, 0x13, 0xcb, 0x7f)),
        self$photo$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      photo <- reader$tgread_object()
      self$new(photo = photo)
    }
  )
)

#  @title MessageActionChatEditTitle
#  @description Telegram API type MessageActionChatEditTitle
#  @export
#  @noRd
#  @noRd
MessageActionChatEditTitle <- R6::R6Class(
  "MessageActionChatEditTitle",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb5a1ce5a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field title Field.
    title = NULL,
    initialize = function(title) {
      self$title <- title
    },
    to_dict = function() {
      list(
        `_` = "MessageActionChatEditTitle",
        title = self$title
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x5a, 0xce, 0xa1, 0xb5)),
        charToRaw(self$title)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      title <- reader$tgread_string()
      self$new(title = title)
    }
  )
)

#  @title MessageActionChatJoinedByLink
#  @description Telegram API type MessageActionChatJoinedByLink
#  @export
#  @noRd
#  @noRd
MessageActionChatJoinedByLink <- R6::R6Class(
  "MessageActionChatJoinedByLink",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x31224c3,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field inviter_id Field.
    inviter_id = NULL,
    initialize = function(inviter_id) {
      self$inviter_id <- inviter_id
    },
    to_dict = function() {
      list(
        `_` = "MessageActionChatJoinedByLink",
        inviter_id = self$inviter_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xc3, 0x24, 0x12, 0x03)),
        writeBin(as.integer64(self$inviter_id), raw(), size = 8, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      inviter_id <- reader$read_long()
      self$new(inviter_id = inviter_id)
    }
  )
)

#  @title MessageActionChatJoinedByRequest
#  @description Telegram API type MessageActionChatJoinedByRequest
#  @export
#  @noRd
#  @noRd
MessageActionChatJoinedByRequest <- R6::R6Class(
  "MessageActionChatJoinedByRequest",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xebbca3cb,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    to_dict = function() {
      list(`_` = "MessageActionChatJoinedByRequest")
    },
    bytes = function() {
      as.raw(c(0xcb, 0xa3, 0xbc, 0xeb))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$new()
    }
  )
)

#  @title MessageActionChatMigrateTo
#  @description Telegram API type MessageActionChatMigrateTo
#  @export
#  @noRd
#  @noRd
MessageActionChatMigrateTo <- R6::R6Class(
  "MessageActionChatMigrateTo",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe1037f92,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field channel_id Field.
    channel_id = NULL,
    initialize = function(channel_id) {
      self$channel_id <- channel_id
    },
    to_dict = function() {
      list(
        `_` = "MessageActionChatMigrateTo",
        channel_id = self$channel_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x92, 0x7f, 0x03, 0xe1)),
        writeBin(as.integer64(self$channel_id), raw(), size = 8, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      channel_id <- reader$read_long()
      self$new(channel_id = channel_id)
    }
  )
)

#  @title MessageActionConferenceCall
#  @description Telegram API type MessageActionConferenceCall
#  @export
#  @noRd
#  @noRd
MessageActionConferenceCall <- R6::R6Class("MessageActionConferenceCall",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x2ffe2f7a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field call_id Field.
    call_id = NULL,
    #  @field missed Field.
    missed = NULL,
    #  @field active Field.
    active = NULL,
    #  @field video Field.
    video = NULL,
    #  @field duration Field.
    duration = NULL,
    #  @field other_participants Field.
    other_participants = NULL,
    initialize = function(call_id, missed = NULL, active = NULL, video = NULL, duration = NULL, other_participants = NULL) {
      self$call_id <- call_id
      self$missed <- missed
      self$active <- active
      self$video <- video
      self$duration <- duration
      self$other_participants <- other_participants
    },
    to_dict = function() {
      list(
        `_` = "MessageActionConferenceCall",
        call_id = self$call_id,
        missed = self$missed,
        active = self$active,
        video = self$video,
        duration = self$duration,
        other_participants = if (is.null(self$other_participants)) NULL else lapply(self$other_participants, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      )
    },
    bytes = function() {
      raw(0)
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      missed <- bitwAnd(flags, 1L) != 0L
      active <- bitwAnd(flags, 2L) != 0L
      video <- bitwAnd(flags, 16L) != 0L
      call_id <- reader$read_long()
      duration <- if (bitwAnd(flags, 4L) != 0L) reader$read_int() else NULL
      other_participants <- NULL
      if (bitwAnd(flags, 8L) != 0L) {
        # vector of TLObjects
        reader$read_int() # marker read (depending on your reader implementation)
        n <- reader$read_int()
        other_participants <- lapply(seq_len(n), function(i) reader$tgread_object())
      }
      list(call_id = call_id, missed = missed, active = active, video = video, duration = duration, other_participants = other_participants)
    }
  ),
  class = TRUE
)

#  @title MessageActionContactSignUp
#  @description Telegram API type MessageActionContactSignUp
#  @export
#  @noRd
#  @noRd
MessageActionContactSignUp <- R6::R6Class("MessageActionContactSignUp",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf3f25f76,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    initialize = function() {},
    to_dict = function() list(`_` = "MessageActionContactSignUp"),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title MessageActionCustomAction
#  @description Telegram API type MessageActionCustomAction
#  @export
#  @noRd
#  @noRd
MessageActionCustomAction <- R6::R6Class("MessageActionCustomAction",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xfae69f56,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field message Field.
    message = NULL,
    initialize = function(message) {
      self$message <- message
    },
    to_dict = function() list(`_` = "MessageActionCustomAction", message = self$message),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      msg <- reader$tgread_string()
      list(message = msg)
    }
  ),
  class = TRUE
)

#  @title MessageActionEmpty
#  @description Telegram API type MessageActionEmpty
#  @export
#  @noRd
#  @noRd
MessageActionEmpty <- R6::R6Class("MessageActionEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb6aef7b0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    initialize = function() {},
    to_dict = function() list(`_` = "MessageActionEmpty"),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title MessageActionChatEditTitle
#  @description Telegram API type MessageActionChatEditTitle
#  @export
#  @noRd
#  @noRd
MessageActionChatEditTitle <- R6::R6Class("MessageActionChatEditTitle",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb5a1ce5a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field title Field.
    title = NULL,
    initialize = function(title) {
      self$title <- title
    },
    to_dict = function() list(`_` = "MessageActionChatEditTitle", title = self$title),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list(title = reader$tgread_string())
  ),
  class = TRUE
)

#  @title MessageActionChatEditPhoto
#  @description Telegram API type MessageActionChatEditPhoto
#  @export
#  @noRd
#  @noRd
MessageActionChatEditPhoto <- R6::R6Class("MessageActionChatEditPhoto",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7fcb13a8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field photo Field.
    photo = NULL,
    initialize = function(photo) {
      self$photo <- photo
    },
    to_dict = function() list(`_` = "MessageActionChatEditPhoto", photo = if (inherits(self$photo, "TLObject")) self$photo$to_dict() else self$photo),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list(photo = reader$tgread_object())
  ),
  class = TRUE
)

#  @title MessageActionChatCreate
#  @description Telegram API type MessageActionChatCreate
#  @export
#  @noRd
#  @noRd
MessageActionChatCreate <- R6::R6Class("MessageActionChatCreate",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbd47cbad,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field title Field.
    title = NULL,
    #  @field users Field.
    users = NULL,
    initialize = function(title, users) {
      self$title <- title
      self$users <- users
    },
    to_dict = function() list(`_` = "MessageActionChatCreate", title = self$title, users = if (is.null(self$users)) NULL else self$users),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      title <- reader$tgread_string()
      reader$read_int()
      n <- reader$read_int()
      users <- lapply(seq_len(n), function(i) reader$read_long())
      list(title = title, users = users)
    }
  ),
  class = TRUE
)

#  @title MessageActionChatAddUser
#  @description Telegram API type MessageActionChatAddUser
#  @export
#  @noRd
#  @noRd
MessageActionChatAddUser <- R6::R6Class("MessageActionChatAddUser",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x15cefd00,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field users Field.
    users = NULL,
    initialize = function(users) {
      self$users <- users
    },
    to_dict = function() list(`_` = "MessageActionChatAddUser", users = if (is.null(self$users)) NULL else self$users),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      n <- reader$read_int()
      users <- lapply(seq_len(n), function(i) reader$read_long())
      list(users = users)
    }
  ),
  class = TRUE
)

#  @title MessageActionChatDeleteUser
#  @description Telegram API type MessageActionChatDeleteUser
#  @export
#  @noRd
#  @noRd
MessageActionChatDeleteUser <- R6::R6Class("MessageActionChatDeleteUser",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa43f30cc,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field user_id Field.
    user_id = NULL,
    initialize = function(user_id) {
      self$user_id <- user_id
    },
    to_dict = function() list(`_` = "MessageActionChatDeleteUser", user_id = self$user_id),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list(user_id = reader$read_long())
  ),
  class = TRUE
)

#  @title MessageActionChatJoinedByLink
#  @description Telegram API type MessageActionChatJoinedByLink
#  @export
#  @noRd
#  @noRd
MessageActionChatJoinedByLink <- R6::R6Class("MessageActionChatJoinedByLink",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x31224c3,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field inviter_id Field.
    inviter_id = NULL,
    initialize = function(inviter_id) {
      self$inviter_id <- inviter_id
    },
    to_dict = function() list(`_` = "MessageActionChatJoinedByLink", inviter_id = self$inviter_id),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list(inviter_id = reader$read_long())
  ),
  class = TRUE
)

#  @title MessageActionChatJoinedByRequest
#  @description Telegram API type MessageActionChatJoinedByRequest
#  @export
#  @noRd
#  @noRd
MessageActionChatJoinedByRequest <- R6::R6Class("MessageActionChatJoinedByRequest",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xebbca3cb,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    initialize = function() {},
    to_dict = function() list(`_` = "MessageActionChatJoinedByRequest"),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title MessageActionChatMigrateTo
#  @description Telegram API type MessageActionChatMigrateTo
#  @export
#  @noRd
#  @noRd
MessageActionChatMigrateTo <- R6::R6Class("MessageActionChatMigrateTo",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe1037f92,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field channel_id Field.
    channel_id = NULL,
    initialize = function(channel_id) {
      self$channel_id <- channel_id
    },
    to_dict = function() list(`_` = "MessageActionChatMigrateTo", channel_id = self$channel_id),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list(channel_id = reader$read_long())
  ),
  class = TRUE
)

#  @title MessageActionChannelCreate
#  @description Telegram API type MessageActionChannelCreate
#  @export
#  @noRd
#  @noRd
MessageActionChannelCreate <- R6::R6Class("MessageActionChannelCreate",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x95d2ac92,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field title Field.
    title = NULL,
    initialize = function(title) {
      self$title <- title
    },
    to_dict = function() list(`_` = "MessageActionChannelCreate", title = self$title),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list(title = reader$tgread_string())
  ),
  class = TRUE
)

#  @title MessageActionChannelMigrateFrom
#  @description Telegram API type MessageActionChannelMigrateFrom
#  @export
#  @noRd
#  @noRd
MessageActionChannelMigrateFrom <- R6::R6Class("MessageActionChannelMigrateFrom",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xea3948e9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field title Field.
    title = NULL,
    #  @field chat_id Field.
    chat_id = NULL,
    initialize = function(title, chat_id) {
      self$title <- title
      self$chat_id <- chat_id
    },
    to_dict = function() list(`_` = "MessageActionChannelMigrateFrom", title = self$title, chat_id = self$chat_id),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list(title = reader$tgread_string(), chat_id = reader$read_long())
  ),
  class = TRUE
)

#  @title MessageActionChatDeletePhoto
#  @description Telegram API type MessageActionChatDeletePhoto
#  @export
#  @noRd
#  @noRd
MessageActionChatDeletePhoto <- R6::R6Class("MessageActionChatDeletePhoto",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x95e3fbef,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    initialize = function() {},
    to_dict = function() list(`_` = "MessageActionChatDeletePhoto"),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title MessageActionGameScore
#  @description Telegram API type MessageActionGameScore
#  @export
#  @noRd
#  @noRd
MessageActionGameScore <- R6::R6Class("MessageActionGameScore",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x92a72876,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field game_id Field.
    game_id = NULL,
    #  @field score Field.
    score = NULL,
    initialize = function(game_id, score) {
      self$game_id <- game_id
      self$score <- score
    },
    to_dict = function() list(`_` = "MessageActionGameScore", game_id = self$game_id, score = self$score),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list(game_id = reader$read_long(), score = reader$read_int())
  ),
  class = TRUE
)

#  @title MessageActionGeoProximityReached
#  @description Telegram API type MessageActionGeoProximityReached
#  @export
#  @noRd
#  @noRd
MessageActionGeoProximityReached <- R6::R6Class("MessageActionGeoProximityReached",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x98e0d697,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field from_id Field.
    from_id = NULL,
    #  @field to_id Field.
    to_id = NULL,
    #  @field distance Field.
    distance = NULL,
    initialize = function(from_id, to_id, distance) {
      self$from_id <- from_id
      self$to_id <- to_id
      self$distance <- distance
    },
    to_dict = function() {
      list(
        `_` = "MessageActionGeoProximityReached",
        from_id = if (inherits(self$from_id, "TLObject")) self$from_id$to_dict() else self$from_id,
        to_id = if (inherits(self$to_id, "TLObject")) self$to_id$to_dict() else self$to_id,
        distance = self$distance
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      from_id <- reader$tgread_object()
      to_id <- reader$tgread_object()
      distance <- reader$read_int()
      list(from_id = from_id, to_id = to_id, distance = distance)
    }
  ),
  class = TRUE
)


#  @title MessageActionConferenceCall
#  @description Telegram API type MessageActionConferenceCall
#  @export
#  @noRd
#  @noRd
MessageActionConferenceCall <- R6::R6Class(
  "MessageActionConferenceCall",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x2ffe2f7a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field call_id Field.
    call_id = NULL,
    #  @field missed Field.
    missed = NULL,
    #  @field active Field.
    active = NULL,
    #  @field video Field.
    video = NULL,
    #  @field duration Field.
    duration = NULL,
    #  @field other_participants Field.
    other_participants = NULL,
    initialize = function(call_id, missed = NULL, active = NULL, video = NULL, duration = NULL, other_participants = NULL) {
      self$call_id <- call_id
      self$missed <- missed
      self$active <- active
      self$video <- video
      self$duration <- duration
      self$other_participants <- other_participants
    },
    to_dict = function() {
      list(
        "_" = "MessageActionConferenceCall",
        call_id = self$call_id,
        missed = self$missed,
        active = self$active,
        video = self$video,
        duration = self$duration,
        other_participants = if (is.null(self$other_participants)) NULL else lapply(self$other_participants, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      missed <- as.logical(bitwAnd(flags, 1))
      active <- as.logical(bitwAnd(flags, 2))
      video <- as.logical(bitwAnd(flags, 16))
      call_id <- reader$read_long()
      duration <- if (bitwAnd(flags, 4) != 0) reader$read_int() else NULL
      other_participants <- NULL
      if (bitwAnd(flags, 8) != 0) {
        # vector of objects: first expect vector constructor then length
        reader$read_int()
        n <- reader$read_int()
        other_participants <- lapply(seq_len(n), function(i) reader$tgread_object())
      }
      self$new(call_id = call_id, missed = missed, active = active, video = video, duration = duration, other_participants = other_participants)
    }
  ),
  class = TRUE
)


#  @title MessageActionContactSignUp
#  @description Telegram API type MessageActionContactSignUp
#  @export
#  @noRd
#  @noRd
MessageActionContactSignUp <- R6::R6Class(
  "MessageActionContactSignUp",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf3f25f76,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    initialize = function() {},
    to_dict = function() list("_" = "MessageActionContactSignUp"),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      value <- reader$read_int()
      emoticon <- reader$tgread_string()
      self$new(value, emoticon)
    }
  ),
  class = TRUE
)


#  @title MessageActionCustomAction
#  @description Telegram API type MessageActionCustomAction
#  @export
#  @noRd
#  @noRd
MessageActionCustomAction <- R6::R6Class(
  "MessageActionCustomAction",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xfae69f56,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field message Field.
    message = NULL,
    initialize = function(message) {
      self$message <- message
    },
    to_dict = function() list("_" = "MessageActionCustomAction", message = self$message),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      msg <- reader$tgread_string()
      self$new(message = msg)
    }
  ),
  class = TRUE
)


#  @title MessageActionEmpty
#  @description Telegram API type MessageActionEmpty
#  @export
#  @noRd
#  @noRd
MessageActionEmpty <- R6::R6Class(
  "MessageActionEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb6aef7b0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    initialize = function() {},
    to_dict = function() list("_" = "MessageActionEmpty"),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      nopremium <- bitwAnd(flags, 8) != 0
      spoiler <- bitwAnd(flags, 16) != 0
      video <- bitwAnd(flags, 64) != 0
      round <- bitwAnd(flags, 128) != 0
      voice <- bitwAnd(flags, 256) != 0
      document <- if (bitwAnd(flags, 1) != 0) reader$tgread_object() else NULL
      alt_documents <- if (bitwAnd(flags, 32) != 0) {
        reader$read_int()
        lapply(seq_len(reader$read_int()), function(x) reader$tgread_object())
      } else {
        NULL
      }
      video_cover <- if (bitwAnd(flags, 512) != 0) reader$tgread_object() else NULL
      video_timestamp <- if (bitwAnd(flags, 1024) != 0) reader$read_int() else NULL
      ttl_seconds <- if (bitwAnd(flags, 4) != 0) reader$read_int() else NULL
      list(
        nopremium = nopremium,
        spoiler = spoiler,
        video = video,
        round = round,
        voice = voice,
        document = document,
        alt_documents = alt_documents,
        video_cover = video_cover,
        video_timestamp = video_timestamp,
        ttl_seconds = ttl_seconds
      )
    }
  ),
  class = TRUE
)


#  @title MessageActionGameScore
#  @description Telegram API type MessageActionGameScore
#  @export
#  @noRd
#  @noRd
MessageActionGameScore <- R6::R6Class(
  "MessageActionGameScore",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x92a72876,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field game_id Field.
    game_id = NULL,
    #  @field score Field.
    score = NULL,
    initialize = function(game_id, score) {
      self$game_id <- game_id
      self$score <- score
    },
    to_dict = function() list("_" = "MessageActionGameScore", game_id = self$game_id, score = self$score),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      game_id <- reader$read_long()
      score <- reader$read_int()
      self$new(game_id = game_id, score = score)
    }
  ),
  class = TRUE
)


#  @title MessageActionGeoProximityReached
#  @description Telegram API type MessageActionGeoProximityReached
#  @export
#  @noRd
#  @noRd
MessageActionGeoProximityReached <- R6::R6Class(
  "MessageActionGeoProximityReached",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x98e0d697,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field from_id Field.
    from_id = NULL,
    #  @field to_id Field.
    to_id = NULL,
    #  @field distance Field.
    distance = NULL,
    initialize = function(from_id, to_id, distance) {
      self$from_id <- from_id
      self$to_id <- to_id
      self$distance <- distance
    },
    to_dict = function() {
      list(
        "_" = "MessageActionGeoProximityReached",
        from_id = if (inherits(self$from_id, "TLObject")) self$from_id$to_dict() else self$from_id,
        to_id = if (inherits(self$to_id, "TLObject")) self$to_id$to_dict() else self$to_id,
        distance = self$distance
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      from_id <- reader$tgread_object()
      to_id <- reader$tgread_object()
      distance <- reader$read_int()
      self$new(from_id = from_id, to_id = to_id, distance = distance)
    }
  ),
  class = TRUE
)


#  @title MessageActionChatEditTitle
#  @description Telegram API type MessageActionChatEditTitle
#  @export
#  @noRd
#  @noRd
MessageActionChatEditTitle <- R6::R6Class(
  "MessageActionChatEditTitle",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb5a1ce5a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field title Field.
    title = NULL,
    initialize = function(title) {
      self$title <- title
    },
    to_dict = function() list("_" = "MessageActionChatEditTitle", title = self$title),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      title <- reader$tgread_string()
      self$new(title = title)
    }
  ),
  class = TRUE
)


#  @title MessageActionChatJoinedByLink
#  @description Telegram API type MessageActionChatJoinedByLink
#  @export
#  @noRd
#  @noRd
MessageActionChatJoinedByLink <- R6::R6Class(
  "MessageActionChatJoinedByLink",
  inherit = TLObject,
  public = list(
    CONSTRUCTOR_ID = 0x031224c3, # keep consistent with encoding above
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field inviter_id Field.
    inviter_id = NULL,
    initialize = function(inviter_id) {
      self$inviter_id <- inviter_id
    },
    to_dict = function() list("_" = "MessageActionChatJoinedByLink", inviter_id = self$inviter_id),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      inviter <- reader$read_long()
      self$new(inviter_id = inviter)
    }
  ),
  class = TRUE
)


#  @title MessageActionChatJoinedByRequest
#  @description Telegram API type MessageActionChatJoinedByRequest
#  @export
#  @noRd
#  @noRd
MessageActionChatJoinedByRequest <- R6::R6Class(
  "MessageActionChatJoinedByRequest",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xebbca3cb,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    initialize = function() {},
    to_dict = function() list("_" = "MessageActionChatJoinedByRequest"),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      id <- reader$read_int()
      peer_id <- if (bitwAnd(flags, 1) != 0) reader$tgread_object() else NULL
      self$new(id = id, peer_id = peer_id)
    }
  ),
  class = TRUE
)

#  @title MessageActionChatMigrateTo
#  @description Telegram API type MessageActionChatMigrateTo
#  @export
#  @noRd
#  @noRd
MessageActionChatMigrateTo <- R6::R6Class(
  "MessageActionChatMigrateTo",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe1037f92,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field channel_id Field.
    channel_id = NULL,
    initialize = function(channel_id) {
      self$channel_id <- channel_id
    },
    to_dict = function() {
      list("_" = "MessageActionChatMigrateTo", channel_id = self$channel_id)
    },
    bytes = function() {
      # placeholder: implement actual serialization if needed
      raw(0)
    }
  ),
  private = list(
    from_reader = function(reader) {
      # reader$read_long() expected
      channel_id <- reader$read_long()
      self$new(channel_id = channel_id)
    }
  ),
  class = TRUE
)

#  @title MessageActionConferenceCall
#  @description Telegram API type MessageActionConferenceCall
#  @export
#  @noRd
#  @noRd
MessageActionConferenceCall <- R6::R6Class(
  "MessageActionConferenceCall",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x2ffe2f7a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field call_id Field.
    call_id = NULL,
    #  @field missed Field.
    missed = NULL,
    #  @field active Field.
    active = NULL,
    #  @field video Field.
    video = NULL,
    #  @field duration Field.
    duration = NULL,
    #  @field other_participants Field.
    other_participants = NULL,
    initialize = function(call_id, missed = NULL, active = NULL, video = NULL, duration = NULL, other_participants = NULL) {
      self$call_id <- call_id
      self$missed <- missed
      self$active <- active
      self$video <- video
      self$duration <- duration
      self$other_participants <- other_participants
    },
    to_dict = function() {
      list(
        "_" = "MessageActionConferenceCall",
        call_id = self$call_id,
        missed = self$missed,
        active = self$active,
        video = self$video,
        duration = self$duration,
        other_participants = if (is.null(self$other_participants)) NULL else lapply(self$other_participants, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      )
    },
    bytes = function() {
      # placeholder for actual binary encoding
      raw(0)
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      missed <- as.logical(bitwAnd(flags, 1))
      active <- as.logical(bitwAnd(flags, 2))
      video <- as.logical(bitwAnd(flags, 16))
      call_id <- reader$read_long()
      duration <- if (bitwAnd(flags, 4) != 0) reader$read_int() else NULL
      other_participants <- NULL
      if (bitwAnd(flags, 8) != 0) {
        # reading vector of objects: assumes tgread_vector / tgread_object helpers
        reader$read_int() # constructor id of vector expected
        count <- reader$read_int()
        other_participants <- vector("list", count)
        for (i in seq_len(count)) other_participants[[i]] <- reader$tgread_object()
      }
      self$new(call_id = call_id, missed = missed, active = active, video = video, duration = duration, other_participants = other_participants)
    }
  ),
  class = TRUE
)

#  @title MessageActionContactSignUp
#  @description Telegram API type MessageActionContactSignUp
#  @export
#  @noRd
#  @noRd
MessageActionContactSignUp <- R6::R6Class(
  "MessageActionContactSignUp",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf3f25f76,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    initialize = function() {},
    to_dict = function() list("_" = "MessageActionContactSignUp"),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      # no fields
      self$new()
    }
  ),
  class = TRUE
)

#  @title MessageActionCustomAction
#  @description Telegram API type MessageActionCustomAction
#  @export
#  @noRd
#  @noRd
MessageActionCustomAction <- R6::R6Class(
  "MessageActionCustomAction",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xfae69f56,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field message Field.
    message = NULL,
    initialize = function(message) {
      self$message <- message
    },
    to_dict = function() list("_" = "MessageActionCustomAction", message = self$message),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      msg <- reader$tgread_string()
      self$new(message = msg)
    }
  ),
  class = TRUE
)

#  @title MessageActionEmpty
#  @description Telegram API type MessageActionEmpty
#  @export
#  @noRd
#  @noRd
MessageActionEmpty <- R6::R6Class(
  "MessageActionEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb6aef7b0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    initialize = function() {},
    to_dict = function() list("_" = "MessageActionEmpty"),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      out <- bitwAnd(flags, 2) != 0
      mentioned <- bitwAnd(flags, 16) != 0
      media_unread <- bitwAnd(flags, 32) != 0
      reactions_are_possible <- bitwAnd(flags, 512) != 0
      silent <- bitwAnd(flags, 8192) != 0
      post <- bitwAnd(flags, 16384) != 0
      legacy <- bitwAnd(flags, 524288) != 0

      id <- reader$read_int()
      from_id <- if (bitwAnd(flags, 256) != 0) reader$tgread_object() else NULL
      peer_id <- reader$tgread_object()
      savedpeer_id <- if (bitwAnd(flags, 268435456) != 0) reader$tgread_object() else NULL
      reply_to <- if (bitwAnd(flags, 8) != 0) reader$tgread_object() else NULL
      date <- reader$tgread_date()
      action <- reader$tgread_object()
      reactions <- if (bitwAnd(flags, 1048576) != 0) reader$tgread_object() else NULL
      ttl_period <- if (bitwAnd(flags, 33554432) != 0) reader$read_int() else NULL

      self$new(
        id = id,
        peer_id = peer_id,
        date = date,
        action = action,
        out = out,
        mentioned = mentioned,
        media_unread = media_unread,
        reactions_are_possible = reactions_are_possible,
        silent = silent,
        post = post,
        legacy = legacy,
        from_id = from_id,
        savedpeer_id = savedpeer_id,
        reply_to = reply_to,
        reactions = reactions,
        ttl_period = ttl_period
      )
    }
  ),
  class = TRUE
)

#  @title MessageActionGameScore
#  @description Telegram API type MessageActionGameScore
#  @export
#  @noRd
#  @noRd
MessageActionGameScore <- R6::R6Class(
  "MessageActionGameScore",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x92a72876,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field game_id Field.
    game_id = NULL,
    #  @field score Field.
    score = NULL,
    initialize = function(game_id, score) {
      self$game_id <- game_id
      self$score <- score
    },
    to_dict = function() list("_" = "MessageActionGameScore", game_id = self$game_id, score = self$score),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      game_id <- reader$read_long()
      score <- reader$read_int()
      self$new(game_id = game_id, score = score)
    }
  ),
  class = TRUE
)

#  @title MessageActionGeoProximityReached
#  @description Telegram API type MessageActionGeoProximityReached
#  @export
#  @noRd
#  @noRd
MessageActionGeoProximityReached <- R6::R6Class(
  "MessageActionGeoProximityReached",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x98e0d697,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field from_id Field.
    from_id = NULL,
    #  @field to_id Field.
    to_id = NULL,
    #  @field distance Field.
    distance = NULL,
    initialize = function(from_id, to_id, distance) {
      self$from_id <- from_id
      self$to_id <- to_id
      self$distance <- distance
    },
    to_dict = function() {
      list(
        "_" = "MessageActionGeoProximityReached",
        from_id = if (inherits(self$from_id, "TLObject")) self$from_id$to_dict() else self$from_id,
        to_id = if (inherits(self$to_id, "TLObject")) self$to_id$to_dict() else self$to_id,
        distance = self$distance
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      from_id <- reader$tgread_object()
      to_id <- reader$tgread_object()
      distance <- reader$read_int()
      self$new(from_id = from_id, to_id = to_id, distance = distance)
    }
  ),
  class = TRUE
)

#  @title MessageActionChatEditTitle
#  @description Telegram API type MessageActionChatEditTitle
#  @export
#  @noRd
#  @noRd
MessageActionChatEditTitle <- R6::R6Class(
  "MessageActionChatEditTitle",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb5a1ce5a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field title Field.
    title = NULL,
    initialize = function(title) {
      self$title <- title
    },
    to_dict = function() list("_" = "MessageActionChatEditTitle", title = self$title),
    bytes = function() {
      # uses TLObject helper serializebytes if available
      if (!is.null(self$title)) {
        return(self$serializebytes(self$title))
      }
      raw(0)
    }
  ),
  private = list(
    from_reader = function(reader) list(title = reader$tgread_string())
  ),
  class = TRUE
)

#  @title MessageActionChatJoinedByLink
#  @description Telegram API type MessageActionChatJoinedByLink
#  @export
#  @noRd
#  @noRd
MessageActionChatJoinedByLink <- R6::R6Class(
  "MessageActionChatJoinedByLink",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x031224c3,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field inviter_id Field.
    inviter_id = NULL,
    initialize = function(inviter_id) {
      self$inviter_id <- inviter_id
    },
    to_dict = function() list("_" = "MessageActionChatJoinedByLink", inviter_id = self$inviter_id),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list(inviter_id = reader$read_long())
  ),
  class = TRUE
)

#  @title MessageActionChatJoinedByRequest
#  @description Telegram API type MessageActionChatJoinedByRequest
#  @export
#  @noRd
#  @noRd
MessageActionChatJoinedByRequest <- R6::R6Class(
  "MessageActionChatJoinedByRequest",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xebbca3cb,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    initialize = function() {},
    to_dict = function() list("_" = "MessageActionChatJoinedByRequest"),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title MessageActionChatMigrateTo
#  @description Telegram API type MessageActionChatMigrateTo
#  @export
#  @noRd
#  @noRd
MessageActionChatMigrateTo <- R6::R6Class(
  "MessageActionChatMigrateTo",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe1037f92,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field channel_id Field.
    channel_id = NULL,
    initialize = function(channel_id) {
      self$channel_id <- channel_id
    },
    to_dict = function() list("_" = "MessageActionChatMigrateTo", channel_id = self$channel_id),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list(channel_id = reader$read_long())
  ),
  class = TRUE
)

#  @title MessageActionConferenceCall
#  @description Telegram API type MessageActionConferenceCall
#  @export
#  @noRd
#  @noRd
MessageActionConferenceCall <- R6::R6Class(
  "MessageActionConferenceCall",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x2ffe2f7a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field call_id Field.
    call_id = NULL,
    #  @field missed Field.
    missed = NULL,
    #  @field active Field.
    active = NULL,
    #  @field video Field.
    video = NULL,
    #  @field duration Field.
    duration = NULL,
    #  @field other_participants Field.
    other_participants = NULL,
    initialize = function(call_id, missed = NULL, active = NULL, video = NULL, duration = NULL, other_participants = NULL) {
      self$call_id <- call_id
      self$missed <- missed
      self$active <- active
      self$video <- video
      self$duration <- duration
      self$other_participants <- other_participants
    },
    to_dict = function() {
      list(
        "_" = "MessageActionConferenceCall",
        call_id = self$call_id,
        missed = self$missed,
        active = self$active,
        video = self$video,
        duration = self$duration,
        other_participants = if (is.null(self$other_participants)) NULL else lapply(self$other_participants, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      missed <- as.logical(bitwAnd(flags, 1))
      active <- as.logical(bitwAnd(flags, 2))
      video <- as.logical(bitwAnd(flags, 16))
      call_id <- reader$read_long()
      duration <- if (bitwAnd(flags, 4) != 0) reader$read_int() else NULL

      other_participants <- NULL
      if (bitwAnd(flags, 8) != 0) {
        # vector marker then length
        reader$read_int()
        n <- reader$read_int()
        lst <- vector("list", n)
        for (i in seq_len(n)) lst[[i]] <- reader$tgread_object()
        other_participants <- lst
      }

      list(call_id = call_id, missed = missed, active = active, video = video, duration = duration, other_participants = other_participants)
    }
  ),
  class = TRUE
)

#  @title MessageActionContactSignUp
#  @description Telegram API type MessageActionContactSignUp
#  @export
#  @noRd
#  @noRd
MessageActionContactSignUp <- R6::R6Class(
  "MessageActionContactSignUp",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf3f25f76,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    initialize = function() {},
    to_dict = function() list("_" = "MessageActionContactSignUp"),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title MessageActionCustomAction
#  @description Telegram API type MessageActionCustomAction
#  @export
#  @noRd
#  @noRd
MessageActionCustomAction <- R6::R6Class(
  "MessageActionCustomAction",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xfae69f56,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field message Field.
    message = NULL,
    initialize = function(message) {
      self$message <- message
    },
    to_dict = function() list("_" = "MessageActionCustomAction", message = self$message),
    bytes = function() {
      if (!is.null(self$message)) {
        return(self$serializebytes(self$message))
      }
      raw(0)
    }
  ),
  private = list(
    from_reader = function(reader) list(message = reader$tgread_string())
  ),
  class = TRUE
)

#  @title MessageActionEmpty
#  @description Telegram API type MessageActionEmpty
#  @export
#  @noRd
#  @noRd
MessageActionEmpty <- R6::R6Class(
  "MessageActionEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb6aef7b0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    initialize = function() {},
    to_dict = function() list("_" = "MessageActionEmpty"),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title MessageActionGameScore
#  @description Telegram API type MessageActionGameScore
#  @export
#  @noRd
#  @noRd
MessageActionGameScore <- R6::R6Class(
  "MessageActionGameScore",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x92a72876,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field game_id Field.
    game_id = NULL,
    #  @field score Field.
    score = NULL,
    initialize = function(game_id, score) {
      self$game_id <- game_id
      self$score <- score
    },
    to_dict = function() list("_" = "MessageActionGameScore", game_id = self$game_id, score = self$score),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list(game_id = reader$read_long(), score = reader$read_int())
  ),
  class = TRUE
)

#  @title MessageActionGeoProximityReached
#  @description Telegram API type MessageActionGeoProximityReached
#  @export
#  @noRd
#  @noRd
MessageActionGeoProximityReached <- R6::R6Class(
  "MessageActionGeoProximityReached",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x98e0d697,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field from_id Field.
    from_id = NULL,
    #  @field to_id Field.
    to_id = NULL,
    #  @field distance Field.
    distance = NULL,
    initialize = function(from_id, to_id, distance) {
      self$from_id <- from_id
      self$to_id <- to_id
      self$distance <- distance
    },
    to_dict = function() {
      list(
        "_" = "MessageActionGeoProximityReached",
        from_id = if (inherits(self$from_id, "TLObject")) self$from_id$to_dict() else self$from_id,
        to_id = if (inherits(self$to_id, "TLObject")) self$to_id$to_dict() else self$to_id,
        distance = self$distance
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      list(from_id = reader$tgread_object(), to_id = reader$tgread_object(), distance = reader$read_int())
    }
  ),
  class = TRUE
)

#  @title MessageActionGiftCode
#  @description Telegram API type MessageActionGiftCode
#  @export
#  @noRd
#  @noRd
MessageActionGiftCode <- R6::R6Class(
  "MessageActionGiftCode",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x56d03994,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field months Field.
    months = NULL,
    #  @field slug Field.
    slug = NULL,
    #  @field via_giveaway Field.
    via_giveaway = NULL,
    #  @field unclaimed Field.
    unclaimed = NULL,
    #  @field boostpeer Field.
    boostpeer = NULL,
    #  @field currency Field.
    currency = NULL,
    #  @field amount Field.
    amount = NULL,
    #  @field crypto_currency Field.
    crypto_currency = NULL,
    #  @field crypto_amount Field.
    crypto_amount = NULL,
    #  @field message Field.
    message = NULL,
    initialize = function(months, slug, via_giveaway = NULL, unclaimed = NULL, boostpeer = NULL, currency = NULL, amount = NULL, crypto_currency = NULL, crypto_amount = NULL, message = NULL) {
      self$months <- months
      self$slug <- slug
      self$via_giveaway <- via_giveaway
      self$unclaimed <- unclaimed
      self$boostpeer <- boostpeer
      self$currency <- currency
      self$amount <- amount
      self$crypto_currency <- crypto_currency
      self$crypto_amount <- crypto_amount
      self$message <- message
    },
    to_dict = function() {
      list(
        "_" = "MessageActionGiftCode",
        months = self$months,
        slug = self$slug,
        via_giveaway = self$via_giveaway,
        unclaimed = self$unclaimed,
        boostpeer = if (inherits(self$boostpeer, "TLObject")) self$boostpeer$to_dict() else self$boostpeer,
        currency = self$currency,
        amount = self$amount,
        crypto_currency = self$crypto_currency,
        crypto_amount = self$crypto_amount,
        message = if (inherits(self$message, "TLObject")) self$message$to_dict() else self$message
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      via_giveaway <- as.logical(bitwAnd(flags, 1))
      unclaimed <- as.logical(bitwAnd(flags, 32))
      boostpeer <- if (bitwAnd(flags, 2) != 0) reader$tgread_object() else NULL
      months <- reader$read_int()
      slug <- reader$tgread_string()
      currency <- if (bitwAnd(flags, 4) != 0) reader$tgread_string() else NULL
      amount <- if (bitwAnd(flags, 4) != 0) reader$read_long() else NULL
      crypto_currency <- if (bitwAnd(flags, 8) != 0) reader$tgread_string() else NULL
      crypto_amount <- if (bitwAnd(flags, 8) != 0) reader$read_long() else NULL
      message <- if (bitwAnd(flags, 16) != 0) reader$tgread_object() else NULL

      list(
        months = months, slug = slug, via_giveaway = via_giveaway, unclaimed = unclaimed,
        boostpeer = boostpeer, currency = currency, amount = amount,
        crypto_currency = crypto_currency, crypto_amount = crypto_amount, message = message
      )
    }
  ),
  class = TRUE
)

#  @title MessageActionGiftPremium
#  @description Telegram API type MessageActionGiftPremium
#  @export
#  @noRd
#  @noRd
MessageActionGiftPremium <- R6::R6Class(
  "MessageActionGiftPremium",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x6c6274fa,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field currency Field.
    currency = NULL,
    #  @field amount Field.
    amount = NULL,
    #  @field months Field.
    months = NULL,
    #  @field crypto_currency Field.
    crypto_currency = NULL,
    #  @field crypto_amount Field.
    crypto_amount = NULL,
    #  @field message Field.
    message = NULL,
    initialize = function(currency, amount, months, crypto_currency = NULL, crypto_amount = NULL, message = NULL) {
      self$currency <- currency
      self$amount <- amount
      self$months <- months
      self$crypto_currency <- crypto_currency
      self$crypto_amount <- crypto_amount
      self$message <- message
    },
    to_dict = function() {
      list(
        "_" = "MessageActionGiftPremium",
        currency = self$currency, amount = self$amount, months = self$months,
        crypto_currency = self$crypto_currency, crypto_amount = self$crypto_amount,
        message = if (inherits(self$message, "TLObject")) self$message$to_dict() else self$message
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      currency <- reader$tgread_string()
      amount <- reader$read_long()
      months <- reader$read_int()
      crypto_currency <- if (bitwAnd(flags, 1) != 0) reader$tgread_string() else NULL
      crypto_amount <- if (bitwAnd(flags, 1) != 0) reader$read_long() else NULL
      message <- if (bitwAnd(flags, 2) != 0) reader$tgread_object() else NULL
      list(currency = currency, amount = amount, months = months, crypto_currency = crypto_currency, crypto_amount = crypto_amount, message = message)
    }
  ),
  class = TRUE
)

#  @title MessageActionGiftStars
#  @description Telegram API type MessageActionGiftStars
#  @export
#  @noRd
#  @noRd
MessageActionGiftStars <- R6::R6Class(
  "MessageActionGiftStars",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x45d5b021,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field currency Field.
    currency = NULL,
    #  @field amount Field.
    amount = NULL,
    #  @field stars Field.
    stars = NULL,
    #  @field crypto_currency Field.
    crypto_currency = NULL,
    #  @field crypto_amount Field.
    crypto_amount = NULL,
    #  @field transaction_id Field.
    transaction_id = NULL,
    initialize = function(currency, amount, stars, crypto_currency = NULL, crypto_amount = NULL, transaction_id = NULL) {
      self$currency <- currency
      self$amount <- amount
      self$stars <- stars
      self$crypto_currency <- crypto_currency
      self$crypto_amount <- crypto_amount
      self$transaction_id <- transaction_id
    },
    to_dict = function() {
      list(
        "_" = "MessageActionGiftStars",
        currency = self$currency, amount = self$amount, stars = self$stars,
        crypto_currency = self$crypto_currency, crypto_amount = self$crypto_amount,
        transaction_id = self$transaction_id
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      currency <- reader$tgread_string()
      amount <- reader$read_long()
      stars <- reader$read_long()
      crypto_currency <- if (bitwAnd(flags, 1) != 0) reader$tgread_string() else NULL
      crypto_amount <- if (bitwAnd(flags, 1) != 0) reader$read_long() else NULL
      transaction_id <- if (bitwAnd(flags, 2) != 0) reader$tgread_string() else NULL
      list(currency = currency, amount = amount, stars = stars, crypto_currency = crypto_currency, crypto_amount = crypto_amount, transaction_id = transaction_id)
    }
  ),
  class = TRUE
)

#  @title MessageActionGiftTon
#  @description Telegram API type MessageActionGiftTon
#  @export
#  @noRd
#  @noRd
MessageActionGiftTon <- R6::R6Class(
  "MessageActionGiftTon",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa8a3c699,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field currency Field.
    currency = NULL,
    #  @field amount Field.
    amount = NULL,
    #  @field crypto_currency Field.
    crypto_currency = NULL,
    #  @field crypto_amount Field.
    crypto_amount = NULL,
    #  @field transaction_id Field.
    transaction_id = NULL,
    initialize = function(currency, amount, crypto_currency, crypto_amount, transaction_id = NULL) {
      self$currency <- currency
      self$amount <- amount
      self$crypto_currency <- crypto_currency
      self$crypto_amount <- crypto_amount
      self$transaction_id <- transaction_id
    },
    to_dict = function() {
      list(
        "_" = "MessageActionGiftTon",
        currency = self$currency, amount = self$amount,
        crypto_currency = self$crypto_currency, crypto_amount = self$crypto_amount,
        transaction_id = self$transaction_id
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      currency <- reader$tgread_string()
      amount <- reader$read_long()
      crypto_currency <- reader$tgread_string()
      crypto_amount <- reader$read_long()
      transaction_id <- if (bitwAnd(flags, 1) != 0) reader$tgread_string() else NULL
      list(currency = currency, amount = amount, crypto_currency = crypto_currency, crypto_amount = crypto_amount, transaction_id = transaction_id)
    }
  ),
  class = TRUE
)

#  @title MessageActionGiveawayLaunch
#  @description Telegram API type MessageActionGiveawayLaunch
#  @export
#  @noRd
#  @noRd
MessageActionGiveawayLaunch <- R6::R6Class(
  "MessageActionGiveawayLaunch",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa80f51e4,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field stars Field.
    stars = NULL,
    initialize = function(stars = NULL) {
      self$stars <- stars
    },
    to_dict = function() list("_" = "MessageActionGiveawayLaunch", stars = self$stars),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      stars <- if (bitwAnd(flags, 1) != 0) reader$read_long() else NULL
      list(stars = stars)
    }
  ),
  class = TRUE
)

#  @title MessageActionGiveawayResults
#  @description Telegram API type MessageActionGiveawayResults
#  @export
#  @noRd
#  @noRd
MessageActionGiveawayResults <- R6::R6Class(
  "MessageActionGiveawayResults",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x87e2f155,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field winners_count Field.
    winners_count = NULL,
    #  @field unclaimed_count Field.
    unclaimed_count = NULL,
    #  @field stars Field.
    stars = NULL,
    initialize = function(winners_count, unclaimed_count, stars = NULL) {
      self$winners_count <- winners_count
      self$unclaimed_count <- unclaimed_count
      self$stars <- stars
    },
    to_dict = function() list("_" = "MessageActionGiveawayResults", winners_count = self$winners_count, unclaimed_count = self$unclaimed_count, stars = self$stars),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      stars <- as.logical(bitwAnd(flags, 1))
      winners_count <- reader$read_int()
      unclaimed_count <- reader$read_int()
      list(winners_count = winners_count, unclaimed_count = unclaimed_count, stars = stars)
    }
  ),
  class = TRUE
)

#  @title MessageActionGroupCall
#  @description Telegram API type MessageActionGroupCall
#  @export
#  @noRd
#  @noRd
MessageActionGroupCall <- R6::R6Class(
  "MessageActionGroupCall",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7a0d7f42,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field call Field.
    call = NULL,
    #  @field duration Field.
    duration = NULL,
    initialize = function(call, duration = NULL) {
      self$call <- call
      self$duration <- duration
    },
    to_dict = function() list("_" = "MessageActionGroupCall", call = if (inherits(self$call, "TLObject")) self$call$to_dict() else self$call, duration = self$duration),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      remaining <- function() length(reader$get_bytes()) - reader$tell_position()
      if (remaining() < 4) {
        return(list(call = NULL, duration = NULL))
      }
      flags <- reader$read_int()
      call <- if (remaining() >= 4) {
        tryCatch(reader$tgread_object(), error = function(e) NULL)
      } else {
        NULL
      }
      duration <- if (bitwAnd(flags, 1) != 0 && remaining() >= 4) reader$read_int() else NULL
      list(call = call, duration = duration)
    }
  ),
  class = TRUE
)

#  @title MessageActionGroupCallScheduled
#  @description Telegram API type MessageActionGroupCallScheduled
#  @export
#  @noRd
#  @noRd
MessageActionGroupCallScheduled <- R6::R6Class(
  "MessageActionGroupCallScheduled",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb3a07661,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field call Field.
    call = NULL,
    #  @field schedule_date Field.
    schedule_date = NULL,
    initialize = function(call, schedule_date) {
      self$call <- call
      self$schedule_date <- schedule_date
    },
    to_dict = function() list("_" = "MessageActionGroupCallScheduled", call = if (inherits(self$call, "TLObject")) self$call$to_dict() else self$call, schedule_date = self$schedule_date),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list(call = reader$tgread_object(), schedule_date = reader$tgread_date())
  ),
  class = TRUE
)

#  @title MessageActionHistoryClear
#  @description Telegram API type MessageActionHistoryClear
#  @export
#  @noRd
#  @noRd
MessageActionHistoryClear <- R6::R6Class(
  "MessageActionHistoryClear",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9fbab604,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    initialize = function() {},
    to_dict = function() list("_" = "MessageActionHistoryClear"),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title MessageActionInviteToGroupCall
#  @description Telegram API type MessageActionInviteToGroupCall
#  @export
#  @noRd
#  @noRd
MessageActionInviteToGroupCall <- R6::R6Class(
  "MessageActionInviteToGroupCall",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x502f92f7,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field call Field.
    call = NULL,
    #  @field users Field.
    users = NULL,
    initialize = function(call, users) {
      self$call <- call
      self$users <- users
    },
    to_dict = function() list("_" = "MessageActionInviteToGroupCall", call = if (inherits(self$call, "TLObject")) self$call$to_dict() else self$call, users = if (is.null(self$users)) NULL else self$users),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      call <- reader$tgread_object()
      # vector marker then length
      reader$read_int()
      n <- reader$read_int()
      users <- integer(0)
      if (n > 0) {
        users <- integer(n)
        for (i in seq_len(n)) users[i] <- reader$read_long()
      }
      list(call = call, users = users)
    }
  ),
  class = TRUE
)

#  @title MessageActionPaidMessagesPrice
#  @description Telegram API type MessageActionPaidMessagesPrice
#  @export
#  @noRd
#  @noRd
MessageActionPaidMessagesPrice <- R6::R6Class(
  "MessageActionPaidMessagesPrice",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x84b88578,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field stars Field.
    stars = NULL,
    #  @field broadcast_messages_allowed Field.
    broadcast_messages_allowed = NULL,
    initialize = function(stars, broadcast_messages_allowed = NULL) {
      self$stars <- stars
      self$broadcast_messages_allowed <- broadcast_messages_allowed
    },
    to_dict = function() list("_" = "MessageActionPaidMessagesPrice", stars = self$stars, broadcast_messages_allowed = self$broadcast_messages_allowed),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      broadcast_messages_allowed <- as.logical(bitwAnd(flags, 1))
      stars <- reader$read_long()
      list(stars = stars, broadcast_messages_allowed = broadcast_messages_allowed)
    }
  ),
  class = TRUE
)

#  @title MessageActionPaidMessagesRefunded
#  @description Telegram API type MessageActionPaidMessagesRefunded
#  @export
#  @noRd
#  @noRd
MessageActionPaidMessagesRefunded <- R6::R6Class(
  "MessageActionPaidMessagesRefunded",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xac1f1fcd,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field count Field.
    count = NULL,
    #  @field stars Field.
    stars = NULL,
    initialize = function(count, stars) {
      self$count <- count
      self$stars <- stars
    },
    to_dict = function() list("_" = "MessageActionPaidMessagesRefunded", count = self$count, stars = self$stars),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list(count = reader$read_int(), stars = reader$read_long())
  ),
  class = TRUE
)

#  @title MessageActionPaymentRefunded
#  @description Telegram API type MessageActionPaymentRefunded
#  @export
#  @noRd
#  @noRd
MessageActionPaymentRefunded <- R6::R6Class(
  "MessageActionPaymentRefunded",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x41b3e202,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field peer Field.
    peer = NULL,
    #  @field currency Field.
    currency = NULL,
    #  @field total_amount Field.
    total_amount = NULL,
    #  @field charge Field.
    charge = NULL,
    #  @field payload Field.
    payload = NULL,
    initialize = function(peer, currency, total_amount, charge, payload = NULL) {
      self$peer <- peer
      self$currency <- currency
      self$total_amount <- total_amount
      self$charge <- charge
      self$payload <- payload
    },
    to_dict = function() {
      list(
        "_" = "MessageActionPaymentRefunded",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        currency = self$currency,
        total_amount = self$total_amount,
        charge = if (inherits(self$charge, "TLObject")) self$charge$to_dict() else self$charge,
        payload = self$payload
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      peer <- reader$tgread_object()
      currency <- reader$tgread_string()
      total_amount <- reader$read_long()
      payload <- if (bitwAnd(flags, 1) != 0) reader$tgreadbytes() else NULL
      charge <- reader$tgread_object()
      list(peer = peer, currency = currency, total_amount = total_amount, charge = charge, payload = payload)
    }
  ),
  class = TRUE
)

#  @title MessageActionPaymentSent
#  @description Telegram API type MessageActionPaymentSent
#  @export
#  @noRd
#  @noRd
MessageActionPaymentSent <- R6::R6Class(
  "MessageActionPaymentSent",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc624b16e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field currency Field.
    currency = NULL,
    #  @field total_amount Field.
    total_amount = NULL,
    #  @field recurring_init Field.
    recurring_init = NULL,
    #  @field recurring_used Field.
    recurring_used = NULL,
    #  @field invoice_slug Field.
    invoice_slug = NULL,
    #  @field subscription_until_date Field.
    subscription_until_date = NULL,
    initialize = function(currency, total_amount, recurring_init = NULL, recurring_used = NULL, invoice_slug = NULL, subscription_until_date = NULL) {
      self$currency <- currency
      self$total_amount <- total_amount
      self$recurring_init <- recurring_init
      self$recurring_used <- recurring_used
      self$invoice_slug <- invoice_slug
      self$subscription_until_date <- subscription_until_date
    },
    to_dict = function() {
      list(
        "_" = "MessageActionPaymentSent",
        currency = self$currency,
        total_amount = self$total_amount,
        recurring_init = self$recurring_init,
        recurring_used = self$recurring_used,
        invoice_slug = self$invoice_slug,
        subscription_until_date = self$subscription_until_date
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      recurring_init <- as.logical(bitwAnd(flags, 4))
      recurring_used <- as.logical(bitwAnd(flags, 8))
      currency <- reader$tgread_string()
      total_amount <- reader$read_long()
      invoice_slug <- if (bitwAnd(flags, 1) != 0) reader$tgread_string() else NULL
      subscription_until_date <- if (bitwAnd(flags, 16) != 0) reader$tgread_date() else NULL
      list(currency = currency, total_amount = total_amount, recurring_init = recurring_init, recurring_used = recurring_used, invoice_slug = invoice_slug, subscription_until_date = subscription_until_date)
    }
  ),
  class = TRUE
)

#  @title MessageActionPaymentSentMe
#  @description Telegram API type MessageActionPaymentSentMe
#  @export
#  @noRd
#  @noRd
MessageActionPaymentSentMe <- R6::R6Class(
  "MessageActionPaymentSentMe",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xffa00ccc,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field currency Field.
    currency = NULL,
    #  @field total_amount Field.
    total_amount = NULL,
    #  @field payload Field.
    payload = NULL,
    #  @field charge Field.
    charge = NULL,
    #  @field recurring_init Field.
    recurring_init = NULL,
    #  @field recurring_used Field.
    recurring_used = NULL,
    #  @field info Field.
    info = NULL,
    #  @field shipping_option_id Field.
    shipping_option_id = NULL,
    #  @field subscription_until_date Field.
    subscription_until_date = NULL,
    initialize = function(currency, total_amount, payload, charge, recurring_init = NULL, recurring_used = NULL, info = NULL, shipping_option_id = NULL, subscription_until_date = NULL) {
      self$currency <- currency
      self$total_amount <- total_amount
      self$payload <- payload
      self$charge <- charge
      self$recurring_init <- recurring_init
      self$recurring_used <- recurring_used
      self$info <- info
      self$shipping_option_id <- shipping_option_id
      self$subscription_until_date <- subscription_until_date
    },
    to_dict = function() {
      list(
        "_" = "MessageActionPaymentSentMe",
        currency = self$currency, total_amount = self$total_amount, payload = self$payload,
        charge = if (inherits(self$charge, "TLObject")) self$charge$to_dict() else self$charge,
        recurring_init = self$recurring_init, recurring_used = self$recurring_used,
        info = if (inherits(self$info, "TLObject")) self$info$to_dict() else self$info,
        shipping_option_id = self$shipping_option_id, subscription_until_date = self$subscription_until_date
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      recurring_init <- as.logical(bitwAnd(flags, 4))
      recurring_used <- as.logical(bitwAnd(flags, 8))
      currency <- reader$tgread_string()
      total_amount <- reader$read_long()
      payload <- reader$tgreadbytes()
      info <- if (bitwAnd(flags, 1) != 0) reader$tgread_object() else NULL
      shipping_option_id <- if (bitwAnd(flags, 2) != 0) reader$tgread_string() else NULL
      charge <- reader$tgread_object()
      subscription_until_date <- if (bitwAnd(flags, 16) != 0) reader$tgread_date() else NULL
      list(currency = currency, total_amount = total_amount, payload = payload, charge = charge, recurring_init = recurring_init, recurring_used = recurring_used, info = info, shipping_option_id = shipping_option_id, subscription_until_date = subscription_until_date)
    }
  ),
  class = TRUE
)

#  @title MessageActionPhoneCall
#  @description Telegram API type MessageActionPhoneCall
#  @export
#  @noRd
#  @noRd
MessageActionPhoneCall <- R6::R6Class(
  "MessageActionPhoneCall",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x80e11a7f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field call_id Field.
    call_id = NULL,
    #  @field video Field.
    video = NULL,
    #  @field reason Field.
    reason = NULL,
    #  @field duration Field.
    duration = NULL,
    initialize = function(call_id, video = NULL, reason = NULL, duration = NULL) {
      self$call_id <- call_id
      self$video <- video
      self$reason <- reason
      self$duration <- duration
    },
    to_dict = function() {
      list(
        "_" = "MessageActionPhoneCall",
        call_id = self$call_id,
        video = self$video,
        reason = if (inherits(self$reason, "TLObject")) self$reason$to_dict() else self$reason,
        duration = self$duration
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      video <- as.logical(bitwAnd(flags, 4))
      call_id <- reader$read_long()
      reason <- if (bitwAnd(flags, 1) != 0) reader$tgread_object() else NULL
      duration <- if (bitwAnd(flags, 2) != 0) reader$read_int() else NULL
      list(call_id = call_id, video = video, reason = reason, duration = duration)
    }
  ),
  class = TRUE
)

#  @title MessageActionPinMessage
#  @description Telegram API type MessageActionPinMessage
#  @export
#  @noRd
#  @noRd
MessageActionPinMessage <- R6::R6Class(
  "MessageActionPinMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x94bd38ed,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    initialize = function() {},
    to_dict = function() list("_" = "MessageActionPinMessage"),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title MessageActionPrizeStars
#  @description Telegram API type MessageActionPrizeStars
#  @export
#  @noRd
#  @noRd
MessageActionPrizeStars <- R6::R6Class(
  "MessageActionPrizeStars",
  inherit = TLObject,
  public = list(
    #  @field stars Field.
    stars = NULL,
    #  @field transaction_id Field.
    transaction_id = NULL,
    #  @field boostpeer Field.
    boostpeer = NULL,
    #  @field giveaway_msg_id Field.
    giveaway_msg_id = NULL,
    #  @field unclaimed Field.
    unclaimed = NULL,
    initialize = function(stars, transaction_id, boostpeer, giveaway_msg_id, unclaimed = NULL) {
      self$stars <- stars
      self$transaction_id <- transaction_id
      self$boostpeer <- boostpeer
      self$giveaway_msg_id <- giveaway_msg_id
      self$unclaimed <- unclaimed
    },
    to_dict = function() {
      list(
        `_` = "MessageActionPrizeStars",
        stars = self$stars,
        transaction_id = self$transaction_id,
        boostpeer = if (inherits(self$boostpeer, "TLObject")) self$boostpeer$to_dict() else self$boostpeer,
        giveaway_msg_id = self$giveaway_msg_id,
        unclaimed = self$unclaimed
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title MessageActionRequestedPeer
#  @description Telegram API type MessageActionRequestedPeer
#  @export
#  @noRd
#  @noRd
MessageActionRequestedPeer <- R6::R6Class(
  "MessageActionRequestedPeer",
  inherit = TLObject,
  public = list(
    #  @field button_id Field.
    button_id = NULL,
    #  @field peers Field.
    peers = NULL,
    initialize = function(button_id, peers) {
      self$button_id <- button_id
      self$peers <- peers
    },
    to_dict = function() {
      list(
        `_` = "MessageActionRequestedPeer",
        button_id = self$button_id,
        peers = if (is.null(self$peers)) list() else lapply(self$peers, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title MessageActionRequestedPeerSentMe
#  @description Telegram API type MessageActionRequestedPeerSentMe
#  @export
#  @noRd
#  @noRd
MessageActionRequestedPeerSentMe <- R6::R6Class(
  "MessageActionRequestedPeerSentMe",
  inherit = TLObject,
  public = list(
    #  @field button_id Field.
    button_id = NULL,
    #  @field peers Field.
    peers = NULL,
    initialize = function(button_id, peers) {
      self$button_id <- button_id
      self$peers <- peers
    },
    to_dict = function() {
      list(
        `_` = "MessageActionRequestedPeerSentMe",
        button_id = self$button_id,
        peers = if (is.null(self$peers)) list() else lapply(self$peers, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title MessageActionScreenshotTaken
#  @description Telegram API type MessageActionScreenshotTaken
#  @export
#  @noRd
#  @noRd
MessageActionScreenshotTaken <- R6::R6Class(
  "MessageActionScreenshotTaken",
  inherit = TLObject,
  public = list(
    initialize = function() {},
    to_dict = function() list(`_` = "MessageActionScreenshotTaken"),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title MessageActionSecureValuesSent
#  @description Telegram API type MessageActionSecureValuesSent
#  @export
#  @noRd
#  @noRd
MessageActionSecureValuesSent <- R6::R6Class(
  "MessageActionSecureValuesSent",
  inherit = TLObject,
  public = list(
    #  @field types Field.
    types = NULL,
    initialize = function(types) {
      self$types <- types
    },
    to_dict = function() {
      list(
        `_` = "MessageActionSecureValuesSent",
        types = if (is.null(self$types)) list() else lapply(self$types, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title MessageActionSecureValuesSentMe
#  @description Telegram API type MessageActionSecureValuesSentMe
#  @export
#  @noRd
#  @noRd
MessageActionSecureValuesSentMe <- R6::R6Class(
  "MessageActionSecureValuesSentMe",
  inherit = TLObject,
  public = list(
    #  @field values Field.
    values = NULL,
    #  @field credentials Field.
    credentials = NULL,
    initialize = function(values, credentials) {
      self$values <- values
      self$credentials <- credentials
    },
    to_dict = function() {
      list(
        `_` = "MessageActionSecureValuesSentMe",
        values = if (is.null(self$values)) list() else lapply(self$values, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        credentials = if (inherits(self$credentials, "TLObject")) self$credentials$to_dict() else self$credentials
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title MessageActionSetChatTheme
#  @description Telegram API type MessageActionSetChatTheme
#  @export
#  @noRd
#  @noRd
MessageActionSetChatTheme <- R6::R6Class(
  "MessageActionSetChatTheme",
  inherit = TLObject,
  public = list(
    #  @field theme Field.
    theme = NULL,
    initialize = function(theme) {
      self$theme <- theme
    },
    to_dict = function() {
      list(
        `_` = "MessageActionSetChatTheme",
        theme = if (inherits(self$theme, "TLObject")) self$theme$to_dict() else self$theme
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title MessageActionSetChatWallPaper
#  @description Telegram API type MessageActionSetChatWallPaper
#  @export
#  @noRd
#  @noRd
MessageActionSetChatWallPaper <- R6::R6Class(
  "MessageActionSetChatWallPaper",
  inherit = TLObject,
  public = list(
    #  @field wallpaper Field.
    wallpaper = NULL,
    #  @field same Field.
    same = NULL,
    #  @field for_both Field.
    for_both = NULL,
    initialize = function(wallpaper, same = NULL, for_both = NULL) {
      self$wallpaper <- wallpaper
      self$same <- same
      self$for_both <- for_both
    },
    to_dict = function() {
      list(
        `_` = "MessageActionSetChatWallPaper",
        wallpaper = if (inherits(self$wallpaper, "TLObject")) self$wallpaper$to_dict() else self$wallpaper,
        same = self$same,
        for_both = self$for_both
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title MessageActionSetMessagesTTL
#  @description Telegram API type MessageActionSetMessagesTTL
#  @export
#  @noRd
#  @noRd
MessageActionSetMessagesTTL <- R6::R6Class(
  "MessageActionSetMessagesTTL",
  inherit = TLObject,
  public = list(
    #  @field period Field.
    period = NULL,
    #  @field auto_setting_from Field.
    auto_setting_from = NULL,
    initialize = function(period, auto_setting_from = NULL) {
      self$period <- period
      self$auto_setting_from <- auto_setting_from
    },
    to_dict = function() {
      list(
        `_` = "MessageActionSetMessagesTTL",
        period = self$period,
        auto_setting_from = self$auto_setting_from
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title MessageActionStarGift
#  @description Telegram API type MessageActionStarGift
#  @export
#  @noRd
#  @noRd
MessageActionStarGift <- R6::R6Class(
  "MessageActionStarGift",
  inherit = TLObject,
  public = list(
    #  @field gift Field.
    gift = NULL,
    #  @field name_hidden Field.
    name_hidden = NULL,
    #  @field saved Field.
    saved = NULL,
    #  @field converted Field.
    converted = NULL,
    #  @field upgraded Field.
    upgraded = NULL,
    #  @field refunded Field.
    refunded = NULL,
    #  @field can_upgrade Field.
    can_upgrade = NULL,
    #  @field prepaid_upgrade Field.
    prepaid_upgrade = NULL,
    #  @field upgrade_separate Field.
    upgrade_separate = NULL,
    #  @field message Field.
    message = NULL,
    #  @field convert_stars Field.
    convert_stars = NULL,
    #  @field upgrade_msg_id Field.
    upgrade_msg_id = NULL,
    #  @field upgrade_stars Field.
    upgrade_stars = NULL,
    #  @field from_id Field.
    from_id = NULL,
    #  @field peer Field.
    peer = NULL,
    #  @field saved_id Field.
    saved_id = NULL,
    #  @field prepaid_upgrade_hash Field.
    prepaid_upgrade_hash = NULL,
    #  @field gift_msg_id Field.
    gift_msg_id = NULL,
    initialize = function(gift, name_hidden = NULL, saved = NULL, converted = NULL, upgraded = NULL, refunded = NULL, can_upgrade = NULL, prepaid_upgrade = NULL, upgrade_separate = NULL, message = NULL, convert_stars = NULL, upgrade_msg_id = NULL, upgrade_stars = NULL, from_id = NULL, peer = NULL, saved_id = NULL, prepaid_upgrade_hash = NULL, gift_msg_id = NULL) {
      self$gift <- gift
      self$name_hidden <- name_hidden
      self$saved <- saved
      self$converted <- converted
      self$upgraded <- upgraded
      self$refunded <- refunded
      self$can_upgrade <- can_upgrade
      self$prepaid_upgrade <- prepaid_upgrade
      self$upgrade_separate <- upgrade_separate
      self$message <- message
      self$convert_stars <- convert_stars
      self$upgrade_msg_id <- upgrade_msg_id
      self$upgrade_stars <- upgrade_stars
      self$from_id <- from_id
      self$peer <- peer
      self$saved_id <- saved_id
      self$prepaid_upgrade_hash <- prepaid_upgrade_hash
      self$gift_msg_id <- gift_msg_id
    },
    to_dict = function() {
      list(
        `_` = "MessageActionStarGift",
        gift = if (inherits(self$gift, "TLObject")) self$gift$to_dict() else self$gift,
        name_hidden = self$name_hidden,
        saved = self$saved,
        converted = self$converted,
        upgraded = self$upgraded,
        refunded = self$refunded,
        can_upgrade = self$can_upgrade,
        prepaid_upgrade = self$prepaid_upgrade,
        upgrade_separate = self$upgrade_separate,
        message = if (inherits(self$message, "TLObject")) self$message$to_dict() else self$message,
        convert_stars = self$convert_stars,
        upgrade_msg_id = self$upgrade_msg_id,
        upgrade_stars = self$upgrade_stars,
        from_id = if (inherits(self$from_id, "TLObject")) self$from_id$to_dict() else self$from_id,
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        saved_id = self$saved_id,
        prepaid_upgrade_hash = self$prepaid_upgrade_hash,
        gift_msg_id = self$gift_msg_id
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title MessageActionStarGiftUnique
#  @description Telegram API type MessageActionStarGiftUnique
#  @export
#  @noRd
#  @noRd
MessageActionStarGiftUnique <- R6::R6Class(
  "MessageActionStarGiftUnique",
  inherit = TLObject,
  public = list(
    #  @field gift Field.
    gift = NULL,
    #  @field upgrade Field.
    upgrade = NULL,
    #  @field transferred Field.
    transferred = NULL,
    #  @field saved Field.
    saved = NULL,
    #  @field refunded Field.
    refunded = NULL,
    #  @field prepaid_upgrade Field.
    prepaid_upgrade = NULL,
    #  @field can_export_at Field.
    can_export_at = NULL,
    #  @field transfer_stars Field.
    transfer_stars = NULL,
    #  @field from_id Field.
    from_id = NULL,
    #  @field peer Field.
    peer = NULL,
    #  @field saved_id Field.
    saved_id = NULL,
    #  @field resale_amount Field.
    resale_amount = NULL,
    #  @field can_transfer_at Field.
    can_transfer_at = NULL,
    #  @field can_resell_at Field.
    can_resell_at = NULL,
    initialize = function(gift, upgrade = NULL, transferred = NULL, saved = NULL, refunded = NULL, prepaid_upgrade = NULL, can_export_at = NULL, transfer_stars = NULL, from_id = NULL, peer = NULL, saved_id = NULL, resale_amount = NULL, can_transfer_at = NULL, can_resell_at = NULL) {
      self$gift <- gift
      self$upgrade <- upgrade
      self$transferred <- transferred
      self$saved <- saved
      self$refunded <- refunded
      self$prepaid_upgrade <- prepaid_upgrade
      self$can_export_at <- can_export_at
      self$transfer_stars <- transfer_stars
      self$from_id <- from_id
      self$peer <- peer
      self$saved_id <- saved_id
      self$resale_amount <- resale_amount
      self$can_transfer_at <- can_transfer_at
      self$can_resell_at <- can_resell_at
    },
    to_dict = function() {
      list(
        `_` = "MessageActionStarGiftUnique",
        gift = if (inherits(self$gift, "TLObject")) self$gift$to_dict() else self$gift,
        upgrade = self$upgrade,
        transferred = self$transferred,
        saved = self$saved,
        refunded = self$refunded,
        prepaid_upgrade = self$prepaid_upgrade,
        can_export_at = self$can_export_at,
        transfer_stars = self$transfer_stars,
        from_id = if (inherits(self$from_id, "TLObject")) self$from_id$to_dict() else self$from_id,
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        saved_id = self$saved_id,
        resale_amount = if (inherits(self$resale_amount, "TLObject")) self$resale_amount$to_dict() else self$resale_amount,
        can_transfer_at = self$can_transfer_at,
        can_resell_at = self$can_resell_at
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title MessageActionSuggestProfilePhoto
#  @description Telegram API type MessageActionSuggestProfilePhoto
#  @export
#  @noRd
#  @noRd
MessageActionSuggestProfilePhoto <- R6::R6Class(
  "MessageActionSuggestProfilePhoto",
  inherit = TLObject,
  public = list(
    #  @field photo Field.
    photo = NULL,
    initialize = function(photo) {
      self$photo <- photo
    },
    to_dict = function() {
      list(
        `_` = "MessageActionSuggestProfilePhoto",
        photo = if (inherits(self$photo, "TLObject")) self$photo$to_dict() else self$photo
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title MessageActionSuggestedPostApproval
#  @description Telegram API type MessageActionSuggestedPostApproval
#  @export
#  @noRd
#  @noRd
MessageActionSuggestedPostApproval <- R6::R6Class(
  "MessageActionSuggestedPostApproval",
  inherit = TLObject,
  public = list(
    #  @field rejected Field.
    rejected = NULL,
    #  @field balance_too_low Field.
    balance_too_low = NULL,
    #  @field reject_comment Field.
    reject_comment = NULL,
    #  @field schedule_date Field.
    schedule_date = NULL,
    #  @field price Field.
    price = NULL,
    initialize = function(rejected = NULL, balance_too_low = NULL, reject_comment = NULL, schedule_date = NULL, price = NULL) {
      self$rejected <- rejected
      self$balance_too_low <- balance_too_low
      self$reject_comment <- reject_comment
      self$schedule_date <- schedule_date
      self$price <- price
    },
    to_dict = function() {
      list(
        `_` = "MessageActionSuggestedPostApproval",
        rejected = self$rejected,
        balance_too_low = self$balance_too_low,
        reject_comment = self$reject_comment,
        schedule_date = self$schedule_date,
        price = if (inherits(self$price, "TLObject")) self$price$to_dict() else self$price
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title MessageActionSuggestedPostRefund
#  @description Telegram API type MessageActionSuggestedPostRefund
#  @export
#  @noRd
#  @noRd
MessageActionSuggestedPostRefund <- R6::R6Class(
  "MessageActionSuggestedPostRefund",
  inherit = TLObject,
  public = list(
    #  @field payer_initiated Field.
    payer_initiated = NULL,
    initialize = function(payer_initiated = NULL) {
      self$payer_initiated <- payer_initiated
    },
    to_dict = function() list(`_` = "MessageActionSuggestedPostRefund", payer_initiated = self$payer_initiated),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title MessageActionSuggestedPostSuccess
#  @description Telegram API type MessageActionSuggestedPostSuccess
#  @export
#  @noRd
#  @noRd
MessageActionSuggestedPostSuccess <- R6::R6Class(
  "MessageActionSuggestedPostSuccess",
  inherit = TLObject,
  public = list(
    #  @field price Field.
    price = NULL,
    initialize = function(price) {
      self$price <- price
    },
    to_dict = function() list(`_` = "MessageActionSuggestedPostSuccess", price = if (inherits(self$price, "TLObject")) self$price$to_dict() else self$price),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title MessageActionTodoAppendTasks
#  @description Telegram API type MessageActionTodoAppendTasks
#  @export
#  @noRd
#  @noRd
MessageActionTodoAppendTasks <- R6::R6Class(
  "MessageActionTodoAppendTasks",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc7edbc83,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field list Field.
    list = NULL,
    initialize = function(list) {
      self$list <- list
    },
    to_dict = function() {
      list(
        `_` = "MessageActionTodoAppendTasks",
        list = if (is.null(self$list)) list() else lapply(self$list, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      phone_number <- reader$tgread_string()
      first_name <- reader$tgread_string()
      last_name <- reader$tgread_string()
      vcard <- reader$tgread_string()
      user_id <- reader$read_long()
      list(
        phone_number = phone_number,
        first_name = first_name,
        last_name = last_name,
        vcard = vcard,
        user_id = user_id
      )
    }
  ),
  class = TRUE
)

#  @title MessageActionTodoCompletions
#  @description Telegram API type MessageActionTodoCompletions
#  @export
#  @noRd
#  @noRd
MessageActionTodoCompletions <- R6::R6Class(
  "MessageActionTodoCompletions",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xcc7c5c89,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field completed Field.
    completed = NULL,
    #  @field incompleted Field.
    incompleted = NULL,
    initialize = function(completed, incompleted) {
      self$completed <- completed
      self$incompleted <- incompleted
    },
    to_dict = function() {
      list(
        `_` = "MessageActionTodoCompletions",
        completed = if (is.null(self$completed)) integer(0) else as.integer(self$completed),
        incompleted = if (is.null(self$incompleted)) integer(0) else as.integer(self$incompleted)
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      imported <- bitwAnd(flags, 128) != 0
      saved_out <- bitwAnd(flags, 2048) != 0
      from_id <- if (bitwAnd(flags, 1) != 0) reader$tgread_object() else NULL
      from_name <- if (bitwAnd(flags, 32) != 0) reader$tgread_string() else NULL
      date <- reader$tgread_date()
      channel_post <- if (bitwAnd(flags, 4) != 0) reader$read_int() else NULL
      post_author <- if (bitwAnd(flags, 8) != 0) reader$tgread_string() else NULL
      saved_frompeer <- if (bitwAnd(flags, 16) != 0) reader$tgread_object() else NULL
      saved_from_msg_id <- if (bitwAnd(flags, 16) != 0) reader$read_int() else NULL
      saved_from_id <- if (bitwAnd(flags, 256) != 0) reader$tgread_object() else NULL
      saved_from_name <- if (bitwAnd(flags, 512) != 0) reader$tgread_string() else NULL
      saved_date <- if (bitwAnd(flags, 1024) != 0) reader$tgread_date() else NULL
      psa_type <- if (bitwAnd(flags, 64) != 0) reader$tgread_string() else NULL
      list(
        date = date,
        imported = imported,
        saved_out = saved_out,
        from_id = from_id,
        from_name = from_name,
        channel_post = channel_post,
        post_author = post_author,
        saved_frompeer = saved_frompeer,
        saved_from_msg_id = saved_from_msg_id,
        saved_from_id = saved_from_id,
        saved_from_name = saved_from_name,
        saved_date = saved_date,
        psa_type = psa_type
      )
    }
  ),
  class = TRUE
)

#  @title MessageActionTopicCreate
#  @description Telegram API type MessageActionTopicCreate
#  @export
#  @noRd
#  @noRd
MessageActionTopicCreate <- R6::R6Class(
  "MessageActionTopicCreate",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x0d999256,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field title Field.
    title = NULL,
    #  @field icon_color Field.
    icon_color = NULL,
    #  @field icon_emoji_id Field.
    icon_emoji_id = NULL,
    initialize = function(title, icon_color, icon_emoji_id = NULL) {
      self$title <- title
      self$icon_color <- icon_color
      self$icon_emoji_id <- icon_emoji_id
    },
    to_dict = function() {
      list(
        `_` = "MessageActionTopicCreate",
        title = self$title, icon_color = self$icon_color, icon_emoji_id = self$icon_emoji_id
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      nopremium <- bitwAnd(flags, 8) != 0
      spoiler <- bitwAnd(flags, 16) != 0
      video <- bitwAnd(flags, 64) != 0
      round <- bitwAnd(flags, 128) != 0
      voice <- bitwAnd(flags, 256) != 0
      document <- if (bitwAnd(flags, 1) != 0) reader$tgread_object() else NULL
      alt_documents <- if (bitwAnd(flags, 32) != 0) {
        reader$read_int()
        lapply(seq_len(reader$read_int()), function(x) reader$tgread_object())
      } else {
        NULL
      }
      video_cover <- if (bitwAnd(flags, 512) != 0) reader$tgread_object() else NULL
      video_timestamp <- if (bitwAnd(flags, 1024) != 0) reader$read_int() else NULL
      ttl_seconds <- if (bitwAnd(flags, 4) != 0) reader$read_int() else NULL
      list(
        nopremium = nopremium,
        spoiler = spoiler,
        video = video,
        round = round,
        voice = voice,
        document = document,
        alt_documents = alt_documents,
        video_cover = video_cover,
        video_timestamp = video_timestamp,
        ttl_seconds = ttl_seconds
      )
    }
  ),
  class = TRUE
)

#  @title MessageActionTopicEdit
#  @description Telegram API type MessageActionTopicEdit
#  @export
#  @noRd
#  @noRd
MessageActionTopicEdit <- R6::R6Class(
  "MessageActionTopicEdit",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc0944820,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field title Field.
    title = NULL,
    #  @field icon_emoji_id Field.
    icon_emoji_id = NULL,
    #  @field closed Field.
    closed = NULL,
    #  @field hidden Field.
    hidden = NULL,
    initialize = function(title = NULL, icon_emoji_id = NULL, closed = NULL, hidden = NULL) {
      self$title <- title
      self$icon_emoji_id <- icon_emoji_id
      self$closed <- closed
      self$hidden <- hidden
    },
    to_dict = function() {
      list(
        `_` = "MessageActionTopicEdit",
        title = self$title, icon_emoji_id = self$icon_emoji_id, closed = self$closed, hidden = self$hidden
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()

      out <- bitwAnd(flags, 2) != 0
      mentioned <- bitwAnd(flags, 16) != 0
      media_unread <- bitwAnd(flags, 32) != 0
      reactions_are_possible <- bitwAnd(flags, 512) != 0
      silent <- bitwAnd(flags, 8192) != 0
      post <- bitwAnd(flags, 16384) != 0
      legacy <- bitwAnd(flags, 524288) != 0

      id <- reader$read_int()
      from_id <- if (bitwAnd(flags, 256) != 0) reader$tgread_object() else NULL
      peer_id <- reader$tgread_object()
      savedpeer_id <- if (bitwAnd(flags, 268435456) != 0) reader$tgread_object() else NULL
      reply_to <- if (bitwAnd(flags, 8) != 0) reader$tgread_object() else NULL
      date <- reader$tgread_date()
      action <- reader$tgread_object()
      reactions <- if (bitwAnd(flags, 1048576) != 0) reader$tgread_object() else NULL
      ttl_period <- if (bitwAnd(flags, 33554432) != 0) reader$read_int() else NULL

      list(
        id = id,
        peer_id = peer_id,
        date = date,
        action = action,
        out = out,
        mentioned = mentioned,
        media_unread = media_unread,
        reactions_are_possible = reactions_are_possible,
        silent = silent,
        post = post,
        legacy = legacy,
        from_id = from_id,
        savedpeer_id = savedpeer_id,
        reply_to = reply_to,
        reactions = reactions,
        ttl_period = ttl_period
      )
    }
  ),
  class = TRUE
)

#  @title MessageActionWebViewDataSent
#  @description Telegram API type MessageActionWebViewDataSent
#  @export
#  @noRd
#  @noRd
MessageActionWebViewDataSent <- R6::R6Class(
  "MessageActionWebViewDataSent",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb4c38cb5,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field text Field.
    text = NULL,
    initialize = function(text) {
      self$text <- text
    },
    to_dict = function() list(`_` = "MessageActionWebViewDataSent", text = self$text),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      shipping_address_requested <- bitwAnd(flags, 2) != 0
      test <- bitwAnd(flags, 8) != 0
      title <- reader$tgread_string()
      description <- reader$tgread_string()
      photo <- if (bitwAnd(flags, 1) != 0) reader$tgread_object() else NULL
      receipt_msg_id <- if (bitwAnd(flags, 4) != 0) reader$read_int() else NULL
      currency <- reader$tgread_string()
      total_amount <- reader$read_long()
      start_param <- reader$tgread_string()
      extended_media <- if (bitwAnd(flags, 16) != 0) reader$tgread_object() else NULL
      list(
        title = title,
        description = description,
        currency = currency,
        total_amount = total_amount,
        start_param = start_param,
        shipping_address_requested = shipping_address_requested,
        test = test,
        photo = photo,
        receipt_msg_id = receipt_msg_id,
        extended_media = extended_media
      )
    }
  ),
  class = TRUE
)

#  @title MessageActionWebViewDataSentMe
#  @description Telegram API type MessageActionWebViewDataSentMe
#  @export
#  @noRd
#  @noRd
MessageActionWebViewDataSentMe <- R6::R6Class(
  "MessageActionWebViewDataSentMe",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x47dd8079,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8680d126,
    #  @field text Field.
    text = NULL,
    #  @field data Field.
    data = NULL,
    initialize = function(text, data) {
      self$text <- text
      self$data <- data
    },
    to_dict = function() list(`_` = "MessageActionWebViewDataSentMe", text = self$text, data = self$data),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      nopremium <- bitwAnd(flags, 8) != 0
      spoiler <- bitwAnd(flags, 16) != 0
      video <- bitwAnd(flags, 64) != 0
      round <- bitwAnd(flags, 128) != 0
      voice <- bitwAnd(flags, 256) != 0
      document <- if (bitwAnd(flags, 1) != 0) reader$tgread_object() else NULL
      alt_documents <- if (bitwAnd(flags, 32) != 0) {
        reader$read_int()
        lapply(seq_len(reader$read_int()), function(x) reader$tgread_object())
      } else {
        NULL
      }
      video_cover <- if (bitwAnd(flags, 512) != 0) reader$tgread_object() else NULL
      video_timestamp <- if (bitwAnd(flags, 1024) != 0) reader$read_int() else NULL
      ttl_seconds <- if (bitwAnd(flags, 4) != 0) reader$read_int() else NULL
      list(
        nopremium = nopremium,
        spoiler = spoiler,
        video = video,
        round = round,
        voice = voice,
        document = document,
        alt_documents = alt_documents,
        video_cover = video_cover,
        video_timestamp = video_timestamp,
        ttl_seconds = ttl_seconds
      )
    }
  ),
  class = TRUE
)

#  @title MessageEmpty
#  @description Telegram API type MessageEmpty
#  @export
#  @noRd
#  @noRd
MessageEmpty <- R6::R6Class(
  "MessageEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x90a6ca84,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x790009e3,
    #  @field id Field.
    id = NULL,
    #  @field peer_id Field.
    peer_id = NULL,
    initialize = function(id, peer_id = NULL) {
      self$id <- id
      self$peer_id <- peer_id
    },
    to_dict = function() list(`_` = "MessageEmpty", id = self$id, peer_id = if (inherits(self$peer_id, "TLObject")) self$peer_id$to_dict() else self$peer_id),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      phone_number <- reader$tgread_string()
      first_name <- reader$tgread_string()
      last_name <- reader$tgread_string()
      vcard <- reader$tgread_string()
      user_id <- reader$read_long()
      list(
        phone_number = phone_number,
        first_name = first_name,
        last_name = last_name,
        vcard = vcard,
        user_id = user_id
      )
    }
  ),
  class = TRUE
)

#  @title MessageEntityBankCard
#  @description Telegram API type MessageEntityBankCard
#  @export
#  @noRd
#  @noRd
MessageEntityBankCard <- R6::R6Class(
  "MessageEntityBankCard",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x761e6af4,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xcf6419dc,
    #  @field offset Field.
    offset = NULL,
    #  @field length Field.
    length = NULL,
    initialize = function(offset, length) {
      self$offset <- offset
      self$length <- length
    },
    to_dict = function() list(`_` = "MessageEntityBankCard", offset = self$offset, length = self$length),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    offset <- reader$read_int()
    length <- reader$read_int()
    list(offset = offset, length = length)
  }),
  class = TRUE
)

#  @title MessageEntityBlockquote
#  @description Telegram API type MessageEntityBlockquote
#  @export
#  @noRd
#  @noRd
MessageEntityBlockquote <- R6::R6Class(
  "MessageEntityBlockquote",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf1ccaaac,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xcf6419dc,
    offset = NULL, length = NULL, collapsed = NULL,
    initialize = function(offset, length, collapsed = NULL) {
      self$offset <- offset
      self$length <- length
      self$collapsed <- collapsed
    },
    to_dict = function() list(`_` = "MessageEntityBlockquote", offset = self$offset, length = self$length, collapsed = self$collapsed),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    flags <- reader$read_int()
    collapsed <- bitwAnd(flags, 1) != 0
    offset <- reader$read_int()
    length <- reader$read_int()
    list(offset = offset, length = length, collapsed = collapsed)
  }),
  class = TRUE
)

#  @title MessageEntityBold
#  @description Telegram API type MessageEntityBold
#  @export
#  @noRd
#  @noRd
MessageEntityBold <- R6::R6Class(
  "MessageEntityBold",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbd610bc9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xcf6419dc,
    offset = NULL, length = NULL,
    initialize = function(offset, length) {
      self$offset <- offset
      self$length <- length
    },
    to_dict = function() list(`_` = "MessageEntityBold", offset = self$offset, length = self$length),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    offset <- reader$read_int()
    length <- reader$read_int()
    list(offset = offset, length = length)
  }),
  class = TRUE
)

#  @title MessageEntityBotCommand
#  @description Telegram API type MessageEntityBotCommand
#  @export
#  @noRd
#  @noRd
MessageEntityBotCommand <- R6::R6Class(
  "MessageEntityBotCommand",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x6cef8ac7,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xcf6419dc,
    offset = NULL, length = NULL,
    initialize = function(offset, length) {
      self$offset <- offset
      self$length <- length
    },
    to_dict = function() list(`_` = "MessageEntityBotCommand", offset = self$offset, length = self$length),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    offset <- reader$read_int()
    length <- reader$read_int()
    list(offset = offset, length = length)
  }),
  class = TRUE
)

#  @title MessageEntityCashtag
#  @description Telegram API type MessageEntityCashtag
#  @export
#  @noRd
#  @noRd
MessageEntityCashtag <- R6::R6Class(
  "MessageEntityCashtag",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4c4e743f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xcf6419dc,
    offset = NULL, length = NULL,
    initialize = function(offset, length) {
      self$offset <- offset
      self$length <- length
    },
    to_dict = function() list(`_` = "MessageEntityCashtag", offset = self$offset, length = self$length),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    offset <- reader$read_int()
    length <- reader$read_int()
    list(offset = offset, length = length)
  }),
  class = TRUE
)

#  @title MessageEntityCode
#  @description Telegram API type MessageEntityCode
#  @export
#  @noRd
#  @noRd
MessageEntityCode <- R6::R6Class(
  "MessageEntityCode",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x28a20571,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xcf6419dc,
    offset = NULL, length = NULL,
    initialize = function(offset, length) {
      self$offset <- offset
      self$length <- length
    },
    to_dict = function() list(`_` = "MessageEntityCode", offset = self$offset, length = self$length),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    offset <- reader$read_int()
    length <- reader$read_int()
    list(offset = offset, length = length)
  }),
  class = TRUE
)

#  @title MessageEntityCustomEmoji
#  @description Telegram API type MessageEntityCustomEmoji
#  @export
#  @noRd
#  @noRd
MessageEntityCustomEmoji <- R6::R6Class(
  "MessageEntityCustomEmoji",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc8cf05f8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xcf6419dc,
    offset = NULL, length = NULL, document_id = NULL,
    initialize = function(offset, length, document_id) {
      self$offset <- offset
      self$length <- length
      self$document_id <- document_id
    },
    to_dict = function() list(`_` = "MessageEntityCustomEmoji", offset = self$offset, length = self$length, document_id = self$document_id),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    offset <- reader$read_int()
    length <- reader$read_int()
    document_id <- reader$read_long()
    list(offset = offset, length = length, document_id = document_id)
  }),
  class = TRUE
)

#  @title MessageEntityEmail
#  @description Telegram API type MessageEntityEmail
#  @export
#  @noRd
#  @noRd
MessageEntityEmail <- R6::R6Class(
  "MessageEntityEmail",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x64e475c2,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xcf6419dc,
    offset = NULL, length = NULL,
    initialize = function(offset, length) {
      self$offset <- offset
      self$length <- length
    },
    to_dict = function() list(`_` = "MessageEntityEmail", offset = self$offset, length = self$length),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    offset <- reader$read_int()
    length <- reader$read_int()
    list(offset = offset, length = length)
  }),
  class = TRUE
)

#  @title MessageEntityHashtag
#  @description Telegram API type MessageEntityHashtag
#  @export
#  @noRd
#  @noRd
MessageEntityHashtag <- R6::R6Class(
  "MessageEntityHashtag",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x6f635b0d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xcf6419dc,
    offset = NULL, length = NULL,
    initialize = function(offset, length) {
      self$offset <- offset
      self$length <- length
    },
    to_dict = function() list(`_` = "MessageEntityHashtag", offset = self$offset, length = self$length),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    offset <- reader$read_int()
    length <- reader$read_int()
    list(offset = offset, length = length)
  }),
  class = TRUE
)

#  @title MessageEntityItalic
#  @description Telegram API type MessageEntityItalic
#  @export
#  @noRd
#  @noRd
MessageEntityItalic <- R6::R6Class(
  "MessageEntityItalic",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x826f8b60,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xcf6419dc,
    offset = NULL, length = NULL,
    initialize = function(offset, length) {
      self$offset <- offset
      self$length <- length
    },
    to_dict = function() list(`_` = "MessageEntityItalic", offset = self$offset, length = self$length),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    offset <- reader$read_int()
    length <- reader$read_int()
    list(offset = offset, length = length)
  }),
  class = TRUE
)

#  @title MessageEntityMention
#  @description Telegram API type MessageEntityMention
#  @export
#  @noRd
#  @noRd
MessageEntityMention <- R6::R6Class(
  "MessageEntityMention",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xfa04579d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xcf6419dc,
    offset = NULL, length = NULL,
    initialize = function(offset, length) {
      self$offset <- offset
      self$length <- length
    },
    to_dict = function() list(`_` = "MessageEntityMention", offset = self$offset, length = self$length),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    offset <- reader$read_int()
    length <- reader$read_int()
    list(offset = offset, length = length)
  }),
  class = TRUE
)

#  @title MessageEntityMentionName
#  @description Telegram API type MessageEntityMentionName
#  @export
#  @noRd
#  @noRd
MessageEntityMentionName <- R6::R6Class(
  "MessageEntityMentionName",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xdc7b1140,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xcf6419dc,
    offset = NULL, length = NULL, user_id = NULL,
    initialize = function(offset, length, user_id) {
      self$offset <- offset
      self$length <- length
      self$user_id <- user_id
    },
    to_dict = function() list(`_` = "MessageEntityMentionName", offset = self$offset, length = self$length, user_id = self$user_id),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    offset <- reader$read_int()
    length <- reader$read_int()
    user_id <- reader$read_long()
    list(offset = offset, length = length, user_id = user_id)
  }),
  class = TRUE
)

#  @title MessageEntityPhone
#  @description Telegram API type MessageEntityPhone
#  @export
#  @noRd
#  @noRd
MessageEntityPhone <- R6::R6Class(
  "MessageEntityPhone",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9b69e34b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xcf6419dc,
    offset = NULL, length = NULL,
    initialize = function(offset, length) {
      self$offset <- offset
      self$length <- length
    },
    to_dict = function() list(`_` = "MessageEntityPhone", offset = self$offset, length = self$length),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    offset <- reader$read_int()
    length <- reader$read_int()
    list(offset = offset, length = length)
  }),
  class = TRUE
)

#  @title MessageEntityPre
#  @description Telegram API type MessageEntityPre
#  @export
#  @noRd
#  @noRd
MessageEntityPre <- R6::R6Class(
  "MessageEntityPre",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x73924be0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xcf6419dc,
    offset = NULL, length = NULL, language = NULL,
    initialize = function(offset, length, language) {
      self$offset <- offset
      self$length <- length
      self$language <- language
    },
    to_dict = function() list(`_` = "MessageEntityPre", offset = self$offset, length = self$length, language = self$language),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    offset <- reader$read_int()
    length <- reader$read_int()
    language <- reader$tgread_string()
    list(offset = offset, length = length, language = language)
  }),
  class = TRUE
)

#  @title MessageEntitySpoiler
#  @description Telegram API type MessageEntitySpoiler
#  @export
#  @noRd
#  @noRd
MessageEntitySpoiler <- R6::R6Class(
  "MessageEntitySpoiler",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x32ca960f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xcf6419dc,
    offset = NULL, length = NULL,
    initialize = function(offset, length) {
      self$offset <- offset
      self$length <- length
    },
    to_dict = function() list(`_` = "MessageEntitySpoiler", offset = self$offset, length = self$length),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    offset <- reader$read_int()
    length <- reader$read_int()
    list(offset = offset, length = length)
  }),
  class = TRUE
)

#  @title MessageEntityStrike
#  @description Telegram API type MessageEntityStrike
#  @export
#  @noRd
#  @noRd
MessageEntityStrike <- R6::R6Class(
  "MessageEntityStrike",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbf0693d4,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xcf6419dc,
    offset = NULL, length = NULL,
    initialize = function(offset, length) {
      self$offset <- offset
      self$length <- length
    },
    to_dict = function() list(`_` = "MessageEntityStrike", offset = self$offset, length = self$length),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    offset <- reader$read_int()
    length <- reader$read_int()
    list(offset = offset, length = length)
  }),
  class = TRUE
)

#  @title MessageEntityTextUrl
#  @description Telegram API type MessageEntityTextUrl
#  @export
#  @noRd
#  @noRd
MessageEntityTextUrl <- R6::R6Class(
  "MessageEntityTextUrl",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x76a6d327,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xcf6419dc,
    #  @field offset Field.
    offset = NULL,
    #  @field length Field.
    length = NULL,
    #  @field url Field.
    url = NULL,
    initialize = function(offset, length, url) {
      self$offset <- offset
      self$length <- length
      self$url <- url
    },
    to_dict = function() list("_" = "MessageEntityTextUrl", offset = self$offset, length = self$length, url = self$url),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      offset <- reader$read_int()
      length <- reader$read_int()
      url <- reader$tgread_string()
      list(offset = offset, length = length, url = url)
    }
  ),
  class = TRUE
)

#  @title MessageEntityUnderline
#  @description Telegram API type MessageEntityUnderline
#  @export
#  @noRd
#  @noRd
MessageEntityUnderline <- R6::R6Class(
  "MessageEntityUnderline",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9c4e7e8b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xcf6419dc,
    #  @field offset Field.
    offset = NULL,
    #  @field length Field.
    length = NULL,
    initialize = function(offset, length) {
      self$offset <- offset
      self$length <- length
    },
    to_dict = function() list("_" = "MessageEntityUnderline", offset = self$offset, length = self$length),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      offset <- reader$read_int()
      length <- reader$read_int()
      list(offset = offset, length = length)
    }
  ),
  class = TRUE
)

#  @title MessageEntityUnknown
#  @description Telegram API type MessageEntityUnknown
#  @export
#  @noRd
#  @noRd
MessageEntityUnknown <- R6::R6Class(
  "MessageEntityUnknown",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbb92ba95,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xcf6419dc,
    #  @field offset Field.
    offset = NULL,
    #  @field length Field.
    length = NULL,
    initialize = function(offset, length) {
      self$offset <- offset
      self$length <- length
    },
    to_dict = function() list("_" = "MessageEntityUnknown", offset = self$offset, length = self$length),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      offset <- reader$read_int()
      length <- reader$read_int()
      list(offset = offset, length = length)
    }
  ),
  class = TRUE
)

#  @title MessageEntityUrl
#  @description Telegram API type MessageEntityUrl
#  @export
#  @noRd
#  @noRd
MessageEntityUrl <- R6::R6Class(
  "MessageEntityUrl",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x6ed02538,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xcf6419dc,
    #  @field offset Field.
    offset = NULL,
    #  @field length Field.
    length = NULL,
    initialize = function(offset, length) {
      self$offset <- offset
      self$length <- length
    },
    to_dict = function() list("_" = "MessageEntityUrl", offset = self$offset, length = self$length),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      offset <- reader$read_int()
      length <- reader$read_int()
      list(offset = offset, length = length)
    }
  ),
  class = TRUE
)

#  @title MessageExtendedMedia
#  @description Telegram API type MessageExtendedMedia
#  @export
#  @noRd
#  @noRd
MessageExtendedMedia <- R6::R6Class(
  "MessageExtendedMedia",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xee479c64,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9727d95d,
    #  @field media Field.
    media = NULL,
    initialize = function(media) {
      self$media <- media
    },
    to_dict = function() list("_" = "MessageExtendedMedia", media = if (inherits(self$media, "TLObject")) self$media$to_dict() else self$media),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      media <- reader$tgread_object()
      list(media = media)
    }
  ),
  class = TRUE
)

#  @title MessageExtendedMediaPreview
#  @description Telegram API type MessageExtendedMediaPreview
#  @export
#  @noRd
#  @noRd
MessageExtendedMediaPreview <- R6::R6Class(
  "MessageExtendedMediaPreview",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xad628cc8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9727d95d,
    #  @field w Field.
    w = NULL,
    #  @field h Field.
    h = NULL,
    #  @field thumb Field.
    thumb = NULL,
    #  @field video_duration Field.
    video_duration = NULL,
    initialize = function(w = NULL, h = NULL, thumb = NULL, video_duration = NULL) {
      self$w <- w
      self$h <- h
      self$thumb <- thumb
      self$video_duration <- video_duration
    },
    to_dict = function() {
      list(
        "_" = "MessageExtendedMediaPreview",
        w = self$w,
        h = self$h,
        thumb = if (inherits(self$thumb, "TLObject")) self$thumb$to_dict() else self$thumb,
        video_duration = self$video_duration
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      w <- if (bitwAnd(flags, 1) != 0) reader$read_int() else NULL
      h <- if (bitwAnd(flags, 1) != 0) reader$read_int() else NULL
      thumb <- if (bitwAnd(flags, 2) != 0) reader$tgread_object() else NULL
      video_duration <- if (bitwAnd(flags, 4) != 0) reader$read_int() else NULL
      list(w = w, h = h, thumb = thumb, video_duration = video_duration)
    }
  ),
  class = TRUE
)

#  @title MessageFwdHeader
#  @description Telegram API type MessageFwdHeader
#  @export
#  @noRd
#  @noRd
MessageFwdHeader <- R6::R6Class(
  "MessageFwdHeader",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4e4df4bb,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x7a286804,
    #  @field date Field.
    date = NULL,
    #  @field imported Field.
    imported = NULL,
    #  @field saved_out Field.
    saved_out = NULL,
    #  @field from_id Field.
    from_id = NULL,
    #  @field from_name Field.
    from_name = NULL,
    #  @field channel_post Field.
    channel_post = NULL,
    #  @field post_author Field.
    post_author = NULL,
    #  @field saved_frompeer Field.
    saved_frompeer = NULL,
    #  @field saved_from_msg_id Field.
    saved_from_msg_id = NULL,
    #  @field saved_from_id Field.
    saved_from_id = NULL,
    #  @field saved_from_name Field.
    saved_from_name = NULL,
    #  @field saved_date Field.
    saved_date = NULL,
    #  @field psa_type Field.
    psa_type = NULL,
    initialize = function(date = NULL, imported = NULL, saved_out = NULL, from_id = NULL, from_name = NULL,
                          channel_post = NULL, post_author = NULL, saved_frompeer = NULL, saved_from_msg_id = NULL,
                          saved_from_id = NULL, saved_from_name = NULL, saved_date = NULL, psa_type = NULL) {
      self$date <- date
      self$imported <- imported
      self$saved_out <- saved_out
      self$from_id <- from_id
      self$from_name <- from_name
      self$channel_post <- channel_post
      self$post_author <- post_author
      self$saved_frompeer <- saved_frompeer
      self$saved_from_msg_id <- saved_from_msg_id
      self$saved_from_id <- saved_from_id
      self$saved_from_name <- saved_from_name
      self$saved_date <- saved_date
      self$psa_type <- psa_type
    },
    to_dict = function() {
      list(
        "_" = "MessageFwdHeader",
        date = self$date,
        imported = self$imported,
        saved_out = self$saved_out,
        from_id = if (inherits(self$from_id, "TLObject")) self$from_id$to_dict() else self$from_id,
        from_name = self$from_name,
        channel_post = self$channel_post,
        post_author = self$post_author,
        saved_frompeer = if (inherits(self$saved_frompeer, "TLObject")) self$saved_frompeer$to_dict() else self$saved_frompeer,
        saved_from_msg_id = self$saved_from_msg_id,
        saved_from_id = if (inherits(self$saved_from_id, "TLObject")) self$saved_from_id$to_dict() else self$saved_from_id,
        saved_from_name = self$saved_from_name,
        saved_date = self$saved_date,
        psa_type = self$psa_type
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      imported <- bitwAnd(flags, 128) != 0
      saved_out <- bitwAnd(flags, 2048) != 0
      from_id <- if (bitwAnd(flags, 1) != 0) reader$tgread_object() else NULL
      from_name <- if (bitwAnd(flags, 32) != 0) reader$tgread_string() else NULL
      date <- reader$tgread_date()
      channel_post <- if (bitwAnd(flags, 4) != 0) reader$read_int() else NULL
      post_author <- if (bitwAnd(flags, 8) != 0) reader$tgread_string() else NULL
      saved_frompeer <- if (bitwAnd(flags, 16) != 0) reader$tgread_object() else NULL
      saved_from_msg_id <- if (bitwAnd(flags, 16) != 0) reader$read_int() else NULL
      saved_from_id <- if (bitwAnd(flags, 256) != 0) reader$tgread_object() else NULL
      saved_from_name <- if (bitwAnd(flags, 512) != 0) reader$tgread_string() else NULL
      saved_date <- if (bitwAnd(flags, 1024) != 0) reader$tgread_date() else NULL
      psa_type <- if (bitwAnd(flags, 64) != 0) reader$tgread_string() else NULL
      list(
        date = date,
        imported = imported,
        saved_out = saved_out,
        from_id = from_id,
        from_name = from_name,
        channel_post = channel_post,
        post_author = post_author,
        saved_frompeer = saved_frompeer,
        saved_from_msg_id = saved_from_msg_id,
        saved_from_id = saved_from_id,
        saved_from_name = saved_from_name,
        saved_date = saved_date,
        psa_type = psa_type
      )
    }
  ),
  class = TRUE
)

#  @title MessageMediaContact
#  @description Telegram API type MessageMediaContact
#  @export
#  @noRd
#  @noRd
MessageMediaContact <- R6::R6Class(
  "MessageMediaContact",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x70322949,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x476cbe32,
    #  @field phone_number Field.
    phone_number = NULL,
    #  @field first_name Field.
    first_name = NULL,
    #  @field last_name Field.
    last_name = NULL,
    #  @field vcard Field.
    vcard = NULL,
    #  @field user_id Field.
    user_id = NULL,
    initialize = function(phone_number, first_name, last_name, vcard, user_id) {
      self$phone_number <- phone_number
      self$first_name <- first_name
      self$last_name <- last_name
      self$vcard <- vcard
      self$user_id <- user_id
    },
    to_dict = function() {
      list(
        "_" = "MessageMediaContact",
        phone_number = self$phone_number,
        first_name = self$first_name,
        last_name = self$last_name,
        vcard = self$vcard,
        user_id = self$user_id
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      phone_number <- reader$tgread_string()
      first_name <- reader$tgread_string()
      last_name <- reader$tgread_string()
      vcard <- reader$tgread_string()
      user_id <- reader$read_long()
      list(
        phone_number = phone_number,
        first_name = first_name,
        last_name = last_name,
        vcard = vcard,
        user_id = user_id
      )
    }
  ),
  class = TRUE
)

#  @title MessageMediaDice
#  @description Telegram API type MessageMediaDice
#  @export
#  @noRd
#  @noRd
MessageMediaDice <- R6::R6Class(
  "MessageMediaDice",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x3f7ee58b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x476cbe32,
    #  @field value Field.
    value = NULL,
    #  @field emoticon Field.
    emoticon = NULL,
    initialize = function(value, emoticon) {
      self$value <- value
      self$emoticon <- emoticon
    },
    to_dict = function() list("_" = "MessageMediaDice", value = self$value, emoticon = self$emoticon),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      value <- reader$read_int()
      emoticon <- reader$tgread_string()
      list(value = value, emoticon = emoticon)
    }
  ),
  class = TRUE
)

#  @title MessageMediaDocument
#  @description Telegram API type MessageMediaDocument
#  @export
#  @noRd
#  @noRd
MessageMediaDocument <- R6::R6Class(
  "MessageMediaDocument",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x52d8ccd9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x476cbe32,
    #  @field nopremium Field.
    nopremium = NULL,
    #  @field spoiler Field.
    spoiler = NULL,
    #  @field video Field.
    video = NULL,
    #  @field round Field.
    round = NULL,
    #  @field voice Field.
    voice = NULL,
    #  @field document Field.
    document = NULL,
    #  @field alt_documents Field.
    alt_documents = NULL,
    #  @field video_cover Field.
    video_cover = NULL,
    #  @field video_timestamp Field.
    video_timestamp = NULL,
    #  @field ttl_seconds Field.
    ttl_seconds = NULL,
    initialize = function(nopremium = NULL, spoiler = NULL, video = NULL, round = NULL, voice = NULL,
                          document = NULL, alt_documents = NULL, video_cover = NULL, video_timestamp = NULL,
                          ttl_seconds = NULL) {
      self$nopremium <- nopremium
      self$spoiler <- spoiler
      self$video <- video
      self$round <- round
      self$voice <- voice
      self$document <- document
      self$alt_documents <- alt_documents
      self$video_cover <- video_cover
      self$video_timestamp <- video_timestamp
      self$ttl_seconds <- ttl_seconds
    },
    to_dict = function() {
      list(
        "_" = "MessageMediaDocument",
        nopremium = self$nopremium,
        spoiler = self$spoiler,
        video = self$video,
        round = self$round,
        voice = self$voice,
        document = if (inherits(self$document, "TLObject")) self$document$to_dict() else self$document,
        alt_documents = if (is.null(self$alt_documents)) NULL else lapply(self$alt_documents, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        video_cover = if (inherits(self$video_cover, "TLObject")) self$video_cover$to_dict() else self$video_cover,
        video_timestamp = self$video_timestamp,
        ttl_seconds = self$ttl_seconds
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      remaining <- function() {
        length(reader$get_bytes()) - reader$tell_position()
      }
      flags <- reader$read_int()
      nopremium <- bitwAnd(flags, 8) != 0
      spoiler <- bitwAnd(flags, 16) != 0
      video <- bitwAnd(flags, 64) != 0
      round <- bitwAnd(flags, 128) != 0
      voice <- bitwAnd(flags, 256) != 0
      document <- if (bitwAnd(flags, 1) != 0) reader$tgread_object() else NULL
      if (bitwAnd(flags, 32) != 0) {
        if (remaining() < 8) {
          return(list(
            nopremium = nopremium,
            spoiler = spoiler,
            video = video,
            round = round,
            voice = voice,
            document = document,
            alt_documents = NULL,
            video_cover = NULL,
            video_timestamp = NULL,
            ttl_seconds = NULL
          ))
        }
        reader$read_int()
        n <- reader$read_int()
        alt_documents <- list()
        if (n > 0) {
          for (i in seq_len(n)) alt_documents[[i]] <- reader$tgread_object()
        }
      } else {
        alt_documents <- NULL
      }
      if (bitwAnd(flags, 512) != 0) {
        video_cover <- if (remaining() >= 4) reader$tgread_object() else NULL
      } else {
        video_cover <- NULL
      }
      if (bitwAnd(flags, 1024) != 0) {
        video_timestamp <- if (remaining() >= 4) reader$read_int() else NULL
      } else {
        video_timestamp <- NULL
      }
      if (bitwAnd(flags, 4) != 0) {
        ttl_seconds <- if (remaining() >= 4) reader$read_int() else NULL
      } else {
        ttl_seconds <- NULL
      }
      list(
        nopremium = nopremium,
        spoiler = spoiler,
        video = video,
        round = round,
        voice = voice,
        document = document,
        alt_documents = alt_documents,
        video_cover = video_cover,
        video_timestamp = video_timestamp,
        ttl_seconds = ttl_seconds
      )
    }
  ),
  class = TRUE
)

#  @title MessageMediaEmpty
#  @description Telegram API type MessageMediaEmpty
#  @export
#  @noRd
#  @noRd
MessageMediaEmpty <- R6::R6Class(
  "MessageMediaEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x3ded6320,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x476cbe32,
    initialize = function() {},
    to_dict = function() list("_" = "MessageMediaEmpty"),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      self$new()
    }
  ),
  class = TRUE
)

#  @title MessageMediaGame
#  @description Telegram API type MessageMediaGame
#  @export
#  @noRd
#  @noRd
MessageMediaGame <- R6::R6Class(
  "MessageMediaGame",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xfdb19008,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x476cbe32,
    #  @field game Field.
    game = NULL,
    initialize = function(game) {
      self$game <- game
    },
    to_dict = function() list("_" = "MessageMediaGame", game = if (inherits(self$game, "TLObject")) self$game$to_dict() else self$game),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      game <- reader$tgread_object()
      list(game = game)
    }
  ),
  class = TRUE
)

#  @title MessageMediaGeo
#  @description Telegram API type MessageMediaGeo
#  @export
#  @noRd
#  @noRd
MessageMediaGeo <- R6::R6Class(
  "MessageMediaGeo",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x56e0d474,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x476cbe32,
    #  @field geo Field.
    geo = NULL,
    initialize = function(geo) {
      self$geo <- geo
    },
    to_dict = function() list(`_` = "MessageMediaGeo", geo = if (inherits(self$geo, "TLObject")) self$geo$to_dict() else self$geo),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      self$new(reader$tgread_object())
    }
  ),
  class = TRUE
)

#  @title MessageMediaGeoLive
#  @description Telegram API type MessageMediaGeoLive
#  @export
#  @noRd
#  @noRd
MessageMediaGeoLive <- R6::R6Class(
  "MessageMediaGeoLive",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb940c666,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x476cbe32,
    #  @field geo Field.
    geo = NULL,
    #  @field period Field.
    period = NULL,
    #  @field heading Field.
    heading = NULL,
    #  @field proximity_notification_radius Field.
    proximity_notification_radius = NULL,
    initialize = function(geo, period, heading = NULL, proximity_notification_radius = NULL) {
      self$geo <- geo
      self$period <- period
      self$heading <- heading
      self$proximity_notification_radius <- proximity_notification_radius
    },
    to_dict = function() {
      list(
        `_` = "MessageMediaGeoLive",
        geo = if (inherits(self$geo, "TLObject")) self$geo$to_dict() else self$geo,
        period = self$period,
        heading = self$heading,
        proximity_notification_radius = self$proximity_notification_radius
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      geo <- reader$tgread_object()
      heading <- if (bitwAnd(flags, 1) != 0) reader$read_int() else NULL
      period <- reader$read_int()
      proximity_notification_radius <- if (bitwAnd(flags, 2) != 0) reader$read_int() else NULL
      list(
        geo = geo,
        period = period,
        heading = heading,
        proximity_notification_radius = proximity_notification_radius
      )
    }
  ),
  class = TRUE
)

#  @title MessageMediaGiveaway
#  @description Telegram API type MessageMediaGiveaway
#  @export
#  @noRd
#  @noRd
MessageMediaGiveaway <- R6::R6Class(
  "MessageMediaGiveaway",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xaa073beb,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x476cbe32,
    #  @field channels Field.
    channels = NULL,
    #  @field quantity Field.
    quantity = NULL,
    #  @field until_date Field.
    until_date = NULL,
    #  @field only_new_subscribers Field.
    only_new_subscribers = NULL,
    #  @field winners_are_visible Field.
    winners_are_visible = NULL,
    #  @field countries_iso2 Field.
    countries_iso2 = NULL,
    #  @field prize_description Field.
    prize_description = NULL,
    #  @field months Field.
    months = NULL,
    #  @field stars Field.
    stars = NULL,
    initialize = function(channels, quantity, until_date = NULL, only_new_subscribers = NULL, winners_are_visible = NULL, countries_iso2 = NULL, prize_description = NULL, months = NULL, stars = NULL) {
      self$channels <- channels
      self$quantity <- quantity
      self$until_date <- until_date
      self$only_new_subscribers <- only_new_subscribers
      self$winners_are_visible <- winners_are_visible
      self$countries_iso2 <- countries_iso2
      self$prize_description <- prize_description
      self$months <- months
      self$stars <- stars
    },
    to_dict = function() {
      list(
        `_` = "MessageMediaGiveaway",
        channels = if (is.null(self$channels)) NULL else self$channels,
        quantity = self$quantity,
        until_date = self$until_date,
        only_new_subscribers = self$only_new_subscribers,
        winners_are_visible = self$winners_are_visible,
        countries_iso2 = if (is.null(self$countries_iso2)) NULL else self$countries_iso2,
        prize_description = self$prize_description,
        months = self$months,
        stars = self$stars
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      only_new_subscribers <- bitwAnd(flags, 1) != 0
      winners_are_visible <- bitwAnd(flags, 4) != 0
      reader$read_int()
      n_channels <- reader$read_int()
      channels <- list()
      if (n_channels > 0) {
        for (i in seq_len(n_channels)) channels[[i]] <- reader$read_long()
      }
      if (bitwAnd(flags, 2) != 0) {
        reader$read_int()
        n_countries <- reader$read_int()
        countries_iso2 <- list()
        if (n_countries > 0) {
          for (i in seq_len(n_countries)) countries_iso2[[i]] <- reader$tgread_string()
        }
      } else {
        countries_iso2 <- NULL
      }
      prize_description <- if (bitwAnd(flags, 8) != 0) reader$tgread_string() else NULL
      quantity <- reader$read_int()
      months <- if (bitwAnd(flags, 16) != 0) reader$read_int() else NULL
      stars <- if (bitwAnd(flags, 32) != 0) reader$read_long() else NULL
      until_date <- reader$tgread_date()
      list(
        channels = channels,
        quantity = quantity,
        until_date = until_date,
        only_new_subscribers = only_new_subscribers,
        winners_are_visible = winners_are_visible,
        countries_iso2 = countries_iso2,
        prize_description = prize_description,
        months = months,
        stars = stars
      )
    }
  ),
  class = TRUE
)

#  @title MessageMediaGiveawayResults
#  @description Telegram API type MessageMediaGiveawayResults
#  @export
#  @noRd
#  @noRd
MessageMediaGiveawayResults <- R6::R6Class(
  "MessageMediaGiveawayResults",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xceaa3ea1,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x476cbe32,
    #  @field channel_id Field.
    channel_id = NULL,
    #  @field launch_msg_id Field.
    launch_msg_id = NULL,
    #  @field winners_count Field.
    winners_count = NULL,
    #  @field unclaimed_count Field.
    unclaimed_count = NULL,
    #  @field winners Field.
    winners = NULL,
    #  @field until_date Field.
    until_date = NULL,
    #  @field only_new_subscribers Field.
    only_new_subscribers = NULL,
    #  @field refunded Field.
    refunded = NULL,
    #  @field additionalpeers_count Field.
    additionalpeers_count = NULL,
    #  @field months Field.
    months = NULL,
    #  @field stars Field.
    stars = NULL,
    #  @field prize_description Field.
    prize_description = NULL,
    initialize = function(channel_id, launch_msg_id, winners_count, unclaimed_count, winners, until_date = NULL, only_new_subscribers = NULL, refunded = NULL, additionalpeers_count = NULL, months = NULL, stars = NULL, prize_description = NULL) {
      self$channel_id <- channel_id
      self$launch_msg_id <- launch_msg_id
      self$winners_count <- winners_count
      self$unclaimed_count <- unclaimed_count
      self$winners <- winners
      self$until_date <- until_date
      self$only_new_subscribers <- only_new_subscribers
      self$refunded <- refunded
      self$additionalpeers_count <- additionalpeers_count
      self$months <- months
      self$stars <- stars
      self$prize_description <- prize_description
    },
    to_dict = function() {
      list(
        `_` = "MessageMediaGiveawayResults",
        channel_id = self$channel_id,
        launch_msg_id = self$launch_msg_id,
        winners_count = self$winners_count,
        unclaimed_count = self$unclaimed_count,
        winners = if (is.null(self$winners)) NULL else self$winners,
        until_date = self$until_date,
        only_new_subscribers = self$only_new_subscribers,
        refunded = self$refunded,
        additionalpeers_count = self$additionalpeers_count,
        months = self$months,
        stars = self$stars,
        prize_description = self$prize_description
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      only_new_subscribers <- bitwAnd(flags, 1) != 0
      refunded <- bitwAnd(flags, 4) != 0
      channel_id <- reader$read_long()
      additionalpeers_count <- if (bitwAnd(flags, 8) != 0) reader$read_int() else NULL
      launch_msg_id <- reader$read_int()
      winners_count <- reader$read_int()
      unclaimed_count <- reader$read_int()
      reader$read_int()
      n_winners <- reader$read_int()
      winners <- list()
      if (n_winners > 0) {
        for (i in seq_len(n_winners)) winners[[i]] <- reader$read_long()
      }
      months <- if (bitwAnd(flags, 16) != 0) reader$read_int() else NULL
      stars <- if (bitwAnd(flags, 32) != 0) reader$read_long() else NULL
      prize_description <- if (bitwAnd(flags, 2) != 0) reader$tgread_string() else NULL
      until_date <- reader$tgread_date()
      list(
        channel_id = channel_id,
        launch_msg_id = launch_msg_id,
        winners_count = winners_count,
        unclaimed_count = unclaimed_count,
        winners = winners,
        until_date = until_date,
        only_new_subscribers = only_new_subscribers,
        refunded = refunded,
        additionalpeers_count = additionalpeers_count,
        months = months,
        stars = stars,
        prize_description = prize_description
      )
    }
  ),
  class = TRUE
)

#  @title MessageMediaInvoice
#  @description Telegram API type MessageMediaInvoice
#  @export
#  @noRd
#  @noRd
MessageMediaInvoice <- R6::R6Class(
  "MessageMediaInvoice",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf6a548d3,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x476cbe32,
    #  @field title Field.
    title = NULL,
    #  @field description Field.
    description = NULL,
    #  @field currency Field.
    currency = NULL,
    #  @field total_amount Field.
    total_amount = NULL,
    #  @field start_param Field.
    start_param = NULL,
    #  @field shipping_address_requested Field.
    shipping_address_requested = NULL,
    #  @field test Field.
    test = NULL,
    #  @field photo Field.
    photo = NULL,
    #  @field receipt_msg_id Field.
    receipt_msg_id = NULL,
    #  @field extended_media Field.
    extended_media = NULL,
    initialize = function(title, description, currency, total_amount, start_param, shipping_address_requested = NULL, test = NULL, photo = NULL, receipt_msg_id = NULL, extended_media = NULL) {
      self$title <- title
      self$description <- description
      self$currency <- currency
      self$total_amount <- total_amount
      self$start_param <- start_param
      self$shipping_address_requested <- shipping_address_requested
      self$test <- test
      self$photo <- photo
      self$receipt_msg_id <- receipt_msg_id
      self$extended_media <- extended_media
    },
    to_dict = function() {
      list(
        `_` = "MessageMediaInvoice",
        title = self$title,
        description = self$description,
        currency = self$currency,
        total_amount = self$total_amount,
        start_param = self$start_param,
        shipping_address_requested = self$shipping_address_requested,
        test = self$test,
        photo = if (inherits(self$photo, "TLObject")) self$photo$to_dict() else self$photo,
        receipt_msg_id = self$receipt_msg_id,
        extended_media = if (is.null(self$extended_media)) NULL else lapply(self$extended_media, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      shipping_address_requested <- bitwAnd(flags, 2) != 0
      test <- bitwAnd(flags, 8) != 0
      title <- reader$tgread_string()
      description <- reader$tgread_string()
      photo <- if (bitwAnd(flags, 1) != 0) reader$tgread_object() else NULL
      receipt_msg_id <- if (bitwAnd(flags, 4) != 0) reader$read_int() else NULL
      currency <- reader$tgread_string()
      total_amount <- reader$read_long()
      start_param <- reader$tgread_string()
      extended_media <- if (bitwAnd(flags, 16) != 0) reader$tgread_object() else NULL
      list(
        title = title,
        description = description,
        currency = currency,
        total_amount = total_amount,
        start_param = start_param,
        shipping_address_requested = shipping_address_requested,
        test = test,
        photo = photo,
        receipt_msg_id = receipt_msg_id,
        extended_media = extended_media
      )
    }
  ),
  class = TRUE
)

#  @title MessageMediaPaidMedia
#  @description Telegram API type MessageMediaPaidMedia
#  @export
#  @noRd
#  @noRd
MessageMediaPaidMedia <- R6::R6Class(
  "MessageMediaPaidMedia",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa8852491,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x476cbe32,
    #  @field stars_amount Field.
    stars_amount = NULL,
    #  @field extended_media Field.
    extended_media = NULL,
    initialize = function(stars_amount, extended_media) {
      self$stars_amount <- stars_amount
      self$extended_media <- extended_media
    },
    to_dict = function() {
      list(
        `_` = "MessageMediaPaidMedia",
        stars_amount = self$stars_amount,
        extended_media = if (is.null(self$extended_media)) NULL else lapply(self$extended_media, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      stars_amount <- reader$read_long()
      reader$read_int()
      n <- reader$read_int()
      extended_media <- list()
      if (n > 0) {
        for (i in seq_len(n)) extended_media[[i]] <- reader$tgread_object()
      }
      list(stars_amount = stars_amount, extended_media = extended_media)
    }
  ),
  class = TRUE
)

#  @title MessageMediaPhoto
#  @description Telegram API type MessageMediaPhoto
#  @export
#  @noRd
#  @noRd
MessageMediaPhoto <- R6::R6Class(
  "MessageMediaPhoto",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x695150d7,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x476cbe32,
    #  @field spoiler Field.
    spoiler = NULL,
    #  @field photo Field.
    photo = NULL,
    #  @field ttl_seconds Field.
    ttl_seconds = NULL,
    initialize = function(spoiler = NULL, photo = NULL, ttl_seconds = NULL) {
      self$spoiler <- spoiler
      self$photo <- photo
      self$ttl_seconds <- ttl_seconds
    },
    to_dict = function() {
      list(
        `_` = "MessageMediaPhoto",
        spoiler = self$spoiler,
        photo = if (inherits(self$photo, "TLObject")) self$photo$to_dict() else self$photo,
        ttl_seconds = self$ttl_seconds
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      spoiler <- bitwAnd(flags, 8) != 0
      photo <- if (bitwAnd(flags, 1) != 0) reader$tgread_object() else NULL
      ttl_seconds <- if (bitwAnd(flags, 4) != 0) reader$read_int() else NULL
      self$new(spoiler = spoiler, photo = photo, ttl_seconds = ttl_seconds)
    }
  ),
  class = TRUE
)

#  @title MessageMediaPoll
#  @description Telegram API type MessageMediaPoll
#  @export
#  @noRd
#  @noRd
MessageMediaPoll <- R6::R6Class(
  "MessageMediaPoll",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4bd6e798,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x476cbe32,
    #  @field poll Field.
    poll = NULL,
    #  @field results Field.
    results = NULL,
    initialize = function(poll, results) {
      self$poll <- poll
      self$results <- results
    },
    to_dict = function() {
      list(
        `_` = "MessageMediaPoll",
        poll = if (inherits(self$poll, "TLObject")) self$poll$to_dict() else self$poll,
        results = if (inherits(self$results, "TLObject")) self$results$to_dict() else self$results
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      self$new(reader$tgread_object(), reader$tgread_object())
    }
  ),
  class = TRUE
)

#  @title MessageMediaStory
#  @description Telegram API type MessageMediaStory
#  @export
#  @noRd
#  @noRd
MessageMediaStory <- R6::R6Class(
  "MessageMediaStory",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x68cb6283,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x476cbe32,
    #  @field peer Field.
    peer = NULL,
    #  @field id Field.
    id = NULL,
    #  @field via_mention Field.
    via_mention = NULL,
    #  @field story Field.
    story = NULL,
    initialize = function(peer, id, via_mention = NULL, story = NULL) {
      self$peer <- peer
      self$id <- id
      self$via_mention <- via_mention
      self$story <- story
    },
    to_dict = function() {
      list(
        `_` = "MessageMediaStory",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        id = self$id,
        via_mention = self$via_mention,
        story = if (inherits(self$story, "TLObject")) self$story$to_dict() else self$story
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      via_mention <- bitwAnd(flags, 2) != 0
      peer <- reader$tgread_object()
      id <- reader$read_int()
      story <- if (bitwAnd(flags, 1) != 0) reader$tgread_object() else NULL
      list(peer = peer, id = id, via_mention = via_mention, story = story)
    }
  ),
  class = TRUE
)

#  @title MessageMediaToDo
#  @description Telegram API type MessageMediaToDo
#  @export
#  @noRd
#  @noRd
MessageMediaToDo <- R6::R6Class(
  "MessageMediaToDo",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8a53b014,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x476cbe32,
    #  @field todo Field.
    todo = NULL,
    #  @field completions Field.
    completions = NULL,
    initialize = function(todo, completions = NULL) {
      self$todo <- todo
      self$completions <- completions
    },
    to_dict = function() {
      list(
        `_` = "MessageMediaToDo",
        todo = if (inherits(self$todo, "TLObject")) self$todo$to_dict() else self$todo,
        completions = if (is.null(self$completions)) NULL else lapply(self$completions, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      self$new(reader$tgread_object(), list())
    }
  ),
  class = TRUE
)

#  @title MessageMediaUnsupported
#  @description Telegram API type MessageMediaUnsupported
#  @export
#  @noRd
#  @noRd
MessageMediaUnsupported <- R6::R6Class(
  "MessageMediaUnsupported",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9f84f49e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x476cbe32,
    initialize = function() {},
    to_dict = function() list(`_` = "MessageMediaUnsupported"),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      self$new()
    }
  ),
  class = TRUE
)

#  @title MessageMediaVenue
#  @description Telegram API type MessageMediaVenue
#  @export
#  @noRd
#  @noRd
MessageMediaVenue <- R6::R6Class(
  "MessageMediaVenue",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x2ec0533f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x476cbe32,
    #  @field geo Field.
    geo = NULL,
    #  @field title Field.
    title = NULL,
    #  @field address Field.
    address = NULL,
    #  @field provider Field.
    provider = NULL,
    #  @field venue_id Field.
    venue_id = NULL,
    #  @field venue_type Field.
    venue_type = NULL,
    initialize = function(geo, title, address, provider, venue_id, venue_type) {
      self$geo <- geo
      self$title <- title
      self$address <- address
      self$provider <- provider
      self$venue_id <- venue_id
      self$venue_type <- venue_type
    },
    to_dict = function() {
      list(
        `_` = "MessageMediaVenue",
        geo = if (inherits(self$geo, "TLObject")) self$geo$to_dict() else self$geo,
        title = self$title,
        address = self$address,
        provider = self$provider,
        venue_id = self$venue_id,
        venue_type = self$venue_type
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      self$new(reader$tgread_object(), reader$tgread_string(), reader$tgread_string(), reader$tgread_string(), reader$tgread_string(), reader$tgread_string())
    }
  ),
  class = TRUE
)

#  @title MessageMediaWebPage
#  @description Telegram API type MessageMediaWebPage
#  @export
#  @noRd
#  @noRd
MessageMediaWebPage <- R6::R6Class(
  "MessageMediaWebPage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xddf10c3b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x476cbe32,
    #  @field webpage Field.
    webpage = NULL,
    #  @field force_large_media Field.
    force_large_media = NULL,
    #  @field force_small_media Field.
    force_small_media = NULL,
    #  @field manual Field.
    manual = NULL,
    #  @field safe Field.
    safe = NULL,
    initialize = function(webpage, force_large_media = NULL, force_small_media = NULL, manual = NULL, safe = NULL) {
      self$webpage <- webpage
      self$force_large_media <- force_large_media
      self$force_small_media <- force_small_media
      self$manual <- manual
      self$safe <- safe
    },
    to_dict = function() {
      list(
        `_` = "MessageMediaWebPage",
        webpage = if (inherits(self$webpage, "TLObject")) self$webpage$to_dict() else self$webpage,
        force_large_media = self$force_large_media,
        force_small_media = self$force_small_media,
        manual = self$manual,
        safe = self$safe
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      force_large_media <- bitwAnd(flags, 1) != 0
      force_small_media <- bitwAnd(flags, 2) != 0
      manual <- bitwAnd(flags, 8) != 0
      safe <- bitwAnd(flags, 16) != 0
      webpage <- reader$tgread_object()
      self$new(
        webpage = webpage,
        force_large_media = force_large_media,
        force_small_media = force_small_media,
        manual = manual,
        safe = safe
      )
    }
  ),
  class = TRUE
)

#  @title MessagePeerReaction
#  @description Telegram API type MessagePeerReaction
#  @export
#  @noRd
#  @noRd
MessagePeerReaction <- R6::R6Class(
  "MessagePeerReaction",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8c79b63c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xaf73a2a5,
    #  @field peer_id Field.
    peer_id = NULL,
    #  @field date Field.
    date = NULL,
    #  @field reaction Field.
    reaction = NULL,
    #  @field big Field.
    big = NULL,
    #  @field unread Field.
    unread = NULL,
    #  @field my Field.
    my = NULL,
    initialize = function(peer_id, date = NULL, reaction, big = NULL, unread = NULL, my = NULL) {
      self$peer_id <- peer_id
      self$date <- date
      self$reaction <- reaction
      self$big <- big
      self$unread <- unread
      self$my <- my
    },
    to_dict = function() {
      list(
        `_` = "MessagePeerReaction",
        peer_id = if (inherits(self$peer_id, "TLObject")) self$peer_id$to_dict() else self$peer_id,
        date = self$date,
        reaction = if (inherits(self$reaction, "TLObject")) self$reaction$to_dict() else self$reaction,
        big = self$big,
        unread = self$unread,
        my = self$my
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      self$new(reader$tgread_object(), reader$tgread_date(), reader$tgread_object())
    }
  ),
  class = TRUE
)

#  @title MessagePeerVote
#  @description Telegram API type MessagePeerVote
#  @export
#  @noRd
#  @noRd
MessagePeerVote <- R6::R6Class(
  "MessagePeerVote",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb6cc2d5c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x85c27202,
    #  @field peer Field.
    peer = NULL,
    #  @field option Field.
    option = NULL,
    #  @field date Field.
    date = NULL,
    initialize = function(peer, option, date) {
      self$peer <- peer
      self$option <- option
      self$date <- date
    },
    to_dict = function() {
      list(
        `_` = "MessagePeerVote",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        option = self$option,
        date = self$date
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      option <- reader$tgreadbytes()
      date <- reader$tgread_date()
      self$new(peer = peer, option = option, date = date)
    }
  ),
  class = TRUE
)

#  @title MessagePeerVoteInputOption
#  @description Telegram API type MessagePeerVoteInputOption
#  @export
#  @noRd
#  @noRd
MessagePeerVoteInputOption <- R6::R6Class(
  "MessagePeerVoteInputOption",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x74cda504,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x85c27202,
    #  @field peer Field.
    peer = NULL,
    #  @field date Field.
    date = NULL,
    initialize = function(peer, date) {
      self$peer <- peer
      self$date <- date
    },
    to_dict = function() {
      list(
        `_` = "MessagePeerVoteInputOption",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        date = self$date
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      date <- reader$tgread_date()
      self$new(peer = peer, date = date)
    }
  ),
  class = TRUE
)

#  @title MessagePeerVoteMultiple
#  @description Telegram API type MessagePeerVoteMultiple
#  @export
#  @noRd
#  @noRd
MessagePeerVoteMultiple <- R6::R6Class(
  "MessagePeerVoteMultiple",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4628f6e6,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x85c27202,
    #  @field peer Field.
    peer = NULL,
    #  @field options Field.
    options = NULL,
    #  @field date Field.
    date = NULL,
    initialize = function(peer, options, date) {
      self$peer <- peer
      self$options <- options
      self$date <- date
    },
    to_dict = function() {
      list(
        `_` = "MessagePeerVoteMultiple",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        options = if (is.null(self$options)) NULL else self$options,
        date = self$date
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      reader$read_int() # vector constructor
      n <- reader$read_int()
      options <- list()
      if (n > 0) {
        for (i in seq_len(n)) {
          options[[i]] <- reader$tgreadbytes()
        }
      }
      date <- reader$tgread_date()
      self$new(peer = peer, options = options, date = date)
    }
  ),
  class = TRUE
)

#  @title MessageRange
#  @description Telegram API type MessageRange
#  @export
#  @noRd
#  @noRd
MessageRange <- R6::R6Class(
  "MessageRange",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x0ae30253,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbec74577,
    #  @field min_id Field.
    min_id = NULL,
    #  @field max_id Field.
    max_id = NULL,
    initialize = function(min_id, max_id) {
      self$min_id <- min_id
      self$max_id <- max_id
    },
    to_dict = function() list(`_` = "MessageRange", min_id = self$min_id, max_id = self$max_id),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      min_id <- reader$read_int()
      max_id <- reader$read_int()
      self$new(min_id = min_id, max_id = max_id)
    }
  ),
  class = TRUE
)

#  @title MessageReactions
#  @description Telegram API type MessageReactions
#  @export
#  @noRd
#  @noRd
MessageReactions <- R6::R6Class(
  "MessageReactions",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x0a339f0b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8a5b071c,
    #  @field results Field.
    results = NULL,
    #  @field min Field.
    min = NULL,
    #  @field can_see_list Field.
    can_see_list = NULL,
    #  @field reactions_as_tags Field.
    reactions_as_tags = NULL,
    #  @field recent_reactions Field.
    recent_reactions = NULL,
    #  @field top_reactors Field.
    top_reactors = NULL,
    initialize = function(results, min = NULL, can_see_list = NULL, reactions_as_tags = NULL, recent_reactions = NULL, top_reactors = NULL) {
      self$results <- results
      self$min <- min
      self$can_see_list <- can_see_list
      self$reactions_as_tags <- reactions_as_tags
      self$recent_reactions <- recent_reactions
      self$top_reactors <- top_reactors
    },
    to_dict = function() {
      list(
        `_` = "MessageReactions",
        results = if (is.null(self$results)) NULL else lapply(self$results, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        min = self$min,
        can_see_list = self$can_see_list,
        reactions_as_tags = self$reactions_as_tags,
        recent_reactions = if (is.null(self$recent_reactions)) NULL else lapply(self$recent_reactions, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        top_reactors = if (is.null(self$top_reactors)) NULL else lapply(self$top_reactors, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      min <- as.logical(bitwAnd(flags, 1))
      can_see_list <- as.logical(bitwAnd(flags, 4))
      reactions_as_tags <- as.logical(bitwAnd(flags, 8))

      reader$read_int() # vector constructor for results
      n <- reader$read_int()
      results <- list()
      if (n > 0) {
        for (i in seq_len(n)) results[[i]] <- reader$tgread_object()
      }

      if (bitwAnd(flags, 2) != 0) {
        reader$read_int()
        m <- reader$read_int()
        recent_reactions <- list()
        if (m > 0) {
          for (i in seq_len(m)) recent_reactions[[i]] <- reader$tgread_object()
        }
      } else {
        recent_reactions <- NULL
      }

      if (bitwAnd(flags, 16) != 0) {
        reader$read_int()
        k <- reader$read_int()
        top_reactors <- list()
        if (k > 0) {
          for (i in seq_len(k)) top_reactors[[i]] <- reader$tgread_object()
        }
      } else {
        top_reactors <- NULL
      }

      self$new(results = results, min = min, can_see_list = can_see_list, reactions_as_tags = reactions_as_tags, recent_reactions = recent_reactions, top_reactors = top_reactors)
    }
  ),
  class = TRUE
)

#  @title MessageReactor
#  @description Telegram API type MessageReactor
#  @export
#  @noRd
#  @noRd
MessageReactor <- R6::R6Class(
  "MessageReactor",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4ba3a95a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf0381ab9,
    #  @field count Field.
    count = NULL,
    #  @field top Field.
    top = NULL,
    #  @field my Field.
    my = NULL,
    #  @field anonymous Field.
    anonymous = NULL,
    #  @field peer_id Field.
    peer_id = NULL,
    initialize = function(count, top = NULL, my = NULL, anonymous = NULL, peer_id = NULL) {
      self$count <- count
      self$top <- top
      self$my <- my
      self$anonymous <- anonymous
      self$peer_id <- peer_id
    },
    to_dict = function() {
      list(
        `_` = "MessageReactor",
        count = self$count,
        top = self$top,
        my = self$my,
        anonymous = self$anonymous,
        peer_id = if (inherits(self$peer_id, "TLObject")) self$peer_id$to_dict() else self$peer_id
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      top <- as.logical(bitwAnd(flags, 1))
      my <- as.logical(bitwAnd(flags, 2))
      anonymous <- as.logical(bitwAnd(flags, 4))
      if (bitwAnd(flags, 8) != 0) {
        peer_id <- reader$tgread_object()
      } else {
        peer_id <- NULL
      }
      count <- reader$read_int()
      self$new(count = count, top = top, my = my, anonymous = anonymous, peer_id = peer_id)
    }
  ),
  class = TRUE
)

#  @title MessageReplies
#  @description Telegram API type MessageReplies
#  @export
#  @noRd
#  @noRd
MessageReplies <- R6::R6Class(
  "MessageReplies",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x83d60fc2,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x6ccd5ce2,
    #  @field replies Field.
    replies = NULL,
    #  @field replies_pts Field.
    replies_pts = NULL,
    #  @field comments Field.
    comments = NULL,
    #  @field recent_repliers Field.
    recent_repliers = NULL,
    #  @field channel_id Field.
    channel_id = NULL,
    #  @field max_id Field.
    max_id = NULL,
    #  @field read_max_id Field.
    read_max_id = NULL,
    initialize = function(replies, replies_pts, comments = NULL, recent_repliers = NULL, channel_id = NULL, max_id = NULL, read_max_id = NULL) {
      self$replies <- replies
      self$replies_pts <- replies_pts
      self$comments <- comments
      self$recent_repliers <- recent_repliers
      self$channel_id <- channel_id
      self$max_id <- max_id
      self$read_max_id <- read_max_id
    },
    to_dict = function() {
      list(
        `_` = "MessageReplies",
        replies = self$replies,
        replies_pts = self$replies_pts,
        comments = self$comments,
        recent_repliers = if (is.null(self$recent_repliers)) NULL else lapply(self$recent_repliers, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        channel_id = self$channel_id,
        max_id = self$max_id,
        read_max_id = self$read_max_id
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      comments <- as.logical(bitwAnd(flags, 1))
      replies <- reader$read_int()
      replies_pts <- reader$read_int()

      if (bitwAnd(flags, 2) != 0) {
        reader$read_int()
        m <- reader$read_int()
        recent_repliers <- list()
        if (m > 0) for (i in seq_len(m)) recent_repliers[[i]] <- reader$tgread_object()
      } else {
        recent_repliers <- NULL
      }

      if (bitwAnd(flags, 1) != 0) {
        channel_id <- reader$read_long()
      } else {
        channel_id <- NULL
      }

      if (bitwAnd(flags, 4) != 0) {
        max_id <- reader$read_int()
      } else {
        max_id <- NULL
      }

      if (bitwAnd(flags, 8) != 0) {
        read_max_id <- reader$read_int()
      } else {
        read_max_id <- NULL
      }

      self$new(replies = replies, replies_pts = replies_pts, comments = comments, recent_repliers = recent_repliers, channel_id = channel_id, max_id = max_id, read_max_id = read_max_id)
    }
  ),
  class = TRUE
)

#  @title MessageReplyHeader
#  @description Telegram API type MessageReplyHeader
#  @export
#  @noRd
#  @noRd
MessageReplyHeader <- R6::R6Class(
  "MessageReplyHeader",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x6917560b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5b4d9167,
    #  @field reply_to_scheduled Field.
    reply_to_scheduled = NULL,
    #  @field forum_topic Field.
    forum_topic = NULL,
    #  @field quote Field.
    quote = NULL,
    #  @field reply_to_msg_id Field.
    reply_to_msg_id = NULL,
    #  @field reply_topeer_id Field.
    reply_topeer_id = NULL,
    #  @field reply_from Field.
    reply_from = NULL,
    #  @field reply_media Field.
    reply_media = NULL,
    #  @field reply_to_top_id Field.
    reply_to_top_id = NULL,
    #  @field quote_text Field.
    quote_text = NULL,
    #  @field quote_entities Field.
    quote_entities = NULL,
    #  @field quote_offset Field.
    quote_offset = NULL,
    #  @field todo_item_id Field.
    todo_item_id = NULL,
    initialize = function(reply_to_scheduled = NULL, forum_topic = NULL, quote = NULL, reply_to_msg_id = NULL, reply_topeer_id = NULL, reply_from = NULL, reply_media = NULL, reply_to_top_id = NULL, quote_text = NULL, quote_entities = NULL, quote_offset = NULL, todo_item_id = NULL) {
      self$reply_to_scheduled <- reply_to_scheduled
      self$forum_topic <- forum_topic
      self$quote <- quote
      self$reply_to_msg_id <- reply_to_msg_id
      self$reply_topeer_id <- reply_topeer_id
      self$reply_from <- reply_from
      self$reply_media <- reply_media
      self$reply_to_top_id <- reply_to_top_id
      self$quote_text <- quote_text
      self$quote_entities <- quote_entities
      self$quote_offset <- quote_offset
      self$todo_item_id <- todo_item_id
    },
    to_dict = function() {
      list(
        `_` = "MessageReplyHeader",
        reply_to_scheduled = self$reply_to_scheduled,
        forum_topic = self$forum_topic,
        quote = self$quote,
        reply_to_msg_id = self$reply_to_msg_id,
        reply_topeer_id = if (inherits(self$reply_topeer_id, "TLObject")) self$reply_topeer_id$to_dict() else self$reply_topeer_id,
        reply_from = if (inherits(self$reply_from, "TLObject")) self$reply_from$to_dict() else self$reply_from,
        reply_media = if (inherits(self$reply_media, "TLObject")) self$reply_media$to_dict() else self$reply_media,
        reply_to_top_id = self$reply_to_top_id,
        quote_text = self$quote_text,
        quote_entities = if (is.null(self$quote_entities)) NULL else lapply(self$quote_entities, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        quote_offset = self$quote_offset,
        todo_item_id = self$todo_item_id
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      reply_to_scheduled <- as.logical(bitwAnd(flags, 4))
      forum_topic <- as.logical(bitwAnd(flags, 8))
      quote <- as.logical(bitwAnd(flags, 512))

      if (bitwAnd(flags, 16) != 0) {
        reply_to_msg_id <- reader$read_int()
      } else {
        reply_to_msg_id <- NULL
      }

      if (bitwAnd(flags, 1) != 0) {
        reply_topeer_id <- reader$tgread_object()
      } else {
        reply_topeer_id <- NULL
      }

      if (bitwAnd(flags, 32) != 0) {
        reply_from <- reader$tgread_object()
      } else {
        reply_from <- NULL
      }

      if (bitwAnd(flags, 256) != 0) {
        reply_media <- reader$tgread_object()
      } else {
        reply_media <- NULL
      }

      if (bitwAnd(flags, 2) != 0) {
        reply_to_top_id <- reader$read_int()
      } else {
        reply_to_top_id <- NULL
      }

      if (bitwAnd(flags, 64) != 0) {
        quote_text <- reader$tgread_string()
      } else {
        quote_text <- NULL
      }

      if (bitwAnd(flags, 128) != 0) {
        reader$read_int()
        m <- reader$read_int()
        quote_entities <- list()
        if (m > 0) for (i in seq_len(m)) quote_entities[[i]] <- reader$tgread_object()
      } else {
        quote_entities <- NULL
      }

      if (bitwAnd(flags, 1024) != 0) {
        quote_offset <- reader$read_int()
      } else {
        quote_offset <- NULL
      }

      if (bitwAnd(flags, 2048) != 0) {
        todo_item_id <- reader$read_int()
      } else {
        todo_item_id <- NULL
      }

      self$new(
        reply_to_scheduled = reply_to_scheduled, forum_topic = forum_topic, quote = quote,
        reply_to_msg_id = reply_to_msg_id, reply_topeer_id = reply_topeer_id,
        reply_from = reply_from, reply_media = reply_media, reply_to_top_id = reply_to_top_id,
        quote_text = quote_text, quote_entities = quote_entities, quote_offset = quote_offset,
        todo_item_id = todo_item_id
      )
    }
  ),
  class = TRUE
)

#  @title MessageReplyStoryHeader
#  @description Telegram API type MessageReplyStoryHeader
#  @export
#  @noRd
#  @noRd
MessageReplyStoryHeader <- R6::R6Class(
  "MessageReplyStoryHeader",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x0e5af939,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5b4d9167,
    #  @field peer Field.
    peer = NULL,
    #  @field story_id Field.
    story_id = NULL,
    initialize = function(peer, story_id) {
      self$peer <- peer
      self$story_id <- story_id
    },
    to_dict = function() {
      list(
        `_` = "MessageReplyStoryHeader",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        story_id = self$story_id
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      story_id <- reader$read_int()
      self$new(peer = peer, story_id = story_id)
    }
  ),
  class = TRUE
)

#  @title MessageReportOption
#  @description Telegram API type MessageReportOption
#  @export
#  @noRd
#  @noRd
MessageReportOption <- R6::R6Class(
  "MessageReportOption",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7903e3d9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xfd79af88,
    #  @field text Field.
    text = NULL,
    #  @field option Field.
    option = NULL,
    initialize = function(text, option) {
      self$text <- text
      self$option <- option
    },
    to_dict = function() list(`_` = "MessageReportOption", text = self$text, option = self$option),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      text <- reader$tgread_string()
      option <- reader$tgreadbytes()
      self$new(text = text, option = option)
    }
  ),
  class = TRUE
)

#  @title MessageService
#  @description Telegram API type MessageService
#  @export
#  @noRd
#  @noRd
MessageService <- R6::R6Class("MessageService",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7a800e0a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x790009e3,
    #  @field id Field.
    id = NULL,
    #  @field peer_id Field.
    peer_id = NULL,
    #  @field date Field.
    date = NULL,
    #  @field action Field.
    action = NULL,
    #  @field out Field.
    out = NULL,
    #  @field mentioned Field.
    mentioned = NULL,
    #  @field media_unread Field.
    media_unread = NULL,
    #  @field reactions_are_possible Field.
    reactions_are_possible = NULL,
    #  @field silent Field.
    silent = NULL,
    #  @field post Field.
    post = NULL,
    #  @field legacy Field.
    legacy = NULL,
    #  @field from_id Field.
    from_id = NULL,
    #  @field savedpeer_id Field.
    savedpeer_id = NULL,
    #  @field reply_to Field.
    reply_to = NULL,
    #  @field reactions Field.
    reactions = NULL,
    #  @field ttl_period Field.
    ttl_period = NULL,
    initialize = function(id, peer_id, date = NULL, action = NULL, out = NULL, mentioned = NULL,
                          media_unread = NULL, reactions_are_possible = NULL, silent = NULL,
                          post = NULL, legacy = NULL, from_id = NULL, savedpeer_id = NULL,
                          reply_to = NULL, reactions = NULL, ttl_period = NULL) {
      self$id <- id
      self$peer_id <- peer_id
      self$date <- date
      self$action <- action
      self$out <- out
      self$mentioned <- mentioned
      self$media_unread <- media_unread
      self$reactions_are_possible <- reactions_are_possible
      self$silent <- silent
      self$post <- post
      self$legacy <- legacy
      self$from_id <- from_id
      self$savedpeer_id <- savedpeer_id
      self$reply_to <- reply_to
      self$reactions <- reactions
      self$ttl_period <- ttl_period
    },
    to_dict = function() {
      list(
        `_` = "MessageService",
        id = self$id,
        peer_id = if (inherits(self$peer_id, "TLObject")) self$peer_id$to_dict() else self$peer_id,
        date = self$date,
        action = if (inherits(self$action, "TLObject")) self$action$to_dict() else self$action,
        out = self$out,
        mentioned = self$mentioned,
        media_unread = self$media_unread,
        reactions_are_possible = self$reactions_are_possible,
        silent = self$silent,
        post = self$post,
        legacy = self$legacy,
        from_id = if (inherits(self$from_id, "TLObject")) self$from_id$to_dict() else self$from_id,
        savedpeer_id = if (inherits(self$savedpeer_id, "TLObject")) self$savedpeer_id$to_dict() else self$savedpeer_id,
        reply_to = if (inherits(self$reply_to, "TLObject")) self$reply_to$to_dict() else self$reply_to,
        reactions = if (inherits(self$reactions, "TLObject")) self$reactions$to_dict() else self$reactions,
        ttl_period = self$ttl_period
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      self$new()
    }
  ),
  class = TRUE
)

#  @title MessageViews
#  @description Telegram API type MessageViews
#  @export
#  @noRd
#  @noRd
MessageViews <- R6::R6Class("MessageViews",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x455b853d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x3cb083b9,
    #  @field views Field.
    views = NULL,
    #  @field forwards Field.
    forwards = NULL,
    #  @field replies Field.
    replies = NULL,
    initialize = function(views = NULL, forwards = NULL, replies = NULL) {
      self$views <- views
      self$forwards <- forwards
      self$replies <- replies
    },
    to_dict = function() {
      list(
        `_` = "MessageViews",
        views = self$views,
        forwards = self$forwards,
        replies = if (inherits(self$replies, "TLObject")) self$replies$to_dict() else self$replies
      )
    },
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    self$new()
  }),
  class = TRUE
)

#  @title MissingInvitee
#  @description Telegram API type MissingInvitee
#  @export
#  @noRd
#  @noRd
MissingInvitee <- R6::R6Class("MissingInvitee",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x628c9224,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5c8cacdc,
    #  @field user_id Field.
    user_id = NULL,
    #  @field premium_would_allow_invite Field.
    premium_would_allow_invite = NULL,
    #  @field premium_required_for_pm Field.
    premium_required_for_pm = NULL,
    initialize = function(user_id, premium_would_allow_invite = NULL, premium_required_for_pm = NULL) {
      self$user_id <- user_id
      self$premium_would_allow_invite <- premium_would_allow_invite
      self$premium_required_for_pm <- premium_required_for_pm
    },
    to_dict = function() {
      list(
        `_` = "MissingInvitee",
        user_id = self$user_id,
        premium_would_allow_invite = self$premium_would_allow_invite,
        premium_required_for_pm = self$premium_required_for_pm
      )
    },
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    self$new(0)
  }),
  class = TRUE
)

#  @title MonoForumDialog
#  @description Telegram API type MonoForumDialog
#  @export
#  @noRd
#  @noRd
MonoForumDialog <- R6::R6Class("MonoForumDialog",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x64407ea7,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x23ba6506,
    #  @field peer Field.
    peer = NULL,
    #  @field top_message Field.
    top_message = NULL,
    #  @field read_inbox_max_id Field.
    read_inbox_max_id = NULL,
    #  @field read_outbox_max_id Field.
    read_outbox_max_id = NULL,
    #  @field unread_count Field.
    unread_count = NULL,
    #  @field unread_reactions_count Field.
    unread_reactions_count = NULL,
    #  @field unread_mark Field.
    unread_mark = NULL,
    #  @field nopaid_messages_exception Field.
    nopaid_messages_exception = NULL,
    #  @field draft Field.
    draft = NULL,
    initialize = function(peer, top_message, read_inbox_max_id, read_outbox_max_id, unread_count, unread_reactions_count,
                          unread_mark = NULL, nopaid_messages_exception = NULL, draft = NULL) {
      self$peer <- peer
      self$top_message <- top_message
      self$read_inbox_max_id <- read_inbox_max_id
      self$read_outbox_max_id <- read_outbox_max_id
      self$unread_count <- unread_count
      self$unread_reactions_count <- unread_reactions_count
      self$unread_mark <- unread_mark
      self$nopaid_messages_exception <- nopaid_messages_exception
      self$draft <- draft
    },
    to_dict = function() {
      list(
        `_` = "MonoForumDialog",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        top_message = self$top_message,
        read_inbox_max_id = self$read_inbox_max_id,
        read_outbox_max_id = self$read_outbox_max_id,
        unread_count = self$unread_count,
        unread_reactions_count = self$unread_reactions_count,
        unread_mark = self$unread_mark,
        nopaid_messages_exception = self$nopaid_messages_exception,
        draft = if (inherits(self$draft, "TLObject")) self$draft$to_dict() else self$draft
      )
    },
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    self$new(NULL, 0, 0, 0, 0, 0)
  }),
  class = TRUE
)

#  @title MsgDetailedInfo
#  @description Telegram API type MsgDetailedInfo
#  @export
#  @noRd
#  @noRd
MsgDetailedInfo <- R6::R6Class("MsgDetailedInfo",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x276d3ec6,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5f32d5ee,
    #  @field msg_id Field.
    msg_id = NULL,
    #  @field answer_msg_id Field.
    answer_msg_id = NULL,
    byte_data = NULL, # Renamed to avoid duplication
    #  @field status Field.
    status = NULL,
    initialize = function(msg_id, answer_msg_id, byte_data, status) {
      self$msg_id <- msg_id
      self$answer_msg_id <- answer_msg_id
      self$byte_data <- byte_data
      self$status <- status
    },
    to_dict = function() {
      list(
        `_` = "MsgDetailedInfo",
        msg_id = self$msg_id,
        answer_msg_id = self$answer_msg_id,
        byte_data = self$byte_data,
        status = self$status
      )
    }
  ),
  private = list(from_reader = function(reader) {
    msg_id <- reader$read_long()
    answer_msg_id <- reader$read_long()
    byte_data <- reader$read_int()
    status <- reader$read_int()
    MsgDetailedInfo$new(msg_id, answer_msg_id, byte_data, status)
  }),
  class = TRUE
)

#  @title MsgNewDetailedInfo
#  @description Telegram API type MsgNewDetailedInfo
#  @export
#  @noRd
#  @noRd
MsgNewDetailedInfo <- R6::R6Class("MsgNewDetailedInfo",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x809db6df,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5f32d5ee,
    #  @field answer_msg_id Field.
    answer_msg_id = NULL,
    #  @field byte_data Field.
    byte_data = NULL,
    #  @field status Field.
    status = NULL,
    initialize = function(answer_msg_id, byte_data, status) {
      self$answer_msg_id <- answer_msg_id
      self$byte_data <- byte_data
      self$status <- status
    },
    to_dict = function() {
      list(
        `_` = "MsgNewDetailedInfo",
        answer_msg_id = self$answer_msg_id,
        byte_data = self$byte_data,
        status = self$status
      )
    },
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    answer_msg_id <- reader$read_long()
    byte_data <- reader$read_int()
    status <- reader$read_int()
    MsgNewDetailedInfo$new(answer_msg_id, byte_data, status)
  }),
  class = TRUE
)

#  @title MsgResendReq
#  @description Telegram API type MsgResendReq
#  @export
#  @noRd
#  @noRd
MsgResendReq <- R6::R6Class("MsgResendReq",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7d861a08,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x2024514,
    #  @field msg_ids Field.
    msg_ids = NULL,
    initialize = function(msg_ids) {
      self$msg_ids <- msg_ids
    },
    to_dict = function() {
      list(
        `_` = "MsgResendReq",
        msg_ids = if (is.null(self$msg_ids)) NULL else self$msg_ids
      )
    },
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    reader$read_int(signed = FALSE) # vector constructor id 0x1cb5c415
    count <- reader$read_int()
    msg_ids <- list()
    for (i in seq_len(count)) {
      msg_ids[[i]] <- reader$read_long()
    }
    MsgResendReq$new(msg_ids)
  }),
  class = TRUE
)

#  @title MsgsAck
#  @description Telegram API type MsgsAck
#  @export
#  @noRd
#  @noRd
MsgsAck <- R6::R6Class("MsgsAck",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x62d6b459,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x827677c4,
    #  @field msg_ids Field.
    msg_ids = NULL,
    initialize = function(msg_ids = NULL) {
      self$msg_ids <- msg_ids
    },
    to_dict = function() list(`_` = "MsgsAck", msg_ids = if (is.null(self$msg_ids)) NULL else self$msg_ids),
    bytes = function() {
      c(
        as.raw(c(0x59, 0xb4, 0xd6, 0x62)),
        packInt32(0x1cb5c415),
        packInt32(length(self$msg_ids)),
        do.call(c, lapply(self$msg_ids, function(id) packInt64(id)))
      )
    }
  ),
  private = list(from_reader = function(reader) {
    vector_id <- reader$read_int(signed = FALSE)
    count <- reader$read_int()
    msg_ids <- list()
    for (i in seq_len(count)) {
      msg_ids[[i]] <- reader$read_long()
    }
    MsgsAck$new(msg_ids)
  }),
  class = TRUE
)

#  @title MsgsAllInfo
#  @description Telegram API type MsgsAllInfo
#  @export
#  @noRd
#  @noRd
MsgsAllInfo <- R6::R6Class("MsgsAllInfo",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8cc0d131,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xfa8fcb54,
    #  @field msg_ids Field.
    msg_ids = NULL,
    #  @field info Field.
    info = NULL,
    initialize = function(msg_ids, info) {
      self$msg_ids <- msg_ids
      self$info <- info
    },
    to_dict = function() list(`_` = "MsgsAllInfo", msg_ids = if (is.null(self$msg_ids)) NULL else self$msg_ids, info = self$info),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    reader$read_int(signed = FALSE) # vector constructor id 0x1cb5c415
    count <- reader$read_int()
    msg_ids <- list()
    for (i in seq_len(count)) {
      msg_ids[[i]] <- reader$read_long()
    }
    info <- reader$tgread_string()
    MsgsAllInfo$new(msg_ids, info)
  }),
  class = TRUE
)

#  @title MsgsStateInfo
#  @description Telegram API type MsgsStateInfo
#  @export
#  @noRd
#  @noRd
MsgsStateInfo <- R6::R6Class("MsgsStateInfo",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x04deb57d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x70a0a64,
    #  @field req_msg_id Field.
    req_msg_id = NULL,
    #  @field info Field.
    info = NULL,
    initialize = function(req_msg_id, info) {
      self$req_msg_id <- req_msg_id
      self$info <- info
    },
    to_dict = function() list(`_` = "MsgsStateInfo", req_msg_id = self$req_msg_id, info = self$info),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    req_msg_id <- reader$read_long()
    info <- reader$tgread_string()
    MsgsStateInfo$new(req_msg_id, info)
  }),
  class = TRUE
)

#  @title MsgsStateReq
#  @description Telegram API type MsgsStateReq
#  @export
#  @noRd
#  @noRd
MsgsStateReq <- R6::R6Class("MsgsStateReq",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xda69fb52,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x18f01dd0,
    #  @field msg_ids Field.
    msg_ids = NULL,
    initialize = function(msg_ids) {
      self$msg_ids <- msg_ids
    },
    to_dict = function() list(`_` = "MsgsStateReq", msg_ids = if (is.null(self$msg_ids)) NULL else self$msg_ids),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    reader$read_int(signed = FALSE) # vector constructor id 0x1cb5c415
    count <- reader$read_int()
    msg_ids <- list()
    for (i in seq_len(count)) {
      msg_ids[[i]] <- reader$read_long()
    }
    MsgsStateReq$new(msg_ids)
  }),
  class = TRUE
)

#  @title MyBoost
#  @description Telegram API type MyBoost
#  @export
#  @noRd
#  @noRd
MyBoost <- R6::R6Class("MyBoost",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc448415c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc51a68bf,
    #  @field slot Field.
    slot = NULL,
    #  @field date Field.
    date = NULL,
    #  @field expires Field.
    expires = NULL,
    #  @field peer Field.
    peer = NULL,
    #  @field cooldown_until_date Field.
    cooldown_until_date = NULL,
    initialize = function(slot, date = NULL, expires = NULL, peer = NULL, cooldown_until_date = NULL) {
      self$slot <- slot
      self$date <- date
      self$expires <- expires
      self$peer <- peer
      self$cooldown_until_date <- cooldown_until_date
    },
    to_dict = function() {
      list(
        `_` = "MyBoost",
        slot = self$slot,
        date = self$date,
        expires = self$expires,
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        cooldown_until_date = self$cooldown_until_date
      )
    },
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    self$new(0)
  }),
  class = TRUE
)

#  @title NearestDc
#  @description Telegram API type NearestDc
#  @export
#  @noRd
#  @noRd
NearestDc <- R6::R6Class("NearestDc",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8e1a1775,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x3877045f,
    #  @field country Field.
    country = NULL,
    #  @field this_dc Field.
    this_dc = NULL,
    #  @field nearest_dc Field.
    nearest_dc = NULL,
    initialize = function(country, this_dc, nearest_dc) {
      self$country <- country
      self$this_dc <- this_dc
      self$nearest_dc <- nearest_dc
    },
    to_dict = function() list(`_` = "NearestDc", country = self$country, this_dc = self$this_dc, nearest_dc = self$nearest_dc),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    self$new("", 0, 0)
  }),
  class = TRUE
)

#  @title NewSessionCreated
#  @description Telegram API type NewSessionCreated
#  @export
#  @noRd
#  @noRd
NewSessionCreated <- R6::R6Class("NewSessionCreated",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9ec20908,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x510d3031,
    #  @field first_msg_id Field.
    first_msg_id = NULL,
    #  @field unique_id Field.
    unique_id = NULL,
    #  @field server_salt Field.
    server_salt = NULL,
    initialize = function(first_msg_id = NULL, unique_id = NULL, server_salt = NULL) {
      self$first_msg_id <- first_msg_id
      self$unique_id <- unique_id
      self$server_salt <- server_salt
    },
    to_dict = function() list(`_` = "NewSessionCreated", first_msg_id = self$first_msg_id, unique_id = self$unique_id, server_salt = self$server_salt),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    first_msg_id <- reader$read_long()
    unique_id <- reader$read_long()
    server_salt <- reader$read_long()
    NewSessionCreated$new(first_msg_id, unique_id, server_salt)
  }),
  class = TRUE
)

#  @title NotificationSoundDefault
#  @description Telegram API type NotificationSoundDefault
#  @export
#  @noRd
#  @noRd
NotificationSoundDefault <- R6::R6Class("NotificationSoundDefault",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x97e8bebe,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf2f5e55b,
    initialize = function() {},
    to_dict = function() list(`_` = "NotificationSoundDefault"),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    self$new()
  }),
  class = TRUE
)

#  @title NotificationSoundLocal
#  @description Telegram API type NotificationSoundLocal
#  @export
#  @noRd
#  @noRd
NotificationSoundLocal <- R6::R6Class("NotificationSoundLocal",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x830b9ae4,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf2f5e55b,
    #  @field title Field.
    title = NULL,
    #  @field data Field.
    data = NULL,
    initialize = function(title, data) {
      self$title <- title
      self$data <- data
    },
    to_dict = function() list(`_` = "NotificationSoundLocal", title = self$title, data = self$data),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    self$new("", "")
  }),
  class = TRUE
)

#  @title NotificationSoundNone
#  @description Telegram API type NotificationSoundNone
#  @export
#  @noRd
#  @noRd
NotificationSoundNone <- R6::R6Class("NotificationSoundNone",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x6f0c34df,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf2f5e55b,
    initialize = function() {},
    to_dict = function() list(`_` = "NotificationSoundNone"),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    self$new()
  }),
  class = TRUE
)

#  @title NotificationSoundRingtone
#  @description Telegram API type NotificationSoundRingtone
#  @export
#  @noRd
#  @noRd
NotificationSoundRingtone <- R6::R6Class("NotificationSoundRingtone",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xff6c8049,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf2f5e55b,
    #  @field id Field.
    id = NULL,
    initialize = function(id) {
      self$id <- id
    },
    to_dict = function() list(`_` = "NotificationSoundRingtone", id = self$id),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    self$new(0)
  }),
  class = TRUE
)

#  @title NotifyBroadcasts
#  @description Telegram API type NotifyBroadcasts
#  @export
#  @noRd
#  @noRd
NotifyBroadcasts <- R6::R6Class("NotifyBroadcasts",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd612e8ef,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xdfe8602e,
    initialize = function() {},
    to_dict = function() list(`_` = "NotifyBroadcasts"),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    self$new()
  }),
  class = TRUE
)

#  @title NotifyChats
#  @description Telegram API type NotifyChats
#  @export
#  @noRd
#  @noRd
NotifyChats <- R6::R6Class("NotifyChats",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc007cec3,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xdfe8602e,
    initialize = function() {},
    to_dict = function() list(`_` = "NotifyChats"),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    self$new()
  }),
  class = TRUE
)

#  @title NotifyForumTopic
#  @description Telegram API type NotifyForumTopic
#  @export
#  @noRd
#  @noRd
NotifyForumTopic <- R6::R6Class("NotifyForumTopic",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x226e6308,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xdfe8602e,
    #  @field peer Field.
    peer = NULL,
    #  @field top_msg_id Field.
    top_msg_id = NULL,
    initialize = function(peer, top_msg_id) {
      self$peer <- peer
      self$top_msg_id <- top_msg_id
    },
    to_dict = function() {
      list(
        `_` = "NotifyForumTopic",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        top_msg_id = self$top_msg_id
      )
    },
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    self$new(NULL, 0)
  }),
  class = TRUE
)

#  @title NotifyPeer
#  @description Telegram API type NotifyPeer
#  @export
#  @noRd
#  @noRd
NotifyPeer <- R6::R6Class("NotifyPeer",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9fd40bd8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xdfe8602e,
    #  @field peer Field.
    peer = NULL,
    initialize = function(peer) {
      self$peer <- peer
    },
    to_dict = function() list(`_` = "NotifyPeer", peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    self$new(NULL)
  }),
  class = TRUE
)

#  @title NotifyUsers
#  @description Telegram API type NotifyUsers
#  @export
#  @noRd
#  @noRd
NotifyUsers <- R6::R6Class("NotifyUsers",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb4c83b4c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xdfe8602e,
    initialize = function() {},
    to_dict = function() list(`_` = "NotifyUsers"),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    self$new()
  }),
  class = TRUE
)

#  @title OutboxReadDate
#  @description Telegram API type OutboxReadDate
#  @export
#  @noRd
#  @noRd
OutboxReadDate <- R6::R6Class("OutboxReadDate",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x3bb842ac,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x6f5183c6,
    #  @field date Field.
    date = NULL,
    initialize = function(date = NULL) {
      self$date <- date
    },
    to_dict = function() list(`_` = "OutboxReadDate", date = self$date),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    self$new(NULL)
  }),
  class = TRUE
)

#  PQInnerData
# 
#  This class has 4 constructors:
#  - \code{\link{PQInnerData}()}
#  - \code{\link{PQInnerDataDc}()}
#  - \code{\link{PQInnerDataTemp}()}
#  - \code{\link{PQInnerDataTempDc}()}
# 
#   pq
#   p
#   q
#   nonce
#   server_nonce
#   new_nonce
#   dc
#   expires_in
#   slot
#   date
#   expires
#   peer
#   cooldown_until_date
#  @title PQInnerData
#  @description Telegram API type PQInnerData
#  @export
#  @noRd
#  @noRd
PQInnerData <- R6::R6Class("PQInnerData",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Integer. Constructor ID of the class.
    CONSTRUCTOR_ID = 0x83c95aec,

    #  @field SUBCLASS_OF_ID Integer. Subclass of ID of the parent class.
    SUBCLASS_OF_ID = 0x41701377,

    #  @field pq Integer. Subclass of ID of the parent class.
    pq = NULL,

    #  @field peer Object. Peer where the story is from.
    p = NULL,

    #  @field id Integer. Story ID.
    #  @field q Field.
    q = NULL,

    #  @field via_mention Logical. Whether the story was sent via mention.
    #  @field nonce Field.
    nonce = NULL,

    #  @field story Object. Story object.
    #  @field server_nonce Field.
    server_nonce = NULL,

    #  @field new_nonce Logical. New nonce for the story.
    new_nonce = NULL,
    initialize = function(pq, p, q, nonce, server_nonce, new_nonce) {
      self$pq <- pq
      self$p <- p
      self$q <- q
      self$nonce <- nonce
      self$server_nonce <- server_nonce
      self$new_nonce <- new_nonce
    },
    to_dict = function() list(`_` = "PQInnerData", pq = self$pq, p = self$p, q = self$q, nonce = self$nonce, server_nonce = self$server_nonce, new_nonce = self$new_nonce),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    self$new(raw(0), raw(0), raw(0), 0, 0, 0)
  }),
  class = TRUE
)

#  @title PQInnerDataDc
#  @description Telegram API type PQInnerDataDc
#  @export
#  @noRd
#  @noRd
PQInnerDataDc <- R6::R6Class("PQInnerDataDc",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa9f55f95,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x41701377,
    #  @field pq Field.
    pq = NULL,
    #  @field p Field.
    p = NULL,
    #  @field q Field.
    q = NULL,
    #  @field nonce Field.
    nonce = NULL,
    #  @field server_nonce Field.
    server_nonce = NULL,
    #  @field new_nonce Field.
    new_nonce = NULL,
    #  @field dc Field.
    dc = NULL,
    initialize = function(pq, p, q, nonce, server_nonce, new_nonce, dc) {
      self$pq <- pq
      self$p <- p
      self$q <- q
      self$nonce <- nonce
      self$server_nonce <- server_nonce
      self$new_nonce <- new_nonce
      self$dc <- dc
    },
    to_dict = function() list(`_` = "PQInnerDataDc", pq = self$pq, p = self$p, q = self$q, nonce = self$nonce, server_nonce = self$server_nonce, new_nonce = self$new_nonce, dc = self$dc),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    self$new(raw(0), raw(0), raw(0), 0, 0, 0, 0)
  }),
  class = TRUE
)

#  @title PQInnerDataTemp
#  @description Telegram API type PQInnerDataTemp
#  @export
#  @noRd
#  @noRd
PQInnerDataTemp <- R6::R6Class("PQInnerDataTemp",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x3c6a84d4,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x41701377,
    #  @field pq Field.
    pq = NULL,
    #  @field p Field.
    p = NULL,
    #  @field q Field.
    q = NULL,
    #  @field nonce Field.
    nonce = NULL,
    #  @field server_nonce Field.
    server_nonce = NULL,
    #  @field new_nonce Field.
    new_nonce = NULL,
    #  @field expires_in Field.
    expires_in = NULL,
    initialize = function(pq, p, q, nonce, server_nonce, new_nonce, expires_in) {
      self$pq <- pq
      self$p <- p
      self$q <- q
      self$nonce <- nonce
      self$server_nonce <- server_nonce
      self$new_nonce <- new_nonce
      self$expires_in <- expires_in
    },
    to_dict = function() list(`_` = "PQInnerDataTemp", pq = self$pq, p = self$p, q = self$q, nonce = self$nonce, server_nonce = self$server_nonce, new_nonce = self$new_nonce, expires_in = self$expires_in),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    self$new(raw(0), raw(0), raw(0), 0, 0, 0, 0)
  }),
  class = TRUE
)

#  @title PQInnerDataTempDc
#  @description Telegram API type PQInnerDataTempDc
#  @export
#  @noRd
#  @noRd
PQInnerDataTempDc <- R6::R6Class("PQInnerDataTempDc",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x56fddf88,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x41701377,
    #  @field pq Field.
    pq = NULL,
    #  @field p Field.
    p = NULL,
    #  @field q Field.
    q = NULL,
    #  @field nonce Field.
    nonce = NULL,
    #  @field server_nonce Field.
    server_nonce = NULL,
    #  @field new_nonce Field.
    new_nonce = NULL,
    #  @field dc Field.
    dc = NULL,
    #  @field expires_in Field.
    expires_in = NULL,
    initialize = function(pq, p, q, nonce, server_nonce, new_nonce, dc, expires_in) {
      self$pq <- pq
      self$p <- p
      self$q <- q
      self$nonce <- nonce
      self$server_nonce <- server_nonce
      self$new_nonce <- new_nonce
      self$dc <- dc
      self$expires_in <- expires_in
    },
    to_dict = function() list(`_` = "PQInnerDataTempDc", pq = self$pq, p = self$p, q = self$q, nonce = self$nonce, server_nonce = self$server_nonce, new_nonce = self$new_nonce, dc = self$dc, expires_in = self$expires_in),
    bytes = function() raw(0)
  ),
  private = list(from_reader = function(reader) {
    self$new(raw(0), raw(0), raw(0), 0, 0, 0, 0, 0)
  }),
  class = TRUE
)

#  @title PQInnerDataTempDc
#  @description Telegram API type PQInnerDataTempDc
#  @export
#  @noRd
#  @noRd
PQInnerDataTempDc <- R6::R6Class(
  "PQInnerDataTempDc",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x56fddf88,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x41701377,
    #  @field pq Field.
    pq = NULL,
    #  @field p Field.
    p = NULL,
    #  @field q Field.
    q = NULL,
    #  @field nonce Field.
    nonce = NULL,
    #  @field server_nonce Field.
    server_nonce = NULL,
    #  @field new_nonce Field.
    new_nonce = NULL,
    #  @field dc Field.
    dc = NULL,
    #  @field expires_in Field.
    expires_in = NULL,
    initialize = function(pq = NULL, p = NULL, q = NULL, nonce = NULL, server_nonce = NULL, new_nonce = NULL, dc = NULL, expires_in = NULL) {
      self$pq <- pq
      self$p <- p
      self$q <- q
      self$nonce <- nonce
      self$server_nonce <- server_nonce
      self$new_nonce <- new_nonce
      self$dc <- dc
      self$expires_in <- expires_in
    },
    to_dict = function() {
      list(
        `_` = "PQInnerDataTempDc",
        pq = self$pq,
        p = self$p,
        q = self$q,
        nonce = self$nonce,
        server_nonce = self$server_nonce,
        new_nonce = self$new_nonce,
        dc = self$dc,
        expires_in = self$expires_in
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      pq <- reader$tgreadbytes()
      p <- reader$tgreadbytes()
      q <- reader$tgreadbytes()
      nonce_val <- reader$tgreadbytes()
      server_nonce_val <- reader$tgreadbytes()
      new_nonce_val <- reader$tgreadbytes()
      dc <- reader$read_int()
      expires_in <- reader$read_int()
      self$new(pq = pq, p = p, q = q, nonce = nonce_val, server_nonce = server_nonce_val, new_nonce = new_nonce_val, dc = dc, expires_in = expires_in)
    }
  ),
  class = TRUE
)

#  @title Page
#  @description Telegram API type Page
#  @export
#  @noRd
#  @noRd
Page <- R6::R6Class(
  "Page",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x98657f0d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb438191e,
    #  @field url Field.
    url = NULL,
    #  @field blocks Field.
    blocks = NULL,
    #  @field photos Field.
    photos = NULL,
    #  @field documents Field.
    documents = NULL,
    #  @field part Field.
    part = NULL,
    #  @field rtl Field.
    rtl = NULL,
    #  @field v2 Field.
    v2 = NULL,
    #  @field views Field.
    views = NULL,
    initialize = function(url = NULL, blocks = list(), photos = list(), documents = list(), part = NULL, rtl = NULL, v2 = NULL, views = NULL) {
      self$url <- url
      self$blocks <- blocks
      self$photos <- photos
      self$documents <- documents
      self$part <- part
      self$rtl <- rtl
      self$v2 <- v2
      self$views <- views
    },
    to_dict = function() {
      list(
        `_` = "Page",
        url = self$url,
        blocks = self$blocks,
        photos = self$photos,
        documents = self$documents,
        part = self$part,
        rtl = self$rtl,
        v2 = self$v2,
        views = self$views
      )
    },
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      part <- as.logical(bitwAnd(flags, 1))
      rtl <- as.logical(bitwAnd(flags, 2))
      v2 <- as.logical(bitwAnd(flags, 4))
      url <- reader$tgread_string()
      n_blocks <- reader$read_int()
      blocks <- vector("list", n_blocks)
      if (n_blocks > 0) for (i in seq_len(n_blocks)) blocks[[i]] <- reader$tgread_object()
      n_photos <- reader$read_int()
      photos <- vector("list", n_photos)
      if (n_photos > 0) for (i in seq_len(n_photos)) photos[[i]] <- reader$tgread_object()
      n_docs <- reader$read_int()
      documents <- vector("list", n_docs)
      if (n_docs > 0) for (i in seq_len(n_docs)) documents[[i]] <- reader$tgread_object()
      views <- if (bitwAnd(flags, 8) != 0) reader$read_int() else NULL
      self$new(url = url, blocks = blocks, photos = photos, documents = documents, part = part, rtl = rtl, v2 = v2, views = views)
    }
  ),
  class = TRUE
)

#  @title PageBlockAnchor
#  @description Telegram API type PageBlockAnchor
#  @export
#  @noRd
#  @noRd
PageBlockAnchor <- R6::R6Class(
  "PageBlockAnchor",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xce0d37b0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1aca5644,
    #  @field name Field.
    name = NULL,
    initialize = function(name) {
      self$name <- name
    },
    to_dict = function() {
      list(
        `_` = "PageBlockAnchor",
        name = self$name
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xb0, 0x7d, 0x0d, 0xce)),
        self$serialize_bytes(self$name)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      name <- reader$tgread_string()
      self$new(name = name)
    }
  ),
  class = TRUE
)

#  @title PageBlockAudio
#  @description Telegram API type PageBlockAudio
#  @export
#  @noRd
#  @noRd
PageBlockAudio <- R6::R6Class(
  "PageBlockAudio",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x804361ea,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1aca5644,
    #  @field audio_id Field.
    audio_id = NULL,
    #  @field caption Field.
    caption = NULL,
    initialize = function(audio_id = NULL, caption = NULL) {
      self$audio_id <- audio_id
      self$caption <- caption
    },
    to_dict = function() list(`_` = "PageBlockAudio", audio_id = self$audio_id, caption = self$caption),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      audio_id <- reader$read_long()
      caption <- reader$tgread_object()
      self$new(audio_id = audio_id, caption = caption)
    }
  ),
  class = TRUE
)

#  @title PageBlockAuthorDate
#  @description Telegram API type PageBlockAuthorDate
#  @export
#  @noRd
#  @noRd
PageBlockAuthorDate <- R6::R6Class(
  "PageBlockAuthorDate",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbaafe5e0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1aca5644,
    #  @field author Field.
    author = NULL,
    #  @field published_date Field.
    published_date = NULL,
    initialize = function(author = NULL, published_date = NULL) {
      self$author <- author
      self$published_date <- published_date
    },
    to_dict = function() list(`_` = "PageBlockAuthorDate", author = self$author, published_date = self$published_date),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      author <- reader$tgread_object()
      published_date <- reader$tgread_date()
      self$new(author = author, published_date = published_date)
    }
  ),
  class = TRUE
)

#  @title PageBlockBlockquote
#  @description Telegram API type PageBlockBlockquote
#  @export
#  @noRd
#  @noRd
PageBlockBlockquote <- R6::R6Class(
  "PageBlockBlockquote",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x263d7c26,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1aca5644,
    #  @field text Field.
    text = NULL,
    #  @field caption Field.
    caption = NULL,
    initialize = function(text = NULL, caption = NULL) {
      self$text <- text
      self$caption <- caption
    },
    to_dict = function() list(`_` = "PageBlockBlockquote", text = self$text, caption = self$caption),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      text <- reader$tgread_object()
      caption <- reader$tgread_object()
      self$new(text = text, caption = caption)
    }
  ),
  class = TRUE
)

#  @title PageBlockChannel
#  @description Telegram API type PageBlockChannel
#  @export
#  @noRd
#  @noRd
PageBlockChannel <- R6::R6Class(
  "PageBlockChannel",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xef1751b5,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1aca5644,
    #  @field channel Field.
    channel = NULL,
    initialize = function(channel = NULL) {
      self$channel <- channel
    },
    to_dict = function() list(`_` = "PageBlockChannel", channel = self$channel),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      channel <- reader$tgread_object()
      self$new(channel = channel)
    }
  ),
  class = TRUE
)

#  @title PageBlockCollage
#  @description Telegram API type PageBlockCollage
#  @export
#  @noRd
#  @noRd
PageBlockCollage <- R6::R6Class(
  "PageBlockCollage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x65a0fa4d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1aca5644,
    #  @field items Field.
    items = NULL,
    #  @field caption Field.
    caption = NULL,
    initialize = function(items = list(), caption = NULL) {
      self$items <- items
      self$caption <- caption
    },
    to_dict = function() list(`_` = "PageBlockCollage", items = self$items, caption = self$caption),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      n_items <- reader$read_int()
      items <- vector("list", n_items)
      if (n_items > 0) for (i in seq_len(n_items)) items[[i]] <- reader$tgread_object()
      caption <- reader$tgread_object()
      self$new(items = items, caption = caption)
    }
  ),
  class = TRUE
)

#  @title PageBlockCover
#  @description Telegram API type PageBlockCover
#  @export
#  @noRd
#  @noRd
PageBlockCover <- R6::R6Class(
  "PageBlockCover",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x39f23300,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1aca5644,
    #  @field cover Field.
    cover = NULL,
    initialize = function(cover = NULL) {
      self$cover <- cover
    },
    to_dict = function() list(`_` = "PageBlockCover", cover = self$cover),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      cover <- reader$tgread_object()
      self$new(cover = cover)
    }
  ),
  class = TRUE
)

#  @title PageBlockDetails
#  @description Telegram API type PageBlockDetails
#  @export
#  @noRd
#  @noRd
PageBlockDetails <- R6::R6Class(
  "PageBlockDetails",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x76768bed,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1aca5644,
    #  @field blocks Field.
    blocks = NULL,
    #  @field title Field.
    title = NULL,
    #  @field open Field.
    open = NULL,
    initialize = function(blocks = list(), title = NULL, open = NULL) {
      self$blocks <- blocks
      self$title <- title
      self$open <- open
    },
    to_dict = function() list(`_` = "PageBlockDetails", blocks = self$blocks, title = self$title, open = self$open),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      open <- as.logical(bitwAnd(flags, 1))
      reader$read_int()
      n_blocks <- reader$read_int()
      blocks <- vector("list", n_blocks)
      if (n_blocks > 0) for (i in seq_len(n_blocks)) blocks[[i]] <- reader$tgread_object()
      title <- reader$tgread_object()
      self$new(blocks = blocks, title = title, open = open)
    }
  ),
  class = TRUE
)

#  @title PageBlockDivider
#  @description Telegram API type PageBlockDivider
#  @export
#  @noRd
#  @noRd
PageBlockDivider <- R6::R6Class(
  "PageBlockDivider",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xdb20b188,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1aca5644,
    initialize = function() {},
    to_dict = function() list(`_` = "PageBlockDivider"),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      self$new()
    }
  ),
  class = TRUE
)

#  @title PageBlockEmbed
#  @description Telegram API type PageBlockEmbed
#  @export
#  @noRd
#  @noRd
PageBlockEmbed <- R6::R6Class(
  "PageBlockEmbed",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa8718dc5,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1aca5644,
    #  @field caption Field.
    caption = NULL,
    #  @field full_width Field.
    full_width = NULL,
    #  @field allow_scrolling Field.
    allow_scrolling = NULL,
    #  @field url Field.
    url = NULL,
    #  @field html Field.
    html = NULL,
    #  @field poster_photo_id Field.
    poster_photo_id = NULL,
    #  @field w Field.
    w = NULL,
    #  @field h Field.
    h = NULL,
    initialize = function(caption = NULL, full_width = NULL, allow_scrolling = NULL, url = NULL, html = NULL, poster_photo_id = NULL, w = NULL, h = NULL) {
      self$caption <- caption
      self$full_width <- full_width
      self$allow_scrolling <- allow_scrolling
      self$url <- url
      self$html <- html
      self$poster_photo_id <- poster_photo_id
      self$w <- w
      self$h <- h
    },
    to_dict = function() list(`_` = "PageBlockEmbed", caption = self$caption, full_width = self$full_width, allow_scrolling = self$allow_scrolling, url = self$url, html = self$html, poster_photo_id = self$poster_photo_id, w = self$w, h = self$h),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      full_width <- as.logical(bitwAnd(flags, 1))
      allow_scrolling <- as.logical(bitwAnd(flags, 8))
      url <- if (bitwAnd(flags, 2) != 0) reader$tgread_string() else NULL
      html <- if (bitwAnd(flags, 4) != 0) reader$tgread_string() else NULL
      poster_photo_id <- if (bitwAnd(flags, 16) != 0) reader$read_long() else NULL
      w <- if (bitwAnd(flags, 32) != 0) reader$read_int() else NULL
      h <- if (bitwAnd(flags, 32) != 0) reader$read_int() else NULL
      caption <- reader$tgread_object()
      self$new(caption = caption, full_width = full_width, allow_scrolling = allow_scrolling, url = url, html = html, poster_photo_id = poster_photo_id, w = w, h = h)
    }
  ),
  class = TRUE
)

#  @title PageBlockEmbedPost
#  @description Telegram API type PageBlockEmbedPost
#  @export
#  @noRd
#  @noRd
PageBlockEmbedPost <- R6::R6Class(
  "PageBlockEmbedPost",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf259a80b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1aca5644,
    #  @field url Field.
    url = NULL,
    #  @field webpage_id Field.
    webpage_id = NULL,
    #  @field author_photo_id Field.
    author_photo_id = NULL,
    #  @field author Field.
    author = NULL,
    #  @field date Field.
    date = NULL,
    #  @field blocks Field.
    blocks = NULL,
    #  @field caption Field.
    caption = NULL,
    initialize = function(url = NULL, webpage_id = NULL, author_photo_id = NULL, author = NULL, date = NULL, blocks = list(), caption = NULL) {
      self$url <- url
      self$webpage_id <- webpage_id
      self$author_photo_id <- author_photo_id
      self$author <- author
      self$date <- date
      self$blocks <- blocks
      self$caption <- caption
    },
    to_dict = function() list(`_` = "PageBlockEmbedPost", url = self$url, webpage_id = self$webpage_id, author_photo_id = self$author_photo_id, author = self$author, date = self$date, blocks = self$blocks, caption = self$caption),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      url <- reader$tgread_string()
      webpage_id <- reader$read_long()
      author_photo_id <- reader$read_long()
      author <- reader$tgread_string()
      date <- reader$tgread_date()
      reader$read_int()
      n_blocks <- reader$read_int()
      blocks <- vector("list", n_blocks)
      if (n_blocks > 0) for (i in seq_len(n_blocks)) blocks[[i]] <- reader$tgread_object()
      caption <- reader$tgread_object()
      self$new(url = url, webpage_id = webpage_id, author_photo_id = author_photo_id, author = author, date = date, blocks = blocks, caption = caption)
    }
  ),
  class = TRUE
)

#  @title PageBlockFooter
#  @description Telegram API type PageBlockFooter
#  @export
#  @noRd
#  @noRd
PageBlockFooter <- R6::R6Class(
  "PageBlockFooter",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x48870999,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1aca5644,
    #  @field text Field.
    text = NULL,
    initialize = function(text = NULL) {
      self$text <- text
    },
    to_dict = function() list(`_` = "PageBlockFooter", text = self$text),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      text <- reader$tgread_object()
      self$new(text = text)
    }
  ),
  class = TRUE
)

#  @title PageBlockHeader
#  @description Telegram API type PageBlockHeader
#  @export
#  @noRd
#  @noRd
PageBlockHeader <- R6::R6Class(
  "PageBlockHeader",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbfd064ec,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1aca5644,
    #  @field text Field.
    text = NULL,
    initialize = function(text = NULL) {
      self$text <- text
    },
    to_dict = function() list(`_` = "PageBlockHeader", text = self$text),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      text <- reader$tgread_object()
      self$new(text = text)
    }
  ),
  class = TRUE
)

#  @title PageBlockKicker
#  @description Telegram API type PageBlockKicker
#  @export
#  @noRd
#  @noRd
PageBlockKicker <- R6::R6Class(
  "PageBlockKicker",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1e148390,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1aca5644,
    #  @field text Field.
    text = NULL,
    initialize = function(text = NULL) {
      self$text <- text
    },
    to_dict = function() list(`_` = "PageBlockKicker", text = self$text),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      text <- reader$tgread_object()
      self$new(text = text)
    }
  ),
  class = TRUE
)

#  @title PageBlockList
#  @description Telegram API type PageBlockList
#  @export
#  @noRd
#  @noRd
PageBlockList <- R6::R6Class(
  "PageBlockList",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe4e88011,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1aca5644,
    #  @field items Field.
    items = NULL,
    initialize = function(items = list()) {
      self$items <- items
    },
    to_dict = function() list(`_` = "PageBlockList", items = self$items),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      n_items <- reader$read_int()
      items <- vector("list", n_items)
      if (n_items > 0) for (i in seq_len(n_items)) items[[i]] <- reader$tgread_object()
      self$new(items = items)
    }
  ),
  class = TRUE
)

#  @title PageBlockMap
#  @description Telegram API type PageBlockMap
#  @export
#  @noRd
#  @noRd
PageBlockMap <- R6::R6Class(
  "PageBlockMap",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa44f3ef6,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1aca5644,
    #  @field geo Field.
    geo = NULL,
    #  @field zoom Field.
    zoom = NULL,
    #  @field w Field.
    w = NULL,
    #  @field h Field.
    h = NULL,
    #  @field caption Field.
    caption = NULL,
    initialize = function(geo = NULL, zoom = NULL, w = NULL, h = NULL, caption = NULL) {
      self$geo <- geo
      self$zoom <- zoom
      self$w <- w
      self$h <- h
      self$caption <- caption
    },
    to_dict = function() list(`_` = "PageBlockMap", geo = self$geo, zoom = self$zoom, w = self$w, h = self$h, caption = self$caption),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      geo <- reader$tgread_object()
      zoom <- reader$read_int()
      w <- reader$read_int()
      h <- reader$read_int()
      caption <- reader$tgread_object()
      self$new(geo = geo, zoom = zoom, w = w, h = h, caption = caption)
    }
  ),
  class = TRUE
)

#  @title PageBlockOrderedList
#  @description Telegram API type PageBlockOrderedList
#  @export
#  @noRd
#  @noRd
PageBlockOrderedList <- R6::R6Class(
  "PageBlockOrderedList",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9a8ae1e1,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1aca5644,
    #  @field items Field.
    items = NULL,
    initialize = function(items = list()) {
      self$items <- items
    },
    to_dict = function() list(`_` = "PageBlockOrderedList", items = self$items),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      n_items <- reader$read_int()
      items <- vector("list", n_items)
      if (n_items > 0) for (i in seq_len(n_items)) items[[i]] <- reader$tgread_object()
      self$new(items = items)
    }
  ),
  class = TRUE
)

#  @title PageBlockParagraph
#  @description Telegram API type PageBlockParagraph
#  @export
#  @noRd
#  @noRd
PageBlockParagraph <- R6::R6Class(
  "PageBlockParagraph",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x467a0766,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1aca5644,
    #  @field text Field.
    text = NULL,
    initialize = function(text = NULL) {
      self$text <- text
    },
    to_dict = function() list(`_` = "PageBlockParagraph", text = self$text),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      text <- reader$tgread_object()
      self$new(text = text)
    }
  ),
  class = TRUE
)

#  @title PageBlockPhoto
#  @description Telegram API type PageBlockPhoto
#  @export
#  @noRd
#  @noRd
PageBlockPhoto <- R6::R6Class(
  "PageBlockPhoto",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1759c560,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1aca5644,
    #  @field photo_id Field.
    photo_id = NULL,
    #  @field caption Field.
    caption = NULL,
    #  @field url Field.
    url = NULL,
    #  @field webpage_id Field.
    webpage_id = NULL,
    initialize = function(photo_id = NULL, caption = NULL, url = NULL, webpage_id = NULL) {
      self$photo_id <- photo_id
      self$caption <- caption
      self$url <- url
      self$webpage_id <- webpage_id
    },
    to_dict = function() list(`_` = "PageBlockPhoto", photo_id = self$photo_id, caption = self$caption, url = self$url, webpage_id = self$webpage_id),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      photo_id <- reader$read_long()
      caption <- reader$tgread_object()
      url <- if (bitwAnd(flags, 1) != 0) reader$tgread_string() else NULL
      webpage_id <- if (bitwAnd(flags, 1) != 0) reader$read_long() else NULL
      self$new(photo_id = photo_id, caption = caption, url = url, webpage_id = webpage_id)
    }
  ),
  class = TRUE
)

#  @title PageBlockPreformatted
#  @description Telegram API type PageBlockPreformatted
#  @export
#  @noRd
#  @noRd
PageBlockPreformatted <- R6::R6Class(
  "PageBlockPreformatted",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc070d93e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1aca5644,
    #  @field text Field.
    text = NULL,
    #  @field language Field.
    language = NULL,
    initialize = function(text = NULL, language = NULL) {
      self$text <- text
      self$language <- language
    },
    to_dict = function() list(`_` = "PageBlockPreformatted", text = self$text, language = self$language),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      text <- reader$tgread_object()
      language <- reader$tgread_string()
      self$new(text = text, language = language)
    }
  ),
  class = TRUE
)

#  @title PageBlockPullquote
#  @description Telegram API type PageBlockPullquote
#  @export
#  @noRd
#  @noRd
PageBlockPullquote <- R6::R6Class(
  "PageBlockPullquote",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4f4456d3,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1aca5644,
    #  @field text Field.
    text = NULL,
    #  @field caption Field.
    caption = NULL,
    initialize = function(text = NULL, caption = NULL) {
      self$text <- text
      self$caption <- caption
    },
    to_dict = function() list(`_` = "PageBlockPullquote", text = self$text, caption = self$caption),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      text <- reader$tgread_object()
      caption <- reader$tgread_object()
      self$new(text = text, caption = caption)
    }
  ),
  class = TRUE
)

#  @title PageBlockRelatedArticles
#  @description Telegram API type PageBlockRelatedArticles
#  @export
#  @noRd
#  @noRd
PageBlockRelatedArticles <- R6::R6Class(
  "PageBlockRelatedArticles",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x16115a96,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1aca5644,
    #  @field title Field.
    title = NULL,
    #  @field articles Field.
    articles = NULL,
    initialize = function(title = NULL, articles = list()) {
      self$title <- title
      self$articles <- articles
    },
    to_dict = function() list(`_` = "PageBlockRelatedArticles", title = self$title, articles = self$articles),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      title <- reader$tgread_object()
      reader$read_int()
      n_articles <- reader$read_int()
      articles <- vector("list", n_articles)
      if (n_articles > 0) for (i in seq_len(n_articles)) articles[[i]] <- reader$tgread_object()
      self$new(title = title, articles = articles)
    }
  ),
  class = TRUE
)

#  @title PageBlockSlideshow
#  @description Telegram API type PageBlockSlideshow
#  @export
#  @noRd
#  @noRd
PageBlockSlideshow <- R6::R6Class(
  "PageBlockSlideshow",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x031f9590,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1aca5644,
    #  @field items Field.
    items = NULL,
    #  @field caption Field.
    caption = NULL,
    initialize = function(items = list(), caption = NULL) {
      self$items <- items
      self$caption <- caption
    },
    to_dict = function() list(`_` = "PageBlockSlideshow", items = self$items, caption = self$caption),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      n_items <- reader$read_int()
      items <- vector("list", n_items)
      if (n_items > 0) for (i in seq_len(n_items)) items[[i]] <- reader$tgread_object()
      caption <- reader$tgread_object()
      self$new(items = items, caption = caption)
    }
  ),
  class = TRUE
)

#  @title PageBlockSubheader
#  @description Telegram API type PageBlockSubheader
#  @export
#  @noRd
#  @noRd
PageBlockSubheader <- R6::R6Class(
  "PageBlockSubheader",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf12bb6e1,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1aca5644,
    #  @field text Field.
    text = NULL,
    initialize = function(text = NULL) {
      self$text <- text
    },
    to_dict = function() list(`_` = "PageBlockSubheader", text = self$text),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      text <- reader$tgread_object()
      self$new(text = text)
    }
  ),
  class = TRUE
)

#  @title PageBlockSubtitle
#  @description Telegram API type PageBlockSubtitle
#  @export
#  @noRd
#  @noRd
PageBlockSubtitle <- R6::R6Class(
  "PageBlockSubtitle",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8ffa9a1f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1aca5644,
    #  @field text Field.
    text = NULL,
    initialize = function(text = NULL) {
      self$text <- text
    },
    to_dict = function() list(`_` = "PageBlockSubtitle", text = self$text),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      text <- reader$tgread_object()
      self$new(text = text)
    }
  ),
  class = TRUE
)

#  @title PageBlockTable
#  @description Telegram API type PageBlockTable
#  @export
#  @noRd
#  @noRd
PageBlockTable <- R6::R6Class(
  "PageBlockTable",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbf4dea82,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1aca5644,
    #  @field title Field.
    title = NULL,
    #  @field rows Field.
    rows = NULL,
    #  @field bordered Field.
    bordered = NULL,
    #  @field striped Field.
    striped = NULL,
    initialize = function(title = NULL, rows = list(), bordered = NULL, striped = NULL) {
      self$title <- title
      self$rows <- rows
      self$bordered <- bordered
      self$striped <- striped
    },
    to_dict = function() list(`_` = "PageBlockTable", title = self$title, rows = self$rows, bordered = self$bordered, striped = self$striped),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      bordered <- as.logical(bitwAnd(flags, 1))
      striped <- as.logical(bitwAnd(flags, 2))
      title <- reader$tgread_object()
      reader$read_int()
      n_rows <- reader$read_int()
      rows <- vector("list", n_rows)
      if (n_rows > 0) for (i in seq_len(n_rows)) rows[[i]] <- reader$tgread_object()
      self$new(title = title, rows = rows, bordered = bordered, striped = striped)
    }
  ),
  class = TRUE
)

#  @title PageBlockTitle
#  @description Telegram API type PageBlockTitle
#  @export
#  @noRd
#  @noRd
PageBlockTitle <- R6::R6Class(
  "PageBlockTitle",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x70abc3fd,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1aca5644,
    #  @field text Field.
    text = NULL,
    initialize = function(text = NULL) {
      self$text <- text
    },
    to_dict = function() list(`_` = "PageBlockTitle", text = self$text),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      text <- reader$tgread_object()
      self$new(text = text)
    }
  ),
  class = TRUE
)

#  @title PageBlockUnsupported
#  @description Telegram API type PageBlockUnsupported
#  @export
#  @noRd
#  @noRd
PageBlockUnsupported <- R6::R6Class(
  "PageBlockUnsupported",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x13567e8a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1aca5644,
    initialize = function() {},
    to_dict = function() list(`_` = "PageBlockUnsupported"),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      self$new()
    }
  ),
  class = TRUE
)

#  @title PageBlockVideo
#  @description Telegram API type PageBlockVideo
#  @export
#  @noRd
#  @noRd
PageBlockVideo <- R6::R6Class(
  "PageBlockVideo",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7c8fe7b6,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1aca5644,
    #  @field video_id Field.
    video_id = NULL,
    #  @field caption Field.
    caption = NULL,
    #  @field autoplay Field.
    autoplay = NULL,
    #  @field loop Field.
    loop = NULL,
    initialize = function(video_id = NULL, caption = NULL, autoplay = NULL, loop = NULL) {
      self$video_id <- video_id
      self$caption <- caption
      self$autoplay <- autoplay
      self$loop <- loop
    },
    to_dict = function() list(`_` = "PageBlockVideo", video_id = self$video_id, caption = self$caption, autoplay = self$autoplay, loop = self$loop),
    bytes = function() raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      autoplay <- as.logical(bitwAnd(flags, 1))
      loop <- as.logical(bitwAnd(flags, 2))
      video_id <- reader$read_long()
      caption <- reader$tgread_object()
      self$new(video_id = video_id, caption = caption, autoplay = autoplay, loop = loop)
    }
  ),
  class = TRUE
)

#  @title PageCaption
#  @description Telegram API type PageCaption
#  @export
#  @noRd
#  @noRd
PageCaption <- R6::R6Class(
  "PageCaption",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x6f747657,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x29b8eeb3,
    #  @field text Field.
    text = NULL,
    #  @field credit Field.
    credit = NULL,
    initialize = function(text = NULL, credit = NULL) {
      self$text <- text
      self$credit <- credit
    },
    to_dict = function() {
      list(
        `_` = "PageCaption",
        text = if (inherits(self$text, "TLObject")) self$text$to_dict() else self$text,
        credit = if (inherits(self$credit, "TLObject")) self$credit$to_dict() else self$credit
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x57, 0x76, 0x74, 0x6f)), # "Wvto" in raw bytes
        self$text$bytes(),
        self$credit$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      text <- reader$tgread_object()
      credit <- reader$tgread_object()
      self$new(text = text, credit = credit)
    }
  ),
  class = TRUE
)

#  @title PageListItemBlocks
#  @description Telegram API type PageListItemBlocks
#  @export
#  @noRd
#  @noRd
PageListItemBlocks <- R6::R6Class("PageListItemBlocks",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x25e073fc,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8caebcb1,
    #  @field blocks Field.
    blocks = NULL,
    initialize = function(blocks = list()) {
      self$blocks <- blocks
    },
    to_dict = function() list(`_` = "PageListItemBlocks", blocks = if (is.null(self$blocks)) list() else lapply(self$blocks, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)),
    bytes = function() {
      c(
        as.raw(c(0xfc, 0x73, 0xe0, 0x25)),
        as.raw(c(0x1c, 0xb5, 0xc4, 0x15)), packBits(intToBits(length(self$blocks)), type = "raw")[1:4], do.call(c, lapply(self$blocks, function(x) x$`bytes`()))
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      blocks <- list()
      for (i in 1:reader$read_int()) {
        x <- reader$tgread_object()
        blocks <- c(blocks, list(x))
      }
      self$initialize(blocks = blocks)
    }
  ),
  class = TRUE
)

#  @title PageListItemText
#  @description Telegram API type PageListItemText
#  @export
#  @noRd
#  @noRd
PageListItemText <- R6::R6Class("PageListItemText",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb92fb6cd,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8caebcb1,
    #  @field text Field.
    text = NULL,
    initialize = function(text = NULL) {
      self$text <- text
    },
    to_dict = function() list(`_` = "PageListItemText", text = if (inherits(self$text, "TLObject")) self$text$to_dict() else self$text),
    bytes = function() {
      c(
        as.raw(c(0xcd, 0xb6, 0x2f, 0xb9)),
        self$text$`bytes`()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      text <- reader$tgread_object()
      self$initialize(text = text)
    }
  ),
  class = TRUE
)

#  @title PageListOrderedItemBlocks
#  @description Telegram API type PageListOrderedItemBlocks
#  @export
#  @noRd
#  @noRd
PageListOrderedItemBlocks <- R6::R6Class("PageListOrderedItemBlocks",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x98dd8936,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xeeda0eb8,
    #  @field num Field.
    num = NULL,
    #  @field blocks Field.
    blocks = NULL,
    initialize = function(num = NULL, blocks = list()) {
      self$num <- num
      self$blocks <- blocks
    },
    to_dict = function() list(`_` = "PageListOrderedItemBlocks", num = self$num, blocks = if (is.null(self$blocks)) list() else lapply(self$blocks, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)),
    bytes = function() {
      c(
        as.raw(c(0x36, 0x89, 0xdd, 0x98)),
        self$serializebytes(self$num),
        as.raw(c(0x1c, 0xb5, 0xc4, 0x15)), packBits(intToBits(length(self$blocks)), type = "raw")[1:4], do.call(c, lapply(self$blocks, function(x) x$`bytes`()))
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      num <- reader$tgread_string()
      reader$read_int()
      blocks <- list()
      for (i in 1:reader$read_int()) {
        x <- reader$tgread_object()
        blocks <- c(blocks, list(x))
      }
      self$initialize(num = num, blocks = blocks)
    }
  ),
  class = TRUE
)

#  @title PageListOrderedItemText
#  @description Telegram API type PageListOrderedItemText
#  @export
#  @noRd
#  @noRd
PageListOrderedItemText <- R6::R6Class("PageListOrderedItemText",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5e068047,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xeeda0eb8,
    #  @field num Field.
    num = NULL,
    #  @field text Field.
    text = NULL,
    initialize = function(num = NULL, text = NULL) {
      self$num <- num
      self$text <- text
    },
    to_dict = function() list(`_` = "PageListOrderedItemText", num = self$num, text = if (inherits(self$text, "TLObject")) self$text$to_dict() else self$text),
    bytes = function() {
      c(
        as.raw(c(0x47, 0x80, 0x06, 0x5e)),
        self$serializebytes(self$num),
        self$text$`bytes`()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      num <- reader$tgread_string()
      text <- reader$tgread_object()
      self$initialize(num = num, text = text)
    }
  ),
  class = TRUE
)

#  @title PageRelatedArticle
#  @description Telegram API type PageRelatedArticle
#  @export
#  @noRd
#  @noRd
PageRelatedArticle <- R6::R6Class("PageRelatedArticle",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb390dc08,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x36d05822,
    #  @field url Field.
    url = NULL,
    #  @field webpage_id Field.
    webpage_id = NULL,
    #  @field title Field.
    title = NULL,
    #  @field description Field.
    description = NULL,
    #  @field photo_id Field.
    photo_id = NULL,
    #  @field author Field.
    author = NULL,
    #  @field published_date Field.
    published_date = NULL,
    initialize = function(url = NULL, webpage_id = NULL, title = NULL, description = NULL, photo_id = NULL, author = NULL, published_date = NULL) {
      self$url <- url
      self$webpage_id <- webpage_id
      self$title <- title
      self$description <- description
      self$photo_id <- photo_id
      self$author <- author
      self$published_date <- published_date
    },
    to_dict = function() list(`_` = "PageRelatedArticle", url = self$url, webpage_id = self$webpage_id, title = self$title, description = self$description, photo_id = self$photo_id, author = self$author, published_date = self$published_date),
    bytes = function() {
      c(
        as.raw(c(0x08, 0xdc, 0x90, 0xb3)),
        packBits(intToBits((if (is.null(self$title)) 0 else 1) | (if (is.null(self$description)) 0 else 2) | (if (is.null(self$photo_id)) 0 else 4) | (if (is.null(self$author)) 0 else 8) | (if (is.null(self$published_date)) 0 else 16)), type = "raw")[1:4],
        self$serializebytes(self$url),
        writeBin(as.double(self$webpage_id), raw(), size = 8, endian = "little"),
        if (!is.null(self$title)) self$serializebytes(self$title) else raw(0),
        if (!is.null(self$description)) self$serializebytes(self$description) else raw(0),
        if (!is.null(self$photo_id)) writeBin(as.double(self$photo_id), raw(), size = 8, endian = "little") else raw(0),
        if (!is.null(self$author)) self$serializebytes(self$author) else raw(0),
        if (!is.null(self$published_date)) self$serialize_datetime(self$published_date) else raw(0)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      url <- reader$tgread_string()
      webpage_id <- reader$read_long()
      title <- if (bitwAnd(flags, 1)) reader$tgread_string() else NULL
      description <- if (bitwAnd(flags, 2)) reader$tgread_string() else NULL
      photo_id <- if (bitwAnd(flags, 4)) reader$read_long() else NULL
      author <- if (bitwAnd(flags, 8)) reader$tgread_string() else NULL
      published_date <- if (bitwAnd(flags, 16)) reader$tgread_date() else NULL
      self$initialize(url = url, webpage_id = webpage_id, title = title, description = description, photo_id = photo_id, author = author, published_date = published_date)
    }
  ),
  class = TRUE
)

#  @title PageTableCell
#  @description Telegram API type PageTableCell
#  @export
#  @noRd
#  @noRd
PageTableCell <- R6::R6Class("PageTableCell",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x34566b6a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb0eb3054,
    #  @field header Field.
    header = NULL,
    #  @field align_center Field.
    align_center = NULL,
    #  @field align_right Field.
    align_right = NULL,
    #  @field valign_middle Field.
    valign_middle = NULL,
    #  @field valign_bottom Field.
    valign_bottom = NULL,
    #  @field text Field.
    text = NULL,
    #  @field colspan Field.
    colspan = NULL,
    #  @field rowspan Field.
    rowspan = NULL,
    initialize = function(header = NULL, align_center = NULL, align_right = NULL, valign_middle = NULL, valign_bottom = NULL, text = NULL, colspan = NULL, rowspan = NULL) {
      self$header <- header
      self$align_center <- align_center
      self$align_right <- align_right
      self$valign_middle <- valign_middle
      self$valign_bottom <- valign_bottom
      self$text <- text
      self$colspan <- colspan
      self$rowspan <- rowspan
    },
    to_dict = function() list(`_` = "PageTableCell", header = self$header, align_center = self$align_center, align_right = self$align_right, valign_middle = self$valign_middle, valign_bottom = self$valign_bottom, text = if (inherits(self$text, "TLObject")) self$text$to_dict() else self$text, colspan = self$colspan, rowspan = self$rowspan),
    bytes = function() {
      c(
        as.raw(c(0x6a, 0x6b, 0x56, 0x34)),
        packBits(intToBits((if (is.null(self$header)) 0 else 1) | (if (is.null(self$align_center)) 0 else 8) | (if (is.null(self$align_right)) 0 else 16) | (if (is.null(self$valign_middle)) 0 else 32) | (if (is.null(self$valign_bottom)) 0 else 64) | (if (is.null(self$text)) 0 else 128) | (if (is.null(self$colspan)) 0 else 2) | (if (is.null(self$rowspan)) 0 else 4)), type = "raw")[1:4],
        if (!is.null(self$text)) self$text$`bytes`() else raw(0),
        if (!is.null(self$colspan)) packBits(intToBits(self$colspan), type = "raw")[1:4] else raw(0),
        if (!is.null(self$rowspan)) packBits(intToBits(self$rowspan), type = "raw")[1:4] else raw(0)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      header <- bitwAnd(flags, 1) != 0
      align_center <- bitwAnd(flags, 8) != 0
      align_right <- bitwAnd(flags, 16) != 0
      valign_middle <- bitwAnd(flags, 32) != 0
      valign_bottom <- bitwAnd(flags, 64) != 0
      text <- if (bitwAnd(flags, 128)) reader$tgread_object() else NULL
      colspan <- if (bitwAnd(flags, 2)) reader$read_int() else NULL
      rowspan <- if (bitwAnd(flags, 4)) reader$read_int() else NULL
      self$initialize(header = header, align_center = align_center, align_right = align_right, valign_middle = valign_middle, valign_bottom = valign_bottom, text = text, colspan = colspan, rowspan = rowspan)
    }
  ),
  class = TRUE
)

#  @title PageTableRow
#  @description Telegram API type PageTableRow
#  @export
#  @noRd
#  @noRd
PageTableRow <- R6::R6Class("PageTableRow",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe0c0c5e5,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x59acee11,
    #  @field cells Field.
    cells = NULL,
    initialize = function(cells = list()) {
      self$cells <- cells
    },
    to_dict = function() list(`_` = "PageTableRow", cells = if (is.null(self$cells)) list() else lapply(self$cells, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)),
    bytes = function() {
      c(
        as.raw(c(0xe5, 0xc5, 0xc0, 0xe0)),
        as.raw(c(0x1c, 0xb5, 0xc4, 0x15)), packBits(intToBits(length(self$cells)), type = "raw")[1:4], do.call(c, lapply(self$cells, function(x) x$`bytes`()))
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      cells <- list()
      for (i in 1:reader$read_int()) {
        x <- reader$tgread_object()
        cells <- c(cells, list(x))
      }
      self$initialize(cells = cells)
    }
  ),
  class = TRUE
)

#  @title PaidReactionPrivacyAnonymous
#  @description Telegram API type PaidReactionPrivacyAnonymous
#  @export
#  @noRd
#  @noRd
PaidReactionPrivacyAnonymous <- R6::R6Class("PaidReactionPrivacyAnonymous",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1f0c1ad9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x65d77636,
    initialize = function() {},
    to_dict = function() list(`_` = "PaidReactionPrivacyAnonymous"),
    bytes = function() as.raw(c(0xd9, 0x1a, 0x0c, 0x1f))
  ),
  private = list(
    from_reader = function(reader) {
      self$initialize()
    }
  ),
  class = TRUE
)

#  @title PaidReactionPrivacyDefault
#  @description Telegram API type PaidReactionPrivacyDefault
#  @export
#  @noRd
#  @noRd
PaidReactionPrivacyDefault <- R6::R6Class("PaidReactionPrivacyDefault",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x206ad49e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x65d77636,
    initialize = function() {},
    to_dict = function() list(`_` = "PaidReactionPrivacyDefault"),
    bytes = function() as.raw(c(0x9e, 0xd4, 0x6a, 0x20))
  ),
  private = list(
    from_reader = function(reader) {
      self$initialize()
    }
  ),
  class = TRUE
)

#  @title PaidReactionPrivacyPeer
#  @description Telegram API type PaidReactionPrivacyPeer
#  @export
#  @noRd
#  @noRd
PaidReactionPrivacyPeer <- R6::R6Class("PaidReactionPrivacyPeer",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xdc6cfcf0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x65d77636,
    #  @field peer Field.
    peer = NULL,
    initialize = function(peer = NULL) {
      self$peer <- peer
    },
    to_dict = function() list(`_` = "PaidReactionPrivacyPeer", peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer),
    bytes = function() {
      c(
        as.raw(c(0xf0, 0xfc, 0x6c, 0xdc)),
        self$peer$`bytes`()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      self$initialize(peer = peer)
    }
  ),
  class = TRUE
)

#  @title PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow
#  @description Telegram API type PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow
#  @export
#  @noRd
#  @noRd
PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow <- R6::R6Class("PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x3a912d4a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x37bcf5cc,
    #  @field salt1 Field.
    salt1 = NULL,
    #  @field salt2 Field.
    salt2 = NULL,
    #  @field g Field.
    g = NULL,
    #  @field p Field.
    p = NULL,
    initialize = function(salt1 = NULL, salt2 = NULL, g = NULL, p = NULL) {
      self$salt1 <- salt1
      self$salt2 <- salt2
      self$g <- g
      self$p <- p
    },
    to_dict = function() list(`_` = "PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow", salt1 = self$salt1, salt2 = self$salt2, g = self$g, p = self$p),
    bytes = function() {
      c(
        as.raw(c(0x4a, 0x2d, 0x91, 0x3a)),
        self$serializebytes(self$salt1),
        self$serializebytes(self$salt2),
        packBits(intToBits(self$g), type = "raw")[1:4],
        self$serializebytes(self$p)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      salt1 <- reader$tgreadbytes()
      salt2 <- reader$tgreadbytes()
      g <- reader$read_int()
      p <- reader$tgreadbytes()
      self$initialize(salt1 = salt1, salt2 = salt2, g = g, p = p)
    }
  ),
  class = TRUE
)

#  @title PasswordKdfAlgoUnknown
#  @description Telegram API type PasswordKdfAlgoUnknown
#  @export
#  @noRd
#  @noRd
PasswordKdfAlgoUnknown <- R6::R6Class("PasswordKdfAlgoUnknown",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd45ab096,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x37bcf5cc,
    initialize = function() {},
    to_dict = function() list(`_` = "PasswordKdfAlgoUnknown"),
    bytes = function() as.raw(c(0x96, 0xb0, 0x5a, 0xd4))
  ),
  private = list(
    from_reader = function(reader) {
      self$initialize()
    }
  ),
  class = TRUE
)

#  @title PaymentCharge
#  @description Telegram API type PaymentCharge
#  @export
#  @noRd
#  @noRd
PaymentCharge <- R6::R6Class("PaymentCharge",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xea02c27e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x3cc830d9,
    #  @field id Field.
    id = NULL,
    #  @field provider_charge_id Field.
    provider_charge_id = NULL,
    initialize = function(id = NULL, provider_charge_id = NULL) {
      self$id <- id
      self$provider_charge_id <- provider_charge_id
    },
    to_dict = function() list(`_` = "PaymentCharge", id = self$id, provider_charge_id = self$provider_charge_id),
    bytes = function() {
      c(
        as.raw(c(0x7e, 0xc2, 0x02, 0xea)),
        self$serializebytes(self$id),
        self$serializebytes(self$provider_charge_id)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      id <- reader$tgread_string()
      provider_charge_id <- reader$tgread_string()
      self$initialize(id = id, provider_charge_id = provider_charge_id)
    }
  ),
  class = TRUE
)

#  @title PaymentFormMethod
#  @description Telegram API type PaymentFormMethod
#  @export
#  @noRd
#  @noRd
PaymentFormMethod <- R6::R6Class("PaymentFormMethod",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x88f8f21b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x3fc1c816,
    #  @field url Field.
    url = NULL,
    #  @field title Field.
    title = NULL,
    initialize = function(url = NULL, title = NULL) {
      self$url <- url
      self$title <- title
    },
    to_dict = function() list(`_` = "PaymentFormMethod", url = self$url, title = self$title),
    bytes = function() {
      c(
        as.raw(c(0x1b, 0xf2, 0xf8, 0x88)),
        self$serializebytes(self$url),
        self$serializebytes(self$title)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      url <- reader$tgread_string()
      title <- reader$tgread_string()
      self$initialize(url = url, title = title)
    }
  ),
  class = TRUE
)

#  @title PaymentRequestedInfo
#  @description Telegram API type PaymentRequestedInfo
#  @export
#  @noRd
#  @noRd
PaymentRequestedInfo <- R6::R6Class("PaymentRequestedInfo",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x909c3f94,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8db03146,
    #  @field name Field.
    name = NULL,
    #  @field phone Field.
    phone = NULL,
    #  @field email Field.
    email = NULL,
    #  @field shipping_address Field.
    shipping_address = NULL,
    initialize = function(name = NULL, phone = NULL, email = NULL, shipping_address = NULL) {
      self$name <- name
      self$phone <- phone
      self$email <- email
      self$shipping_address <- shipping_address
    },
    to_dict = function() list(`_` = "PaymentRequestedInfo", name = self$name, phone = self$phone, email = self$email, shipping_address = if (inherits(self$shipping_address, "TLObject")) self$shipping_address$to_dict() else self$shipping_address),
    bytes = function() {
      c(
        as.raw(c(0x94, 0x3f, 0x9c, 0x90)),
        packBits(intToBits((if (is.null(self$name)) 0 else 1) | (if (is.null(self$phone)) 0 else 2) | (if (is.null(self$email)) 0 else 4) | (if (is.null(self$shipping_address)) 0 else 8)), type = "raw")[1:4],
        if (!is.null(self$name)) self$serializebytes(self$name) else raw(0),
        if (!is.null(self$phone)) self$serializebytes(self$phone) else raw(0),
        if (!is.null(self$email)) self$serializebytes(self$email) else raw(0),
        if (!is.null(self$shipping_address)) self$shipping_address$`bytes`() else raw(0)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      name <- if (bitwAnd(flags, 1)) reader$tgread_string() else NULL
      phone <- if (bitwAnd(flags, 2)) reader$tgread_string() else NULL
      email <- if (bitwAnd(flags, 4)) reader$tgread_string() else NULL
      shipping_address <- if (bitwAnd(flags, 8)) reader$tgread_object() else NULL
      self$initialize(name = name, phone = phone, email = email, shipping_address = shipping_address)
    }
  ),
  class = TRUE
)

#  @title PaymentSavedCredentialsCard
#  @description Telegram API type PaymentSavedCredentialsCard
#  @export
#  @noRd
#  @noRd
PaymentSavedCredentialsCard <- R6::R6Class("PaymentSavedCredentialsCard",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xcdc27a1f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb3627ee3,
    #  @field id Field.
    id = NULL,
    #  @field title Field.
    title = NULL,
    initialize = function(id = NULL, title = NULL) {
      self$id <- id
      self$title <- title
    },
    to_dict = function() list(`_` = "PaymentSavedCredentialsCard", id = self$id, title = self$title),
    bytes = function() {
      c(
        as.raw(c(0x1f, 0x7a, 0xc2, 0xcd)),
        self$serializebytes(self$id),
        self$serializebytes(self$title)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      id <- reader$tgread_string()
      title <- reader$tgread_string()
      self$initialize(id = id, title = title)
    }
  ),
  class = TRUE
)

#  @title PeerBlocked
#  @description Telegram API type PeerBlocked
#  @export
#  @noRd
#  @noRd
PeerBlocked <- R6::R6Class("PeerBlocked",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe8fd8014,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x54f2fc98,
    #  @field peer_id Field.
    peer_id = NULL,
    #  @field date Field.
    date = NULL,
    initialize = function(peer_id = NULL, date = NULL) {
      self$peer_id <- peer_id
      self$date <- date
    },
    to_dict = function() list(`_` = "PeerBlocked", peer_id = if (inherits(self$peer_id, "TLObject")) self$peer_id$to_dict() else self$peer_id, date = self$date),
    bytes = function() {
      c(
        as.raw(c(0x14, 0x80, 0xfd, 0xe8)),
        self$peer_id$`bytes`(),
        self$serialize_datetime(self$date)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      peer_id <- reader$tgread_object()
      date <- reader$tgread_date()
      self$initialize(peer_id = peer_id, date = date)
    }
  ),
  class = TRUE
)

#  @title PeerChannel
#  @description Telegram API type PeerChannel
#  @export
#  @noRd
#  @noRd
PeerChannel <- R6::R6Class("PeerChannel",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa2a5371e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x2d45687,
    #  @field channel_id Field.
    channel_id = NULL,
    initialize = function(channel_id = NULL) {
      self$channel_id <- channel_id
    },
    to_dict = function() list(`_` = "PeerChannel", channel_id = self$channel_id),
    bytes = function() {
      c(
        as.raw(c(0x1e, 0x37, 0xa5, 0xa2)),
        writeBin(as.double(self$channel_id), raw(), size = 8, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      channel_id <- reader$read_long()
      self$initialize(channel_id = channel_id)
    }
  ),
  class = TRUE
)

#  @title PeerChat
#  @description Telegram API type PeerChat
#  @export
#  @noRd
#  @noRd
PeerChat <- R6::R6Class("PeerChat",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x36c6019a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x2d45687,
    #  @field chat_id Field.
    chat_id = NULL,
    initialize = function(chat_id = NULL) {
      self$chat_id <- chat_id
    },
    to_dict = function() list(`_` = "PeerChat", chat_id = self$chat_id),
    bytes = function() {
      c(
        as.raw(c(0x9a, 0x01, 0xc6, 0x36)),
        writeBin(as.double(self$chat_id), raw(), size = 8, endian = "little")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      chat_id <- reader$read_long()
      self$initialize(chat_id = chat_id)
    }
  ),
  class = TRUE
)

#  @title PeerColor
#  @description Telegram API type PeerColor
#  @export
#  @noRd
#  @noRd
PeerColor <- R6::R6Class("PeerColor",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb54b5acf,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf281a47f,
    #  @field color Field.
    color = NULL,
    #  @field background_emoji_id Field.
    background_emoji_id = NULL,
    initialize = function(color = NULL, background_emoji_id = NULL) {
      self$color <- color
      self$background_emoji_id <- background_emoji_id
    },
    to_dict = function() list(`_` = "PeerColor", color = self$color, background_emoji_id = self$background_emoji_id),
    bytes = function() {
      c(
        as.raw(c(0xcf, 0x5a, 0x4b, 0xb5)),
        packBits(intToBits((if (is.null(self$color)) 0 else 1) | (if (is.null(self$background_emoji_id)) 0 else 2)), type = "raw")[1:4],
        if (!is.null(self$color)) packBits(intToBits(self$color), type = "raw")[1:4] else raw(0),
        if (!is.null(self$background_emoji_id)) writeBin(as.double(self$background_emoji_id), raw(), size = 8, endian = "little") else raw(0)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      color <- if (bitwAnd(flags, 1)) reader$read_int() else NULL
      background_emoji_id <- if (bitwAnd(flags, 2)) reader$read_long() else NULL
      self$initialize(color = color, background_emoji_id = background_emoji_id)
    }
  ),
  class = TRUE
)

#  @title PeerLocated
#  @description Telegram API type PeerLocated
#  @export
#  @noRd
#  @noRd
PeerLocated <- R6::R6Class("PeerLocated",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xca461b5d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xfada34ac,
    #  @field peer Field.
    peer = NULL,
    #  @field expires Field.
    expires = NULL,
    #  @field distance Field.
    distance = NULL,
    initialize = function(peer = NULL, expires = NULL, distance = NULL) {
      self$peer <- peer
      self$expires <- expires
      self$distance <- distance
    },
    to_dict = function() list(`_` = "PeerLocated", peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer, expires = self$expires, distance = self$distance),
    bytes = function() {
      c(
        as.raw(c(0x5d, 0x1b, 0x46, 0xca)),
        self$peer$`bytes`(),
        self$serialize_datetime(self$expires),
        packBits(intToBits(self$distance), type = "raw")[1:4]
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      expires <- reader$tgread_date()
      distance <- reader$read_int()
      self$initialize(peer = peer, expires = expires, distance = distance)
    }
  ),
  class = TRUE
)

#  @title PeerNotifySettings
#  @description Telegram API type PeerNotifySettings
#  @export
#  @noRd
#  @noRd
PeerNotifySettings <- R6::R6Class("PeerNotifySettings",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x99622c0c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xcf20c074,
    #  @field show_previews Field.
    show_previews = NULL,
    #  @field silent Field.
    silent = NULL,
    #  @field mute_until Field.
    mute_until = NULL,
    #  @field ios_sound Field.
    ios_sound = NULL,
    #  @field android_sound Field.
    android_sound = NULL,
    #  @field other_sound Field.
    other_sound = NULL,
    #  @field stories_muted Field.
    stories_muted = NULL,
    #  @field stories_hide_sender Field.
    stories_hide_sender = NULL,
    #  @field stories_ios_sound Field.
    stories_ios_sound = NULL,
    #  @field stories_android_sound Field.
    stories_android_sound = NULL,
    #  @field stories_other_sound Field.
    stories_other_sound = NULL,
    initialize = function(show_previews = NULL, silent = NULL, mute_until = NULL, ios_sound = NULL, android_sound = NULL, other_sound = NULL, stories_muted = NULL, stories_hide_sender = NULL, stories_ios_sound = NULL, stories_android_sound = NULL, stories_other_sound = NULL) {
      self$show_previews <- show_previews
      self$silent <- silent
      self$mute_until <- mute_until
      self$ios_sound <- ios_sound
      self$android_sound <- android_sound
      self$other_sound <- other_sound
      self$stories_muted <- stories_muted
      self$stories_hide_sender <- stories_hide_sender
      self$stories_ios_sound <- stories_ios_sound
      self$stories_android_sound <- stories_android_sound
      self$stories_other_sound <- stories_other_sound
    },
    to_dict = function() list(`_` = "PeerNotifySettings", show_previews = self$show_previews, silent = self$silent, mute_until = self$mute_until, ios_sound = if (inherits(self$ios_sound, "TLObject")) self$ios_sound$to_dict() else self$ios_sound, android_sound = if (inherits(self$android_sound, "TLObject")) self$android_sound$to_dict() else self$android_sound, other_sound = if (inherits(self$other_sound, "TLObject")) self$other_sound$to_dict() else self$other_sound, stories_muted = self$stories_muted, stories_hide_sender = self$stories_hide_sender, stories_ios_sound = if (inherits(self$stories_ios_sound, "TLObject")) self$stories_ios_sound$to_dict() else self$stories_ios_sound, stories_android_sound = if (inherits(self$stories_android_sound, "TLObject")) self$stories_android_sound$to_dict() else self$stories_android_sound, stories_other_sound = if (inherits(self$stories_other_sound, "TLObject")) self$stories_other_sound$to_dict() else self$stories_other_sound),
    bytes = function() {
      c(
        as.raw(c(0x0c, 0x2c, 0x62, 0x99)),
        as.raw(c((ifelse(is.null(self$show_previews), 0, 1)) | (ifelse(is.null(self$silent), 0, 2)) | (ifelse(is.null(self$mute_until), 0, 4)) | (ifelse(is.null(self$ios_sound), 0, 8)) | (ifelse(is.null(self$android_sound), 0, 16)) | (ifelse(is.null(self$other_sound), 0, 32)) | (ifelse(is.null(self$stories_muted), 0, 64)) | (ifelse(is.null(self$stories_hide_sender), 0, 128)) | (ifelse(is.null(self$stories_ios_sound), 0, 256)) | (ifelse(is.null(self$stories_android_sound), 0, 512)) | (ifelse(is.null(self$stories_other_sound), 0, 1024)))),
        if (!is.null(self$show_previews)) if (self$show_previews) as.raw(c(0xb5, 0x75, 0x72, 0x99)) else as.raw(c(0x37, 0x97, 0x79, 0xbc)) else raw(0),
        if (!is.null(self$silent)) if (self$silent) as.raw(c(0xb5, 0x75, 0x72, 0x99)) else as.raw(c(0x37, 0x97, 0x79, 0xbc)) else raw(0),
        if (!is.null(self$mute_until)) self$serialize_datetime(self$mute_until) else raw(0),
        if (!is.null(self$ios_sound)) self$ios_sound$bytes() else raw(0),
        if (!is.null(self$android_sound)) self$android_sound$bytes() else raw(0),
        if (!is.null(self$other_sound)) self$other_sound$bytes() else raw(0),
        if (!is.null(self$stories_muted)) if (self$stories_muted) as.raw(c(0xb5, 0x75, 0x72, 0x99)) else as.raw(c(0x37, 0x97, 0x79, 0xbc)) else raw(0),
        if (!is.null(self$stories_hide_sender)) if (self$stories_hide_sender) as.raw(c(0xb5, 0x75, 0x72, 0x99)) else as.raw(c(0x37, 0x97, 0x79, 0xbc)) else raw(0),
        if (!is.null(self$stories_ios_sound)) self$stories_ios_sound$bytes() else raw(0),
        if (!is.null(self$stories_android_sound)) self$stories_android_sound$bytes() else raw(0),
        if (!is.null(self$stories_other_sound)) self$stories_other_sound$bytes() else raw(0)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      if (bitwAnd(flags, 1)) {
        self$show_previews <- reader$tgread_bool()
      } else {
        self$show_previews <- NULL
      }
      if (bitwAnd(flags, 2)) {
        self$silent <- reader$tgread_bool()
      } else {
        self$silent <- NULL
      }
      if (bitwAnd(flags, 4)) {
        self$mute_until <- reader$tgread_date()
      } else {
        self$mute_until <- NULL
      }
      if (bitwAnd(flags, 8)) {
        self$ios_sound <- reader$tgread_object()
      } else {
        self$ios_sound <- NULL
      }
      if (bitwAnd(flags, 16)) {
        self$android_sound <- reader$tgread_object()
      } else {
        self$android_sound <- NULL
      }
      if (bitwAnd(flags, 32)) {
        self$other_sound <- reader$tgread_object()
      } else {
        self$other_sound <- NULL
      }
      if (bitwAnd(flags, 64)) {
        self$stories_muted <- reader$tgread_bool()
      } else {
        self$stories_muted <- NULL
      }
      if (bitwAnd(flags, 128)) {
        self$stories_hide_sender <- reader$tgread_bool()
      } else {
        self$stories_hide_sender <- NULL
      }
      if (bitwAnd(flags, 256)) {
        self$stories_ios_sound <- reader$tgread_object()
      } else {
        self$stories_ios_sound <- NULL
      }
      if (bitwAnd(flags, 512)) {
        self$stories_android_sound <- reader$tgread_object()
      } else {
        self$stories_android_sound <- NULL
      }
      if (bitwAnd(flags, 1024)) {
        self$stories_other_sound <- reader$tgread_object()
      } else {
        self$stories_other_sound <- NULL
      }
      self
    }
  ),
  class = TRUE
)

#  @title PeerSelfLocated
#  @description Telegram API type PeerSelfLocated
#  @export
#  @noRd
#  @noRd
PeerSelfLocated <- R6::R6Class("PeerSelfLocated",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf8ec284b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xfada34ac,
    #  @field expires Field.
    expires = NULL,
    initialize = function(expires = NULL) {
      self$expires <- expires
    },
    to_dict = function() list(`_` = "PeerSelfLocated", expires = self$expires),
    bytes = function() {
      c(
        as.raw(c(0x4b, 0x28, 0xec, 0xf8)),
        self$serialize_datetime(self$expires)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$expires <- reader$tgread_date()
      self
    }
  ),
  class = TRUE
)

#  @title PeerSettings
#  @description Telegram API type PeerSettings
#  @export
#  @noRd
#  @noRd
PeerSettings <- R6::R6Class("PeerSettings",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf47741f7,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf6a79f84,
    #  @field report_spam Field.
    report_spam = NULL,
    #  @field add_contact Field.
    add_contact = NULL,
    #  @field block_contact Field.
    block_contact = NULL,
    #  @field share_contact Field.
    share_contact = NULL,
    #  @field need_contacts_exception Field.
    need_contacts_exception = NULL,
    #  @field report_geo Field.
    report_geo = NULL,
    #  @field autoarchived Field.
    autoarchived = NULL,
    #  @field invite_members Field.
    invite_members = NULL,
    #  @field request_chat_broadcast Field.
    request_chat_broadcast = NULL,
    #  @field business_bot_paused Field.
    business_bot_paused = NULL,
    #  @field business_bot_can_reply Field.
    business_bot_can_reply = NULL,
    #  @field geo_distance Field.
    geo_distance = NULL,
    #  @field request_chat_title Field.
    request_chat_title = NULL,
    #  @field request_chat_date Field.
    request_chat_date = NULL,
    #  @field business_bot_id Field.
    business_bot_id = NULL,
    #  @field business_bot_manage_url Field.
    business_bot_manage_url = NULL,
    #  @field charge_paid_message_stars Field.
    charge_paid_message_stars = NULL,
    #  @field registration_month Field.
    registration_month = NULL,
    #  @field phone_country Field.
    phone_country = NULL,
    #  @field name_change_date Field.
    name_change_date = NULL,
    #  @field photo_change_date Field.
    photo_change_date = NULL,
    initialize = function(report_spam = NULL, add_contact = NULL, block_contact = NULL, share_contact = NULL, need_contacts_exception = NULL, report_geo = NULL, autoarchived = NULL, invite_members = NULL, request_chat_broadcast = NULL, business_bot_paused = NULL, business_bot_can_reply = NULL, geo_distance = NULL, request_chat_title = NULL, request_chat_date = NULL, business_bot_id = NULL, business_bot_manage_url = NULL, charge_paid_message_stars = NULL, registration_month = NULL, phone_country = NULL, name_change_date = NULL, photo_change_date = NULL) {
      self$report_spam <- report_spam
      self$add_contact <- add_contact
      self$block_contact <- block_contact
      self$share_contact <- share_contact
      self$need_contacts_exception <- need_contacts_exception
      self$report_geo <- report_geo
      self$autoarchived <- autoarchived
      self$invite_members <- invite_members
      self$request_chat_broadcast <- request_chat_broadcast
      self$business_bot_paused <- business_bot_paused
      self$business_bot_can_reply <- business_bot_can_reply
      self$geo_distance <- geo_distance
      self$request_chat_title <- request_chat_title
      self$request_chat_date <- request_chat_date
      self$business_bot_id <- business_bot_id
      self$business_bot_manage_url <- business_bot_manage_url
      self$charge_paid_message_stars <- charge_paid_message_stars
      self$registration_month <- registration_month
      self$phone_country <- phone_country
      self$name_change_date <- name_change_date
      self$photo_change_date <- photo_change_date
    },
    to_dict = function() list(`_` = "PeerSettings", report_spam = self$report_spam, add_contact = self$add_contact, block_contact = self$block_contact, share_contact = self$share_contact, need_contacts_exception = self$need_contacts_exception, report_geo = self$report_geo, autoarchived = self$autoarchived, invite_members = self$invite_members, request_chat_broadcast = self$request_chat_broadcast, business_bot_paused = self$business_bot_paused, business_bot_can_reply = self$business_bot_can_reply, geo_distance = self$geo_distance, request_chat_title = self$request_chat_title, request_chat_date = self$request_chat_date, business_bot_id = self$business_bot_id, business_bot_manage_url = self$business_bot_manage_url, charge_paid_message_stars = self$charge_paid_message_stars, registration_month = self$registration_month, phone_country = self$phone_country, name_change_date = self$name_change_date, photo_change_date = self$photo_change_date),
    bytes = function() {
      stopifnot(((!is.null(self$request_chat_title) && !is.null(self$request_chat_date)) || (is.null(self$request_chat_title) && is.null(self$request_chat_date))))
      stopifnot(((!is.null(self$business_bot_id) && !is.null(self$business_bot_manage_url)) || (is.null(self$business_bot_id) && is.null(self$business_bot_manage_url))))
      c(
        as.raw(c(0xf7, 0x41, 0x77, 0xf4)),
        as.raw(c((ifelse(is.null(self$report_spam), 0, 1)) | (ifelse(is.null(self$add_contact), 0, 2)) | (ifelse(is.null(self$block_contact), 0, 4)) | (ifelse(is.null(self$share_contact), 0, 8)) | (ifelse(is.null(self$need_contacts_exception), 0, 16)) | (ifelse(is.null(self$report_geo), 0, 32)) | (ifelse(is.null(self$autoarchived), 0, 128)) | (ifelse(is.null(self$invite_members), 0, 256)) | (ifelse(is.null(self$request_chat_broadcast), 0, 1024)) | (ifelse(is.null(self$business_bot_paused), 0, 2048)) | (ifelse(is.null(self$business_bot_can_reply), 0, 4096)) | (ifelse(is.null(self$geo_distance), 0, 64)) | (ifelse(is.null(self$request_chat_title), 0, 512)) | (ifelse(is.null(self$request_chat_date), 0, 512)) | (ifelse(is.null(self$business_bot_id), 0, 8192)) | (ifelse(is.null(self$business_bot_manage_url), 0, 8192)) | (ifelse(is.null(self$charge_paid_message_stars), 0, 16384)) | (ifelse(is.null(self$registration_month), 0, 32768)) | (ifelse(is.null(self$phone_country), 0, 65536)) | (ifelse(is.null(self$name_change_date), 0, 131072)) | (ifelse(is.null(self$photo_change_date), 0, 262144)))),
        if (!is.null(self$geo_distance)) packBits(intToBits(self$geo_distance), type = "raw") else raw(0),
        if (!is.null(self$request_chat_title)) self$serializebytes(self$request_chat_title) else raw(0),
        if (!is.null(self$request_chat_date)) self$serialize_datetime(self$request_chat_date) else raw(0),
        if (!is.null(self$business_bot_id)) packBits(intToBits(self$business_bot_id), type = "raw") else raw(0),
        if (!is.null(self$business_bot_manage_url)) self$serializebytes(self$business_bot_manage_url) else raw(0),
        if (!is.null(self$charge_paid_message_stars)) packBits(intToBits(self$charge_paid_message_stars), type = "raw") else raw(0),
        if (!is.null(self$registration_month)) self$serializebytes(self$registration_month) else raw(0),
        if (!is.null(self$phone_country)) self$serializebytes(self$phone_country) else raw(0),
        if (!is.null(self$name_change_date)) self$serialize_datetime(self$name_change_date) else raw(0),
        if (!is.null(self$photo_change_date)) self$serialize_datetime(self$photo_change_date) else raw(0)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      self$report_spam <- bitwAnd(flags, 1) != 0
      self$add_contact <- bitwAnd(flags, 2) != 0
      self$block_contact <- bitwAnd(flags, 4) != 0
      self$share_contact <- bitwAnd(flags, 8) != 0
      self$need_contacts_exception <- bitwAnd(flags, 16) != 0
      self$report_geo <- bitwAnd(flags, 32) != 0
      self$autoarchived <- bitwAnd(flags, 128) != 0
      self$invite_members <- bitwAnd(flags, 256) != 0
      self$request_chat_broadcast <- bitwAnd(flags, 1024) != 0
      self$business_bot_paused <- bitwAnd(flags, 2048) != 0
      self$business_bot_can_reply <- bitwAnd(flags, 4096) != 0
      if (bitwAnd(flags, 64)) {
        self$geo_distance <- reader$read_int()
      } else {
        self$geo_distance <- NULL
      }
      if (bitwAnd(flags, 512)) {
        self$request_chat_title <- reader$tgread_string()
      } else {
        self$request_chat_title <- NULL
      }
      if (bitwAnd(flags, 512)) {
        self$request_chat_date <- reader$tgread_date()
      } else {
        self$request_chat_date <- NULL
      }
      if (bitwAnd(flags, 8192)) {
        self$business_bot_id <- reader$read_long()
      } else {
        self$business_bot_id <- NULL
      }
      if (bitwAnd(flags, 8192)) {
        self$business_bot_manage_url <- reader$tgread_string()
      } else {
        self$business_bot_manage_url <- NULL
      }
      if (bitwAnd(flags, 16384)) {
        self$charge_paid_message_stars <- reader$read_long()
      } else {
        self$charge_paid_message_stars <- NULL
      }
      if (bitwAnd(flags, 32768)) {
        self$registration_month <- reader$tgread_string()
      } else {
        self$registration_month <- NULL
      }
      if (bitwAnd(flags, 65536)) {
        self$phone_country <- reader$tgread_string()
      } else {
        self$phone_country <- NULL
      }
      if (bitwAnd(flags, 131072)) {
        self$name_change_date <- reader$tgread_date()
      } else {
        self$name_change_date <- NULL
      }
      if (bitwAnd(flags, 262144)) {
        self$photo_change_date <- reader$tgread_date()
      } else {
        self$photo_change_date <- NULL
      }
      self
    }
  ),
  class = TRUE
)

#  @title PeerStories
#  @description Telegram API type PeerStories
#  @export
#  @noRd
#  @noRd
PeerStories <- R6::R6Class("PeerStories",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9a35e999,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x122c8a47,
    #  @field peer Field.
    peer = NULL,
    #  @field stories Field.
    stories = NULL,
    #  @field max_read_id Field.
    max_read_id = NULL,
    initialize = function(peer = NULL, stories = NULL, max_read_id = NULL) {
      self$peer <- peer
      self$stories <- stories
      self$max_read_id <- max_read_id
    },
    to_dict = function() list(`_` = "PeerStories", peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer, stories = if (is.null(self$stories)) list() else lapply(self$stories, function(x) if (inherits(x, "TLObject")) x$to_dict() else x), max_read_id = self$max_read_id),
    bytes = function() {
      c(
        as.raw(c(0x99, 0xe9, 0x35, 0x9a)),
        as.raw(c(ifelse(is.null(self$max_read_id), 0, 1))),
        self$peer$bytes(),
        if (!is.null(self$max_read_id)) packBits(intToBits(self$max_read_id), type = "raw") else raw(0),
        as.raw(c(0x1c, 0xb5, 0xc4, 0x15)), packBits(intToBits(length(self$stories)), type = "raw"), do.call(c, lapply(self$stories, function(x) x$bytes()))
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      self$peer <- reader$tgread_object()
      if (bitwAnd(flags, 1)) {
        self$max_read_id <- reader$read_int()
      } else {
        self$max_read_id <- NULL
      }
      reader$read_int()
      self$stories <- list()
      for (i in 1:reader$read_int()) {
        self$stories[[i]] <- reader$tgread_object()
      }
      self
    }
  ),
  class = TRUE
)

#  @title PeerUser
#  @description Telegram API type PeerUser
#  @export
#  @noRd
#  @noRd
PeerUser <- R6::R6Class("PeerUser",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x59511722,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x2d45687,
    #  @field user_id Field.
    user_id = NULL,
    initialize = function(user_id = NULL) {
      self$user_id <- user_id
    },
    to_dict = function() list(`_` = "PeerUser", user_id = self$user_id),
    bytes = function() {
      c(
        as.raw(c(0x22, 0x17, 0x51, 0x59)),
        packBits(intToBits(self$user_id), type = "raw")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$user_id <- reader$read_long()
      self
    }
  ),
  class = TRUE
)

#  @title PendingSuggestion
#  @description Telegram API type PendingSuggestion
#  @export
#  @noRd
#  @noRd
PendingSuggestion <- R6::R6Class("PendingSuggestion",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe7e82e12,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xba6174a7,
    #  @field suggestion Field.
    suggestion = NULL,
    #  @field title Field.
    title = NULL,
    #  @field description Field.
    description = NULL,
    #  @field url Field.
    url = NULL,
    initialize = function(suggestion = NULL, title = NULL, description = NULL, url = NULL) {
      self$suggestion <- suggestion
      self$title <- title
      self$description <- description
      self$url <- url
    },
    to_dict = function() list(`_` = "PendingSuggestion", suggestion = self$suggestion, title = if (inherits(self$title, "TLObject")) self$title$to_dict() else self$title, description = if (inherits(self$description, "TLObject")) self$description$to_dict() else self$description, url = self$url),
    bytes = function() {
      c(
        as.raw(c(0x12, 0x2e, 0xe8, 0xe7)),
        self$serializebytes(self$suggestion),
        self$title$bytes(),
        self$description$bytes(),
        self$serializebytes(self$url)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$suggestion <- reader$tgread_string()
      self$title <- reader$tgread_object()
      self$description <- reader$tgread_object()
      self$url <- reader$tgread_string()
      self
    }
  ),
  class = TRUE
)

#  @title PhoneCall
#  @description Telegram API type PhoneCall
#  @export
#  @noRd
#  @noRd
PhoneCall <- R6::R6Class("PhoneCall",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x30535af5,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc47f1bd1,
    #  @field id Field.
    id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    #  @field date Field.
    date = NULL,
    #  @field admin_id Field.
    admin_id = NULL,
    #  @field participant_id Field.
    participant_id = NULL,
    #  @field g_a_or_b Field.
    g_a_or_b = NULL,
    #  @field key_fingerprint Field.
    key_fingerprint = NULL,
    #  @field protocol Field.
    protocol = NULL,
    #  @field connections Field.
    connections = NULL,
    #  @field start_date Field.
    start_date = NULL,
    #  @field p2p_allowed Field.
    p2p_allowed = NULL,
    #  @field video Field.
    video = NULL,
    #  @field conference_supported Field.
    conference_supported = NULL,
    #  @field custom_parameters Field.
    custom_parameters = NULL,
    initialize = function(id = NULL, access_hash = NULL, date = NULL, admin_id = NULL, participant_id = NULL, g_a_or_b = NULL, key_fingerprint = NULL, protocol = NULL, connections = NULL, start_date = NULL, p2p_allowed = NULL, video = NULL, conference_supported = NULL, custom_parameters = NULL) {
      self$id <- id
      self$access_hash <- access_hash
      self$date <- date
      self$admin_id <- admin_id
      self$participant_id <- participant_id
      self$g_a_or_b <- g_a_or_b
      self$key_fingerprint <- key_fingerprint
      self$protocol <- protocol
      self$connections <- connections
      self$start_date <- start_date
      self$p2p_allowed <- p2p_allowed
      self$video <- video
      self$conference_supported <- conference_supported
      self$custom_parameters <- custom_parameters
    },
    to_dict = function() list(`_` = "PhoneCall", id = self$id, access_hash = self$access_hash, date = self$date, admin_id = self$admin_id, participant_id = self$participant_id, g_a_or_b = self$g_a_or_b, key_fingerprint = self$key_fingerprint, protocol = if (inherits(self$protocol, "TLObject")) self$protocol$to_dict() else self$protocol, connections = if (is.null(self$connections)) list() else lapply(self$connections, function(x) if (inherits(x, "TLObject")) x$to_dict() else x), start_date = self$start_date, p2p_allowed = self$p2p_allowed, video = self$video, conference_supported = self$conference_supported, custom_parameters = if (inherits(self$custom_parameters, "TLObject")) self$custom_parameters$to_dict() else self$custom_parameters),
    bytes = function() {
      c(
        as.raw(c(0xf5, 0x5a, 0x53, 0x30)),
        as.raw(c((if (is.null(self$p2p_allowed)) 0 else 32) | (if (is.null(self$video)) 0 else 64) | (if (is.null(self$conference_supported)) 0 else 256) | (if (is.null(self$custom_parameters)) 0 else 128))),
        packBits(intToBits(self$id), type = "raw"),
        packBits(intToBits(self$access_hash), type = "raw"),
        self$serialize_datetime(self$date),
        packBits(intToBits(self$admin_id), type = "raw"),
        packBits(intToBits(self$participant_id), type = "raw"),
        self$serializebytes(self$g_a_or_b),
        packBits(intToBits(self$key_fingerprint), type = "raw"),
        self$protocol$bytes(),
        as.raw(c(0x1c, 0xb5, 0xc4, 0x15)), packBits(intToBits(length(self$connections)), type = "raw"), do.call(c, lapply(self$connections, function(x) x$bytes())),
        self$serialize_datetime(self$start_date),
        if (!is.null(self$custom_parameters)) self$custom_parameters$bytes() else raw(0)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      self$p2p_allowed <- bitwAnd(flags, 32) != 0
      self$video <- bitwAnd(flags, 64) != 0
      self$conference_supported <- bitwAnd(flags, 256) != 0
      self$id <- reader$read_long()
      self$access_hash <- reader$read_long()
      self$date <- reader$tgread_date()
      self$admin_id <- reader$read_long()
      self$participant_id <- reader$read_long()
      self$g_a_or_b <- reader$tgreadbytes()
      self$key_fingerprint <- reader$read_long()
      self$protocol <- reader$tgread_object()
      reader$read_int()
      self$connections <- list()
      for (i in 1:reader$read_int()) {
        self$connections[[i]] <- reader$tgread_object()
      }
      self$start_date <- reader$tgread_date()
      if (bitwAnd(flags, 128)) {
        self$custom_parameters <- reader$tgread_object()
      } else {
        self$custom_parameters <- NULL
      }
      self
    }
  ),
  class = TRUE
)

#  @title PhoneCallAccepted
#  @description Telegram API type PhoneCallAccepted
#  @export
#  @noRd
#  @noRd
PhoneCallAccepted <- R6::R6Class("PhoneCallAccepted",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x3660c311,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc47f1bd1,
    #  @field id Field.
    id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    #  @field date Field.
    date = NULL,
    #  @field admin_id Field.
    admin_id = NULL,
    #  @field participant_id Field.
    participant_id = NULL,
    #  @field g_b Field.
    g_b = NULL,
    #  @field protocol Field.
    protocol = NULL,
    #  @field video Field.
    video = NULL,
    initialize = function(id = NULL, access_hash = NULL, date = NULL, admin_id = NULL, participant_id = NULL, g_b = NULL, protocol = NULL, video = NULL) {
      self$id <- id
      self$access_hash <- access_hash
      self$date <- date
      self$admin_id <- admin_id
      self$participant_id <- participant_id
      self$g_b <- g_b
      self$protocol <- protocol
      self$video <- video
    },
    to_dict = function() list(`_` = "PhoneCallAccepted", id = self$id, access_hash = self$access_hash, date = self$date, admin_id = self$admin_id, participant_id = self$participant_id, g_b = self$g_b, protocol = if (inherits(self$protocol, "TLObject")) self$protocol$to_dict() else self$protocol, video = self$video),
    bytes = function() {
      c(
        as.raw(c(0x11, 0xc3, 0x60, 0x36)),
        as.raw(ifelse(is.null(self$video), 0, 64)),
        packBits(intToBits(self$id), type = "raw"),
        packBits(intToBits(self$access_hash), type = "raw"),
        self$serialize_datetime(self$date),
        packBits(intToBits(self$admin_id), type = "raw"),
        packBits(intToBits(self$participant_id), type = "raw"),
        self$serializebytes(self$g_b),
        self$protocol$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      self$video <- bitwAnd(flags, 64) != 0
      self$id <- reader$read_long()
      self$access_hash <- reader$read_long()
      self$date <- reader$tgread_date()
      self$admin_id <- reader$read_long()
      self$participant_id <- reader$read_long()
      self$g_b <- reader$tgreadbytes()
      self$protocol <- reader$tgread_object()
      self
    }
  ),
  class = TRUE
)

#  @title PhoneCallDiscardReasonBusy
#  @description Telegram API type PhoneCallDiscardReasonBusy
#  @export
#  @noRd
#  @noRd
PhoneCallDiscardReasonBusy <- R6::R6Class("PhoneCallDiscardReasonBusy",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xfaf7e8c9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd89bad3d,
    to_dict = function() list(`_` = "PhoneCallDiscardReasonBusy"),
    bytes = function() as.raw(c(0xc9, 0xe8, 0xf7, 0xfa))
  ),
  private = list(
    from_reader = function(reader) self
  ),
  class = TRUE
)

#  @title PhoneCallDiscardReasonDisconnect
#  @description Telegram API type PhoneCallDiscardReasonDisconnect
#  @export
#  @noRd
#  @noRd
PhoneCallDiscardReasonDisconnect <- R6::R6Class("PhoneCallDiscardReasonDisconnect",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe095c1a0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd89bad3d,
    to_dict = function() list(`_` = "PhoneCallDiscardReasonDisconnect"),
    bytes = function() as.raw(c(0xa0, 0xc1, 0x95, 0xe0))
  ),
  private = list(
    from_reader = function(reader) self
  ),
  class = TRUE
)

#  @title PhoneCallDiscardReasonHangup
#  @description Telegram API type PhoneCallDiscardReasonHangup
#  @export
#  @noRd
#  @noRd
PhoneCallDiscardReasonHangup <- R6::R6Class("PhoneCallDiscardReasonHangup",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x57adc690,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd89bad3d,
    to_dict = function() list(`_` = "PhoneCallDiscardReasonHangup"),
    bytes = function() as.raw(c(0x90, 0xc6, 0xad, 0x57))
  ),
  private = list(
    from_reader = function(reader) self
  ),
  class = TRUE
)

#  @title PhoneCallDiscardReasonMigrateConferenceCall
#  @description Telegram API type PhoneCallDiscardReasonMigrateConferenceCall
#  @export
#  @noRd
#  @noRd
PhoneCallDiscardReasonMigrateConferenceCall <- R6::R6Class("PhoneCallDiscardReasonMigrateConferenceCall",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9fbbf1f7,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd89bad3d,
    #  @field slug Field.
    slug = NULL,
    initialize = function(slug = NULL) {
      self$slug <- slug
    },
    to_dict = function() list(`_` = "PhoneCallDiscardReasonMigrateConferenceCall", slug = self$slug),
    bytes = function() {
      c(
        as.raw(c(0xf7, 0xf1, 0xbb, 0x9f)),
        self$serializebytes(self$slug)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$slug <- reader$tgread_string()
      self
    }
  ),
  class = TRUE
)

#  @title PhoneCallDiscardReasonMissed
#  @description Telegram API type PhoneCallDiscardReasonMissed
#  @export
#  @noRd
#  @noRd
PhoneCallDiscardReasonMissed <- R6::R6Class("PhoneCallDiscardReasonMissed",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x85e42301,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd89bad3d,
    to_dict = function() list(`_` = "PhoneCallDiscardReasonMissed"),
    bytes = function() as.raw(c(0x01, 0x23, 0xe4, 0x85))
  ),
  private = list(
    from_reader = function(reader) self
  ),
  class = TRUE
)

#  @title PhoneCallDiscarded
#  @description Telegram API type PhoneCallDiscarded
#  @export
#  @noRd
#  @noRd
PhoneCallDiscarded <- R6::R6Class("PhoneCallDiscarded",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x50ca4de1,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc47f1bd1,
    #  @field id Field.
    id = NULL,
    #  @field need_rating Field.
    need_rating = NULL,
    #  @field need_debug Field.
    need_debug = NULL,
    #  @field video Field.
    video = NULL,
    #  @field reason Field.
    reason = NULL,
    #  @field duration Field.
    duration = NULL,
    initialize = function(id = NULL, need_rating = NULL, need_debug = NULL, video = NULL, reason = NULL, duration = NULL) {
      self$id <- id
      self$need_rating <- need_rating
      self$need_debug <- need_debug
      self$video <- video
      self$reason <- reason
      self$duration <- duration
    },
    to_dict = function() list(`_` = "PhoneCallDiscarded", id = self$id, need_rating = self$need_rating, need_debug = self$need_debug, video = self$video, reason = if (inherits(self$reason, "TLObject")) self$reason$to_dict() else self$reason, duration = self$duration),
    bytes = function() {
      c(
        as.raw(c(0xe1, 0x4d, 0xca, 0x50)),
        as.raw(c((ifelse(is.null(self$need_rating), 0, 4)) | (ifelse(is.null(self$need_debug), 0, 8)) | (ifelse(is.null(self$video), 0, 64)) | (ifelse(is.null(self$reason), 0, 1)) | (ifelse(is.null(self$duration), 0, 2)))),
        packBits(intToBits(self$id), type = "raw"),
        if (!is.null(self$reason)) self$reason$bytes() else raw(0),
        if (!is.null(self$duration)) packBits(intToBits(self$duration), type = "raw") else raw(0)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      self$need_rating <- bitwAnd(flags, 4) != 0
      self$need_debug <- bitwAnd(flags, 8) != 0
      self$video <- bitwAnd(flags, 64) != 0
      self$id <- reader$read_long()
      if (bitwAnd(flags, 1)) {
        self$reason <- reader$tgread_object()
      } else {
        self$reason <- NULL
      }
      if (bitwAnd(flags, 2)) {
        self$duration <- reader$read_int()
      } else {
        self$duration <- NULL
      }
      self
    }
  ),
  class = TRUE
)

#  @title PhoneCallEmpty
#  @description Telegram API type PhoneCallEmpty
#  @export
#  @noRd
#  @noRd
PhoneCallEmpty <- R6::R6Class("PhoneCallEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5366c915,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc47f1bd1,
    #  @field id Field.
    id = NULL,
    initialize = function(id = NULL) {
      self$id <- id
    },
    to_dict = function() list(`_` = "PhoneCallEmpty", id = self$id),
    bytes = function() {
      c(
        as.raw(c(0x15, 0xc9, 0x66, 0x53)),
        packBits(intToBits(self$id), type = "raw")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$id <- reader$read_long()
      self
    }
  ),
  class = TRUE
)

#  @title PhoneCallProtocol
#  @description Telegram API type PhoneCallProtocol
#  @export
#  @noRd
#  @noRd
PhoneCallProtocol <- R6::R6Class("PhoneCallProtocol",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xfc878fc8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x783991a3,
    #  @field min_layer Field.
    min_layer = NULL,
    #  @field max_layer Field.
    max_layer = NULL,
    #  @field library_versions Field.
    library_versions = NULL,
    #  @field udp_p2p Field.
    udp_p2p = NULL,
    #  @field udp_reflector Field.
    udp_reflector = NULL,
    initialize = function(min_layer = NULL, max_layer = NULL, library_versions = NULL, udp_p2p = NULL, udp_reflector = NULL) {
      self$min_layer <- min_layer
      self$max_layer <- max_layer
      self$library_versions <- library_versions
      self$udp_p2p <- udp_p2p
      self$udp_reflector <- udp_reflector
    },
    to_dict = function() list(`_` = "PhoneCallProtocol", min_layer = self$min_layer, max_layer = self$max_layer, library_versions = if (is.null(self$library_versions)) list() else self$library_versions, udp_p2p = self$udp_p2p, udp_reflector = self$udp_reflector),
    bytes = function() {
      c(
        as.raw(c(0xc8, 0x8f, 0x87, 0xfc)),
        as.raw(c((ifelse(is.null(self$udp_p2p), 0, 1)) | (ifelse(is.null(self$udp_reflector), 0, 2)))),
        packBits(intToBits(self$min_layer), type = "raw"),
        packBits(intToBits(self$max_layer), type = "raw"),
        as.raw(c(0x1c, 0xb5, 0xc4, 0x15)), packBits(intToBits(length(self$library_versions)), type = "raw"), do.call(c, lapply(self$library_versions, function(x) self$serializebytes(x)))
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      self$udp_p2p <- bitwAnd(flags, 1) != 0
      self$udp_reflector <- bitwAnd(flags, 2) != 0
      self$min_layer <- reader$read_int()
      self$max_layer <- reader$read_int()
      reader$read_int()
      self$library_versions <- list()
      for (i in 1:reader$read_int()) {
        self$library_versions[[i]] <- reader$tgread_string()
      }
      self
    }
  ),
  class = TRUE
)

#  @title PhoneCallRequested
#  @description Telegram API type PhoneCallRequested
#  @export
#  @noRd
#  @noRd
PhoneCallRequested <- R6::R6Class("PhoneCallRequested",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x14b0ed0c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc47f1bd1,
    #  @field id Field.
    id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    #  @field date Field.
    date = NULL,
    #  @field admin_id Field.
    admin_id = NULL,
    #  @field participant_id Field.
    participant_id = NULL,
    #  @field g_a_hash Field.
    g_a_hash = NULL,
    #  @field protocol Field.
    protocol = NULL,
    #  @field video Field.
    video = NULL,
    initialize = function(id = NULL, access_hash = NULL, date = NULL, admin_id = NULL, participant_id = NULL, g_a_hash = NULL, protocol = NULL, video = NULL) {
      self$id <- id
      self$access_hash <- access_hash
      self$date <- date
      self$admin_id <- admin_id
      self$participant_id <- participant_id
      self$g_a_hash <- g_a_hash
      self$protocol <- protocol
      self$video <- video
    },
    to_dict = function() list(`_` = "PhoneCallRequested", id = self$id, access_hash = self$access_hash, date = self$date, admin_id = self$admin_id, participant_id = self$participant_id, g_a_hash = self$g_a_hash, protocol = if (inherits(self$protocol, "TLObject")) self$protocol$to_dict() else self$protocol, video = self$video),
    bytes = function() {
      c(
        as.raw(c(0x0c, 0xed, 0xb0, 0x14)),
        as.raw(ifelse(is.null(self$video), 0, 64)),
        packBits(intToBits(self$id), type = "raw"),
        packBits(intToBits(self$access_hash), type = "raw"),
        self$serialize_datetime(self$date),
        packBits(intToBits(self$admin_id), type = "raw"),
        packBits(intToBits(self$participant_id), type = "raw"),
        self$serializebytes(self$g_a_hash),
        self$protocol$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      self$video <- bitwAnd(flags, 64) != 0
      self$id <- reader$read_long()
      self$access_hash <- reader$read_long()
      self$date <- reader$tgread_date()
      self$admin_id <- reader$read_long()
      self$participant_id <- reader$read_long()
      self$g_a_hash <- reader$tgreadbytes()
      self$protocol <- reader$tgread_object()
      self
    }
  ),
  class = TRUE
)

#  @title PhoneCallWaiting
#  @description Telegram API type PhoneCallWaiting
#  @export
#  @noRd
#  @noRd
PhoneCallWaiting <- R6::R6Class("PhoneCallWaiting",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc5226f17,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc47f1bd1,
    #  @field id Field.
    id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    #  @field date Field.
    date = NULL,
    #  @field admin_id Field.
    admin_id = NULL,
    #  @field participant_id Field.
    participant_id = NULL,
    #  @field protocol Field.
    protocol = NULL,
    #  @field video Field.
    video = NULL,
    #  @field receive_date Field.
    receive_date = NULL,
    initialize = function(id = NULL, access_hash = NULL, date = NULL, admin_id = NULL, participant_id = NULL, protocol = NULL, video = NULL, receive_date = NULL) {
      self$id <- id
      self$access_hash <- access_hash
      self$date <- date
      self$admin_id <- admin_id
      self$participant_id <- participant_id
      self$protocol <- protocol
      self$video <- video
      self$receive_date <- receive_date
    },
    to_dict = function() list(`_` = "PhoneCallWaiting", id = self$id, access_hash = self$access_hash, date = self$date, admin_id = self$admin_id, participant_id = self$participant_id, protocol = if (inherits(self$protocol, "TLObject")) self$protocol$to_dict() else self$protocol, video = self$video, receive_date = self$receive_date),
    bytes = function() {
      c(
        as.raw(c(0x17, 0x6f, 0x22, 0xc5)),
        as.raw(c((ifelse(is.null(self$video), 0, 64)) | (ifelse(is.null(self$receive_date), 0, 1)))),
        packBits(intToBits(self$id), type = "raw"),
        packBits(intToBits(self$access_hash), type = "raw"),
        self$serialize_datetime(self$date),
        packBits(intToBits(self$admin_id), type = "raw"),
        packBits(intToBits(self$participant_id), type = "raw"),
        self$protocol$bytes(),
        if (!is.null(self$receive_date)) self$serialize_datetime(self$receive_date) else raw(0)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      self$video <- bitwAnd(flags, 64) != 0
      self$id <- reader$read_long()
      self$access_hash <- reader$read_long()
      self$date <- reader$tgread_date()
      self$admin_id <- reader$read_long()
      self$participant_id <- reader$read_long()
      self$protocol <- reader$tgread_object()
      if (bitwAnd(flags, 1)) {
        self$receive_date <- reader$tgread_date()
      } else {
        self$receive_date <- NULL
      }
      self
    }
  ),
  class = TRUE
)

#  @title PhoneConnection
#  @description Telegram API type PhoneConnection
#  @export
#  @noRd
#  @noRd
PhoneConnection <- R6::R6Class("PhoneConnection",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9cc123c7,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xaa8de40d,
    #  @field id Field.
    id = NULL,
    #  @field ip Field.
    ip = NULL,
    #  @field ipv6 Field.
    ipv6 = NULL,
    #  @field port Field.
    port = NULL,
    #  @field peer_tag Field.
    peer_tag = NULL,
    #  @field tcp Field.
    tcp = NULL,
    initialize = function(id = NULL, ip = NULL, ipv6 = NULL, port = NULL, peer_tag = NULL, tcp = NULL) {
      self$id <- id
      self$ip <- ip
      self$ipv6 <- ipv6
      self$port <- port
      self$peer_tag <- peer_tag
      self$tcp <- tcp
    },
    to_dict = function() list(`_` = "PhoneConnection", id = self$id, ip = self$ip, ipv6 = self$ipv6, port = self$port, peer_tag = self$peer_tag, tcp = self$tcp),
    bytes = function() {
      c(
        as.raw(c(0xc7, 0x23, 0xc1, 0x9c)),
        as.raw(ifelse(is.null(self$tcp), 0, 1)),
        packBits(intToBits(self$id), type = "raw"),
        self$serializebytes(self$ip),
        self$serializebytes(self$ipv6),
        packBits(intToBits(self$port), type = "raw"),
        self$serializebytes(self$peer_tag)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      self$tcp <- bitwAnd(flags, 1) != 0
      self$id <- reader$read_long()
      self$ip <- reader$tgread_string()
      self$ipv6 <- reader$tgread_string()
      self$port <- reader$read_int()
      self$peer_tag <- reader$tgreadbytes()
      self
    }
  ),
  class = TRUE
)

#  @title PhoneConnectionWebrtc
#  @description Telegram API type PhoneConnectionWebrtc
#  @export
#  @noRd
#  @noRd
PhoneConnectionWebrtc <- R6::R6Class("PhoneConnectionWebrtc",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x635fe375,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xaa8de40d,
    #  @field id Field.
    id = NULL,
    #  @field ip Field.
    ip = NULL,
    #  @field ipv6 Field.
    ipv6 = NULL,
    #  @field port Field.
    port = NULL,
    #  @field username Field.
    username = NULL,
    #  @field password Field.
    password = NULL,
    #  @field turn Field.
    turn = NULL,
    #  @field stun Field.
    stun = NULL,
    initialize = function(id = NULL, ip = NULL, ipv6 = NULL, port = NULL, username = NULL, password = NULL, turn = NULL, stun = NULL) {
      self$id <- id
      self$ip <- ip
      self$ipv6 <- ipv6
      self$port <- port
      self$username <- username
      self$password <- password
      self$turn <- turn
      self$stun <- stun
    },
    to_dict = function() list(`_` = "PhoneConnectionWebrtc", id = self$id, ip = self$ip, ipv6 = self$ipv6, port = self$port, username = self$username, password = self$password, turn = self$turn, stun = self$stun),
    bytes = function() {
      c(
        as.raw(c(0x75, 0xe3, 0x5f, 0x63)),
        as.raw(c(ifelse(is.null(self$turn), 0, 1) | ifelse(is.null(self$stun), 0, 2))),
        packBits(intToBits(self$id), type = "raw"),
        self$serializebytes(self$ip),
        self$serializebytes(self$ipv6),
        packBits(intToBits(self$port), type = "raw"),
        self$serializebytes(self$username),
        self$serializebytes(self$password)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      self$turn <- bitwAnd(flags, 1) != 0
      self$stun <- bitwAnd(flags, 2) != 0
      self$id <- reader$read_long()
      self$ip <- reader$tgread_string()
      self$ipv6 <- reader$tgread_string()
      self$port <- reader$read_int()
      self$username <- reader$tgread_string()
      self$password <- reader$tgread_string()
      self
    }
  ),
  class = TRUE
)

#  @title Photo
#  @description Telegram API type Photo
#  @export
#  @noRd
#  @noRd
Photo <- R6::R6Class("Photo",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xfb197a65,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd576ab1c,
    #  @field id Field.
    id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    #  @field file_reference Field.
    file_reference = NULL,
    #  @field date Field.
    date = NULL,
    #  @field sizes Field.
    sizes = NULL,
    #  @field dc_id Field.
    dc_id = NULL,
    #  @field has_stickers Field.
    has_stickers = NULL,
    #  @field video_sizes Field.
    video_sizes = NULL,
    initialize = function(id = NULL, access_hash = NULL, file_reference = NULL, date = NULL, sizes = NULL, dc_id = NULL, has_stickers = NULL, video_sizes = NULL) {
      self$id <- id
      self$access_hash <- access_hash
      self$file_reference <- file_reference
      self$date <- date
      self$sizes <- sizes
      self$dc_id <- dc_id
      self$has_stickers <- has_stickers
      self$video_sizes <- video_sizes
    },
    to_dict = function() list(`_` = "Photo", id = self$id, access_hash = self$access_hash, file_reference = self$file_reference, date = self$date, sizes = if (is.null(self$sizes)) list() else lapply(self$sizes, function(x) if (inherits(x, "TLObject")) x$to_dict() else x), dc_id = self$dc_id, has_stickers = self$has_stickers, video_sizes = if (is.null(self$video_sizes)) list() else lapply(self$video_sizes, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)),
    bytes = function() {
      c(
        as.raw(c(0x65, 0x7a, 0x19, 0xfb)),
        as.raw(c((ifelse(is.null(self$has_stickers), 0, 1)) | (ifelse(is.null(self$video_sizes), 0, 2)))),
        packBits(intToBits(self$id), type = "raw"),
        packBits(intToBits(self$access_hash), type = "raw"),
        self$serializebytes(self$file_reference),
        self$serialize_datetime(self$date),
        as.raw(c(0x1c, 0xb5, 0xc4, 0x15)), packBits(intToBits(length(self$sizes)), type = "raw"), do.call(c, lapply(self$sizes, function(x) x$bytes())),
        if (!is.null(self$video_sizes)) c(as.raw(c(0x1c, 0xb5, 0xc4, 0x15)), packBits(intToBits(length(self$video_sizes)), type = "raw"), do.call(c, lapply(self$video_sizes, function(x) x$bytes()))) else raw(0),
        packBits(intToBits(self$dc_id), type = "raw")
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      has_stickers <- bitwAnd(flags, 1) != 0
      id <- reader$read_long()
      access_hash <- reader$read_long()
      file_reference <- reader$tgreadbytes()
      date <- reader$tgread_date()
      reader$read_int()
      n_sizes <- reader$read_int()
      sizes <- if (n_sizes > 0) lapply(seq_len(n_sizes), function(i) reader$tgread_object()) else list()
      if (bitwAnd(flags, 2)) {
        reader$read_int()
        n_video <- reader$read_int()
        video_sizes <- if (n_video > 0) lapply(seq_len(n_video), function(i) reader$tgread_object()) else list()
      } else {
        video_sizes <- NULL
      }
      dc_id <- reader$read_int()
      list(
        id = id,
        access_hash = access_hash,
        file_reference = file_reference,
        date = date,
        sizes = sizes,
        dc_id = dc_id,
        has_stickers = has_stickers,
        video_sizes = video_sizes
      )
    }
  ),
  class = TRUE
)

#  @title PhotoCachedSize
#  @description Telegram API type PhotoCachedSize
#  @export
#  @noRd
#  @noRd
PhotoCachedSize <- R6::R6Class("PhotoCachedSize",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x21e1ad6,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x17cc29d9,
    #  @field type Field.
    type = NULL,
    #  @field w Field.
    w = NULL,
    #  @field h Field.
    h = NULL,
    #  @field bytes Field.
    bytes = NULL,
    initialize = function(type = NULL, w = NULL, h = NULL, bytes = NULL) {
      self$type <- type
      self$w <- w
      self$h <- h
      self$bytes <- bytes
    },
    to_dict = function() list(`_` = "PhotoCachedSize", type = self$type, w = self$w, h = self$h, bytes = self$bytes)
  ),
  private = list(
    from_reader = function(reader) {
      list(
        type = reader$tgread_string(),
        w = reader$read_int(),
        h = reader$read_int(),
        bytes = reader$tgreadbytes()
      )
    }
  ),
  class = TRUE
)

#  @title PhotoEmpty
#  @description Telegram API type PhotoEmpty
#  @export
#  @noRd
#  @noRd
PhotoEmpty <- R6::R6Class("PhotoEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x2331b22d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd576ab1c,
    #  @field id Field.
    id = NULL,
    initialize = function(id = NULL) {
      self$id <- id
    },
    to_dict = function() list(`_` = "PhotoEmpty", id = self$id),
    bytes = function() {
      cid <- as.raw(c(0x2d, 0xb2, 0x31, 0x23))
      idbytes <- writeBin(self$id, raw(), size = 8, endian = "little")
      c(cid, idbytes)
    }
  ),
  private = list(
    from_reader = function(reader) list(id = reader$read_long())
  ),
  class = TRUE
)

#  @title PhotoPathSize
#  @description Telegram API type PhotoPathSize
#  @export
#  @noRd
#  @noRd
PhotoPathSize <- R6::R6Class("PhotoPathSize",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd8214d41,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x17cc29d9,
    #  @field type Field.
    type = NULL,
    #  @field bytes Field.
    bytes = NULL,
    initialize = function(type = NULL, bytes = NULL) {
      self$type <- type
      self$bytes <- bytes
    },
    to_dict = function() list(`_` = "PhotoPathSize", type = self$type, bytes_value = self$bytes),
    generate_bytes = function() {
      cid <- as.raw(c(0x41, 0x4d, 0x21, 0xd8))
      typebytes <- charToRaw(self$type)
      bytesbytes <- self$bytes
      c(cid, typebytes, bytesbytes)
    }
  ),
  private = list(
    from_reader = function(reader) list(type = reader$tgread_string(), bytes = reader$tgreadbytes())
  ),
  class = TRUE
)

#  @title PhotoSize
#  @description Telegram API type PhotoSize
#  @export
#  @noRd
#  @noRd
PhotoSize <- R6::R6Class("PhotoSize",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x75c78e60,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x17cc29d9,
    #  @field type Field.
    type = NULL,
    #  @field w Field.
    w = NULL,
    #  @field h Field.
    h = NULL,
    #  @field size Field.
    size = NULL,
    initialize = function(type = NULL, w = NULL, h = NULL, size = NULL) {
      self$type <- type
      self$w <- w
      self$h <- h
      self$size <- size
    },
    to_dict = function() list(`_` = "PhotoSize", type = self$type, w = self$w, h = self$h, size = self$size),
    bytes = function() {
      cid <- as.raw(c(0x60, 0x8e, 0xc7, 0x75))
      typebytes <- charToRaw(self$type)
      wbytes <- writeBin(self$w, raw(), size = 4, endian = "little")
      hbytes <- writeBin(self$h, raw(), size = 4, endian = "little")
      sizebytes <- writeBin(self$size, raw(), size = 4, endian = "little")
      c(cid, typebytes, wbytes, hbytes, sizebytes)
    }
  ),
  private = list(
    from_reader = function(reader) list(type = reader$tgread_string(), w = reader$read_int(), h = reader$read_int(), size = reader$read_int())
  ),
  class = TRUE
)

#  @title PhotoSizeEmpty
#  @description Telegram API type PhotoSizeEmpty
#  @export
#  @noRd
#  @noRd
PhotoSizeEmpty <- R6::R6Class("PhotoSizeEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe17e23c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x17cc29d9,
    #  @field type Field.
    type = NULL,
    initialize = function(type = NULL) {
      self$type <- type
    },
    to_dict = function() list(`_` = "PhotoSizeEmpty", type = self$type),
    bytes = function() as.raw(c(0x3c, 0xe2, 0x17, 0x0e))
  ),
  private = list(
    from_reader = function(reader) list(type = reader$tgread_string())
  ),
  class = TRUE
)

#  @title PhotoSizeProgressive
#  @description Telegram API type PhotoSizeProgressive
#  @export
#  @noRd
#  @noRd
PhotoSizeProgressive <- R6::R6Class("PhotoSizeProgressive",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xfa3efb95,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x17cc29d9,
    #  @field type Field.
    type = NULL,
    #  @field w Field.
    w = NULL,
    #  @field h Field.
    h = NULL,
    #  @field sizes Field.
    sizes = NULL,
    initialize = function(type = NULL, w = NULL, h = NULL, sizes = NULL) {
      self$type <- type
      self$w <- w
      self$h <- h
      self$sizes <- sizes
    },
    to_dict = function() list(`_` = "PhotoSizeProgressive", type = self$type, w = self$w, h = self$h, sizes = if (is.null(self$sizes)) list() else self$sizes),
    bytes = function() {
      cid <- as.raw(c(0x95, 0xfb, 0x3e, 0xfa))
      typebytes <- charToRaw(self$type)
      wbytes <- writeBin(self$w, raw(), size = 4, endian = "little")
      hbytes <- writeBin(self$h, raw(), size = 4, endian = "little")
      sizesbytes <- c(writeBin(length(self$sizes), raw(), size = 4, endian = "little"), unlist(lapply(self$sizes, function(x) writeBin(x, raw(), size = 4, endian = "little"))))
      c(cid, typebytes, wbytes, hbytes, sizesbytes)
    }
  ),
  private = list(
    from_reader = function(reader) {
      type <- reader$tgread_string()
      w <- reader$read_int()
      h <- reader$read_int()
      reader$read_int()
      sizes <- list()
      n_sizes <- reader$read_int()
      if (n_sizes > 0) {
        for (i in seq_len(n_sizes)) {
          sizes <- c(sizes, reader$read_int())
        }
      }
      list(type = type, w = w, h = h, sizes = sizes)
    }
  ),
  class = TRUE
)

#  @title PhotoStrippedSize
#  @description Telegram API type PhotoStrippedSize
#  @export
#  @noRd
#  @noRd
PhotoStrippedSize <- R6::R6Class("PhotoStrippedSize",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe0b0bc2e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x17cc29d9,
    #  @field type Field.
    type = NULL,
    #  @field raw_bytes Field.
    raw_bytes = NULL,
    initialize = function(type = NULL, raw_bytes = NULL) {
      self$type <- type
      self$raw_bytes <- raw_bytes
    },
    to_dict = function() list(`_` = "PhotoStrippedSize", type = self$type, raw_bytes = self$raw_bytes),
    bytes = function() {
      cid <- as.raw(c(0x2e, 0xbc, 0xb0, 0xe0))
      typebytes <- charToRaw(self$type)
      bytesbytes <- self$raw_bytes
      c(cid, typebytes, bytesbytes)
    }
  ),
  private = list(
    from_reader = function(reader) list(type = reader$tgread_string(), raw_bytes = reader$tgreadbytes())
  ),
  class = TRUE
)

#  @title Poll
#  @description Telegram API type Poll
#  @export
#  @noRd
#  @noRd
Poll <- R6::R6Class("Poll",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x58747131,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x248e557b,
    #  @field id Field.
    id = NULL,
    #  @field question Field.
    question = NULL,
    #  @field answers Field.
    answers = NULL,
    #  @field closed Field.
    closed = NULL,
    #  @field public_voters Field.
    public_voters = NULL,
    #  @field multiple_choice Field.
    multiple_choice = NULL,
    #  @field quiz Field.
    quiz = NULL,
    #  @field close_period Field.
    close_period = NULL,
    #  @field close_date Field.
    close_date = NULL,
    initialize = function(id = NULL, question = NULL, answers = NULL, closed = NULL, public_voters = NULL, multiple_choice = NULL, quiz = NULL, close_period = NULL, close_date = NULL) {
      self$id <- id
      self$question <- question
      self$answers <- answers
      self$closed <- closed
      self$public_voters <- public_voters
      self$multiple_choice <- multiple_choice
      self$quiz <- quiz
      self$close_period <- close_period
      self$close_date <- close_date
    },
    to_dict = function() list(`_` = "Poll", id = self$id, question = if (inherits(self$question, "TLObject")) self$question$to_dict() else self$question, answers = if (is.null(self$answers)) list() else lapply(self$answers, function(x) if (inherits(x, "TLObject")) x$to_dict() else x), closed = self$closed, public_voters = self$public_voters, multiple_choice = self$multiple_choice, quiz = self$quiz, close_period = self$close_period, close_date = self$close_date),
    bytes = function() {
      cid <- as.raw(c(0x31, 0x71, 0x74, 0x58))
      flags <- (if (is.null(self$closed) || !self$closed) 0 else 1) | (if (is.null(self$public_voters) || !self$public_voters) 0 else 2) | (if (is.null(self$multiple_choice) || !self$multiple_choice) 0 else 4) | (if (is.null(self$quiz) || !self$quiz) 0 else 8) | (if (is.null(self$close_period)) 0 else 16) | (if (is.null(self$close_date)) 0 else 32)
      flagsbytes <- writeBin(flags, raw(), size = 4, endian = "little")
      idbytes <- writeBin(self$id, raw(), size = 8, endian = "little")
      questionbytes <- self$question$bytes()
      answersbytes <- c(writeBin(length(self$answers), raw(), size = 4, endian = "little"), unlist(lapply(self$answers, function(x) x$bytes())))
      close_periodbytes <- if (!is.null(self$close_period)) writeBin(self$close_period, raw(), size = 4, endian = "little") else raw()
      close_datebytes <- if (!is.null(self$close_date)) self$serialize_datetime(self$close_date) else raw()
      c(cid, flagsbytes, idbytes, questionbytes, answersbytes, close_periodbytes, close_datebytes)
    }
  ),
  private = list(
    from_reader = function(reader) {
      id <- reader$read_long()
      flags <- reader$read_int()
      closed <- bitwAnd(flags, 1) != 0
      public_voters <- bitwAnd(flags, 2) != 0
      multiple_choice <- bitwAnd(flags, 4) != 0
      quiz <- bitwAnd(flags, 8) != 0
      question <- reader$tgread_object()
      reader$read_int()
      answers <- list()
      for (i in 1:reader$read_int()) {
        answers <- c(answers, reader$tgread_object())
      }
      close_period <- if (bitwAnd(flags, 16) != 0) reader$read_int() else NULL
      close_date <- if (bitwAnd(flags, 32) != 0) reader$tgread_date() else NULL
      list(id = id, question = question, answers = answers, closed = closed, public_voters = public_voters, multiple_choice = multiple_choice, quiz = quiz, close_period = close_period, close_date = close_date)
    }
  ),
  class = TRUE
)

#  @title PollAnswer
#  @description Telegram API type PollAnswer
#  @export
#  @noRd
#  @noRd
PollAnswer <- R6::R6Class("PollAnswer",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xff16e2ca,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x7ea5dd9e,
    #  @field text Field.
    text = NULL,
    #  @field option Field.
    option = NULL,
    initialize = function(text = NULL, option = NULL) {
      self$text <- text
      self$option <- option
    },
    to_dict = function() list(`_` = "PollAnswer", text = if (inherits(self$text, "TLObject")) self$text$to_dict() else self$text, option = self$option),
    bytes = function() {
      cid <- as.raw(c(0xca, 0xe2, 0x16, 0xff))
      textbytes <- self$text$bytes()
      optionbytes <- self$option
      c(cid, textbytes, optionbytes)
    }
  ),
  private = list(
    from_reader = function(reader) list(text = reader$tgread_object(), option = reader$tgreadbytes())
  ),
  class = TRUE
)

#  @title PollAnswerVoters
#  @description Telegram API type PollAnswerVoters
#  @export
#  @noRd
#  @noRd
PollAnswerVoters <- R6::R6Class("PollAnswerVoters",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x3b6ddad2,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x7ce0cf91,
    #  @field option Field.
    option = NULL,
    #  @field voters Field.
    voters = NULL,
    #  @field chosen Field.
    chosen = NULL,
    #  @field correct Field.
    correct = NULL,
    initialize = function(option = NULL, voters = NULL, chosen = NULL, correct = NULL) {
      self$option <- option
      self$voters <- voters
      self$chosen <- chosen
      self$correct <- correct
    },
    to_dict = function() list(`_` = "PollAnswerVoters", option = self$option, voters = self$voters, chosen = self$chosen, correct = self$correct),
    bytes = function() {
      cid <- as.raw(c(0xd2, 0xda, 0x6d, 0x3b))
      flags <- (if (is.null(self$chosen) || !self$chosen) 0 else 1) | (if (is.null(self$correct) || !self$correct) 0 else 2)
      flagsbytes <- writeBin(flags, raw(), size = 4, endian = "little")
      optionbytes <- self$option
      votersbytes <- writeBin(self$voters, raw(), size = 4, endian = "little")
      c(cid, flagsbytes, optionbytes, votersbytes)
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      chosen <- bitwAnd(flags, 1) != 0
      correct <- bitwAnd(flags, 2) != 0
      option <- reader$tgreadbytes()
      voters <- reader$read_int()
      list(option = option, voters = voters, chosen = chosen, correct = correct)
    }
  ),
  class = TRUE
)

#  @title PollResults
#  @description Telegram API type PollResults
#  @export
#  @noRd
#  @noRd
PollResults <- R6::R6Class("PollResults",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7adf2420,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc3b4f687,
    #  @field min Field.
    min = NULL,
    #  @field results Field.
    results = NULL,
    #  @field total_voters Field.
    total_voters = NULL,
    #  @field recent_voters Field.
    recent_voters = NULL,
    #  @field solution Field.
    solution = NULL,
    #  @field solution_entities Field.
    solution_entities = NULL,
    initialize = function(min = NULL, results = NULL, total_voters = NULL, recent_voters = NULL, solution = NULL, solution_entities = NULL) {
      self$min <- min
      self$results <- results
      self$total_voters <- total_voters
      self$recent_voters <- recent_voters
      self$solution <- solution
      self$solution_entities <- solution_entities
    },
    to_dict = function() list(`_` = "PollResults", min = self$min, results = if (is.null(self$results)) list() else lapply(self$results, function(x) if (inherits(x, "TLObject")) x$to_dict() else x), total_voters = self$total_voters, recent_voters = if (is.null(self$recent_voters)) list() else lapply(self$recent_voters, function(x) if (inherits(x, "TLObject")) x$to_dict() else x), solution = self$solution, solution_entities = if (is.null(self$solution_entities)) list() else lapply(self$solution_entities, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)),
    bytes = function() {
      cid <- as.raw(c(0x20, 0x24, 0xdf, 0x7a))
      flags <- (if (is.null(self$min) || !self$min) 0 else 1) | (if (is.null(self$results)) 0 else 2) | (if (is.null(self$total_voters)) 0 else 4) | (if (is.null(self$recent_voters)) 0 else 8) | (if (is.null(self$solution)) 0 else 16) | (if (is.null(self$solution_entities)) 0 else 16)
      flagsbytes <- writeBin(flags, raw(), size = 4, endian = "little")
      resultsbytes <- if (!is.null(self$results)) c(writeBin(length(self$results), raw(), size = 4, endian = "little"), unlist(lapply(self$results, function(x) x$bytes()))) else raw()
      total_votersbytes <- if (!is.null(self$total_voters)) writeBin(self$total_voters, raw(), size = 4, endian = "little") else raw()
      recent_votersbytes <- if (!is.null(self$recent_voters)) c(writeBin(length(self$recent_voters), raw(), size = 4, endian = "little"), unlist(lapply(self$recent_voters, function(x) x$bytes()))) else raw()
      solutionbytes <- if (!is.null(self$solution)) charToRaw(self$solution) else raw()
      solution_entitiesbytes <- if (!is.null(self$solution_entities)) c(writeBin(length(self$solution_entities), raw(), size = 4, endian = "little"), unlist(lapply(self$solution_entities, function(x) x$bytes()))) else raw()
      c(cid, flagsbytes, resultsbytes, total_votersbytes, recent_votersbytes, solutionbytes, solution_entitiesbytes)
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      min <- bitwAnd(flags, 1) != 0
      results <- if (bitwAnd(flags, 2) != 0) {
        reader$read_int()
        res <- list()
        for (i in 1:reader$read_int()) {
          res <- c(res, reader$tgread_object())
        }
        res
      } else {
        NULL
      }
      total_voters <- if (bitwAnd(flags, 4) != 0) reader$read_int() else NULL
      recent_voters <- if (bitwAnd(flags, 8) != 0) {
        reader$read_int()
        rv <- list()
        for (i in 1:reader$read_int()) {
          rv <- c(rv, reader$tgread_object())
        }
        rv
      } else {
        NULL
      }
      solution <- if (bitwAnd(flags, 16) != 0) reader$tgread_string() else NULL
      solution_entities <- if (bitwAnd(flags, 16) != 0) {
        reader$read_int()
        se <- list()
        for (i in 1:reader$read_int()) {
          se <- c(se, reader$tgread_object())
        }
        se
      } else {
        NULL
      }
      list(min = min, results = results, total_voters = total_voters, recent_voters = recent_voters, solution = solution, solution_entities = solution_entities)
    }
  ),
  class = TRUE
)

#  @title Pong
#  @description Telegram API type Pong
#  @export
#  @noRd
#  @noRd
Pong <- R6::R6Class("Pong",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x347773c5,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x816aee71,
    #  @field msg_id Field.
    msg_id = NULL,
    #  @field ping_id Field.
    ping_id = NULL,
    initialize = function(msg_id = NULL, ping_id = NULL) {
      self$msg_id <- msg_id
      self$ping_id <- ping_id
    },
    to_dict = function() list(`_` = "Pong", msg_id = self$msg_id, ping_id = self$ping_id),
    bytes = function() {
      cid <- as.raw(c(0xc5, 0x73, 0x77, 0x34))
      msg_idbytes <- writeBin(self$msg_id, raw(), size = 8, endian = "little")
      ping_idbytes <- writeBin(self$ping_id, raw(), size = 8, endian = "little")
      c(cid, msg_idbytes, ping_idbytes)
    }
  ),
  private = list(
    from_reader = function(reader) list(msg_id = reader$read_long(), ping_id = reader$read_long())
  ),
  class = TRUE
)

#  @title PopularContact
#  @description Telegram API type PopularContact
#  @export
#  @noRd
#  @noRd
PopularContact <- R6::R6Class("PopularContact",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5ce14175,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x409255a,
    #  @field client_id Field.
    client_id = NULL,
    #  @field importers Field.
    importers = NULL,
    initialize = function(client_id = NULL, importers = NULL) {
      self$client_id <- client_id
      self$importers <- importers
    },
    to_dict = function() list(`_` = "PopularContact", client_id = self$client_id, importers = self$importers),
    bytes = function() {
      cid <- as.raw(c(0x75, 0x41, 0xe1, 0x5c))
      client_idbytes <- writeBin(self$client_id, raw(), size = 8, endian = "little")
      importersbytes <- writeBin(self$importers, raw(), size = 4, endian = "little")
      c(cid, client_idbytes, importersbytes)
    }
  ),
  private = list(
    from_reader = function(reader) list(client_id = reader$read_long(), importers = reader$read_int())
  ),
  class = TRUE
)

#  @title PostAddress
#  @description Telegram API type PostAddress
#  @export
#  @noRd
#  @noRd
PostAddress <- R6::R6Class("PostAddress",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1e8caaeb,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8d7eda2c,
    #  @field street_line1 Field.
    street_line1 = NULL,
    #  @field street_line2 Field.
    street_line2 = NULL,
    #  @field city Field.
    city = NULL,
    #  @field state Field.
    state = NULL,
    #  @field country_iso2 Field.
    country_iso2 = NULL,
    #  @field post_code Field.
    post_code = NULL,
    initialize = function(street_line1 = NULL, street_line2 = NULL, city = NULL, state = NULL, country_iso2 = NULL, post_code = NULL) {
      self$street_line1 <- street_line1
      self$street_line2 <- street_line2
      self$city <- city
      self$state <- state
      self$country_iso2 <- country_iso2
      self$post_code <- post_code
    },
    to_dict = function() list(`_` = "PostAddress", street_line1 = self$street_line1, street_line2 = self$street_line2, city = self$city, state = self$state, country_iso2 = self$country_iso2, post_code = self$post_code),
    bytes = function() {
      cid <- as.raw(c(0xeb, 0xaa, 0x8c, 0x1e))
      street_line1bytes <- charToRaw(self$street_line1)
      street_line2bytes <- charToRaw(self$street_line2)
      citybytes <- charToRaw(self$city)
      statebytes <- charToRaw(self$state)
      country_iso2bytes <- charToRaw(self$country_iso2)
      post_codebytes <- charToRaw(self$post_code)
      c(cid, street_line1bytes, street_line2bytes, citybytes, statebytes, country_iso2bytes, post_codebytes)
    }
  ),
  private = list(
    from_reader = function(reader) list(street_line1 = reader$tgread_string(), street_line2 = reader$tgread_string(), city = reader$tgread_string(), state = reader$tgread_string(), country_iso2 = reader$tgread_string(), post_code = reader$tgread_string())
  ),
  class = TRUE
)

#  @title PostInteractionCountersMessage
#  @description Telegram API type PostInteractionCountersMessage
#  @export
#  @noRd
#  @noRd
PostInteractionCountersMessage <- R6::R6Class("PostInteractionCountersMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe7058e7f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x6e4a459b,
    #  @field msg_id Field.
    msg_id = NULL,
    #  @field views Field.
    views = NULL,
    #  @field forwards Field.
    forwards = NULL,
    #  @field reactions Field.
    reactions = NULL,
    initialize = function(msg_id = NULL, views = NULL, forwards = NULL, reactions = NULL) {
      self$msg_id <- msg_id
      self$views <- views
      self$forwards <- forwards
      self$reactions <- reactions
    },
    to_dict = function() list(`_` = "PostInteractionCountersMessage", msg_id = self$msg_id, views = self$views, forwards = self$forwards, reactions = self$reactions),
    bytes = function() {
      cid <- as.raw(c(0x7f, 0x8e, 0x05, 0xe7))
      msg_idbytes <- writeBin(self$msg_id, raw(), size = 4, endian = "little")
      viewsbytes <- writeBin(self$views, raw(), size = 4, endian = "little")
      forwardsbytes <- writeBin(self$forwards, raw(), size = 4, endian = "little")
      reactionsbytes <- writeBin(self$reactions, raw(), size = 4, endian = "little")
      c(cid, msg_idbytes, viewsbytes, forwardsbytes, reactionsbytes)
    }
  ),
  private = list(
    from_reader = function(reader) list(msg_id = reader$read_int(), views = reader$read_int(), forwards = reader$read_int(), reactions = reader$read_int())
  ),
  class = TRUE
)

#  @title PostInteractionCountersStory
#  @description Telegram API type PostInteractionCountersStory
#  @export
#  @noRd
#  @noRd
PostInteractionCountersStory <- R6::R6Class("PostInteractionCountersStory",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8a480e27,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x6e4a459b,
    #  @field story_id Field.
    story_id = NULL,
    #  @field views Field.
    views = NULL,
    #  @field forwards Field.
    forwards = NULL,
    #  @field reactions Field.
    reactions = NULL,
    initialize = function(story_id = NULL, views = NULL, forwards = NULL, reactions = NULL) {
      self$story_id <- story_id
      self$views <- views
      self$forwards <- forwards
      self$reactions <- reactions
    },
    to_dict = function() list(`_` = "PostInteractionCountersStory", story_id = self$story_id, views = self$views, forwards = self$forwards, reactions = self$reactions),
    bytes = function() {
      cid <- as.raw(c(0x27, 0x0e, 0x48, 0x8a))
      story_idbytes <- writeBin(self$story_id, raw(), size = 4, endian = "little")
      viewsbytes <- writeBin(self$views, raw(), size = 4, endian = "little")
      forwardsbytes <- writeBin(self$forwards, raw(), size = 4, endian = "little")
      reactionsbytes <- writeBin(self$reactions, raw(), size = 4, endian = "little")
      c(cid, story_idbytes, viewsbytes, forwardsbytes, reactionsbytes)
    }
  ),
  private = list(
    from_reader = function(reader) list(story_id = reader$read_int(), views = reader$read_int(), forwards = reader$read_int(), reactions = reader$read_int())
  ),
  class = TRUE
)

#  @title PremiumGiftCodeOption
#  @description Telegram API type PremiumGiftCodeOption
#  @export
#  @noRd
#  @noRd
PremiumGiftCodeOption <- R6::R6Class("PremiumGiftCodeOption",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x257e962b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x21d3c2,
    #  @field users Field.
    users = NULL,
    #  @field months Field.
    months = NULL,
    #  @field currency Field.
    currency = NULL,
    #  @field amount Field.
    amount = NULL,
    #  @field store_product Field.
    store_product = NULL,
    #  @field store_quantity Field.
    store_quantity = NULL,
    initialize = function(users = NULL, months = NULL, currency = NULL, amount = NULL, store_product = NULL, store_quantity = NULL) {
      self$users <- users
      self$months <- months
      self$currency <- currency
      self$amount <- amount
      self$store_product <- store_product
      self$store_quantity <- store_quantity
    },
    to_dict = function() list(`_` = "PremiumGiftCodeOption", users = self$users, months = self$months, currency = self$currency, amount = self$amount, store_product = self$store_product, store_quantity = self$store_quantity),
    bytes = function() {
      cid <- as.raw(c(0x2b, 0x96, 0x7e, 0x25))
      flags <- (if (is.null(self$store_product)) 0 else 1) | (if (is.null(self$store_quantity)) 0 else 2)
      flagsbytes <- writeBin(flags, raw(), size = 4, endian = "little")
      usersbytes <- writeBin(self$users, raw(), size = 4, endian = "little")
      monthsbytes <- writeBin(self$months, raw(), size = 4, endian = "little")
      store_productbytes <- if (!is.null(self$store_product)) charToRaw(self$store_product) else raw()
      store_quantitybytes <- if (!is.null(self$store_quantity)) writeBin(self$store_quantity, raw(), size = 4, endian = "little") else raw()
      currencybytes <- charToRaw(self$currency)
      amountbytes <- writeBin(self$amount, raw(), size = 8, endian = "little")
      c(cid, flagsbytes, usersbytes, monthsbytes, store_productbytes, store_quantitybytes, currencybytes, amountbytes)
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      users <- reader$read_int()
      months <- reader$read_int()
      store_product <- if (bitwAnd(flags, 1) != 0) reader$tgread_string() else NULL
      store_quantity <- if (bitwAnd(flags, 2) != 0) reader$read_int() else NULL
      currency <- reader$tgread_string()
      amount <- reader$read_long()
      list(users = users, months = months, currency = currency, amount = amount, store_product = store_product, store_quantity = store_quantity)
    }
  ),
  class = TRUE
)

#  @title PremiumSubscriptionOption
#  @description Telegram API type PremiumSubscriptionOption
#  @export
#  @noRd
#  @noRd
PremiumSubscriptionOption <- R6::R6Class("PremiumSubscriptionOption",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5f2d1df2,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x2e2dc73f,
    #  @field months Field.
    months = NULL,
    #  @field currency Field.
    currency = NULL,
    #  @field amount Field.
    amount = NULL,
    #  @field bot_url Field.
    bot_url = NULL,
    #  @field current Field.
    current = NULL,
    #  @field can_purchase_upgrade Field.
    can_purchase_upgrade = NULL,
    #  @field transaction Field.
    transaction = NULL,
    #  @field store_product Field.
    store_product = NULL,
    initialize = function(months = NULL, currency = NULL, amount = NULL, bot_url = NULL, current = NULL, can_purchase_upgrade = NULL, transaction = NULL, store_product = NULL) {
      self$months <- months
      self$currency <- currency
      self$amount <- amount
      self$bot_url <- bot_url
      self$current <- current
      self$can_purchase_upgrade <- can_purchase_upgrade
      self$transaction <- transaction
      self$store_product <- store_product
    },
    to_dict = function() list(`_` = "PremiumSubscriptionOption", months = self$months, currency = self$currency, amount = self$amount, bot_url = self$bot_url, current = self$current, can_purchase_upgrade = self$can_purchase_upgrade, transaction = self$transaction, store_product = self$store_product),
    bytes = function() {
      cid <- as.raw(c(0xf2, 0x1d, 0x2d, 0x5f))
      flags <- (if (is.null(self$current) || !self$current) 0 else 2) | (if (is.null(self$can_purchase_upgrade) || !self$can_purchase_upgrade) 0 else 4) | (if (is.null(self$transaction)) 0 else 8) | (if (is.null(self$store_product)) 0 else 1)
      flagsbytes <- writeBin(flags, raw(), size = 4, endian = "little")
      transactionbytes <- if (!is.null(self$transaction)) charToRaw(self$transaction) else raw()
      monthsbytes <- writeBin(self$months, raw(), size = 4, endian = "little")
      currencybytes <- charToRaw(self$currency)
      amountbytes <- writeBin(self$amount, raw(), size = 8, endian = "little")
      bot_urlbytes <- charToRaw(self$bot_url)
      store_productbytes <- if (!is.null(self$store_product)) charToRaw(self$store_product) else raw()
      c(cid, flagsbytes, transactionbytes, monthsbytes, currencybytes, amountbytes, bot_urlbytes, store_productbytes)
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      current <- bitwAnd(flags, 2) != 0
      can_purchase_upgrade <- bitwAnd(flags, 4) != 0
      transaction <- if (bitwAnd(flags, 8) != 0) reader$tgread_string() else NULL
      months <- reader$read_int()
      currency <- reader$tgread_string()
      amount <- reader$read_long()
      bot_url <- reader$tgread_string()
      store_product <- if (bitwAnd(flags, 1) != 0) reader$tgread_string() else NULL
      list(months = months, currency = currency, amount = amount, bot_url = bot_url, current = current, can_purchase_upgrade = can_purchase_upgrade, transaction = transaction, store_product = store_product)
    }
  ),
  class = TRUE
)

#  @title PrepaidGiveaway
#  @description Telegram API type PrepaidGiveaway
#  @export
#  @noRd
#  @noRd
PrepaidGiveaway <- R6::R6Class("PrepaidGiveaway",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb2539d54,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xee3e6780,
    #  @field id Field.
    id = NULL,
    #  @field months Field.
    months = NULL,
    #  @field quantity Field.
    quantity = NULL,
    #  @field date Field.
    date = NULL,
    initialize = function(id = NULL, months = NULL, quantity = NULL, date = NULL) {
      self$id <- id
      self$months <- months
      self$quantity <- quantity
      self$date <- date
    },
    to_dict = function() list(`_` = "PrepaidGiveaway", id = self$id, months = self$months, quantity = self$quantity, date = self$date),
    bytes = function() {
      cid <- as.raw(c(0x54, 0x9d, 0x53, 0xb2))
      idbytes <- writeBin(self$id, raw(), size = 8, endian = "little")
      monthsbytes <- writeBin(self$months, raw(), size = 4, endian = "little")
      quantitybytes <- writeBin(self$quantity, raw(), size = 4, endian = "little")
      datebytes <- self$serialize_datetime(self$date)
      c(cid, idbytes, monthsbytes, quantitybytes, datebytes)
    }
  ),
  private = list(
    from_reader = function(reader) list(id = reader$read_long(), months = reader$read_int(), quantity = reader$read_int(), date = reader$tgread_date())
  ),
  class = TRUE
)

#  @title PrepaidStarsGiveaway
#  @description Telegram API type PrepaidStarsGiveaway
#  @export
#  @noRd
#  @noRd
PrepaidStarsGiveaway <- R6::R6Class("PrepaidStarsGiveaway",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9a9d77e0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xee3e6780,
    #  @field id Field.
    id = NULL,
    #  @field stars Field.
    stars = NULL,
    #  @field quantity Field.
    quantity = NULL,
    #  @field boosts Field.
    boosts = NULL,
    #  @field date Field.
    date = NULL,
    initialize = function(id = NULL, stars = NULL, quantity = NULL, boosts = NULL, date = NULL) {
      self$id <- id
      self$stars <- stars
      self$quantity <- quantity
      self$boosts <- boosts
      self$date <- date
    },
    to_dict = function() list(`_` = "PrepaidStarsGiveaway", id = self$id, stars = self$stars, quantity = self$quantity, boosts = self$boosts, date = self$date),
    bytes = function() {
      cid <- as.raw(c(0xe0, 0x77, 0x9d, 0x9a))
      idbytes <- writeBin(self$id, raw(), size = 8, endian = "little")
      starsbytes <- writeBin(self$stars, raw(), size = 8, endian = "little")
      quantitybytes <- writeBin(self$quantity, raw(), size = 4, endian = "little")
      boostsbytes <- writeBin(self$boosts, raw(), size = 4, endian = "little")
      datebytes <- self$serialize_datetime(self$date)
      c(cid, idbytes, starsbytes, quantitybytes, boostsbytes, datebytes)
    }
  ),
  private = list(
    from_reader = function(reader) list(id = reader$read_long(), stars = reader$read_long(), quantity = reader$read_int(), boosts = reader$read_int(), date = reader$tgread_date())
  ),
  class = TRUE
)

#  @title PrivacyKeyAbout
#  @description Telegram API type PrivacyKeyAbout
#  @export
#  @noRd
#  @noRd
PrivacyKeyAbout <- R6::R6Class("PrivacyKeyAbout",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa486b761,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x824651c3,
    to_dict = function() list(`_` = "PrivacyKeyAbout"),
    bytes = function() as.raw(c(0x61, 0xb7, 0x86, 0xa4))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title PrivacyKeyAddedByPhone
#  @description Telegram API type PrivacyKeyAddedByPhone
#  @export
#  @noRd
#  @noRd
PrivacyKeyAddedByPhone <- R6::R6Class("PrivacyKeyAddedByPhone",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x42ffd42b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x824651c3,
    to_dict = function() list(`_` = "PrivacyKeyAddedByPhone"),
    bytes = function() as.raw(c(0x2b, 0xd4, 0xff, 0x42))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title PrivacyKeyBirthday
#  @description Telegram API type PrivacyKeyBirthday
#  @export
#  @noRd
#  @noRd
PrivacyKeyBirthday <- R6::R6Class("PrivacyKeyBirthday",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x2000a518,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x824651c3,
    to_dict = function() list(`_` = "PrivacyKeyBirthday"),
    bytes = function() as.raw(c(0x18, 0xa5, 0x00, 0x20))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title PrivacyKeyChatInvite
#  @description Telegram API type PrivacyKeyChatInvite
#  @export
#  @noRd
#  @noRd
PrivacyKeyChatInvite <- R6::R6Class("PrivacyKeyChatInvite",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x500e6dfa,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x824651c3,
    to_dict = function() list(`_` = "PrivacyKeyChatInvite"),
    bytes = function() as.raw(c(0xfa, 0x6d, 0x0e, 0x50))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title PrivacyKeyForwards
#  @description Telegram API type PrivacyKeyForwards
#  @export
#  @noRd
#  @noRd
PrivacyKeyForwards <- R6::R6Class("PrivacyKeyForwards",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x69ec56a3,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x824651c3,
    to_dict = function() list(`_` = "PrivacyKeyForwards"),
    bytes = function() as.raw(c(0xa3, 0x56, 0xec, 0x69))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title PrivacyKeyNoPaidMessages
#  @description Telegram API type PrivacyKeyNoPaidMessages
#  @export
#  @noRd
#  @noRd
PrivacyKeyNoPaidMessages <- R6::R6Class("PrivacyKeyNoPaidMessages",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x17d348d2,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x824651c3,
    to_dict = function() list(`_` = "PrivacyKeyNoPaidMessages"),
    bytes = function() as.raw(c(0xd2, 0x48, 0xd3, 0x17))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title PrivacyKeyPhoneCall
#  @description Telegram API type PrivacyKeyPhoneCall
#  @export
#  @noRd
#  @noRd
PrivacyKeyPhoneCall <- R6::R6Class("PrivacyKeyPhoneCall",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x3d662b7b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x824651c3,
    to_dict = function() list(`_` = "PrivacyKeyPhoneCall"),
    bytes = function() as.raw(c(0x7b, 0x2b, 0x66, 0x3d))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title PrivacyKeyPhoneNumber
#  @description Telegram API type PrivacyKeyPhoneNumber
#  @export
#  @noRd
#  @noRd
PrivacyKeyPhoneNumber <- R6::R6Class("PrivacyKeyPhoneNumber",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd19ae46d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x824651c3,
    to_dict = function() list(`_` = "PrivacyKeyPhoneNumber"),
    bytes = function() as.raw(c(0x6d, 0xe4, 0x9a, 0xd1))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title PrivacyKeyPhoneP2P
#  @description Telegram API type PrivacyKeyPhoneP2P
#  @export
#  @noRd
#  @noRd
PrivacyKeyPhoneP2P <- R6::R6Class("PrivacyKeyPhoneP2P",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x39491cc8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x824651c3,
    to_dict = function() list(`_` = "PrivacyKeyPhoneP2P"),
    bytes = function() as.raw(c(0xc8, 0x1c, 0x49, 0x39))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title PrivacyKeyProfilePhoto
#  @description Telegram API type PrivacyKeyProfilePhoto
#  @export
#  @noRd
#  @noRd
PrivacyKeyProfilePhoto <- R6::R6Class("PrivacyKeyProfilePhoto",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x96151fed,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x824651c3,
    to_dict = function() list(`_` = "PrivacyKeyProfilePhoto"),
    bytes = function() as.raw(c(0xed, 0x1f, 0x15, 0x96))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title PrivacyKeyStarGiftsAutoSave
#  @description Telegram API type PrivacyKeyStarGiftsAutoSave
#  @export
#  @noRd
#  @noRd
PrivacyKeyStarGiftsAutoSave <- R6::R6Class("PrivacyKeyStarGiftsAutoSave",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x2ca4fdf8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x824651c3,
    to_dict = function() list(`_` = "PrivacyKeyStarGiftsAutoSave"),
    bytes = function() as.raw(c(0xf8, 0xfd, 0xa4, 0x2c))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title PrivacyKeyStatusTimestamp
#  @description Telegram API type PrivacyKeyStatusTimestamp
#  @export
#  @noRd
#  @noRd
PrivacyKeyStatusTimestamp <- R6::R6Class("PrivacyKeyStatusTimestamp",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbc2eab30,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x824651c3,
    to_dict = function() list(`_` = "PrivacyKeyStatusTimestamp"),
    bytes = function() as.raw(c(0x30, 0xab, 0x2e, 0xbc))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title PrivacyKeyVoiceMessages
#  @description Telegram API type PrivacyKeyVoiceMessages
#  @export
#  @noRd
#  @noRd
PrivacyKeyVoiceMessages <- R6::R6Class("PrivacyKeyVoiceMessages",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x697f414,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x824651c3,
    to_dict = function() list(`_` = "PrivacyKeyVoiceMessages"),
    bytes = function() as.raw(c(0x14, 0xf4, 0x97, 0x06))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title PrivacyValueAllowAll
#  @description Telegram API type PrivacyValueAllowAll
#  @export
#  @noRd
#  @noRd
PrivacyValueAllowAll <- R6::R6Class("PrivacyValueAllowAll",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x65427b82,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xebb7f270,
    to_dict = function() list(`_` = "PrivacyValueAllowAll"),
    bytes = function() as.raw(c(0x82, 0x7b, 0x42, 0x65))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title PrivacyValueAllowBots
#  @description Telegram API type PrivacyValueAllowBots
#  @export
#  @noRd
#  @noRd
PrivacyValueAllowBots <- R6::R6Class("PrivacyValueAllowBots",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x21461b5d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xebb7f270,
    to_dict = function() list(`_` = "PrivacyValueAllowBots"),
    bytes = function() as.raw(c(0x5d, 0x1b, 0x46, 0x21))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title PrivacyValueAllowChatParticipants
#  @description Telegram API type PrivacyValueAllowChatParticipants
#  @export
#  @noRd
#  @noRd
PrivacyValueAllowChatParticipants <- R6::R6Class("PrivacyValueAllowChatParticipants",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x6b134e8e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xebb7f270,
    #  @field chats Field.
    chats = NULL,
    initialize = function(chats = NULL) {
      self$chats <- chats
    },
    to_dict = function() list(`_` = "PrivacyValueAllowChatParticipants", chats = if (is.null(self$chats)) list() else self$chats),
    bytes = function() {
      cid <- as.raw(c(0x8e, 0x4e, 0x13, 0x6b))
      chatsbytes <- c(writeBin(length(self$chats), raw(), size = 4, endian = "little"), unlist(lapply(self$chats, function(x) writeBin(x, raw(), size = 8, endian = "little"))))
      c(cid, chatsbytes)
    }
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      chats <- list()
      for (i in 1:reader$read_int()) {
        chats <- c(chats, reader$read_long())
      }
      list(chats = chats)
    }
  ),
  class = TRUE
)

#  @title PrivacyValueAllowCloseFriends
#  @description Telegram API type PrivacyValueAllowCloseFriends
#  @export
#  @noRd
#  @noRd
PrivacyValueAllowCloseFriends <- R6::R6Class("PrivacyValueAllowCloseFriends",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf7e8d89b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xebb7f270,
    to_dict = function() list(`_` = "PrivacyValueAllowCloseFriends"),
    bytes = function() as.raw(c(0x9b, 0xd8, 0xe8, 0xf7))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title PrivacyValueAllowContacts
#  @description Telegram API type PrivacyValueAllowContacts
#  @export
#  @noRd
#  @noRd
PrivacyValueAllowContacts <- R6::R6Class("PrivacyValueAllowContacts",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xfffe1bac,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xebb7f270,
    to_dict = function() list(`_` = "PrivacyValueAllowContacts"),
    bytes = function() as.raw(c(0xac, 0x1b, 0xfe, 0xff))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title PrivacyValueAllowPremium
#  @description Telegram API type PrivacyValueAllowPremium
#  @export
#  @noRd
#  @noRd
PrivacyValueAllowPremium <- R6::R6Class("PrivacyValueAllowPremium",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xece9814b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xebb7f270,
    to_dict = function() list(`_` = "PrivacyValueAllowPremium"),
    bytes = function() as.raw(c(0x4b, 0x81, 0xe9, 0xec))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title PrivacyValueAllowUsers
#  @description Telegram API type PrivacyValueAllowUsers
#  @export
#  @noRd
#  @noRd
PrivacyValueAllowUsers <- R6::R6Class("PrivacyValueAllowUsers",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb8905fb2,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xebb7f270,
    #  @field users Field.
    users = NULL,
    initialize = function(users = NULL) {
      self$users <- users
    },
    to_dict = function() list(`_` = "PrivacyValueAllowUsers", users = if (is.null(self$users)) list() else self$users),
    bytes = function() {
      cid <- as.raw(c(0xb2, 0x5f, 0x90, 0xb8))
      usersbytes <- c(writeBin(length(self$users), raw(), size = 4, endian = "little"), unlist(lapply(self$users, function(x) writeBin(x, raw(), size = 8, endian = "little"))))
      c(cid, usersbytes)
    }
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      users <- list()
      for (i in 1:reader$read_int()) {
        users <- c(users, reader$read_long())
      }
      list(users = users)
    }
  ),
  class = TRUE
)

#  @title PrivacyValueDisallowAll
#  @description Telegram API type PrivacyValueDisallowAll
#  @export
#  @noRd
#  @noRd
PrivacyValueDisallowAll <- R6::R6Class("PrivacyValueDisallowAll",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8b73e763,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xebb7f270,
    to_dict = function() list(`_` = "PrivacyValueDisallowAll"),
    bytes = function() as.raw(c(0x63, 0xe7, 0x73, 0x8b))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title PrivacyValueDisallowBots
#  @description Telegram API type PrivacyValueDisallowBots
#  @export
#  @noRd
#  @noRd
PrivacyValueDisallowBots <- R6::R6Class("PrivacyValueDisallowBots",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf6a5f82f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xebb7f270,
    to_dict = function() list(`_` = "PrivacyValueDisallowBots"),
    bytes = function() as.raw(c(0x2f, 0xf8, 0xa5, 0xf6))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title PrivacyValueDisallowChatParticipants
#  @description Telegram API type PrivacyValueDisallowChatParticipants
#  @export
#  @noRd
#  @noRd
PrivacyValueDisallowChatParticipants <- R6::R6Class("PrivacyValueDisallowChatParticipants",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x41c87565,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xebb7f270,
    #  @field chats Field.
    chats = NULL,
    initialize = function(chats = NULL) {
      self$chats <- chats
    },
    to_dict = function() list(`_` = "PrivacyValueDisallowChatParticipants", chats = if (is.null(self$chats)) list() else self$chats),
    bytes = function() {
      b <- c()
      b <- c(b, as.raw(c(0x65, 0x75, 0xc8, 0x41)))
      b <- c(b, as.raw(c(0x15, 0xc4, 0xb5, 0x1c)))
      b <- c(b, pack("<i", length(self$chats)))
      for (x in self$chats) {
        b <- c(b, pack("<q", x))
      }
      as.raw(b)
    }
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      chats <- list()
      for (i in 1:reader$read_int()) {
        x <- reader$read_long()
        chats <- c(chats, x)
      }
      self$chats <- chats
    }
  ),
  class = TRUE
)

#  @title PrivacyValueDisallowContacts
#  @description Telegram API type PrivacyValueDisallowContacts
#  @export
#  @noRd
#  @noRd
PrivacyValueDisallowContacts <- R6::R6Class("PrivacyValueDisallowContacts",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf888fa1a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xebb7f270,
    to_dict = function() list(`_` = "PrivacyValueDisallowContacts"),
    bytes = function() as.raw(c(0x1a, 0xfa, 0x88, 0xf8))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title PrivacyValueDisallowUsers
#  @description Telegram API type PrivacyValueDisallowUsers
#  @export
#  @noRd
#  @noRd
PrivacyValueDisallowUsers <- R6::R6Class("PrivacyValueDisallowUsers",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe4621141,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xebb7f270,
    #  @field users Field.
    users = NULL,
    initialize = function(users = NULL) {
      self$users <- users
    },
    to_dict = function() list(`_` = "PrivacyValueDisallowUsers", users = if (is.null(self$users)) list() else self$users),
    bytes = function() {
      b <- c()
      b <- c(b, as.raw(c(0x41, 0x11, 0x62, 0xe4)))
      b <- c(b, as.raw(c(0x15, 0xc4, 0xb5, 0x1c)))
      b <- c(b, pack("<i", length(self$users)))
      for (x in self$users) {
        b <- c(b, pack("<q", x))
      }
      as.raw(b)
    }
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      users <- list()
      for (i in 1:reader$read_int()) {
        x <- reader$read_long()
        users <- c(users, x)
      }
      self$users <- users
    }
  ),
  class = TRUE
)

#  @title ProfileTabFiles
#  @description Telegram API type ProfileTabFiles
#  @export
#  @noRd
#  @noRd
ProfileTabFiles <- R6::R6Class("ProfileTabFiles",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xab339c00,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xae48d1b4,
    to_dict = function() list(`_` = "ProfileTabFiles"),
    bytes = function() as.raw(c(0x00, 0x9c, 0x33, 0xab))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title ProfileTabGifs
#  @description Telegram API type ProfileTabGifs
#  @export
#  @noRd
#  @noRd
ProfileTabGifs <- R6::R6Class("ProfileTabGifs",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa2c0f695,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xae48d1b4,
    to_dict = function() list(`_` = "ProfileTabGifs"),
    bytes = function() as.raw(c(0x95, 0xf6, 0xc0, 0xa2))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title ProfileTabGifts
#  @description Telegram API type ProfileTabGifts
#  @export
#  @noRd
#  @noRd
ProfileTabGifts <- R6::R6Class("ProfileTabGifts",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4d4bd46a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xae48d1b4,
    to_dict = function() list(`_` = "ProfileTabGifts"),
    bytes = function() as.raw(c(0x6a, 0xd4, 0x4b, 0x4d))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title ProfileTabLinks
#  @description Telegram API type ProfileTabLinks
#  @export
#  @noRd
#  @noRd
ProfileTabLinks <- R6::R6Class("ProfileTabLinks",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd3656499,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xae48d1b4,
    to_dict = function() list(`_` = "ProfileTabLinks"),
    bytes = function() as.raw(c(0x99, 0x64, 0x65, 0xd3))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title ProfileTabMedia
#  @description Telegram API type ProfileTabMedia
#  @export
#  @noRd
#  @noRd
ProfileTabMedia <- R6::R6Class("ProfileTabMedia",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x72c64955,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xae48d1b4,
    to_dict = function() list(`_` = "ProfileTabMedia"),
    bytes = function() as.raw(c(0x55, 0x49, 0xc6, 0x72))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title ProfileTabMusic
#  @description Telegram API type ProfileTabMusic
#  @export
#  @noRd
#  @noRd
ProfileTabMusic <- R6::R6Class("ProfileTabMusic",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9f27d26e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xae48d1b4,
    to_dict = function() list(`_` = "ProfileTabMusic"),
    bytes = function() as.raw(c(0x6e, 0xd2, 0x27, 0x9f))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title ProfileTabPosts
#  @description Telegram API type ProfileTabPosts
#  @export
#  @noRd
#  @noRd
ProfileTabPosts <- R6::R6Class("ProfileTabPosts",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb98cd696,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xae48d1b4,
    to_dict = function() list(`_` = "ProfileTabPosts"),
    bytes = function() as.raw(c(0x96, 0xd6, 0x8c, 0xb9))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title ProfileTabVoice
#  @description Telegram API type ProfileTabVoice
#  @export
#  @noRd
#  @noRd
ProfileTabVoice <- R6::R6Class("ProfileTabVoice",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe477092e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xae48d1b4,
    to_dict = function() list(`_` = "ProfileTabVoice"),
    bytes = function() as.raw(c(0x2e, 0x09, 0x77, 0xe4))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title PublicForwardMessage
#  @description Telegram API type PublicForwardMessage
#  @export
#  @noRd
#  @noRd
PublicForwardMessage <- R6::R6Class("PublicForwardMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1f2bf4a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x629015d3,
    #  @field message Field.
    message = NULL,
    initialize = function(message = NULL) {
      self$message <- message
    },
    to_dict = function() list(`_` = "PublicForwardMessage", message = if (is.null(self$message)) NULL else self$message$to_dict()),
    bytes = function() {
      b <- c()
      b <- c(b, as.raw(c(0x4a, 0xf4, 0x2b, 0x01)))
      b <- c(b, self$message$bytes())
      as.raw(b)
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$message <- reader$tgread_object()
    }
  ),
  class = TRUE
)

#  @title PublicForwardStory
#  @description Telegram API type PublicForwardStory
#  @export
#  @noRd
#  @noRd
PublicForwardStory <- R6::R6Class("PublicForwardStory",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xedf3add0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x629015d3,
    #  @field peer Field.
    peer = NULL,
    #  @field story Field.
    story = NULL,
    initialize = function(peer = NULL, story = NULL) {
      self$peer <- peer
      self$story <- story
    },
    to_dict = function() list(`_` = "PublicForwardStory", peer = if (is.null(self$peer)) NULL else self$peer$to_dict(), story = if (is.null(self$story)) NULL else self$story$to_dict()),
    bytes = function() {
      b <- c()
      b <- c(b, as.raw(c(0xd0, 0xad, 0xf3, 0xed)))
      b <- c(b, self$peer$bytes())
      b <- c(b, self$story$bytes())
      as.raw(b)
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$peer <- reader$tgread_object()
      self$story <- reader$tgread_object()
    }
  ),
  class = TRUE
)

#  @title QuickReply
#  @description Telegram API type QuickReply
#  @export
#  @noRd
#  @noRd
QuickReply <- R6::R6Class("QuickReply",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x697102b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xe2ea0f12,
    #  @field shortcut_id Field.
    shortcut_id = NULL,
    #  @field shortcut Field.
    shortcut = NULL,
    #  @field top_message Field.
    top_message = NULL,
    #  @field count Field.
    count = NULL,
    initialize = function(shortcut_id = NULL, shortcut = NULL, top_message = NULL, count = NULL) {
      self$shortcut_id <- shortcut_id
      self$shortcut <- shortcut
      self$top_message <- top_message
      self$count <- count
    },
    to_dict = function() list(`_` = "QuickReply", shortcut_id = self$shortcut_id, shortcut = self$shortcut, top_message = self$top_message, count = self$count),
    bytes = function() {
      b <- c()
      b <- c(b, as.raw(c(0x2b, 0x10, 0x97, 0x06)))
      b <- c(b, pack("<i", self$shortcut_id))
      b <- c(b, self$serializebytes(self$shortcut))
      b <- c(b, pack("<i", self$top_message))
      b <- c(b, pack("<i", self$count))
      as.raw(b)
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$shortcut_id <- reader$read_int()
      self$shortcut <- reader$tgread_string()
      self$top_message <- reader$read_int()
      self$count <- reader$read_int()
    }
  ),
  class = TRUE
)

#  @title ReactionCount
#  @description Telegram API type ReactionCount
#  @export
#  @noRd
#  @noRd
ReactionCount <- R6::R6Class("ReactionCount",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa3d1cb80,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd208ce3f,
    #  @field reaction Field.
    reaction = NULL,
    #  @field count Field.
    count = NULL,
    #  @field chosen_order Field.
    chosen_order = NULL,
    initialize = function(reaction = NULL, count = NULL, chosen_order = NULL) {
      self$reaction <- reaction
      self$count <- count
      self$chosen_order <- chosen_order
    },
    to_dict = function() list(`_` = "ReactionCount", reaction = if (is.null(self$reaction)) NULL else self$reaction$to_dict(), count = self$count, chosen_order = self$chosen_order),
    bytes = function() {
      b <- c()
      b <- c(b, as.raw(c(0x80, 0xcb, 0xd1, 0xa3)))
      flags <- 0
      if (!is.null(self$chosen_order)) flags <- bitwOr(flags, 1)
      b <- c(b, pack("<I", flags))
      if (!is.null(self$chosen_order)) b <- c(b, pack("<i", self$chosen_order))
      b <- c(b, self$reaction$bytes())
      b <- c(b, pack("<i", self$count))
      as.raw(b)
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      chosen_order <- if (bitwAnd(flags, 1) != 0) reader$read_int() else NULL
      reaction <- reader$tgread_object()
      count <- reader$read_int()
      list(reaction = reaction, count = count, chosen_order = chosen_order)
    }
  ),
  class = TRUE
)

#  @title ReactionCustomEmoji
#  @description Telegram API type ReactionCustomEmoji
#  @export
#  @noRd
#  @noRd
ReactionCustomEmoji <- R6::R6Class("ReactionCustomEmoji",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8935fc73,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5da165a1,
    #  @field document_id Field.
    document_id = NULL,
    initialize = function(document_id = NULL) {
      self$document_id <- document_id
    },
    to_dict = function() list(`_` = "ReactionCustomEmoji", document_id = self$document_id),
    bytes = function() {
      b <- c()
      b <- c(b, as.raw(c(0x73, 0xfc, 0x35, 0x89)))
      b <- c(b, pack("<q", self$document_id))
      as.raw(b)
    }
  ),
  private = list(
    from_reader = function(reader) {
      document_id <- reader$read_long()
      list(document_id = document_id)
    }
  ),
  class = TRUE
)

#  @title ReactionEmoji
#  @description Telegram API type ReactionEmoji
#  @export
#  @noRd
#  @noRd
ReactionEmoji <- R6::R6Class("ReactionEmoji",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1b2286b8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5da165a1,
    #  @field emoticon Field.
    emoticon = NULL,
    initialize = function(emoticon = NULL) {
      self$emoticon <- emoticon
    },
    to_dict = function() list(`_` = "ReactionEmoji", emoticon = self$emoticon),
    bytes = function() {
      b <- c()
      b <- c(b, as.raw(c(0xb8, 0x86, 0x22, 0x1b)))
      b <- c(b, self$serializebytes(self$emoticon))
      as.raw(b)
    }
  ),
  private = list(
    from_reader = function(reader) {
      emoticon <- reader$tgread_string()
      list(emoticon = emoticon)
    }
  ),
  class = TRUE
)

#  @title ReactionEmpty
#  @description Telegram API type ReactionEmpty
#  @export
#  @noRd
#  @noRd
ReactionEmpty <- R6::R6Class("ReactionEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x79f5d419,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5da165a1,
    to_dict = function() list(`_` = "ReactionEmpty"),
    bytes = function() as.raw(c(0x19, 0xd4, 0xf5, 0x79))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title ReactionNotificationsFromAll
#  @description Telegram API type ReactionNotificationsFromAll
#  @export
#  @noRd
#  @noRd
ReactionNotificationsFromAll <- R6::R6Class("ReactionNotificationsFromAll",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4b9e22a0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x345f7940,
    to_dict = function() list(`_` = "ReactionNotificationsFromAll"),
    bytes = function() as.raw(c(0xa0, 0x22, 0x9e, 0x4b))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title ReactionNotificationsFromContacts
#  @description Telegram API type ReactionNotificationsFromContacts
#  @export
#  @noRd
#  @noRd
ReactionNotificationsFromContacts <- R6::R6Class("ReactionNotificationsFromContacts",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbac3a61a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x345f7940,
    to_dict = function() list(`_` = "ReactionNotificationsFromContacts"),
    bytes = function() as.raw(c(0x1a, 0xa6, 0xc3, 0xba))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title ReactionPaid
#  @description Telegram API type ReactionPaid
#  @export
#  @noRd
#  @noRd
ReactionPaid <- R6::R6Class("ReactionPaid",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x523da4eb,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5da165a1,
    to_dict = function() list(`_` = "ReactionPaid"),
    bytes = function() as.raw(c(0xeb, 0xa4, 0x3d, 0x52))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title ReactionsNotifySettings
#  @description Telegram API type ReactionsNotifySettings
#  @export
#  @noRd
#  @noRd
ReactionsNotifySettings <- R6::R6Class("ReactionsNotifySettings",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x56e34970,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8dff0851,
    #  @field sound Field.
    sound = NULL,
    #  @field show_previews Field.
    show_previews = NULL,
    #  @field messages_notify_from Field.
    messages_notify_from = NULL,
    #  @field stories_notify_from Field.
    stories_notify_from = NULL,
    initialize = function(sound = NULL, show_previews = NULL, messages_notify_from = NULL, stories_notify_from = NULL) {
      self$sound <- sound
      self$show_previews <- show_previews
      self$messages_notify_from <- messages_notify_from
      self$stories_notify_from <- stories_notify_from
    },
    to_dict = function() list(`_` = "ReactionsNotifySettings", sound = if (is.null(self$sound)) NULL else self$sound$to_dict(), show_previews = self$show_previews, messages_notify_from = if (is.null(self$messages_notify_from)) NULL else self$messages_notify_from$to_dict(), stories_notify_from = if (is.null(self$stories_notify_from)) NULL else self$stories_notify_from$to_dict()),
    bytes = function() {
      b <- c()
      b <- c(b, as.raw(c(0x70, 0x49, 0xe3, 0x56)))
      flags <- 0
      if (!is.null(self$messages_notify_from)) flags <- bitwOr(flags, 1)
      if (!is.null(self$stories_notify_from)) flags <- bitwOr(flags, 2)
      b <- c(b, pack("<I", flags))
      if (!is.null(self$messages_notify_from)) b <- c(b, self$messages_notify_from$bytes())
      if (!is.null(self$stories_notify_from)) b <- c(b, self$stories_notify_from$bytes())
      b <- c(b, self$sound$bytes())
      b <- c(b, if (self$show_previews) as.raw(c(0xb5, 0x75, 0x72, 0x99)) else as.raw(c(0x37, 0x97, 0x79, 0xbc)))
      as.raw(b)
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      if (bitwAnd(flags, 1) != 0) {
        self$messages_notify_from <- reader$tgread_object()
      } else {
        self$messages_notify_from <- NULL
      }
      if (bitwAnd(flags, 2) != 0) {
        self$stories_notify_from <- reader$tgread_object()
      } else {
        self$stories_notify_from <- NULL
      }
      self$sound <- reader$tgread_object()
      self$show_previews <- reader$tgread_bool()
    }
  ),
  class = TRUE
)

#  @title ReadParticipantDate
#  @description Telegram API type ReadParticipantDate
#  @export
#  @noRd
#  @noRd
ReadParticipantDate <- R6::R6Class("ReadParticipantDate",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4a4ff172,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xfd078ce2,
    #  @field user_id Field.
    user_id = NULL,
    #  @field date Field.
    date = NULL,
    initialize = function(user_id = NULL, date = NULL) {
      self$user_id <- user_id
      self$date <- date
    },
    to_dict = function() list(`_` = "ReadParticipantDate", user_id = self$user_id, date = self$date),
    bytes = function() {
      b <- c()
      b <- c(b, as.raw(c(0x72, 0xf1, 0x4f, 0x4a)))
      b <- c(b, pack("<q", self$user_id))
      b <- c(b, self$serialize_datetime(self$date))
      as.raw(b)
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$user_id <- reader$read_long()
      self$date <- reader$tgread_date()
    }
  ),
  class = TRUE
)

#  @title ReceivedNotifyMessage
#  @description Telegram API type ReceivedNotifyMessage
#  @export
#  @noRd
#  @noRd
ReceivedNotifyMessage <- R6::R6Class("ReceivedNotifyMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa384b779,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xa962381e,
    #  @field id Field.
    id = NULL,
    #  @field flags Field.
    flags = NULL,
    initialize = function(id = NULL, flags = NULL) {
      self$id <- id
      self$flags <- flags
    },
    to_dict = function() list(`_` = "ReceivedNotifyMessage", id = self$id, flags = self$flags),
    bytes = function() {
      b <- c()
      b <- c(b, as.raw(c(0x79, 0xb7, 0x84, 0xa3)))
      b <- c(b, pack("<i", self$id))
      b <- c(b, pack("<i", self$flags))
      as.raw(b)
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$id <- reader$read_int()
      self$flags <- reader$read_int()
    }
  ),
  class = TRUE
)

#  @title RecentMeUrlChat
#  @description Telegram API type RecentMeUrlChat
#  @export
#  @noRd
#  @noRd
RecentMeUrlChat <- R6::R6Class("RecentMeUrlChat",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb2da71d2,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x55a53079,
    #  @field url Field.
    url = NULL,
    #  @field chat_id Field.
    chat_id = NULL,
    initialize = function(url = NULL, chat_id = NULL) {
      self$url <- url
      self$chat_id <- chat_id
    },
    to_dict = function() list(`_` = "RecentMeUrlChat", url = self$url, chat_id = self$chat_id),
    bytes = function() {
      b <- c()
      b <- c(b, as.raw(c(0xd2, 0x71, 0xda, 0xb2)))
      b <- c(b, self$serializebytes(self$url))
      b <- c(b, pack("<q", self$chat_id))
      as.raw(b)
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$url <- reader$tgread_string()
      self$chat_id <- reader$read_long()
    }
  ),
  class = TRUE
)

#  @title RecentMeUrlChatInvite
#  @description Telegram API type RecentMeUrlChatInvite
#  @export
#  @noRd
#  @noRd
RecentMeUrlChatInvite <- R6::R6Class("RecentMeUrlChatInvite",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xeb49081d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x55a53079,
    #  @field url Field.
    url = NULL,
    #  @field chat_invite Field.
    chat_invite = NULL,
    initialize = function(url = NULL, chat_invite = NULL) {
      self$url <- url
      self$chat_invite <- chat_invite
    },
    to_dict = function() list(`_` = "RecentMeUrlChatInvite", url = self$url, chat_invite = if (is.null(self$chat_invite)) NULL else self$chat_invite$to_dict()),
    bytes = function() {
      b <- c()
      b <- c(b, as.raw(c(0x1d, 0x08, 0x49, 0xeb)))
      b <- c(b, self$serializebytes(self$url))
      b <- c(b, self$chat_invite$bytes())
      as.raw(b)
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$url <- reader$tgread_string()
      self$chat_invite <- reader$tgread_object()
    }
  ),
  class = TRUE
)

#  @title RecentMeUrlStickerSet
#  @description Telegram API type RecentMeUrlStickerSet
#  @export
#  @noRd
#  @noRd
RecentMeUrlStickerSet <- R6::R6Class("RecentMeUrlStickerSet",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbc0a57dc,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x55a53079,
    #  @field url Field.
    url = NULL,
    #  @field set Field.
    set = NULL,
    initialize = function(url = NULL, set = NULL) {
      self$url <- url
      self$set <- set
    },
    to_dict = function() list(`_` = "RecentMeUrlStickerSet", url = self$url, set = if (is.null(self$set)) NULL else self$set$to_dict()),
    bytes = function() {
      b <- c()
      b <- c(b, as.raw(c(0xdc, 0x57, 0x0a, 0xbc)))
      b <- c(b, self$serializebytes(self$url))
      b <- c(b, self$set$bytes())
      as.raw(b)
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$url <- reader$tgread_string()
      self$set <- reader$tgread_object()
    }
  ),
  class = TRUE
)

#  @title RecentMeUrlUnknown
#  @description Telegram API type RecentMeUrlUnknown
#  @export
#  @noRd
#  @noRd
RecentMeUrlUnknown <- R6::R6Class("RecentMeUrlUnknown",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x46e1d13d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x55a53079,
    #  @field url Field.
    url = NULL,
    initialize = function(url = NULL) {
      self$url <- url
    },
    to_dict = function() list(`_` = "RecentMeUrlUnknown", url = self$url),
    bytes = function() {
      b <- c()
      b <- c(b, as.raw(c(0x3d, 0xd1, 0xe1, 0x46)))
      b <- c(b, self$serializebytes(self$url))
      as.raw(b)
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$url <- reader$tgread_string()
    }
  ),
  class = TRUE
)

#  @title RecentMeUrlUser
#  @description Telegram API type RecentMeUrlUser
#  @export
#  @noRd
#  @noRd
RecentMeUrlUser <- R6::R6Class("RecentMeUrlUser",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb92c09e2,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x55a53079,
    #  @field url Field.
    url = NULL,
    #  @field user_id Field.
    user_id = NULL,
    initialize = function(url = NULL, user_id = NULL) {
      self$url <- url
      self$user_id <- user_id
    },
    to_dict = function() list(`_` = "RecentMeUrlUser", url = self$url, user_id = self$user_id),
    bytes = function() {
      b <- c()
      b <- c(b, as.raw(c(0xe2, 0x09, 0x2c, 0xb9)))
      b <- c(b, self$serializebytes(self$url))
      b <- c(b, pack("<q", self$user_id))
      as.raw(b)
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$url <- reader$tgread_string()
      self$user_id <- reader$read_long()
    }
  ),
  class = TRUE
)

#  @title ReplyInlineMarkup
#  @description Telegram API type ReplyInlineMarkup
#  @export
#  @noRd
#  @noRd
ReplyInlineMarkup <- R6::R6Class("ReplyInlineMarkup",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x48a30254,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xe2e10ef2,
    #  @field rows Field.
    rows = NULL,
    initialize = function(rows = NULL) {
      self$rows <- rows
    },
    to_dict = function() list(`_` = "ReplyInlineMarkup", rows = if (is.null(self$rows)) list() else lapply(self$rows, function(x) x$to_dict())),
    bytes = function() {
      b <- c()
      b <- c(b, as.raw(c(0x54, 0x02, 0xa3, 0x48)))
      b <- c(b, as.raw(c(0x15, 0xc4, 0xb5, 0x1c)))
      b <- c(b, pack("<i", length(self$rows)))
      for (x in self$rows) {
        b <- c(b, x$bytes())
      }
      as.raw(b)
    }
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      self$rows <- list()
      for (i in 1:reader$read_int()) {
        x <- reader$tgread_object()
        self$rows <- c(self$rows, x)
      }
    }
  ),
  class = TRUE
)

#  @title ReplyKeyboardForceReply
#  @description Telegram API type ReplyKeyboardForceReply
#  @export
#  @noRd
#  @noRd
ReplyKeyboardForceReply <- R6::R6Class("ReplyKeyboardForceReply",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x86b40b08,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xe2e10ef2,
    #  @field single_use Field.
    single_use = NULL,
    #  @field selective Field.
    selective = NULL,
    #  @field placeholder Field.
    placeholder = NULL,
    initialize = function(single_use = NULL, selective = NULL, placeholder = NULL) {
      self$single_use <- single_use
      self$selective <- selective
      self$placeholder <- placeholder
    },
    to_dict = function() list(`_` = "ReplyKeyboardForceReply", single_use = self$single_use, selective = self$selective, placeholder = self$placeholder),
    bytes = function() {
      b <- c()
      b <- c(b, as.raw(c(0x08, 0x0b, 0xb4, 0x86)))
      flags <- 0
      if (!is.null(self$single_use) && self$single_use) flags <- bitwOr(flags, 2)
      if (!is.null(self$selective) && self$selective) flags <- bitwOr(flags, 4)
      if (!is.null(self$placeholder)) flags <- bitwOr(flags, 8)
      b <- c(b, pack("<I", flags))
      if (!is.null(self$placeholder)) b <- c(b, self$serializebytes(self$placeholder))
      as.raw(b)
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      self$single_use <- bitwAnd(flags, 2) != 0
      self$selective <- bitwAnd(flags, 4) != 0
      if (bitwAnd(flags, 8) != 0) {
        self$placeholder <- reader$tgread_string()
      } else {
        self$placeholder <- NULL
      }
    }
  ),
  class = TRUE
)

#  @title ReplyKeyboardHide
#  @description Telegram API type ReplyKeyboardHide
#  @export
#  @noRd
#  @noRd
ReplyKeyboardHide <- R6::R6Class("ReplyKeyboardHide",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa03e5b85,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xe2e10ef2,
    #  @field selective Field.
    selective = NULL,
    initialize = function(selective = NULL) {
      self$selective <- selective
    },
    to_dict = function() list(`_` = "ReplyKeyboardHide", selective = self$selective),
    bytes = function() {
      b <- c()
      b <- c(b, as.raw(c(0x85, 0x5b, 0x3e, 0xa0)))
      flags <- 0
      if (!is.null(self$selective) && self$selective) flags <- bitwOr(flags, 4)
      b <- c(b, pack("<I", flags))
      as.raw(b)
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      self$selective <- bitwAnd(flags, 4) != 0
    }
  ),
  class = TRUE
)

#  @title ReplyKeyboardMarkup
#  @description Telegram API type ReplyKeyboardMarkup
#  @export
#  @noRd
#  @noRd
ReplyKeyboardMarkup <- R6::R6Class("ReplyKeyboardMarkup",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x85dd99d1,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xe2e10ef2,
    #  @field rows Field.
    rows = NULL,
    #  @field resize Field.
    resize = NULL,
    #  @field single_use Field.
    single_use = NULL,
    #  @field selective Field.
    selective = NULL,
    #  @field persistent Field.
    persistent = NULL,
    #  @field placeholder Field.
    placeholder = NULL,
    initialize = function(rows = NULL, resize = NULL, single_use = NULL, selective = NULL, persistent = NULL, placeholder = NULL) {
      self$rows <- rows
      self$resize <- resize
      self$single_use <- single_use
      self$selective <- selective
      self$persistent <- persistent
      self$placeholder <- placeholder
    },
    to_dict = function() list(`_` = "ReplyKeyboardMarkup", rows = if (is.null(self$rows)) list() else lapply(self$rows, function(x) x$to_dict()), resize = self$resize, single_use = self$single_use, selective = self$selective, persistent = self$persistent, placeholder = self$placeholder),
    bytes = function() {
      b <- c()
      b <- c(b, as.raw(c(0xd1, 0x99, 0xdd, 0x85)))
      flags <- 0
      if (!is.null(self$resize) && self$resize) flags <- bitwOr(flags, 1)
      if (!is.null(self$single_use) && self$single_use) flags <- bitwOr(flags, 2)
      if (!is.null(self$selective) && self$selective) flags <- bitwOr(flags, 4)
      if (!is.null(self$persistent) && self$persistent) flags <- bitwOr(flags, 16)
      if (!is.null(self$placeholder)) flags <- bitwOr(flags, 8)
      b <- c(b, pack("<I", flags))
      b <- c(b, as.raw(c(0x15, 0xc4, 0xb5, 0x1c)))
      b <- c(b, pack("<i", length(self$rows)))
      for (x in self$rows) {
        b <- c(b, x$bytes())
      }
      if (!is.null(self$placeholder)) b <- c(b, self$serializebytes(self$placeholder))
      as.raw(b)
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      self$resize <- bitwAnd(flags, 1) != 0
      self$single_use <- bitwAnd(flags, 2) != 0
      self$selective <- bitwAnd(flags, 4) != 0
      self$persistent <- bitwAnd(flags, 16) != 0
      reader$read_int()
      self$rows <- list()
      for (i in 1:reader$read_int()) {
        x <- reader$tgread_object()
        self$rows <- c(self$rows, x)
      }
      if (bitwAnd(flags, 8) != 0) {
        self$placeholder <- reader$tgread_string()
      } else {
        self$placeholder <- NULL
      }
    }
  ),
  class = TRUE
)

#  @title ReportResultAddComment
#  @description Telegram API type ReportResultAddComment
#  @export
#  @noRd
#  @noRd
ReportResultAddComment <- R6::R6Class("ReportResultAddComment",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x6f09ac31,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xacd3f438,
    #  @field option Field.
    option = NULL,
    #  @field optional Field.
    optional = NULL,
    initialize = function(option = NULL, optional = NULL) {
      self$option <- option
      self$optional <- optional
    },
    to_dict = function() list(`_` = "ReportResultAddComment", option = self$option, optional = self$optional),
    bytes = function() {
      b <- c()
      b <- c(b, as.raw(c(0x31, 0xac, 0x09, 0x6f)))
      flags <- 0
      if (!is.null(self$optional) && self$optional) flags <- bitwOr(flags, 1)
      b <- c(b, pack("<I", flags))
      b <- c(b, self$serializebytes(self$option))
      as.raw(b)
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      self$optional <- bitwAnd(flags, 1) != 0
      self$option <- reader$tgreadbytes()
    }
  ),
  class = TRUE
)

#  @title ReportResultChooseOption
#  @description Telegram API type ReportResultChooseOption
#  @export
#  @noRd
#  @noRd
ReportResultChooseOption <- R6::R6Class("ReportResultChooseOption",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf0e4e0b6,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xacd3f438,
    #  @field title Field.
    title = NULL,
    #  @field options Field.
    options = NULL,
    initialize = function(title = NULL, options = NULL) {
      self$title <- title
      self$options <- options
    },
    to_dict = function() list(`_` = "ReportResultChooseOption", title = self$title, options = if (is.null(self$options)) list() else lapply(self$options, function(x) x$to_dict())),
    bytes = function() {
      b <- c()
      b <- c(b, as.raw(c(0xb6, 0xe0, 0xe4, 0xf0)))
      b <- c(b, self$serializebytes(self$title))
      b <- c(b, as.raw(c(0x15, 0xc4, 0xb5, 0x1c)))
      b <- c(b, pack("<i", length(self$options)))
      for (x in self$options) {
        b <- c(b, x$bytes())
      }
      as.raw(b)
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$title <- reader$tgread_string()
      reader$read_int()
      self$options <- list()
      for (i in 1:reader$read_int()) {
        x <- reader$tgread_object()
        self$options <- c(self$options, x)
      }
    }
  ),
  class = TRUE
)

#  @title ReportResultReported
#  @description Telegram API type ReportResultReported
#  @export
#  @noRd
#  @noRd
ReportResultReported <- R6::R6Class("ReportResultReported",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8db33c4b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xacd3f438,
    to_dict = function() list(`_` = "ReportResultReported"),
    bytes = function() as.raw(c(0x4b, 0x3c, 0xb3, 0x8d))
  ),
  private = list(
    from_reader = function(reader) list()
  ),
  class = TRUE
)

#  @title RequestPeerTypeBroadcast
#  @description Telegram API type RequestPeerTypeBroadcast
#  @export
#  @noRd
#  @noRd
RequestPeerTypeBroadcast <- R6::R6Class("RequestPeerTypeBroadcast",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x339bef6c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xe9a0e814,
    #  @field creator Field.
    creator = NULL,
    #  @field has_username Field.
    has_username = NULL,
    #  @field user_admin_rights Field.
    user_admin_rights = NULL,
    #  @field bot_admin_rights Field.
    bot_admin_rights = NULL,
    initialize = function(creator = NULL, has_username = NULL, user_admin_rights = NULL, bot_admin_rights = NULL) {
      self$creator <- creator
      self$has_username <- has_username
      self$user_admin_rights <- user_admin_rights
      self$bot_admin_rights <- bot_admin_rights
    },
    to_dict = function() list(`_` = "RequestPeerTypeBroadcast", creator = self$creator, has_username = self$has_username, user_admin_rights = if (is.null(self$user_admin_rights)) NULL else self$user_admin_rights$to_dict(), bot_admin_rights = if (is.null(self$bot_admin_rights)) NULL else self$bot_admin_rights$to_dict()),
    bytes = function() {
      b <- c()
      b <- c(b, as.raw(c(0x6c, 0xef, 0x9b, 0x33)))
      flags <- 0
      if (!is.null(self$creator) && self$creator) flags <- bitwOr(flags, 1)
      if (!is.null(self$has_username)) flags <- bitwOr(flags, 8)
      if (!is.null(self$user_admin_rights)) flags <- bitwOr(flags, 2)
      if (!is.null(self$bot_admin_rights)) flags <- bitwOr(flags, 4)
      b <- c(b, pack("<I", flags))
      if (!is.null(self$has_username)) b <- c(b, if (self$has_username) as.raw(c(0xb5, 0x75, 0x72, 0x99)) else as.raw(c(0x37, 0x97, 0x79, 0xbc)))
      if (!is.null(self$user_admin_rights)) b <- c(b, self$user_admin_rights$bytes())
      if (!is.null(self$bot_admin_rights)) b <- c(b, self$bot_admin_rights$bytes())
      as.raw(b)
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      self$creator <- bitwAnd(flags, 1) != 0
      if (bitwAnd(flags, 8) != 0) {
        self$has_username <- reader$tgread_bool()
      } else {
        self$has_username <- NULL
      }
      if (bitwAnd(flags, 2) != 0) {
        self$user_admin_rights <- reader$tgread_object()
      } else {
        self$user_admin_rights <- NULL
      }
      if (bitwAnd(flags, 4) != 0) {
        self$bot_admin_rights <- reader$tgread_object()
      } else {
        self$bot_admin_rights <- NULL
      }
    }
  ),
  class = TRUE
)

#  @title RequestPeerTypeChat
#  @description Telegram API type RequestPeerTypeChat
#  @export
#  @noRd
#  @noRd
RequestPeerTypeChat <- R6::R6Class("RequestPeerTypeChat",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc9f06e1b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xe9a0e814,
    #  @field creator Field.
    creator = NULL,
    #  @field bot_participant Field.
    bot_participant = NULL,
    #  @field has_username Field.
    has_username = NULL,
    #  @field forum Field.
    forum = NULL,
    #  @field user_admin_rights Field.
    user_admin_rights = NULL,
    #  @field bot_admin_rights Field.
    bot_admin_rights = NULL,
    initialize = function(creator = NULL, bot_participant = NULL, has_username = NULL, forum = NULL, user_admin_rights = NULL, bot_admin_rights = NULL) {
      self$creator <- creator
      self$bot_participant <- bot_participant
      self$has_username <- has_username
      self$forum <- forum
      self$user_admin_rights <- user_admin_rights
      self$bot_admin_rights <- bot_admin_rights
    },
    to_dict = function() list(`_` = "RequestPeerTypeChat", creator = self$creator, bot_participant = self$bot_participant, has_username = self$has_username, forum = self$forum, user_admin_rights = if (is.null(self$user_admin_rights)) NULL else self$user_admin_rights$to_dict(), bot_admin_rights = if (is.null(self$bot_admin_rights)) NULL else self$bot_admin_rights$to_dict()),
    bytes = function() {
      b <- c()
      b <- c(b, as.raw(c(0x1b, 0x6e, 0xf0, 0xc9)))
      flags <- 0
      if (!is.null(self$creator) && self$creator) flags <- bitwOr(flags, 1)
      if (!is.null(self$bot_participant) && self$bot_participant) flags <- bitwOr(flags, 32)
      if (!is.null(self$has_username)) flags <- bitwOr(flags, 8)
      if (!is.null(self$forum)) flags <- bitwOr(flags, 16)
      if (!is.null(self$user_admin_rights)) flags <- bitwOr(flags, 2)
      if (!is.null(self$bot_admin_rights)) flags <- bitwOr(flags, 4)
      b <- c(b, pack("<I", flags))
      if (!is.null(self$has_username)) b <- c(b, if (self$has_username) as.raw(c(0xb5, 0x75, 0x72, 0x99)) else as.raw(c(0x37, 0x97, 0x79, 0xbc)))
      if (!is.null(self$forum)) b <- c(b, if (self$forum) as.raw(c(0xb5, 0x75, 0x72, 0x99)) else as.raw(c(0x37, 0x97, 0x79, 0xbc)))
      if (!is.null(self$user_admin_rights)) b <- c(b, self$user_admin_rights$bytes())
      if (!is.null(self$bot_admin_rights)) b <- c(b, self$bot_admin_rights$bytes())
      as.raw(b)
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      self$creator <- bitwAnd(flags, 1) != 0
      self$bot_participant <- bitwAnd(flags, 32) != 0
      if (bitwAnd(flags, 8) != 0) {
        self$has_username <- reader$tgread_bool()
      } else {
        self$has_username <- NULL
      }
      if (bitwAnd(flags, 16) != 0) {
        self$forum <- reader$tgread_bool()
      } else {
        self$forum <- NULL
      }
      if (bitwAnd(flags, 2) != 0) {
        self$user_admin_rights <- reader$tgread_object()
      } else {
        self$user_admin_rights <- NULL
      }
      if (bitwAnd(flags, 4) != 0) {
        self$bot_admin_rights <- reader$tgread_object()
      } else {
        self$bot_admin_rights <- NULL
      }
    }
  ),
  class = TRUE
)

#  @title RequestPeerTypeUser
#  @description Telegram API type RequestPeerTypeUser
#  @export
#  @noRd
#  @noRd
RequestPeerTypeUser <- R6::R6Class("RequestPeerTypeUser",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5f3b8a00,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xe9a0e814,
    #  @field bot Field.
    bot = NULL,
    #  @field premium Field.
    premium = NULL,
    initialize = function(bot = NULL, premium = NULL) {
      self$bot <- bot
      self$premium <- premium
    },
    to_dict = function() list(`_` = "RequestPeerTypeUser", bot = self$bot, premium = self$premium),
    bytes = function() {
      b <- c()
      b <- c(b, as.raw(c(0x00, 0x8a, 0x3b, 0x5f)))
      flags <- 0
      if (!is.null(self$bot)) flags <- bitwOr(flags, 1)
      if (!is.null(self$premium)) flags <- bitwOr(flags, 2)
      b <- c(b, pack("<I", flags))
      if (!is.null(self$bot)) b <- c(b, if (self$bot) as.raw(c(0xb5, 0x75, 0x72, 0x99)) else as.raw(c(0x37, 0x97, 0x79, 0xbc)))
      if (!is.null(self$premium)) b <- c(b, if (self$premium) as.raw(c(0xb5, 0x75, 0x72, 0x99)) else as.raw(c(0x37, 0x97, 0x79, 0xbc)))
      as.raw(b)
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      if (bitwAnd(flags, 1) != 0) {
        self$bot <- reader$tgread_bool()
      } else {
        self$bot <- NULL
      }
      if (bitwAnd(flags, 2) != 0) {
        self$premium <- reader$tgread_bool()
      } else {
        self$premium <- NULL
      }
    }
  ),
  class = TRUE
)

#  @title RequestedPeerChannel
#  @description Telegram API type RequestedPeerChannel
#  @export
#  @noRd
#  @noRd
RequestedPeerChannel <- R6::R6Class("RequestedPeerChannel",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8ba403e4,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc2887c10,
    #  @field channel_id Field.
    channel_id = NULL,
    #  @field title Field.
    title = NULL,
    #  @field username Field.
    username = NULL,
    #  @field photo Field.
    photo = NULL,
    initialize = function(channel_id = NULL, title = NULL, username = NULL, photo = NULL) {
      self$channel_id <- channel_id
      self$title <- title
      self$username <- username
      self$photo <- photo
    },
    to_dict = function() list(`_` = "RequestedPeerChannel", channel_id = self$channel_id, title = self$title, username = self$username, photo = if (is.null(self$photo)) NULL else self$photo$to_dict()),
    bytes = function() {
      b <- c()
      b <- c(b, as.raw(c(0xe4, 0x03, 0xa4, 0x8b)))
      flags <- 0
      if (!is.null(self$title)) flags <- bitwOr(flags, 1)
      if (!is.null(self$username)) flags <- bitwOr(flags, 2)
      if (!is.null(self$photo)) flags <- bitwOr(flags, 4)
      b <- c(b, pack("<I", flags))
      b <- c(b, pack("<q", self$channel_id))
      if (!is.null(self$title)) b <- c(b, self$serializebytes(self$title))
      if (!is.null(self$username)) b <- c(b, self$serializebytes(self$username))
      if (!is.null(self$photo)) b <- c(b, self$photo$bytes())
      as.raw(b)
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      self$channel_id <- reader$read_long()
      if (bitwAnd(flags, 1) != 0) {
        self$title <- reader$tgread_string()
      } else {
        self$title <- NULL
      }
      if (bitwAnd(flags, 2) != 0) {
        self$username <- reader$tgread_string()
      } else {
        self$username <- NULL
      }
      if (bitwAnd(flags, 4) != 0) {
        self$photo <- reader$tgread_object()
      } else {
        self$photo <- NULL
      }
    }
  ),
  class = TRUE
)

#  @title RequestedPeerChat
#  @description Telegram API type RequestedPeerChat
#  @export
#  @noRd
#  @noRd
RequestedPeerChat <- R6::R6Class("RequestedPeerChat",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7307544f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc2887c10,
    #  @field chat_id Field.
    chat_id = NULL,
    #  @field title Field.
    title = NULL,
    #  @field photo Field.
    photo = NULL,
    initialize = function(chat_id = NULL, title = NULL, photo = NULL) {
      self$chat_id <- chat_id
      self$title <- title
      self$photo <- photo
    },
    to_dict = function() list(`_` = "RequestedPeerChat", chat_id = self$chat_id, title = self$title, photo = if (is.null(self$photo)) NULL else self$photo$to_dict()),
    bytes = function() {
      b <- c()
      b <- c(b, as.raw(c(0x4f, 0x54, 0x07, 0x73)))
      flags <- 0
      if (!is.null(self$title)) flags <- bitwOr(flags, 1)
      if (!is.null(self$photo)) flags <- bitwOr(flags, 4)
      b <- c(b, pack("<I", flags))
      b <- c(b, pack("<q", self$chat_id))
      if (!is.null(self$title)) b <- c(b, self$serializebytes(self$title))
      if (!is.null(self$photo)) b <- c(b, self$photo$bytes())
      as.raw(b)
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      self$chat_id <- reader$read_long()
      if (bitwAnd(flags, 1) != 0) {
        self$title <- reader$tgread_string()
      } else {
        self$title <- NULL
      }
      if (bitwAnd(flags, 4) != 0) {
        self$photo <- reader$tgread_object()
      } else {
        self$photo <- NULL
      }
    }
  ),
  class = TRUE
)

#  @title RequestedPeerUser
#  @description Telegram API type RequestedPeerUser
#  @export
#  @noRd
#  @noRd
RequestedPeerUser <- R6::R6Class("RequestedPeerUser",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd62ff46a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc2887c10,
    #  @field user_id Field.
    user_id = NULL,
    #  @field first_name Field.
    first_name = NULL,
    #  @field last_name Field.
    last_name = NULL,
    #  @field username Field.
    username = NULL,
    #  @field photo Field.
    photo = NULL,
    initialize = function(user_id = NULL, first_name = NULL, last_name = NULL, username = NULL, photo = NULL) {
      self$user_id <- user_id
      self$first_name <- first_name
      self$last_name <- last_name
      self$username <- username
      self$photo <- photo
    },
    to_dict = function() list(`_` = "RequestedPeerUser", user_id = self$user_id, first_name = self$first_name, last_name = self$last_name, username = self$username, photo = if (is.null(self$photo)) NULL else self$photo$to_dict()),
    bytes = function() {
      b <- c()
      b <- c(b, as.raw(c(0x6a, 0xf4, 0x2f, 0xd6)))
      flags <- 0
      if (!is.null(self$first_name)) flags <- bitwOr(flags, 1)
      if (!is.null(self$last_name)) flags <- bitwOr(flags, 1)
      if (!is.null(self$username)) flags <- bitwOr(flags, 2)
      if (!is.null(self$photo)) flags <- bitwOr(flags, 4)
      b <- c(b, pack("<I", flags))
      b <- c(b, pack("<q", self$user_id))
      if (!is.null(self$first_name)) b <- c(b, self$serializebytes(self$first_name))
      if (!is.null(self$last_name)) b <- c(b, self$serializebytes(self$last_name))
      if (!is.null(self$username)) b <- c(b, self$serializebytes(self$username))
      if (!is.null(self$photo)) b <- c(b, self$photo$bytes())
      as.raw(b)
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      self$user_id <- reader$read_long()
      if (bitwAnd(flags, 1) != 0) {
        self$first_name <- reader$tgread_string()
      } else {
        self$first_name <- NULL
      }
      if (bitwAnd(flags, 1) != 0) {
        self$last_name <- reader$tgread_string()
      } else {
        self$last_name <- NULL
      }
      if (bitwAnd(flags, 2) != 0) {
        self$username <- reader$tgread_string()
      } else {
        self$username <- NULL
      }
      if (bitwAnd(flags, 4) != 0) {
        self$photo <- reader$tgread_object()
      } else {
        self$photo <- NULL
      }
    }
  ),
  class = TRUE
)

#  @title RequirementToContactEmpty
#  @description Telegram API type RequirementToContactEmpty
#  @export
#  @noRd
#  @noRd
RequirementToContactEmpty <- R6::R6Class("RequirementToContactEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x50a9839,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8d756391,
    to_dict = function() list(`_` = "RequirementToContactEmpty"),
    bytes = function() as.raw(c(0x39, 0x98, 0x0a, 0x05))
  ),
  private = list(
    from_reader = function(reader) self$new()
  ),
  class = TRUE
)

#  @title RequirementToContactPaidMessages
#  @description Telegram API type RequirementToContactPaidMessages
#  @export
#  @noRd
#  @noRd
RequirementToContactPaidMessages <- R6::R6Class("RequirementToContactPaidMessages",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb4f67e93,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8d756391,
    #  @field stars_amount Field.
    stars_amount = NULL,
    initialize = function(stars_amount = NULL) {
      self$stars_amount <- stars_amount
    },
    to_dict = function() list(`_` = "RequirementToContactPaidMessages", stars_amount = self$stars_amount),
    bytes = function() as.raw(c(0x93, 0x7e, 0xf6, 0xb4)) + pack("q", self$stars_amount)
  ),
  private = list(
    from_reader = function(reader) {
      stars_amount <- reader$read_long()
      self$new(stars_amount = stars_amount)
    }
  ),
  class = TRUE
)

#  @title RequirementToContactPremium
#  @description Telegram API type RequirementToContactPremium
#  @export
#  @noRd
#  @noRd
RequirementToContactPremium <- R6::R6Class("RequirementToContactPremium",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe581e4e9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8d756391,
    to_dict = function() list(`_` = "RequirementToContactPremium"),
    bytes = function() as.raw(c(0xe9, 0xe4, 0x81, 0xe5))
  ),
  private = list(
    from_reader = function(reader) self$new()
  ),
  class = TRUE
)

#  @title ResPQ
#  @description Telegram API type ResPQ
#  @export
#  @noRd
#  @noRd
ResPQ <- R6::R6Class("ResPQ",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5162463,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x786986b8,
    #  @field nonce Field.
    nonce = NULL,
    #  @field server_nonce Field.
    server_nonce = NULL,
    #  @field pq Field.
    pq = NULL,
    #  @field server_public_key_fingerprints Field.
    server_public_key_fingerprints = NULL,
    initialize = function(nonce = NULL, server_nonce = NULL, pq = NULL, server_public_key_fingerprints = NULL) {
      self$nonce <- nonce
      self$server_nonce <- server_nonce
      self$pq <- pq
      self$server_public_key_fingerprints <- server_public_key_fingerprints
    },
    to_dict = function() list(`_` = "ResPQ", nonce = self$nonce, server_nonce = self$server_nonce, pq = self$pq, server_public_key_fingerprints = self$server_public_key_fingerprints),
    bytes = function() as.raw(c(0x63, 0x24, 0x16, 0x05)) + self$nonce$tobytes(16, "little", TRUE) + self$server_nonce$tobytes(16, "little", TRUE) + self$serializebytes(self$pq) + as.raw(c(0x1c, 0xb5, 0xc4, 0x15)) + pack("i", length(self$server_public_key_fingerprints)) + do.call(c, lapply(self$server_public_key_fingerprints, function(x) pack("q", x)))
  ),
  private = list(
    from_reader = function(reader) {
      nonce <- reader$read_large_int(bits = 128)
      server_nonce <- reader$read_large_int(bits = 128)
      pq <- reader$tgreadbytes()
      reader$read_int()
      server_public_key_fingerprints <- lapply(seq_len(reader$read_int()), function(i) reader$read_long())
      self$new(nonce = nonce, server_nonce = server_nonce, pq = pq, server_public_key_fingerprints = server_public_key_fingerprints)
    }
  ),
  class = TRUE
)

#  @title RestrictionReason
#  @description Telegram API type RestrictionReason
#  @export
#  @noRd
#  @noRd
RestrictionReason <- R6::R6Class("RestrictionReason",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd072acb4,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x6ad95ad,
    #  @field platform Field.
    platform = NULL,
    #  @field reason Field.
    reason = NULL,
    #  @field text Field.
    text = NULL,
    initialize = function(platform = NULL, reason = NULL, text = NULL) {
      self$platform <- platform
      self$reason <- reason
      self$text <- text
    },
    to_dict = function() list(`_` = "RestrictionReason", platform = self$platform, reason = self$reason, text = self$text),
    bytes = function() as.raw(c(0xb4, 0xac, 0x72, 0xd0)) + self$serializebytes(self$platform) + self$serializebytes(self$reason) + self$serializebytes(self$text)
  ),
  private = list(
    from_reader = function(reader) {
      platform <- reader$tgread_string()
      reason <- reader$tgread_string()
      text <- reader$tgread_string()
      self$new(platform = platform, reason = reason, text = text)
    }
  ),
  class = TRUE
)

#  @title RpcAnswerDropped
#  @description Telegram API type RpcAnswerDropped
#  @export
#  @noRd
#  @noRd
RpcAnswerDropped <- R6::R6Class("RpcAnswerDropped",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa43ad8b7,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x4bca7570,
    #  @field msg_id Field.
    msg_id = NULL,
    #  @field seq_no Field.
    seq_no = NULL,
    #  @field raw_bytes Field.
    raw_bytes = NULL,
    initialize = function(msg_id = NULL, seq_no = NULL, raw_bytes = NULL) {
      self$msg_id <- msg_id
      self$seq_no <- seq_no
      self$raw_bytes <- raw_bytes
    },
    to_dict = function() list(`_` = "RpcAnswerDropped", msg_id = self$msg_id, seq_no = self$seq_no, raw_bytes = self$raw_bytes),
    bytes = function() as.raw(c(0xb7, 0xd8, 0x3a, 0xa4)) + pack("q", self$msg_id) + pack("i", self$seq_no) + pack("i", self$raw_bytes)
  ),
  private = list(
    from_reader = function(reader) {
      msg_id <- reader$read_long()
      seq_no <- reader$read_int()
      raw_bytes <- reader$read_int()
      self$new(msg_id = msg_id, seq_no = seq_no, raw_bytes = raw_bytes)
    }
  ),
  class = TRUE
)

#  @title RpcAnswerDroppedRunning
#  @description Telegram API type RpcAnswerDroppedRunning
#  @export
#  @noRd
#  @noRd
RpcAnswerDroppedRunning <- R6::R6Class("RpcAnswerDroppedRunning",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xcd78e586,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x4bca7570,
    to_dict = function() list(`_` = "RpcAnswerDroppedRunning"),
    bytes = function() as.raw(c(0x86, 0xe5, 0x78, 0xcd))
  ),
  private = list(
    from_reader = function(reader) self$new()
  ),
  class = TRUE
)

#  @title RpcAnswerUnknown
#  @description Telegram API type RpcAnswerUnknown
#  @export
#  @noRd
#  @noRd
RpcAnswerUnknown <- R6::R6Class("RpcAnswerUnknown",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5e2ad36e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x4bca7570,
    to_dict = function() list(`_` = "RpcAnswerUnknown"),
    bytes = function() as.raw(c(0x6e, 0xd3, 0x2a, 0x5e))
  ),
  private = list(
    from_reader = function(reader) self$new()
  ),
  class = TRUE
)

#  @title RpcError
#  @description Telegram API type RpcError
#  @export
#  @noRd
#  @noRd
RpcError <- R6::R6Class("RpcError",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x2144ca19,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x4a17e265,
    #  @field error_code Field.
    error_code = NULL,
    #  @field error_message Field.
    error_message = NULL,
    initialize = function(error_code = NULL, error_message = NULL) {
      self$error_code <- error_code
      self$error_message <- error_message
    },
    to_dict = function() list(`_` = "RpcError", error_code = self$error_code, error_message = self$error_message),
    bytes = function() as.raw(c(0x19, 0xca, 0x44, 0x21)) + pack("i", self$error_code) + self$serializebytes(self$error_message)
  ),
  private = list(
    from_reader = function(reader) {
      error_code <- reader$read_int()
      error_message <- reader$tgread_string()
      RpcError$new(error_code = error_code, error_message = error_message)
    }
  ),
  class = TRUE
)

#  @title SavedDialog
#  @description Telegram API type SavedDialog
#  @export
#  @noRd
#  @noRd
SavedDialog <- R6::R6Class("SavedDialog",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbd87cb6c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x23ba6506,
    #  @field peer Field.
    peer = NULL,
    #  @field top_message Field.
    top_message = NULL,
    #  @field pinned Field.
    pinned = NULL,
    initialize = function(peer = NULL, top_message = NULL, pinned = NULL) {
      self$peer <- peer
      self$top_message <- top_message
      self$pinned <- pinned
    },
    to_dict = function() list(`_` = "SavedDialog", peer = if (is.null(self$peer)) NULL else self$peer$to_dict(), top_message = self$top_message, pinned = self$pinned),
    bytes = function() as.raw(c(0x6c, 0xcb, 0x87, 0xbd)) + pack("I", if (is.null(self$pinned) || !self$pinned) 0 else 4) + self$peer$bytes() + pack("i", self$top_message)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      pinned <- bitwAnd(flags, 4) != 0
      peer <- reader$tgread_object()
      top_message <- reader$read_int()
      self$new(peer = peer, top_message = top_message, pinned = pinned)
    }
  ),
  class = TRUE
)

#  @title SavedPhoneContact
#  @description Telegram API type SavedPhoneContact
#  @export
#  @noRd
#  @noRd
SavedPhoneContact <- R6::R6Class("SavedPhoneContact",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1142bd56,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x6db98c4,
    #  @field phone Field.
    phone = NULL,
    #  @field first_name Field.
    first_name = NULL,
    #  @field last_name Field.
    last_name = NULL,
    #  @field date Field.
    date = NULL,
    initialize = function(phone = NULL, first_name = NULL, last_name = NULL, date = NULL) {
      self$phone <- phone
      self$first_name <- first_name
      self$last_name <- last_name
      self$date <- date
    },
    to_dict = function() list(`_` = "SavedPhoneContact", phone = self$phone, first_name = self$first_name, last_name = self$last_name, date = self$date),
    bytes = function() as.raw(c(0x56, 0xbd, 0x42, 0x11)) + self$serializebytes(self$phone) + self$serializebytes(self$first_name) + self$serializebytes(self$last_name) + self$serialize_datetime(self$date)
  ),
  private = list(
    from_reader = function(reader) {
      phone <- reader$tgread_string()
      first_name <- reader$tgread_string()
      last_name <- reader$tgread_string()
      date <- reader$tgread_date()
      self$new(phone = phone, first_name = first_name, last_name = last_name, date = date)
    }
  ),
  class = TRUE
)

#  @title SavedReactionTag
#  @description Telegram API type SavedReactionTag
#  @export
#  @noRd
#  @noRd
SavedReactionTag <- R6::R6Class("SavedReactionTag",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xcb6ff828,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xed681418,
    #  @field reaction Field.
    reaction = NULL,
    #  @field count Field.
    count = NULL,
    #  @field title Field.
    title = NULL,
    initialize = function(reaction = NULL, count = NULL, title = NULL) {
      self$reaction <- reaction
      self$count <- count
      self$title <- title
    },
    to_dict = function() list(`_` = "SavedReactionTag", reaction = if (is.null(self$reaction)) NULL else self$reaction$to_dict(), count = self$count, title = self$title),
    bytes = function() as.raw(c(0x28, 0xf8, 0x6f, 0xcb)) + pack("I", if (is.null(self$title) || self$title == "") 0 else 1) + self$reaction$bytes() + if (is.null(self$title) || self$title == "") raw(0) else self$serializebytes(self$title) + pack("i", self$count)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      reaction <- reader$tgread_object()
      if (bitwAnd(flags, 1) != 0) title <- reader$tgread_string() else title <- NULL
      count <- reader$read_int()
      self$new(reaction = reaction, count = count, title = title)
    }
  ),
  class = TRUE
)

#  @title SavedStarGift
#  @description Telegram API type SavedStarGift
#  @export
#  @noRd
#  @noRd
SavedStarGift <- R6::R6Class("SavedStarGift",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x19a9b572,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8e2b3c14,
    #  @field date Field.
    date = NULL,
    #  @field gift Field.
    gift = NULL,
    #  @field name_hidden Field.
    name_hidden = NULL,
    #  @field unsaved Field.
    unsaved = NULL,
    #  @field refunded Field.
    refunded = NULL,
    #  @field can_upgrade Field.
    can_upgrade = NULL,
    #  @field pinned_to_top Field.
    pinned_to_top = NULL,
    #  @field upgrade_separate Field.
    upgrade_separate = NULL,
    #  @field from_id Field.
    from_id = NULL,
    #  @field message Field.
    message = NULL,
    #  @field msg_id Field.
    msg_id = NULL,
    #  @field saved_id Field.
    saved_id = NULL,
    #  @field convert_stars Field.
    convert_stars = NULL,
    #  @field upgrade_stars Field.
    upgrade_stars = NULL,
    #  @field can_export_at Field.
    can_export_at = NULL,
    #  @field transfer_stars Field.
    transfer_stars = NULL,
    #  @field can_transfer_at Field.
    can_transfer_at = NULL,
    #  @field can_resell_at Field.
    can_resell_at = NULL,
    #  @field collection_id Field.
    collection_id = NULL,
    #  @field prepaid_upgrade_hash Field.
    prepaid_upgrade_hash = NULL,
    initialize = function(date = NULL, gift = NULL, name_hidden = NULL, unsaved = NULL, refunded = NULL, can_upgrade = NULL, pinned_to_top = NULL, upgrade_separate = NULL, from_id = NULL, message = NULL, msg_id = NULL, saved_id = NULL, convert_stars = NULL, upgrade_stars = NULL, can_export_at = NULL, transfer_stars = NULL, can_transfer_at = NULL, can_resell_at = NULL, collection_id = NULL, prepaid_upgrade_hash = NULL) {
      self$date <- date
      self$gift <- gift
      self$name_hidden <- name_hidden
      self$unsaved <- unsaved
      self$refunded <- refunded
      self$can_upgrade <- can_upgrade
      self$pinned_to_top <- pinned_to_top
      self$upgrade_separate <- upgrade_separate
      self$from_id <- from_id
      self$message <- message
      self$msg_id <- msg_id
      self$saved_id <- saved_id
      self$convert_stars <- convert_stars
      self$upgrade_stars <- upgrade_stars
      self$can_export_at <- can_export_at
      self$transfer_stars <- transfer_stars
      self$can_transfer_at <- can_transfer_at
      self$can_resell_at <- can_resell_at
      self$collection_id <- collection_id
      self$prepaid_upgrade_hash <- prepaid_upgrade_hash
    },
    to_dict = function() list(`_` = "SavedStarGift", date = self$date, gift = if (is.null(self$gift)) NULL else self$gift$to_dict(), name_hidden = self$name_hidden, unsaved = self$unsaved, refunded = self$refunded, can_upgrade = self$can_upgrade, pinned_to_top = self$pinned_to_top, upgrade_separate = self$upgrade_separate, from_id = if (is.null(self$from_id)) NULL else self$from_id$to_dict(), message = if (is.null(self$message)) NULL else self$message$to_dict(), msg_id = self$msg_id, saved_id = self$saved_id, convert_stars = self$convert_stars, upgrade_stars = self$upgrade_stars, can_export_at = self$can_export_at, transfer_stars = self$transfer_stars, can_transfer_at = self$can_transfer_at, can_resell_at = self$can_resell_at, collection_id = self$collection_id, prepaid_upgrade_hash = self$prepaid_upgrade_hash),
    bytes = function() {
      flags <- 0
      if (!is.null(self$name_hidden) && self$name_hidden) flags <- bitwOr(flags, 1)
      if (!is.null(self$unsaved) && self$unsaved) flags <- bitwOr(flags, 32)
      if (!is.null(self$refunded) && self$refunded) flags <- bitwOr(flags, 512)
      if (!is.null(self$can_upgrade) && self$can_upgrade) flags <- bitwOr(flags, 1024)
      if (!is.null(self$pinned_to_top) && self$pinned_to_top) flags <- bitwOr(flags, 4096)
      if (!is.null(self$upgrade_separate) && self$upgrade_separate) flags <- bitwOr(flags, 131072)
      if (!is.null(self$from_id)) flags <- bitwOr(flags, 2)
      if (!is.null(self$message)) flags <- bitwOr(flags, 4)
      if (!is.null(self$msg_id)) flags <- bitwOr(flags, 8)
      if (!is.null(self$saved_id)) flags <- bitwOr(flags, 2048)
      if (!is.null(self$convert_stars)) flags <- bitwOr(flags, 16)
      if (!is.null(self$upgrade_stars)) flags <- bitwOr(flags, 64)
      if (!is.null(self$can_export_at)) flags <- bitwOr(flags, 128)
      if (!is.null(self$transfer_stars)) flags <- bitwOr(flags, 256)
      if (!is.null(self$can_transfer_at)) flags <- bitwOr(flags, 8192)
      if (!is.null(self$can_resell_at)) flags <- bitwOr(flags, 16384)
      if (!is.null(self$collection_id)) flags <- bitwOr(flags, 32768)
      if (!is.null(self$prepaid_upgrade_hash)) flags <- bitwOr(flags, 65536)
      as.raw(c(0x72, 0xb5, 0xa9, 0x19)) + pack("I", flags) + if (!is.null(self$from_id)) self$from_id$bytes() else raw(0) + self$serialize_datetime(self$date) + self$gift$bytes() + if (!is.null(self$message)) self$message$bytes() else raw(0) + if (!is.null(self$msg_id)) pack("i", self$msg_id) else raw(0) + if (!is.null(self$saved_id)) pack("q", self$saved_id) else raw(0) + if (!is.null(self$convert_stars)) pack("q", self$convert_stars) else raw(0) + if (!is.null(self$upgrade_stars)) pack("q", self$upgrade_stars) else raw(0) + if (!is.null(self$can_export_at)) pack("i", self$can_export_at) else raw(0) + if (!is.null(self$transfer_stars)) pack("q", self$transfer_stars) else raw(0) + if (!is.null(self$can_transfer_at)) pack("i", self$can_transfer_at) else raw(0) + if (!is.null(self$can_resell_at)) pack("i", self$can_resell_at) else raw(0) + if (!is.null(self$collection_id)) as.raw(c(0x1c, 0xb5, 0xc4, 0x15)) + pack("i", length(self$collection_id)) + do.call(c, lapply(self$collection_id, function(x) pack("i", x))) else raw(0) + if (!is.null(self$prepaid_upgrade_hash)) self$serializebytes(self$prepaid_upgrade_hash) else raw(0)
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      name_hidden <- bitwAnd(flags, 1) != 0
      unsaved <- bitwAnd(flags, 32) != 0
      refunded <- bitwAnd(flags, 512) != 0
      can_upgrade <- bitwAnd(flags, 1024) != 0
      pinned_to_top <- bitwAnd(flags, 4096) != 0
      upgrade_separate <- bitwAnd(flags, 131072) != 0
      if (bitwAnd(flags, 2) != 0) from_id <- reader$tgread_object() else from_id <- NULL
      date <- reader$tgread_date()
      gift <- reader$tgread_object()
      if (bitwAnd(flags, 4) != 0) message <- reader$tgread_object() else message <- NULL
      if (bitwAnd(flags, 8) != 0) msg_id <- reader$read_int() else msg_id <- NULL
      if (bitwAnd(flags, 2048) != 0) saved_id <- reader$read_long() else saved_id <- NULL
      if (bitwAnd(flags, 16) != 0) convert_stars <- reader$read_long() else convert_stars <- NULL
      if (bitwAnd(flags, 64) != 0) upgrade_stars <- reader$read_long() else upgrade_stars <- NULL
      if (bitwAnd(flags, 128) != 0) can_export_at <- reader$read_int() else can_export_at <- NULL
      if (bitwAnd(flags, 256) != 0) transfer_stars <- reader$read_long() else transfer_stars <- NULL
      if (bitwAnd(flags, 8192) != 0) can_transfer_at <- reader$read_int() else can_transfer_at <- NULL
      if (bitwAnd(flags, 16384) != 0) can_resell_at <- reader$read_int() else can_resell_at <- NULL
      if (bitwAnd(flags, 32768) != 0) {
        reader$read_int()
        collection_id <- lapply(seq_len(reader$read_int()), function(i) reader$read_int())
      } else {
        collection_id <- NULL
      }
      if (bitwAnd(flags, 65536) != 0) prepaid_upgrade_hash <- reader$tgread_string() else prepaid_upgrade_hash <- NULL
      self$new(date = date, gift = gift, name_hidden = name_hidden, unsaved = unsaved, refunded = refunded, can_upgrade = can_upgrade, pinned_to_top = pinned_to_top, upgrade_separate = upgrade_separate, from_id = from_id, message = message, msg_id = msg_id, saved_id = saved_id, convert_stars = convert_stars, upgrade_stars = upgrade_stars, can_export_at = can_export_at, transfer_stars = transfer_stars, can_transfer_at = can_transfer_at, can_resell_at = can_resell_at, collection_id = collection_id, prepaid_upgrade_hash = prepaid_upgrade_hash)
    }
  ),
  class = TRUE
)

#  @title SearchPostsFlood
#  @description Telegram API type SearchPostsFlood
#  @export
#  @noRd
#  @noRd
SearchPostsFlood <- R6::R6Class("SearchPostsFlood",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x3e0b5b6a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc2c0ccc1,
    #  @field total_daily Field.
    total_daily = NULL,
    #  @field remains Field.
    remains = NULL,
    #  @field stars_amount Field.
    stars_amount = NULL,
    #  @field query_is_free Field.
    query_is_free = NULL,
    #  @field wait_till Field.
    wait_till = NULL,
    initialize = function(total_daily = NULL, remains = NULL, stars_amount = NULL, query_is_free = NULL, wait_till = NULL) {
      self$total_daily <- total_daily
      self$remains <- remains
      self$stars_amount <- stars_amount
      self$query_is_free <- query_is_free
      self$wait_till <- wait_till
    },
    to_dict = function() list(`_` = "SearchPostsFlood", total_daily = self$total_daily, remains = self$remains, stars_amount = self$stars_amount, query_is_free = self$query_is_free, wait_till = self$wait_till),
    bytes = function() as.raw(c(0x6a, 0x5b, 0x0b, 0x3e)) + pack("I", if (is.null(self$query_is_free) || !self$query_is_free) 0 else 1 | if (is.null(self$wait_till)) 0 else 2) + pack("i", self$total_daily) + pack("i", self$remains) + if (!is.null(self$wait_till)) pack("i", self$wait_till) else raw(0) + pack("q", self$stars_amount)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      query_is_free <- bitwAnd(flags, 1) != 0
      total_daily <- reader$read_int()
      remains <- reader$read_int()
      if (bitwAnd(flags, 2) != 0) wait_till <- reader$read_int() else wait_till <- NULL
      stars_amount <- reader$read_long()
      self$new(total_daily = total_daily, remains = remains, stars_amount = stars_amount, query_is_free = query_is_free, wait_till = wait_till)
    }
  ),
  class = TRUE
)

#  @title SearchResultPosition
#  @description Telegram API type SearchResultPosition
#  @export
#  @noRd
#  @noRd
SearchResultPosition <- R6::R6Class("SearchResultPosition",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7f648b67,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb8e21614,
    #  @field msg_id Field.
    msg_id = NULL,
    #  @field date Field.
    date = NULL,
    #  @field offset Field.
    offset = NULL,
    initialize = function(msg_id = NULL, date = NULL, offset = NULL) {
      self$msg_id <- msg_id
      self$date <- date
      self$offset <- offset
    },
    to_dict = function() list(`_` = "SearchResultPosition", msg_id = self$msg_id, date = self$date, offset = self$offset),
    bytes = function() as.raw(c(0x67, 0x8b, 0x64, 0x7f)) + pack("i", self$msg_id) + self$serialize_datetime(self$date) + pack("i", self$offset)
  ),
  private = list(
    from_reader = function(reader) {
      msg_id <- reader$read_int()
      date <- reader$tgread_date()
      offset <- reader$read_int()
      self$new(msg_id = msg_id, date = date, offset = offset)
    }
  ),
  class = TRUE
)

#  @title SearchResultsCalendarPeriod
#  @description Telegram API type SearchResultsCalendarPeriod
#  @export
#  @noRd
#  @noRd
SearchResultsCalendarPeriod <- R6::R6Class("SearchResultsCalendarPeriod",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc9b0539f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xe25cf8ff,
    #  @field date Field.
    date = NULL,
    #  @field min_msg_id Field.
    min_msg_id = NULL,
    #  @field max_msg_id Field.
    max_msg_id = NULL,
    #  @field count Field.
    count = NULL,
    initialize = function(date = NULL, min_msg_id = NULL, max_msg_id = NULL, count = NULL) {
      self$date <- date
      self$min_msg_id <- min_msg_id
      self$max_msg_id <- max_msg_id
      self$count <- count
    },
    to_dict = function() list(`_` = "SearchResultsCalendarPeriod", date = self$date, min_msg_id = self$min_msg_id, max_msg_id = self$max_msg_id, count = self$count),
    bytes = function() as.raw(c(0x9f, 0x53, 0xb0, 0xc9)) + self$serialize_datetime(self$date) + pack("i", self$min_msg_id) + pack("i", self$max_msg_id) + pack("i", self$count)
  ),
  private = list(
    from_reader = function(reader) {
      date <- reader$tgread_date()
      min_msg_id <- reader$read_int()
      max_msg_id <- reader$read_int()
      count <- reader$read_int()
      self$new(date = date, min_msg_id = min_msg_id, max_msg_id = max_msg_id, count = count)
    }
  ),
  class = TRUE
)

#  @title SecureCredentialsEncrypted
#  @description Telegram API type SecureCredentialsEncrypted
#  @export
#  @noRd
#  @noRd
SecureCredentialsEncrypted <- R6::R6Class("SecureCredentialsEncrypted",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x33f0ea47,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x94dc7633,
    #  @field data Field.
    data = NULL,
    #  @field hash Field.
    hash = NULL,
    #  @field secret Field.
    secret = NULL,
    initialize = function(data = NULL, hash = NULL, secret = NULL) {
      self$data <- data
      self$hash <- hash
      self$secret <- secret
    },
    to_dict = function() list(`_` = "SecureCredentialsEncrypted", data = self$data, hash = self$hash, secret = self$secret),
    bytes = function() as.raw(c(0x47, 0xea, 0xf0, 0x33)) + self$serializebytes(self$data) + self$serializebytes(self$hash) + self$serializebytes(self$secret)
  ),
  private = list(
    from_reader = function(reader) {
      data <- reader$tgreadbytes()
      hash <- reader$tgreadbytes()
      secret <- reader$tgreadbytes()
      self$new(data = data, hash = hash, secret = secret)
    }
  ),
  class = TRUE
)

#  @title SecureData
#  @description Telegram API type SecureData
#  @export
#  @noRd
#  @noRd
SecureData <- R6::R6Class("SecureData",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8aeabec3,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x7cd41eb4,
    #  @field data Field.
    data = NULL,
    #  @field data_hash Field.
    data_hash = NULL,
    #  @field secret Field.
    secret = NULL,
    initialize = function(data = NULL, data_hash = NULL, secret = NULL) {
      self$data <- data
      self$data_hash <- data_hash
      self$secret <- secret
    },
    to_dict = function() list(`_` = "SecureData", data = self$data, data_hash = self$data_hash, secret = self$secret),
    bytes = function() as.raw(c(0xc3, 0xbe, 0xea, 0x8a)) + self$serializebytes(self$data) + self$serializebytes(self$data_hash) + self$serializebytes(self$secret)
  ),
  private = list(
    from_reader = function(reader) {
      data <- reader$tgreadbytes()
      data_hash <- reader$tgreadbytes()
      secret <- reader$tgreadbytes()
      self$new(data = data, data_hash = data_hash, secret = secret)
    }
  ),
  class = TRUE
)

#  @title SecureFile
#  @description Telegram API type SecureFile
#  @export
#  @noRd
#  @noRd
SecureFile <- R6::R6Class("SecureFile",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7d09c27e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5db8dbc7,
    #  @field id Field.
    id = NULL,
    #  @field access_hash Field.
    access_hash = NULL,
    #  @field size Field.
    size = NULL,
    #  @field dc_id Field.
    dc_id = NULL,
    #  @field date Field.
    date = NULL,
    #  @field file_hash Field.
    file_hash = NULL,
    #  @field secret Field.
    secret = NULL,
    initialize = function(id = NULL, access_hash = NULL, size = NULL, dc_id = NULL, date = NULL, file_hash = NULL, secret = NULL) {
      self$id <- id
      self$access_hash <- access_hash
      self$size <- size
      self$dc_id <- dc_id
      self$date <- date
      self$file_hash <- file_hash
      self$secret <- secret
    },
    to_dict = function() list(`_` = "SecureFile", id = self$id, access_hash = self$access_hash, size = self$size, dc_id = self$dc_id, date = self$date, file_hash = self$file_hash, secret = self$secret),
    bytes = function() as.raw(c(0x7e, 0xc2, 0x09, 0x7d)) + pack("q", self$id) + pack("q", self$access_hash) + pack("q", self$size) + pack("i", self$dc_id) + self$serialize_datetime(self$date) + self$serializebytes(self$file_hash) + self$serializebytes(self$secret)
  ),
  private = list(
    from_reader = function(reader) {
      id <- reader$read_long()
      access_hash <- reader$read_long()
      size <- reader$read_long()
      dc_id <- reader$read_int()
      date <- reader$tgread_date()
      file_hash <- reader$tgreadbytes()
      secret <- reader$tgreadbytes()
      self$new(id = id, access_hash = access_hash, size = size, dc_id = dc_id, date = date, file_hash = file_hash, secret = secret)
    }
  ),
  class = TRUE
)

#  @title SecureFileEmpty
#  @description Telegram API type SecureFileEmpty
#  @export
#  @noRd
#  @noRd
SecureFileEmpty <- R6::R6Class("SecureFileEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x64199744,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5db8dbc7,
    to_dict = function() list(`_` = "SecureFileEmpty"),
    bytes = function() as.raw(c(0x44, 0x97, 0x19, 0x64))
  ),
  private = list(
    from_reader = function(reader) self$new()
  ),
  class = TRUE
)

#  @title SecurePasswordKdfAlgoPBKDF2HMACSHA512iter100000
#  @description Telegram API type SecurePasswordKdfAlgoPBKDF2HMACSHA512iter100000
#  @export
#  @noRd
#  @noRd
SecurePasswordKdfAlgoPBKDF2HMACSHA512iter100000 <- R6::R6Class("SecurePasswordKdfAlgoPBKDF2HMACSHA512iter100000",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbbf2dda0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x77262943,
    #  @field salt Field.
    salt = NULL,
    initialize = function(salt = NULL) {
      self$salt <- salt
    },
    to_dict = function() list(`_` = "SecurePasswordKdfAlgoPBKDF2HMACSHA512iter100000", salt = self$salt),
    bytes = function() as.raw(c(0xa0, 0xdd, 0xf2, 0xbb)) + self$serializebytes(self$salt)
  ),
  private = list(
    from_reader = function(reader) {
      salt <- reader$tgreadbytes()
      self$new(salt = salt)
    }
  ),
  class = TRUE
)

#  @title SecurePasswordKdfAlgoSHA512
#  @description Telegram API type SecurePasswordKdfAlgoSHA512
#  @export
#  @noRd
#  @noRd
SecurePasswordKdfAlgoSHA512 <- R6::R6Class("SecurePasswordKdfAlgoSHA512",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x86471d92,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x77262943,
    #  @field salt Field.
    salt = NULL,
    initialize = function(salt = NULL) {
      self$salt <- salt
    },
    to_dict = function() list(`_` = "SecurePasswordKdfAlgoSHA512", salt = self$salt),
    bytes = function() as.raw(c(0x92, 0x1d, 0x47, 0x86)) + self$serializebytes(self$salt)
  ),
  private = list(
    from_reader = function(reader) {
      salt <- reader$tgreadbytes()
      self$new(salt = salt)
    }
  ),
  class = TRUE
)

#  @title SecurePasswordKdfAlgoUnknown
#  @description Telegram API type SecurePasswordKdfAlgoUnknown
#  @export
#  @noRd
#  @noRd
SecurePasswordKdfAlgoUnknown <- R6::R6Class("SecurePasswordKdfAlgoUnknown",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4a8537,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x77262943,
    to_dict = function() list(`_` = "SecurePasswordKdfAlgoUnknown"),
    bytes = function() as.raw(c(0x37, 0x85, 0x4a, 0x00))
  ),
  private = list(
    from_reader = function(reader) self$new()
  ),
  class = TRUE
)

#  @title SecurePlainEmail
#  @description Telegram API type SecurePlainEmail
#  @export
#  @noRd
#  @noRd
SecurePlainEmail <- R6::R6Class("SecurePlainEmail",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x21ec5a5f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x23b2afb6,
    #  @field email Field.
    email = NULL,
    initialize = function(email = NULL) {
      self$email <- email
    },
    to_dict = function() list(`_` = "SecurePlainEmail", email = self$email),
    bytes = function() as.raw(c(0x5f, 0x5a, 0xec, 0x21)) + self$serializebytes(self$email)
  ),
  private = list(
    from_reader = function(reader) {
      email <- reader$tgread_string()
      self$new(email = email)
    }
  ),
  class = TRUE
)

#  @title SecurePlainPhone
#  @description Telegram API type SecurePlainPhone
#  @export
#  @noRd
#  @noRd
SecurePlainPhone <- R6::R6Class("SecurePlainPhone",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7d6099dd,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x23b2afb6,
    #  @field phone Field.
    phone = NULL,
    initialize = function(phone = NULL) {
      self$phone <- phone
    },
    to_dict = function() list(`_` = "SecurePlainPhone", phone = self$phone),
    bytes = function() as.raw(c(0xdd, 0x99, 0x60, 0x7d)) + self$serializebytes(self$phone)
  ),
  private = list(
    from_reader = function(reader) {
      phone <- reader$tgread_string()
      self$new(phone = phone)
    }
  ),
  class = TRUE
)

#  @title SecureRequiredType
#  @description Telegram API type SecureRequiredType
#  @export
#  @noRd
#  @noRd
SecureRequiredType <- R6::R6Class("SecureRequiredType",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x829d99da,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x7c7b420a,
    #  @field type Field.
    type = NULL,
    #  @field native_names Field.
    native_names = NULL,
    #  @field selfie_required Field.
    selfie_required = NULL,
    #  @field translation_required Field.
    translation_required = NULL,
    initialize = function(type = NULL, native_names = NULL, selfie_required = NULL, translation_required = NULL) {
      self$type <- type
      self$native_names <- native_names
      self$selfie_required <- selfie_required
      self$translation_required <- translation_required
    },
    to_dict = function() list(`_` = "SecureRequiredType", type = if (is.null(self$type)) NULL else self$type$to_dict(), native_names = self$native_names, selfie_required = self$selfie_required, translation_required = self$translation_required),
    bytes = function() as.raw(c(0xda, 0x99, 0x9d, 0x82)) + pack("I", if (is.null(self$native_names) || !self$native_names) 0 else 1 | if (is.null(self$selfie_required) || !self$selfie_required) 0 else 2 | if (is.null(self$translation_required) || !self$translation_required) 0 else 4) + self$type$bytes()
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      native_names <- bitwAnd(flags, 1) != 0
      selfie_required <- bitwAnd(flags, 2) != 0
      translation_required <- bitwAnd(flags, 4) != 0
      type <- reader$tgread_object()
      self$new(type = type, native_names = native_names, selfie_required = selfie_required, translation_required = translation_required)
    }
  ),
  class = TRUE
)

#  @title SecureRequiredTypeOneOf
#  @description Telegram API type SecureRequiredTypeOneOf
#  @export
#  @noRd
#  @noRd
SecureRequiredTypeOneOf <- R6::R6Class("SecureRequiredTypeOneOf",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x27477b4,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x7c7b420a,
    #  @field types Field.
    types = NULL,
    initialize = function(types = NULL) {
      self$types <- types
    },
    to_dict = function() list(`_` = "SecureRequiredTypeOneOf", types = if (is.null(self$types)) list() else lapply(self$types, function(x) x$to_dict())),
    bytes = function() as.raw(c(0xb4, 0x7b, 0x74, 0x02)) + as.raw(c(0x1c, 0xb5, 0xc4, 0x15)) + pack("i", length(self$types)) + do.call(c, lapply(self$types, function(x) x$bytes()))
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      types <- lapply(seq_len(reader$read_int()), function(i) reader$tgread_object())
      self$new(types = types)
    }
  ),
  class = TRUE
)

#  @title SecureSecretSettings
#  @description Telegram API type SecureSecretSettings
#  @export
#  @noRd
#  @noRd
SecureSecretSettings <- R6::R6Class("SecureSecretSettings",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1527bcac,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc6c802fb,
    #  @field secure_algo Field.
    secure_algo = NULL,
    #  @field secure_secret Field.
    secure_secret = NULL,
    #  @field secure_secret_id Field.
    secure_secret_id = NULL,
    initialize = function(secure_algo = NULL, secure_secret = NULL, secure_secret_id = NULL) {
      self$secure_algo <- secure_algo
      self$secure_secret <- secure_secret
      self$secure_secret_id <- secure_secret_id
    },
    to_dict = function() list(`_` = "SecureSecretSettings", secure_algo = if (is.null(self$secure_algo)) NULL else self$secure_algo$to_dict(), secure_secret = self$secure_secret, secure_secret_id = self$secure_secret_id),
    bytes = function() as.raw(c(0xac, 0xbc, 0x27, 0x15)) + self$secure_algo$bytes() + self$serializebytes(self$secure_secret) + pack("q", self$secure_secret_id)
  ),
  private = list(
    from_reader = function(reader) {
      secure_algo <- reader$tgread_object()
      secure_secret <- reader$tgreadbytes()
      secure_secret_id <- reader$read_long()
      self$new(secure_algo = secure_algo, secure_secret = secure_secret, secure_secret_id = secure_secret_id)
    }
  ),
  class = TRUE
)

#  @title SecureValue
#  @description Telegram API type SecureValue
#  @export
#  @noRd
#  @noRd
SecureValue <- R6::R6Class("SecureValue",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x187fa0ca,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x51138ae,
    #  @field type Field.
    type = NULL,
    #  @field hash Field.
    hash = NULL,
    #  @field data Field.
    data = NULL,
    #  @field front_side Field.
    front_side = NULL,
    #  @field reverse_side Field.
    reverse_side = NULL,
    #  @field selfie Field.
    selfie = NULL,
    #  @field translation Field.
    translation = NULL,
    #  @field files Field.
    files = NULL,
    #  @field plaindata Field.
    plaindata = NULL,
    initialize = function(type = NULL, hash = NULL, data = NULL, front_side = NULL, reverse_side = NULL, selfie = NULL, translation = NULL, files = NULL, plaindata = NULL) {
      self$type <- type
      self$hash <- hash
      self$data <- data
      self$front_side <- front_side
      self$reverse_side <- reverse_side
      self$selfie <- selfie
      self$translation <- translation
      self$files <- files
      self$plaindata <- plaindata
    },
    to_dict = function() list(`_` = "SecureValue", type = if (is.null(self$type)) NULL else self$type$to_dict(), hash = self$hash, data = if (is.null(self$data)) NULL else self$data$to_dict(), front_side = if (is.null(self$front_side)) NULL else self$front_side$to_dict(), reverse_side = if (is.null(self$reverse_side)) NULL else self$reverse_side$to_dict(), selfie = if (is.null(self$selfie)) NULL else self$selfie$to_dict(), translation = if (is.null(self$translation)) list() else lapply(self$translation, function(x) x$to_dict()), files = if (is.null(self$files)) list() else lapply(self$files, function(x) x$to_dict()), plaindata = if (is.null(self$plaindata)) NULL else self$plaindata$to_dict()),
    bytes = function() {
      flags <- 0
      if (!is.null(self$data)) flags <- bitwOr(flags, 1)
      if (!is.null(self$front_side)) flags <- bitwOr(flags, 2)
      if (!is.null(self$reverse_side)) flags <- bitwOr(flags, 4)
      if (!is.null(self$selfie)) flags <- bitwOr(flags, 8)
      if (!is.null(self$translation)) flags <- bitwOr(flags, 64)
      if (!is.null(self$files)) flags <- bitwOr(flags, 16)
      if (!is.null(self$plaindata)) flags <- bitwOr(flags, 32)
      as.raw(c(0xca, 0xa0, 0x7f, 0x18)) + pack("I", flags) + self$type$bytes() + if (!is.null(self$data)) self$data$bytes() else raw(0) + if (!is.null(self$front_side)) self$front_side$bytes() else raw(0) + if (!is.null(self$reverse_side)) self$reverse_side$bytes() else raw(0) + if (!is.null(self$selfie)) self$selfie$bytes() else raw(0) + if (!is.null(self$translation)) as.raw(c(0x1c, 0xb5, 0xc4, 0x15)) + pack("i", length(self$translation)) + do.call(c, lapply(self$translation, function(x) x$bytes())) else raw(0) + if (!is.null(self$files)) as.raw(c(0x1c, 0xb5, 0xc4, 0x15)) + pack("i", length(self$files)) + do.call(c, lapply(self$files, function(x) x$bytes())) else raw(0) + if (!is.null(self$plaindata)) self$plaindata$bytes() else raw(0) + self$serializebytes(self$hash)
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      type <- reader$tgread_object()
      if (bitwAnd(flags, 1) != 0) data <- reader$tgread_object() else data <- NULL
      if (bitwAnd(flags, 2) != 0) front_side <- reader$tgread_object() else front_side <- NULL
      if (bitwAnd(flags, 4) != 0) reverse_side <- reader$tgread_object() else reverse_side <- NULL
      if (bitwAnd(flags, 8) != 0) selfie <- reader$tgread_object() else selfie <- NULL
      if (bitwAnd(flags, 64) != 0) {
        reader$read_int()
        translation <- lapply(seq_len(reader$read_int()), function(i) reader$tgread_object())
      } else {
        translation <- NULL
      }
      if (bitwAnd(flags, 16) != 0) {
        reader$read_int()
        files <- lapply(seq_len(reader$read_int()), function(i) reader$tgread_object())
      } else {
        files <- NULL
      }
      if (bitwAnd(flags, 32) != 0) plaindata <- reader$tgread_object() else plaindata <- NULL
      hash <- reader$tgreadbytes()
      self$new(type = type, hash = hash, data = data, front_side = front_side, reverse_side = reverse_side, selfie = selfie, translation = translation, files = files, plaindata = plaindata)
    }
  ),
  class = TRUE
)

#  @title SecureValueError
#  @description Telegram API type SecureValueError
#  @export
#  @noRd
#  @noRd
SecureValueError <- R6::R6Class("SecureValueError",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x869d758f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x6075fce,
    #  @field type Field.
    type = NULL,
    #  @field hash Field.
    hash = NULL,
    #  @field text Field.
    text = NULL,
    initialize = function(type = NULL, hash = NULL, text = NULL) {
      self$type <- type
      self$hash <- hash
      self$text <- text
    },
    to_dict = function() list(`_` = "SecureValueError", type = if (is.null(self$type)) NULL else self$type$to_dict(), hash = self$hash, text = self$text),
    bytes = function() as.raw(c(0x8f, 0x75, 0x9d, 0x86)) + self$type$bytes() + self$serializebytes(self$hash) + self$serializebytes(self$text)
  ),
  private = list(
    from_reader = function(reader) {
      type <- reader$tgread_object()
      hash <- reader$tgreadbytes()
      text <- reader$tgread_string()
      self$new(type = type, hash = hash, text = text)
    }
  ),
  class = TRUE
)

#  @title SecureValueErrorData
#  @description Telegram API type SecureValueErrorData
#  @export
#  @noRd
#  @noRd
SecureValueErrorData <- R6::R6Class("SecureValueErrorData",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe8a40bd9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x6075fce,
    #  @field type Field.
    type = NULL,
    #  @field data_hash Field.
    data_hash = NULL,
    #  @field field Field.
    field = NULL,
    #  @field text Field.
    text = NULL,
    initialize = function(type = NULL, data_hash = NULL, field = NULL, text = NULL) {
      self$type <- type
      self$data_hash <- data_hash
      self$field <- field
      self$text <- text
    },
    to_dict = function() list(`_` = "SecureValueErrorData", type = if (is.null(self$type)) NULL else self$type$to_dict(), data_hash = self$data_hash, field = self$field, text = self$text),
    bytes = function() as.raw(c(0xd9, 0x0b, 0xa4, 0xe8)) + self$type$bytes() + self$serializebytes(self$data_hash) + self$serializebytes(self$field) + self$serializebytes(self$text)
  ),
  private = list(
    from_reader = function(reader) {
      type <- reader$tgread_object()
      data_hash <- reader$tgreadbytes()
      field <- reader$tgread_string()
      text <- reader$tgread_string()
      self$new(type = type, data_hash = data_hash, field = field, text = text)
    }
  ),
  class = TRUE
)

#  @title SecureValueErrorFile
#  @description Telegram API type SecureValueErrorFile
#  @export
#  @noRd
#  @noRd
SecureValueErrorFile <- R6::R6Class("SecureValueErrorFile",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7a700873,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x6075fce,
    initialize = function(type, file_hash, text) {
      self$type <- type
      self$file_hash <- file_hash
      self$text <- text
    },
    to_dict = function() {
      list(
        `_` = "SecureValueErrorFile",
        type = if (inherits(self$type, "TLObject")) self$type$to_dict() else self$type,
        file_hash = self$file_hash,
        text = self$text
      )
    },
    bytes = function() {
      c(as.raw(c(0x73, 0x08, 0x70, 0x7a)), self$type$bytes(), self$serializebytes(self$file_hash), self$serializebytes(self$text))
    }
  ),
  private = list(
    from_reader = function(reader) {
      type <- reader$tgread_object()
      file_hash <- reader$tgreadbytes()
      text <- reader$tgread_string()
      self$initialize(type, file_hash, text)
    }
  ),
  class = TRUE
)

#  @title SecureValueErrorFiles
#  @description Telegram API type SecureValueErrorFiles
#  @export
#  @noRd
#  @noRd
SecureValueErrorFiles <- R6::R6Class("SecureValueErrorFiles",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x666220e9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x6075fce,
    initialize = function(type, file_hash, text) {
      self$type <- type
      self$file_hash <- file_hash
      self$text <- text
    },
    to_dict = function() {
      list(
        `_` = "SecureValueErrorFiles",
        type = if (inherits(self$type, "TLObject")) self$type$to_dict() else self$type,
        file_hash = if (is.null(self$file_hash)) list() else self$file_hash,
        text = self$text
      )
    },
    bytes = function() {
      c(as.raw(c(0xe9, 0x20, 0x62, 0x66)), self$type$bytes(), as.raw(c(0x1c, 0xb5, 0xc4, 0x15)), pack("i", length(self$file_hash)), do.call(c, lapply(self$file_hash, self$serializebytes)), self$serializebytes(self$text))
    }
  ),
  private = list(
    from_reader = function(reader) {
      type <- reader$tgread_object()
      reader$read_int()
      file_hash <- list()
      for (i in seq_len(reader$read_int())) {
        x <- reader$tgreadbytes()
        file_hash <- c(file_hash, x)
      }
      text <- reader$tgread_string()
      self$initialize(type, file_hash, text)
    }
  ),
  class = TRUE
)

#  @title SecureValueErrorFrontSide
#  @description Telegram API type SecureValueErrorFrontSide
#  @export
#  @noRd
#  @noRd
SecureValueErrorFrontSide <- R6::R6Class("SecureValueErrorFrontSide",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbe3dfa,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x6075fce,
    initialize = function(type, file_hash, text) {
      self$type <- type
      self$file_hash <- file_hash
      self$text <- text
    },
    to_dict = function() {
      list(
        `_` = "SecureValueErrorFrontSide",
        type = if (inherits(self$type, "TLObject")) self$type$to_dict() else self$type,
        file_hash = self$file_hash,
        text = self$text
      )
    },
    bytes = function() {
      c(as.raw(c(0xfa, 0x3d, 0xbe, 0x00)), self$type$bytes(), self$serializebytes(self$file_hash), self$serializebytes(self$text))
    }
  ),
  private = list(
    from_reader = function(reader) {
      type <- reader$tgread_object()
      file_hash <- reader$tgreadbytes()
      text <- reader$tgread_string()
      self$initialize(type, file_hash, text)
    }
  ),
  class = TRUE
)

#  @title SecureValueErrorReverseSide
#  @description Telegram API type SecureValueErrorReverseSide
#  @export
#  @noRd
#  @noRd
SecureValueErrorReverseSide <- R6::R6Class("SecureValueErrorReverseSide",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x868a2aa5,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x6075fce,
    initialize = function(type, file_hash, text) {
      self$type <- type
      self$file_hash <- file_hash
      self$text <- text
    },
    to_dict = function() {
      list(
        `_` = "SecureValueErrorReverseSide",
        type = if (inherits(self$type, "TLObject")) self$type$to_dict() else self$type,
        file_hash = self$file_hash,
        text = self$text
      )
    },
    bytes = function() {
      c(as.raw(c(0xa5, 0x2a, 0x8a, 0x86)), self$type$bytes(), self$serializebytes(self$file_hash), self$serializebytes(self$text))
    }
  ),
  private = list(
    from_reader = function(reader) {
      type <- reader$tgread_object()
      file_hash <- reader$tgreadbytes()
      text <- reader$tgread_string()
      self$initialize(type, file_hash, text)
    }
  ),
  class = TRUE
)

#  @title SecureValueErrorSelfie
#  @description Telegram API type SecureValueErrorSelfie
#  @export
#  @noRd
#  @noRd
SecureValueErrorSelfie <- R6::R6Class("SecureValueErrorSelfie",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe537ced6,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x6075fce,
    initialize = function(type, file_hash, text) {
      self$type <- type
      self$file_hash <- file_hash
      self$text <- text
    },
    to_dict = function() {
      list(
        `_` = "SecureValueErrorSelfie",
        type = if (inherits(self$type, "TLObject")) self$type$to_dict() else self$type,
        file_hash = self$file_hash,
        text = self$text
      )
    },
    bytes = function() {
      c(as.raw(c(0xd6, 0xce, 0x37, 0xe5)), self$type$bytes(), self$serializebytes(self$file_hash), self$serializebytes(self$text))
    }
  ),
  private = list(
    from_reader = function(reader) {
      type <- reader$tgread_object()
      file_hash <- reader$tgreadbytes()
      text <- reader$tgread_string()
      self$initialize(type, file_hash, text)
    }
  ),
  class = TRUE
)

#  @title SecureValueErrorTranslationFile
#  @description Telegram API type SecureValueErrorTranslationFile
#  @export
#  @noRd
#  @noRd
SecureValueErrorTranslationFile <- R6::R6Class("SecureValueErrorTranslationFile",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa1144770,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x6075fce,
    initialize = function(type, file_hash, text) {
      self$type <- type
      self$file_hash <- file_hash
      self$text <- text
    },
    to_dict = function() {
      list(
        `_` = "SecureValueErrorTranslationFile",
        type = if (inherits(self$type, "TLObject")) self$type$to_dict() else self$type,
        file_hash = self$file_hash,
        text = self$text
      )
    },
    bytes = function() {
      c(as.raw(c(0x70, 0x47, 0x14, 0xa1)), self$type$bytes(), self$serializebytes(self$file_hash), self$serializebytes(self$text))
    }
  ),
  private = list(
    from_reader = function(reader) {
      type <- reader$tgread_object()
      file_hash <- reader$tgreadbytes()
      text <- reader$tgread_string()
      self$initialize(type, file_hash, text)
    }
  ),
  class = TRUE
)

#  @title SecureValueErrorTranslationFiles
#  @description Telegram API type SecureValueErrorTranslationFiles
#  @export
#  @noRd
#  @noRd
SecureValueErrorTranslationFiles <- R6::R6Class("SecureValueErrorTranslationFiles",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x34636dd8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x6075fce,
    initialize = function(type, file_hash, text) {
      self$type <- type
      self$file_hash <- file_hash
      self$text <- text
    },
    to_dict = function() {
      list(
        `_` = "SecureValueErrorTranslationFiles",
        type = if (inherits(self$type, "TLObject")) self$type$to_dict() else self$type,
        file_hash = if (is.null(self$file_hash)) list() else self$file_hash,
        text = self$text
      )
    },
    bytes = function() {
      c(as.raw(c(0xd8, 0x6d, 0x63, 0x34)), self$type$bytes(), as.raw(c(0x1c, 0xb5, 0xc4, 0x15)), pack("i", length(self$file_hash)), do.call(c, lapply(self$file_hash, self$serializebytes)), self$serializebytes(self$text))
    }
  ),
  private = list(
    from_reader = function(reader) {
      type <- reader$tgread_object()
      reader$read_int()
      file_hash <- list()
      for (i in seq_len(reader$read_int())) {
        x <- reader$tgreadbytes()
        file_hash <- c(file_hash, x)
      }
      text <- reader$tgread_string()
      self$initialize(type, file_hash, text)
    }
  ),
  class = TRUE
)

#  @title SecureValueHash
#  @description Telegram API type SecureValueHash
#  @export
#  @noRd
#  @noRd
SecureValueHash <- R6::R6Class("SecureValueHash",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xed1ecdb0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xd5f5c007,
    initialize = function(type, hash) {
      self$type <- type
      self$hash <- hash
    },
    to_dict = function() {
      list(
        `_` = "SecureValueHash",
        type = if (inherits(self$type, "TLObject")) self$type$to_dict() else self$type,
        hash = self$hash
      )
    },
    bytes = function() {
      c(as.raw(c(0xb0, 0xcd, 0x1e, 0xed)), self$type$bytes(), self$serializebytes(self$hash))
    }
  ),
  private = list(
    from_reader = function(reader) {
      type <- reader$tgread_object()
      hash <- reader$tgreadbytes()
      self$initialize(type, hash)
    }
  ),
  class = TRUE
)

#  @title SecureValueTypeAddress
#  @description Telegram API type SecureValueTypeAddress
#  @export
#  @noRd
#  @noRd
SecureValueTypeAddress <- R6::R6Class("SecureValueTypeAddress",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xcbe31e26,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8893f596,
    to_dict = function() {
      list(`_` = "SecureValueTypeAddress")
    },
    bytes = function() {
      as.raw(c(0x26, 0x1e, 0xe3, 0xcb))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title SecureValueTypeBankStatement
#  @description Telegram API type SecureValueTypeBankStatement
#  @export
#  @noRd
#  @noRd
SecureValueTypeBankStatement <- R6::R6Class("SecureValueTypeBankStatement",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x89137c0d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8893f596,
    to_dict = function() {
      list(`_` = "SecureValueTypeBankStatement")
    },
    bytes = function() {
      as.raw(c(0x0d, 0x7c, 0x13, 0x89))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title SecureValueTypeDriverLicense
#  @description Telegram API type SecureValueTypeDriverLicense
#  @export
#  @noRd
#  @noRd
SecureValueTypeDriverLicense <- R6::R6Class("SecureValueTypeDriverLicense",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x6e425c4,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8893f596,
    to_dict = function() {
      list(`_` = "SecureValueTypeDriverLicense")
    },
    bytes = function() {
      as.raw(c(0xc4, 0x25, 0xe4, 0x06))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title SecureValueTypeEmail
#  @description Telegram API type SecureValueTypeEmail
#  @export
#  @noRd
#  @noRd
SecureValueTypeEmail <- R6::R6Class("SecureValueTypeEmail",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8e3ca7ee,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8893f596,
    to_dict = function() {
      list(`_` = "SecureValueTypeEmail")
    },
    bytes = function() {
      as.raw(c(0xee, 0xa7, 0x3c, 0x8e))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title SecureValueTypeIdentityCard
#  @description Telegram API type SecureValueTypeIdentityCard
#  @export
#  @noRd
#  @noRd
SecureValueTypeIdentityCard <- R6::R6Class("SecureValueTypeIdentityCard",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa0d0744b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8893f596,
    to_dict = function() {
      list(`_` = "SecureValueTypeIdentityCard")
    },
    bytes = function() {
      as.raw(c(0x4b, 0x74, 0xd0, 0xa0))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title SecureValueTypeInternalPassport
#  @description Telegram API type SecureValueTypeInternalPassport
#  @export
#  @noRd
#  @noRd
SecureValueTypeInternalPassport <- R6::R6Class("SecureValueTypeInternalPassport",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x99a48f23,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8893f596,
    to_dict = function() {
      list(`_` = "SecureValueTypeInternalPassport")
    },
    bytes = function() {
      as.raw(c(0x23, 0x8f, 0xa4, 0x99))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title SecureValueTypePassport
#  @description Telegram API type SecureValueTypePassport
#  @export
#  @noRd
#  @noRd
SecureValueTypePassport <- R6::R6Class("SecureValueTypePassport",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x3dac6a00,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8893f596,
    to_dict = function() {
      list(`_` = "SecureValueTypePassport")
    },
    bytes = function() {
      as.raw(c(0x00, 0x6a, 0xac, 0x3d))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title SecureValueTypePassportRegistration
#  @description Telegram API type SecureValueTypePassportRegistration
#  @export
#  @noRd
#  @noRd
SecureValueTypePassportRegistration <- R6::R6Class("SecureValueTypePassportRegistration",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x99e3806a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8893f596,
    to_dict = function() {
      list(`_` = "SecureValueTypePassportRegistration")
    },
    bytes = function() {
      as.raw(c(0x6a, 0x80, 0xe3, 0x99))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title SecureValueTypePersonalDetails
#  @description Telegram API type SecureValueTypePersonalDetails
#  @export
#  @noRd
#  @noRd
SecureValueTypePersonalDetails <- R6::R6Class("SecureValueTypePersonalDetails",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9d2a81e3,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8893f596,
    to_dict = function() {
      list(`_` = "SecureValueTypePersonalDetails")
    },
    bytes = function() {
      as.raw(c(0xe3, 0x81, 0x2a, 0x9d))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title SecureValueTypePhone
#  @description Telegram API type SecureValueTypePhone
#  @export
#  @noRd
#  @noRd
SecureValueTypePhone <- R6::R6Class("SecureValueTypePhone",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb320aadb,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8893f596,
    to_dict = function() {
      list(`_` = "SecureValueTypePhone")
    },
    bytes = function() {
      as.raw(c(0xdb, 0xaa, 0x20, 0xb3))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title SecureValueTypeRentalAgreement
#  @description Telegram API type SecureValueTypeRentalAgreement
#  @export
#  @noRd
#  @noRd
SecureValueTypeRentalAgreement <- R6::R6Class("SecureValueTypeRentalAgreement",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8b883488,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8893f596,
    to_dict = function() {
      list(`_` = "SecureValueTypeRentalAgreement")
    },
    bytes = function() {
      as.raw(c(0x88, 0x34, 0x88, 0x8b))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title SecureValueTypeTemporaryRegistration
#  @description Telegram API type SecureValueTypeTemporaryRegistration
#  @export
#  @noRd
#  @noRd
SecureValueTypeTemporaryRegistration <- R6::R6Class("SecureValueTypeTemporaryRegistration",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xea02ec33,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8893f596,
    to_dict = function() {
      list(`_` = "SecureValueTypeTemporaryRegistration")
    },
    bytes = function() {
      as.raw(c(0x33, 0xec, 0x02, 0xea))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title SecureValueTypeUtilityBill
#  @description Telegram API type SecureValueTypeUtilityBill
#  @export
#  @noRd
#  @noRd
SecureValueTypeUtilityBill <- R6::R6Class("SecureValueTypeUtilityBill",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xfc36954e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8893f596,
    to_dict = function() {
      list(`_` = "SecureValueTypeUtilityBill")
    },
    bytes = function() {
      as.raw(c(0x4e, 0x95, 0x36, 0xfc))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title SendAsPeer
#  @description Telegram API type SendAsPeer
#  @export
#  @noRd
#  @noRd
SendAsPeer <- R6::R6Class("SendAsPeer",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb81c7034,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x442381e4,
    initialize = function(peer, premium_required = NULL) {
      self$peer <- peer
      self$premium_required <- premium_required
    },
    to_dict = function() {
      list(
        `_` = "SendAsPeer",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        premium_required = self$premium_required
      )
    },
    bytes = function() {
      c(as.raw(c(0x34, 0x70, 0x1c, 0xb8)), pack("I", if (is.null(self$premium_required) || !self$premium_required) 0 else 1), self$peer$bytes())
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      premium_required <- bitwAnd(flags, 1) != 0
      peer <- reader$tgread_object()
      self$initialize(peer, premium_required)
    }
  ),
  class = TRUE
)

#  @title SendMessageCancelAction
#  @description Telegram API type SendMessageCancelAction
#  @export
#  @noRd
#  @noRd
SendMessageCancelAction <- R6::R6Class("SendMessageCancelAction",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xfd5ec8f5,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x20b2cc21,
    to_dict = function() {
      list(`_` = "SendMessageCancelAction")
    },
    bytes = function() {
      as.raw(c(0xf5, 0xc8, 0x5e, 0xfd))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title SendMessageChooseContactAction
#  @description Telegram API type SendMessageChooseContactAction
#  @export
#  @noRd
#  @noRd
SendMessageChooseContactAction <- R6::R6Class("SendMessageChooseContactAction",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x628cbc6f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x20b2cc21,
    to_dict = function() {
      list(`_` = "SendMessageChooseContactAction")
    },
    bytes = function() {
      as.raw(c(0x6f, 0xbc, 0x8c, 0x62))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title SendMessageChooseStickerAction
#  @description Telegram API type SendMessageChooseStickerAction
#  @export
#  @noRd
#  @noRd
SendMessageChooseStickerAction <- R6::R6Class("SendMessageChooseStickerAction",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb05ac6b1,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x20b2cc21,
    to_dict = function() {
      list(`_` = "SendMessageChooseStickerAction")
    },
    bytes = function() {
      as.raw(c(0xb1, 0xc6, 0x5a, 0xb0))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title SendMessageEmojiInteraction
#  @description Telegram API type SendMessageEmojiInteraction
#  @export
#  @noRd
#  @noRd
SendMessageEmojiInteraction <- R6::R6Class("SendMessageEmojiInteraction",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x25972bcb,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x20b2cc21,
    initialize = function(emoticon, msg_id, interaction) {
      self$emoticon <- emoticon
      self$msg_id <- msg_id
      self$interaction <- interaction
    },
    to_dict = function() {
      list(
        `_` = "SendMessageEmojiInteraction",
        emoticon = self$emoticon,
        msg_id = self$msg_id,
        interaction = if (inherits(self$interaction, "TLObject")) self$interaction$to_dict() else self$interaction
      )
    },
    bytes = function() {
      c(as.raw(c(0xcb, 0x2b, 0x97, 0x25)), self$serializebytes(self$emoticon), pack("i", self$msg_id), self$interaction$bytes())
    }
  ),
  private = list(
    from_reader = function(reader) {
      emoticon <- reader$tgread_string()
      msg_id <- reader$read_int()
      interaction <- reader$tgread_object()
      self$initialize(emoticon, msg_id, interaction)
    }
  ),
  class = TRUE
)

#  @title SendMessageEmojiInteractionSeen
#  @description Telegram API type SendMessageEmojiInteractionSeen
#  @export
#  @noRd
#  @noRd
SendMessageEmojiInteractionSeen <- R6::R6Class("SendMessageEmojiInteractionSeen",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb665902e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x20b2cc21,
    initialize = function(emoticon) {
      self$emoticon <- emoticon
    },
    to_dict = function() {
      list(
        `_` = "SendMessageEmojiInteractionSeen",
        emoticon = self$emoticon
      )
    },
    bytes = function() {
      c(as.raw(c(0x2e, 0x90, 0x65, 0xb6)), self$serializebytes(self$emoticon))
    }
  ),
  private = list(
    from_reader = function(reader) {
      emoticon <- reader$tgread_string()
      self$initialize(emoticon)
    }
  ),
  class = TRUE
)

#  @title SendMessageGamePlayAction
#  @description Telegram API type SendMessageGamePlayAction
#  @export
#  @noRd
#  @noRd
SendMessageGamePlayAction <- R6::R6Class("SendMessageGamePlayAction",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xdd6a8f48,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x20b2cc21,
    to_dict = function() {
      list(`_` = "SendMessageGamePlayAction")
    },
    bytes = function() {
      as.raw(c(0x48, 0x8f, 0x6a, 0xdd))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title SendMessageGeoLocationAction
#  @description Telegram API type SendMessageGeoLocationAction
#  @export
#  @noRd
#  @noRd
SendMessageGeoLocationAction <- R6::R6Class("SendMessageGeoLocationAction",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x176f8ba1,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x20b2cc21,
    to_dict = function() {
      list(`_` = "SendMessageGeoLocationAction")
    },
    bytes = function() {
      as.raw(c(0xa1, 0x8b, 0x6f, 0x17))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title SendMessageHistoryImportAction
#  @description Telegram API type SendMessageHistoryImportAction
#  @export
#  @noRd
#  @noRd
SendMessageHistoryImportAction <- R6::R6Class("SendMessageHistoryImportAction",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xdbda9246,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x20b2cc21,
    #  @field progress Field.
    progress = NULL,
    initialize = function(progress) {
      self$progress <- progress
    },
    to_dict = function() {
      list(
        `_` = "SendMessageHistoryImportAction",
        progress = self$progress
      )
    },
    bytes = function() {
      c(as.raw(c(0x46, 0x92, 0xda, 0xdb)), pack("i", self$progress))
    }
  ),
  private = list(
    from_reader = function(reader) {
      progress <- reader$read_int()
      self$initialize(progress)
    }
  ),
  class = TRUE
)

#  @title SendMessageRecordAudioAction
#  @description Telegram API type SendMessageRecordAudioAction
#  @export
#  @noRd
#  @noRd
SendMessageRecordAudioAction <- R6::R6Class("SendMessageRecordAudioAction",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd52f73f7,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x20b2cc21,
    to_dict = function() {
      list(`_` = "SendMessageRecordAudioAction")
    },
    bytes = function() {
      as.raw(c(0xf7, 0x73, 0x2f, 0xd5))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title SendMessageRecordRoundAction
#  @description Telegram API type SendMessageRecordRoundAction
#  @export
#  @noRd
#  @noRd
SendMessageRecordRoundAction <- R6::R6Class("SendMessageRecordRoundAction",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x88f27fbc,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x20b2cc21,
    to_dict = function() {
      list(`_` = "SendMessageRecordRoundAction")
    },
    bytes = function() {
      as.raw(c(0xbc, 0x7f, 0xf2, 0x88))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title SendMessageRecordVideoAction
#  @description Telegram API type SendMessageRecordVideoAction
#  @export
#  @noRd
#  @noRd
SendMessageRecordVideoAction <- R6::R6Class("SendMessageRecordVideoAction",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa187d66f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x20b2cc21,
    to_dict = function() {
      list(`_` = "SendMessageRecordVideoAction")
    },
    bytes = function() {
      as.raw(c(0x6f, 0xd6, 0x87, 0xa1))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  Senders msg_id as int, but it should be long
# 
#  @title SendMessageTypingAction
#  @description Telegram API type SendMessageTypingAction
#  @export
#  @noRd
#  @noRd
SendMessageTypingAction <- R6::R6Class("SendMessageTypingAction",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x16bf744e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x20b2cc21,
    to_dict = function() {
      list(`_` = "SendMessageTypingAction")
    },
    bytes = function() {
      as.raw(c(0x4e, 0x74, 0xbf, 0x16))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title SendMessageUploadAudioAction
#  @description Telegram API type SendMessageUploadAudioAction
#  @export
#  @noRd
#  @noRd
SendMessageUploadAudioAction <- R6::R6Class("SendMessageUploadAudioAction",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf351d7ab,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x20b2cc21,
    #  @field progress Field.
    progress = NULL,
    initialize = function(progress) {
      self$progress <- progress
    },
    to_dict = function() {
      list(
        `_` = "SendMessageUploadAudioAction",
        progress = self$progress
      )
    },
    bytes = function() {
      c(as.raw(c(0xab, 0xd7, 0x51, 0xf3)), pack("i", self$progress))
    }
  ),
  private = list(
    from_reader = function(reader) {
      progress <- reader$read_int()
      self$initialize(progress)
    }
  ),
  class = TRUE
)

#  @title SendMessageUploadDocumentAction
#  @description Telegram API type SendMessageUploadDocumentAction
#  @export
#  @noRd
#  @noRd
SendMessageUploadDocumentAction <- R6::R6Class("SendMessageUploadDocumentAction",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xaa0cd9e4,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x20b2cc21,
    #  @field progress Field.
    progress = NULL,
    initialize = function(progress) {
      self$progress <- progress
    },
    to_dict = function() {
      list(
        `_` = "SendMessageUploadDocumentAction",
        progress = self$progress
      )
    },
    bytes = function() {
      c(as.raw(c(0xe4, 0xd9, 0x0c, 0xaa)), pack("i", self$progress))
    }
  ),
  private = list(
    from_reader = function(reader) {
      progress <- reader$read_int()
      self$initialize(progress)
    }
  ),
  class = TRUE
)

#  @title SendMessageUploadPhotoAction
#  @description Telegram API type SendMessageUploadPhotoAction
#  @export
#  @noRd
#  @noRd
SendMessageUploadPhotoAction <- R6::R6Class("SendMessageUploadPhotoAction",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd1d34a26,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x20b2cc21,
    #  @field progress Field.
    progress = NULL,
    initialize = function(progress) {
      self$progress <- progress
    },
    to_dict = function() {
      list(
        `_` = "SendMessageUploadPhotoAction",
        progress = self$progress
      )
    },
    bytes = function() {
      c(as.raw(c(0x26, 0x4a, 0xd3, 0xd1)), pack("i", self$progress))
    }
  ),
  private = list(
    from_reader = function(reader) {
      progress <- reader$read_int()
      self$initialize(progress)
    }
  ),
  class = TRUE
)

#  @title SendMessageUploadRoundAction
#  @description Telegram API type SendMessageUploadRoundAction
#  @export
#  @noRd
#  @noRd
SendMessageUploadRoundAction <- R6::R6Class("SendMessageUploadRoundAction",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x243e1c66,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x20b2cc21,
    #  @field progress Field.
    progress = NULL,
    initialize = function(progress) {
      self$progress <- progress
    },
    to_dict = function() {
      list(
        `_` = "SendMessageUploadRoundAction",
        progress = self$progress
      )
    },
    bytes = function() {
      c(as.raw(c(0x66, 0x1c, 0x3e, 0x24)), pack("i", self$progress))
    }
  ),
  private = list(
    from_reader = function(reader) {
      progress <- reader$read_int()
      self$initialize(progress)
    }
  ),
  class = TRUE
)

#  @title SendMessageUploadVideoAction
#  @description Telegram API type SendMessageUploadVideoAction
#  @export
#  @noRd
#  @noRd
SendMessageUploadVideoAction <- R6::R6Class("SendMessageUploadVideoAction",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe9763aec,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x20b2cc21,
    #  @field progress Field.
    progress = NULL,
    initialize = function(progress) {
      self$progress <- progress
    },
    to_dict = function() {
      list(
        `_` = "SendMessageUploadVideoAction",
        progress = self$progress
      )
    },
    bytes = function() {
      c(as.raw(c(0xec, 0x3a, 0x76, 0xe9)), pack("i", self$progress))
    }
  ),
  private = list(
    from_reader = function(reader) {
      progress <- reader$read_int()
      self$initialize(progress)
    }
  ),
  class = TRUE
)

#  @title ServerDHInnerData
#  @description Telegram API type ServerDHInnerData
#  @export
#  @noRd
#  @noRd
ServerDHInnerData <- R6::R6Class("ServerDHInnerData",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb5890dba,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc69a67bc,
    initialize = function(nonce, server_nonce, g, dh_prime, g_a, server_time) {
      self$nonce <- nonce
      self$server_nonce <- server_nonce
      self$g <- g
      self$dh_prime <- dh_prime
      self$g_a <- g_a
      self$server_time <- server_time
    },
    to_dict = function() {
      list(
        `_` = "ServerDHInnerData",
        nonce = self$nonce,
        server_nonce = self$server_nonce,
        g = self$g,
        dh_prime = self$dh_prime,
        g_a = self$g_a,
        server_time = self$server_time
      )
    },
    bytes = function() {
      c(as.raw(c(0xba, 0x0d, 0x89, 0xb5)), self$nonce$tobytes(16, "little", TRUE), self$server_nonce$tobytes(16, "little", TRUE), pack("i", self$g), self$serializebytes(self$dh_prime), self$serializebytes(self$g_a), pack("i", self$server_time))
    }
  ),
  private = list(
    from_reader = function(reader) {
      nonce <- reader$read_large_int(bits = 128)
      server_nonce <- reader$read_large_int(bits = 128)
      g <- reader$read_int()
      dh_prime <- reader$tgreadbytes()
      g_a <- reader$tgreadbytes()
      server_time <- reader$read_int()
      self$initialize(nonce, server_nonce, g, dh_prime, g_a, server_time)
    }
  ),
  class = TRUE
)

#  @title ServerDHParamsFail
#  @description Telegram API type ServerDHParamsFail
#  @export
#  @noRd
#  @noRd
ServerDHParamsFail <- R6::R6Class(
  "ServerDHParamsFail",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x79cb045d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xa6188d9e,
    initialize = function(nonce, server_nonce, new_nonce_hash) {
      self$nonce <- nonce
      self$server_nonce <- server_nonce
      self$new_nonce_hash <- new_nonce_hash
    },
    to_dict = function() {
      list(
        `_` = "ServerDHParamsFail",
        nonce = self$nonce,
        server_nonce = self$server_nonce,
        new_nonce_hash = self$new_nonce_hash
      )
    },
    bytes = function() {
      as.raw(c(0x5d, 0x04, 0xcb, 0x79)) +
        self$nonce$tobytes(16, "little", TRUE) +
        self$server_nonce$tobytes(16, "little", TRUE) +
        self$new_nonce_hash$tobytes(16, "little", TRUE)
    }
  ),
  private = list(
    from_reader = function(reader) {
      nonce <- reader$read_large_int(bits = 128)
      server_nonce <- reader$read_large_int(bits = 128)
      new_nonce_hash <- reader$read_large_int(bits = 128)
      self$initialize(nonce, server_nonce, new_nonce_hash)
      self
    }
  ),
  class = TRUE
)

#  @title ServerDHParamsOk
#  @description Telegram API type ServerDHParamsOk
#  @export
#  @noRd
#  @noRd
ServerDHParamsOk <- R6::R6Class(
  "ServerDHParamsOk",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd0e8075c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xa6188d9e,
    initialize = function(nonce, server_nonce, encrypted_answer) {
      self$nonce <- nonce
      self$server_nonce <- server_nonce
      self$encrypted_answer <- encrypted_answer
    },
    to_dict = function() {
      list(
        `_` = "ServerDHParamsOk",
        nonce = self$nonce,
        server_nonce = self$server_nonce,
        encrypted_answer = self$encrypted_answer
      )
    },
    bytes = function() {
      as.raw(c(0x5c, 0x07, 0xe8, 0xd0)) +
        self$nonce$tobytes(16, "little", TRUE) +
        self$server_nonce$tobytes(16, "little", TRUE) +
        self$serializebytes(self$encrypted_answer)
    }
  ),
  private = list(
    from_reader = function(reader) {
      nonce <- reader$read_large_int(bits = 128)
      server_nonce <- reader$read_large_int(bits = 128)
      encrypted_answer <- reader$tgreadbytes()
      self$initialize(nonce, server_nonce, encrypted_answer)
      self
    }
  ),
  class = TRUE
)

#  @title ShippingOption
#  @description Telegram API type ShippingOption
#  @export
#  @noRd
#  @noRd
ShippingOption <- R6::R6Class(
  "ShippingOption",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb6213cdf,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf4e94c78,
    initialize = function(id, title, prices) {
      self$id <- id
      self$title <- title
      self$prices <- prices
    },
    to_dict = function() {
      list(
        `_` = "ShippingOption",
        id = self$id,
        title = self$title,
        prices = lapply(self$prices, function(x) if (inherits(x, "R6")) x$to_dict() else x)
      )
    },
    bytes = function() {
      as.raw(c(0xdf, 0x3c, 0x21, 0xb6)) +
        self$serializebytes(self$id) +
        self$serializebytes(self$title) +
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)) + pack("i", length(self$prices)) + do.call(c, lapply(self$prices, function(x) x$bytes()))
    }
  ),
  private = list(
    from_reader = function(reader) {
      id <- reader$tgread_string()
      title <- reader$tgread_string()
      reader$read_int()
      prices <- list()
      for (i in 1:reader$read_int()) {
        x <- reader$tgread_object()
        prices <- c(prices, list(x))
      }
      self$initialize(id, title, prices)
      self
    }
  ),
  class = TRUE
)

#  @title SmsJob
#  @description Telegram API type SmsJob
#  @export
#  @noRd
#  @noRd
SmsJob <- R6::R6Class(
  "SmsJob",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe6a1eeb8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1f24187e,
    initialize = function(job_id, phone_number, text) {
      self$job_id <- job_id
      self$phone_number <- phone_number
      self$text <- text
    },
    to_dict = function() {
      list(
        `_` = "SmsJob",
        job_id = self$job_id,
        phone_number = self$phone_number,
        text = self$text
      )
    },
    bytes = function() {
      as.raw(c(0xb8, 0xee, 0xa1, 0xe6)) +
        self$serializebytes(self$job_id) +
        self$serializebytes(self$phone_number) +
        self$serializebytes(self$text)
    }
  ),
  private = list(
    from_reader = function(reader) {
      job_id <- reader$tgread_string()
      phone_number <- reader$tgread_string()
      text <- reader$tgread_string()
      self$initialize(job_id, phone_number, text)
      self
    }
  ),
  class = TRUE
)

#  @title SpeakingInGroupCallAction
#  @description Telegram API type SpeakingInGroupCallAction
#  @export
#  @noRd
#  @noRd
SpeakingInGroupCallAction <- R6::R6Class(
  "SpeakingInGroupCallAction",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd92c2285,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x20b2cc21,
    to_dict = function() {
      list(`_` = "SpeakingInGroupCallAction")
    },
    bytes = function() {
      as.raw(c(0x85, 0x22, 0x2c, 0xd9))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title SponsoredMessage
#  @description Telegram API type SponsoredMessage
#  @export
#  @noRd
#  @noRd
SponsoredMessage <- R6::R6Class(
  "SponsoredMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7dbf8673,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xe157d836,
    initialize = function(url, title, message, button_text, recommended = NULL, can_report = NULL, random_id = NULL, entities = NULL, photo = NULL, media = NULL, color = NULL, sponsor_info = NULL, additional_info = NULL, min_display_duration = NULL, max_display_duration = NULL) {
      self$url <- url
      self$title <- title
      self$message <- message
      self$button_text <- button_text
      self$recommended <- recommended
      self$can_report <- can_report
      self$random_id <- if (is.null(random_id)) intToBits(sample(.Machine$integer.max, 1)) else random_id
      self$entities <- entities
      self$photo <- photo
      self$media <- media
      self$color <- color
      self$sponsor_info <- sponsor_info
      self$additional_info <- additional_info
      self$min_display_duration <- min_display_duration
      self$max_display_duration <- max_display_duration
    },
    to_dict = function() {
      list(
        `_` = "SponsoredMessage",
        url = self$url,
        title = self$title,
        message = self$message,
        button_text = self$button_text,
        recommended = self$recommended,
        can_report = self$can_report,
        random_id = self$random_id,
        entities = if (is.null(self$entities)) list() else lapply(self$entities, function(x) if (inherits(x, "R6")) x$to_dict() else x),
        photo = if (inherits(self$photo, "R6")) self$photo$to_dict() else self$photo,
        media = if (inherits(self$media, "R6")) self$media$to_dict() else self$media,
        color = if (inherits(self$color, "R6")) self$color$to_dict() else self$color,
        sponsor_info = self$sponsor_info,
        additional_info = self$additional_info,
        min_display_duration = self$min_display_duration,
        max_display_duration = self$max_display_duration
      )
    },
    bytes = function() {
      flags <- (if (is.null(self$recommended) || !self$recommended) 0 else 32) |
        (if (is.null(self$can_report) || !self$can_report) 0 else 4096) |
        (if (is.null(self$entities) || length(self$entities) == 0) 0 else 2) |
        (if (is.null(self$photo)) 0 else 64) |
        (if (is.null(self$media)) 0 else 16384) |
        (if (is.null(self$color)) 0 else 8192) |
        (if (is.null(self$sponsor_info)) 0 else 128) |
        (if (is.null(self$additional_info)) 0 else 256) |
        (if (is.null(self$min_display_duration)) 0 else 32768) |
        (if (is.null(self$max_display_duration)) 0 else 32768)
      stopifnot((!is.null(self$min_display_duration) && !is.null(self$max_display_duration)) || (is.null(self$min_display_duration) && is.null(self$max_display_duration)))
      as.raw(c(0x73, 0x86, 0xbf, 0x7d)) +
        pack("I", flags) +
        self$serializebytes(self$random_id) +
        self$serializebytes(self$url) +
        self$serializebytes(self$title) +
        self$serializebytes(self$message) +
        if (is.null(self$entities) || length(self$entities) == 0) {
          raw(0)
        } else {
          as.raw(c(0x15, 0xc4, 0xb5, 0x1c)) + pack("i", length(self$entities)) + do.call(c, lapply(self$entities, function(x) x$bytes())) +
            if (is.null(self$photo)) {
              raw(0)
            } else {
              self$photo$bytes() +
                if (is.null(self$media)) {
                  raw(0)
                } else {
                  self$media$bytes() +
                    if (is.null(self$color)) {
                      raw(0)
                    } else {
                      self$color$bytes() +
                        self$serializebytes(self$button_text) +
                        if (is.null(self$sponsor_info)) {
                          raw(0)
                        } else {
                          self$serializebytes(self$sponsor_info) +
                            if (is.null(self$additional_info)) {
                              raw(0)
                            } else {
                              self$serializebytes(self$additional_info) +
                                if (is.null(self$min_display_duration)) {
                                  raw(0)
                                } else {
                                  pack("i", self$min_display_duration) +
                                    if (is.null(self$max_display_duration)) raw(0) else pack("i", self$max_display_duration)
                                }
                            }
                        }
                    }
                }
            }
        }
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      recommended <- bitwAnd(flags, 32) != 0
      can_report <- bitwAnd(flags, 4096) != 0
      random_id <- reader$tgreadbytes()
      url <- reader$tgread_string()
      title <- reader$tgread_string()
      message <- reader$tgread_string()
      entities <- if (bitwAnd(flags, 2) != 0) {
        reader$read_int()
        lapply(1:reader$read_int(), function(i) reader$tgread_object())
      } else {
        NULL
      }
      photo <- if (bitwAnd(flags, 64) != 0) reader$tgread_object() else NULL
      media <- if (bitwAnd(flags, 16384) != 0) reader$tgread_object() else NULL
      color <- if (bitwAnd(flags, 8192) != 0) reader$tgread_object() else NULL
      button_text <- reader$tgread_string()
      sponsor_info <- if (bitwAnd(flags, 128) != 0) reader$tgread_string() else NULL
      additional_info <- if (bitwAnd(flags, 256) != 0) reader$tgread_string() else NULL
      min_display_duration <- if (bitwAnd(flags, 32768) != 0) reader$read_int() else NULL
      max_display_duration <- if (bitwAnd(flags, 32768) != 0) reader$read_int() else NULL
      self$initialize(url, title, message, button_text, recommended, can_report, random_id, entities, photo, media, color, sponsor_info, additional_info, min_display_duration, max_display_duration)
      self
    }
  ),
  class = TRUE
)

#  @title SponsoredMessageReportOption
#  @description Telegram API type SponsoredMessageReportOption
#  @export
#  @noRd
#  @noRd
SponsoredMessageReportOption <- R6::R6Class(
  "SponsoredMessageReportOption",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x430d3150,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xdd32a718,
    initialize = function(text, option) {
      self$text <- text
      self$option <- option
    },
    to_dict = function() {
      list(
        `_` = "SponsoredMessageReportOption",
        text = self$text,
        option = self$option
      )
    },
    bytes = function() {
      as.raw(c(0x50, 0x31, 0x0d, 0x43)) +
        self$serializebytes(self$text) +
        self$serializebytes(self$option)
    }
  ),
  private = list(
    from_reader = function(reader) {
      text <- reader$tgread_string()
      option <- reader$tgreadbytes()
      self$initialize(text, option)
      self
    }
  ),
  class = TRUE
)

#  @title SponsoredPeer
#  @description Telegram API type SponsoredPeer
#  @export
#  @noRd
#  @noRd
SponsoredPeer <- R6::R6Class(
  "SponsoredPeer",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc69708d3,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x3f75800e,
    initialize = function(peer, random_id = NULL, sponsor_info = NULL, additional_info = NULL) {
      self$peer <- peer
      self$random_id <- if (is.null(random_id)) intToBits(sample(.Machine$integer.max, 1)) else random_id
      self$sponsor_info <- sponsor_info
      self$additional_info <- additional_info
    },
    to_dict = function() {
      list(
        `_` = "SponsoredPeer",
        peer = if (inherits(self$peer, "R6")) self$peer$to_dict() else self$peer,
        random_id = self$random_id,
        sponsor_info = self$sponsor_info,
        additional_info = self$additional_info
      )
    },
    bytes = function() {
      flags <- (if (is.null(self$sponsor_info)) 0 else 1) | (if (is.null(self$additional_info)) 0 else 2)
      as.raw(c(0xd3, 0x08, 0x97, 0xc6)) +
        pack("I", flags) +
        self$serializebytes(self$random_id) +
        self$peer$bytes() +
        if (is.null(self$sponsor_info)) {
          raw(0)
        } else {
          self$serializebytes(self$sponsor_info) +
            if (is.null(self$additional_info)) raw(0) else self$serializebytes(self$additional_info)
        }
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      random_id <- reader$tgreadbytes()
      peer <- reader$tgread_object()
      sponsor_info <- if (bitwAnd(flags, 1) != 0) reader$tgread_string() else NULL
      additional_info <- if (bitwAnd(flags, 2) != 0) reader$tgread_string() else NULL
      self$initialize(peer, random_id, sponsor_info, additional_info)
      self
    }
  ),
  class = TRUE
)

#  @title StarGift
#  @description Telegram API type StarGift
#  @export
#  @noRd
#  @noRd
StarGift <- R6::R6Class(
  "StarGift",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x80ac53c3,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc31c590b,
    initialize = function(id, sticker, stars, convert_stars, limited = NULL, sold_out = NULL, birthday = NULL, require_premium = NULL, limited_per_user = NULL, availability_remains = NULL, availability_total = NULL, availability_resale = NULL, first_sale_date = NULL, last_sale_date = NULL, upgrade_stars = NULL, resell_min_stars = NULL, title = NULL, released_by = NULL, per_user_total = NULL, per_user_remains = NULL, locked_until_date = NULL) {
      self$id <- id
      self$sticker <- sticker
      self$stars <- stars
      self$convert_stars <- convert_stars
      self$limited <- limited
      self$sold_out <- sold_out
      self$birthday <- birthday
      self$require_premium <- require_premium
      self$limited_per_user <- limited_per_user
      self$availability_remains <- availability_remains
      self$availability_total <- availability_total
      self$availability_resale <- availability_resale
      self$first_sale_date <- first_sale_date
      self$last_sale_date <- last_sale_date
      self$upgrade_stars <- upgrade_stars
      self$resell_min_stars <- resell_min_stars
      self$title <- title
      self$released_by <- released_by
      self$per_user_total <- per_user_total
      self$per_user_remains <- per_user_remains
      self$locked_until_date <- locked_until_date
    },
    to_dict = function() {
      list(
        `_` = "StarGift",
        id = self$id,
        sticker = if (inherits(self$sticker, "R6")) self$sticker$to_dict() else self$sticker,
        stars = self$stars,
        convert_stars = self$convert_stars,
        limited = self$limited,
        sold_out = self$sold_out,
        birthday = self$birthday,
        require_premium = self$require_premium,
        limited_per_user = self$limited_per_user,
        availability_remains = self$availability_remains,
        availability_total = self$availability_total,
        availability_resale = self$availability_resale,
        first_sale_date = self$first_sale_date,
        last_sale_date = self$last_sale_date,
        upgrade_stars = self$upgrade_stars,
        resell_min_stars = self$resell_min_stars,
        title = self$title,
        released_by = if (inherits(self$released_by, "R6")) self$released_by$to_dict() else self$released_by,
        per_user_total = self$per_user_total,
        per_user_remains = self$per_user_remains,
        locked_until_date = self$locked_until_date
      )
    },
    bytes = function() {
      flags <- (if (is.null(self$limited) || !self$limited) 0 else 1) |
        (if (is.null(self$sold_out) || !self$sold_out) 0 else 2) |
        (if (is.null(self$birthday) || !self$birthday) 0 else 4) |
        (if (is.null(self$require_premium) || !self$require_premium) 0 else 128) |
        (if (is.null(self$limited_per_user) || !self$limited_per_user) 0 else 256) |
        (if (is.null(self$availability_remains)) 0 else 1) |
        (if (is.null(self$availability_total)) 0 else 1) |
        (if (is.null(self$availability_resale)) 0 else 16) |
        (if (is.null(self$first_sale_date)) 0 else 2) |
        (if (is.null(self$last_sale_date)) 0 else 2) |
        (if (is.null(self$upgrade_stars)) 0 else 8) |
        (if (is.null(self$resell_min_stars)) 0 else 16) |
        (if (is.null(self$title)) 0 else 32) |
        (if (is.null(self$released_by)) 0 else 64) |
        (if (is.null(self$per_user_total)) 0 else 256) |
        (if (is.null(self$per_user_remains)) 0 else 256) |
        (if (is.null(self$locked_until_date)) 0 else 512)
      stopifnot((!is.null(self$limited) && !is.null(self$availability_remains) && !is.null(self$availability_total)) || (is.null(self$limited) && is.null(self$availability_remains) && is.null(self$availability_total)))
      stopifnot((!is.null(self$sold_out) && !is.null(self$first_sale_date) && !is.null(self$last_sale_date)) || (is.null(self$sold_out) && is.null(self$first_sale_date) && is.null(self$last_sale_date)))
      stopifnot((!is.null(self$limited_per_user) && !is.null(self$per_user_total) && !is.null(self$per_user_remains)) || (is.null(self$limited_per_user) && is.null(self$per_user_total) && is.null(self$per_user_remains)))
      stopifnot((!is.null(self$availability_resale) && !is.null(self$resell_min_stars)) || (is.null(self$availability_resale) && is.null(self$resell_min_stars)))
      as.raw(c(0xc3, 0x53, 0xac, 0x80)) +
        pack("I", flags) +
        pack("q", self$id) +
        self$sticker$bytes() +
        pack("q", self$stars) +
        if (is.null(self$availability_remains)) {
          raw(0)
        } else {
          pack("i", self$availability_remains) +
            if (is.null(self$availability_total)) {
              raw(0)
            } else {
              pack("i", self$availability_total) +
                if (is.null(self$availability_resale)) {
                  raw(0)
                } else {
                  pack("q", self$availability_resale) +
                    pack("q", self$convert_stars) +
                    if (is.null(self$first_sale_date)) {
                      raw(0)
                    } else {
                      self$serialize_datetime(self$first_sale_date) +
                        if (is.null(self$last_sale_date)) {
                          raw(0)
                        } else {
                          self$serialize_datetime(self$last_sale_date) +
                            if (is.null(self$upgrade_stars)) {
                              raw(0)
                            } else {
                              pack("q", self$upgrade_stars) +
                                if (is.null(self$resell_min_stars)) {
                                  raw(0)
                                } else {
                                  pack("q", self$resell_min_stars) +
                                    if (is.null(self$title)) {
                                      raw(0)
                                    } else {
                                      self$serializebytes(self$title) +
                                        if (is.null(self$released_by)) {
                                          raw(0)
                                        } else {
                                          self$released_by$bytes() +
                                            if (is.null(self$per_user_total)) {
                                              raw(0)
                                            } else {
                                              pack("i", self$per_user_total) +
                                                if (is.null(self$per_user_remains)) {
                                                  raw(0)
                                                } else {
                                                  pack("i", self$per_user_remains) +
                                                    if (is.null(self$locked_until_date)) raw(0) else self$serialize_datetime(self$locked_until_date)
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      limited <- bitwAnd(flags, 1) != 0
      sold_out <- bitwAnd(flags, 2) != 0
      birthday <- bitwAnd(flags, 4) != 0
      require_premium <- bitwAnd(flags, 128) != 0
      limited_per_user <- bitwAnd(flags, 256) != 0
      id <- reader$read_long()
      sticker <- reader$tgread_object()
      stars <- reader$read_long()
      availability_remains <- if (bitwAnd(flags, 1) != 0) reader$read_int() else NULL
      availability_total <- if (bitwAnd(flags, 1) != 0) reader$read_int() else NULL
      availability_resale <- if (bitwAnd(flags, 16) != 0) reader$read_long() else NULL
      convert_stars <- reader$read_long()
      first_sale_date <- if (bitwAnd(flags, 2) != 0) reader$tgread_date() else NULL
      last_sale_date <- if (bitwAnd(flags, 2) != 0) reader$tgread_date() else NULL
      upgrade_stars <- if (bitwAnd(flags, 8) != 0) reader$read_long() else NULL
      resell_min_stars <- if (bitwAnd(flags, 16) != 0) reader$read_long() else NULL
      title <- if (bitwAnd(flags, 32) != 0) reader$tgread_string() else NULL
      released_by <- if (bitwAnd(flags, 64) != 0) reader$tgread_object() else NULL
      per_user_total <- if (bitwAnd(flags, 256) != 0) reader$read_int() else NULL
      per_user_remains <- if (bitwAnd(flags, 256) != 0) reader$read_int() else NULL
      locked_until_date <- if (bitwAnd(flags, 512) != 0) reader$tgread_date() else NULL
      self$initialize(id, sticker, stars, convert_stars, limited, sold_out, birthday, require_premium, limited_per_user, availability_remains, availability_total, availability_resale, first_sale_date, last_sale_date, upgrade_stars, resell_min_stars, title, released_by, per_user_total, per_user_remains, locked_until_date)
      self
    }
  ),
  class = TRUE
)

#  @title StarGiftAttributeBackdrop
#  @description Telegram API type StarGiftAttributeBackdrop
#  @export
#  @noRd
#  @noRd
StarGiftAttributeBackdrop <- R6::R6Class(
  "StarGiftAttributeBackdrop",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd93d859c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x87b581c8,
    initialize = function(name, backdrop_id, center_color, edge_color, pattern_color, text_color, rarity_permille) {
      self$name <- name
      self$backdrop_id <- backdrop_id
      self$center_color <- center_color
      self$edge_color <- edge_color
      self$pattern_color <- pattern_color
      self$text_color <- text_color
      self$rarity_permille <- rarity_permille
    },
    to_dict = function() {
      list(
        `_` = "StarGiftAttributeBackdrop",
        name = self$name,
        backdrop_id = self$backdrop_id,
        center_color = self$center_color,
        edge_color = self$edge_color,
        pattern_color = self$pattern_color,
        text_color = self$text_color,
        rarity_permille = self$rarity_permille
      )
    },
    bytes = function() {
      as.raw(c(0x9c, 0x85, 0x3d, 0xd9)) +
        self$serializebytes(self$name) +
        pack("i", self$backdrop_id) +
        pack("i", self$center_color) +
        pack("i", self$edge_color) +
        pack("i", self$pattern_color) +
        pack("i", self$text_color) +
        pack("i", self$rarity_permille)
    }
  ),
  private = list(
    from_reader = function(reader) {
      name <- reader$tgread_string()
      backdrop_id <- reader$read_int()
      center_color <- reader$read_int()
      edge_color <- reader$read_int()
      pattern_color <- reader$read_int()
      text_color <- reader$read_int()
      rarity_permille <- reader$read_int()
      self$initialize(name, backdrop_id, center_color, edge_color, pattern_color, text_color, rarity_permille)
      self
    }
  ),
  class = TRUE
)

#  @title StarGiftAttributeCounter
#  @description Telegram API type StarGiftAttributeCounter
#  @export
#  @noRd
#  @noRd
StarGiftAttributeCounter <- R6::R6Class(
  "StarGiftAttributeCounter",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x2eb1b658,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8c28b293,
    initialize = function(attribute, count) {
      self$attribute <- attribute
      self$count <- count
    },
    to_dict = function() {
      list(
        `_` = "StarGiftAttributeCounter",
        attribute = if (inherits(self$attribute, "R6")) self$attribute$to_dict() else self$attribute,
        count = self$count
      )
    },
    bytes = function() {
      as.raw(c(0x58, 0xb6, 0xb1, 0x2e)) +
        self$attribute$bytes() +
        pack("i", self$count)
    }
  ),
  private = list(
    from_reader = function(reader) {
      attribute <- reader$tgread_object()
      count <- reader$read_int()
      self$initialize(attribute, count)
      self
    }
  ),
  class = TRUE
)

#  @title StarGiftAttributeIdBackdrop
#  @description Telegram API type StarGiftAttributeIdBackdrop
#  @export
#  @noRd
#  @noRd
StarGiftAttributeIdBackdrop <- R6::R6Class(
  "StarGiftAttributeIdBackdrop",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1f01c757,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb3212ab7,
    initialize = function(backdrop_id) {
      self$backdrop_id <- backdrop_id
    },
    to_dict = function() {
      list(
        `_` = "StarGiftAttributeIdBackdrop",
        backdrop_id = self$backdrop_id
      )
    },
    bytes = function() {
      as.raw(c(0x57, 0xc7, 0x01, 0x1f)) +
        pack("i", self$backdrop_id)
    }
  ),
  private = list(
    from_reader = function(reader) {
      backdrop_id <- reader$read_int()
      self$initialize(backdrop_id)
      self
    }
  ),
  class = TRUE
)

#  @title StarGiftAttributeIdModel
#  @description Telegram API type StarGiftAttributeIdModel
#  @export
#  @noRd
#  @noRd
StarGiftAttributeIdModel <- R6::R6Class(
  "StarGiftAttributeIdModel",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x48aaae3c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb3212ab7,
    initialize = function(document_id) {
      self$document_id <- document_id
    },
    to_dict = function() {
      list(
        `_` = "StarGiftAttributeIdModel",
        document_id = self$document_id
      )
    },
    bytes = function() {
      as.raw(c(0x3c, 0xae, 0xaa, 0x48)) +
        pack("q", self$document_id)
    }
  ),
  private = list(
    from_reader = function(reader) {
      document_id <- reader$read_long()
      self$initialize(document_id)
      self
    }
  ),
  class = TRUE
)

#  @title StarGiftAttributeIdPattern
#  @description Telegram API type StarGiftAttributeIdPattern
#  @export
#  @noRd
#  @noRd
StarGiftAttributeIdPattern <- R6::R6Class(
  "StarGiftAttributeIdPattern",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4a162433,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xb3212ab7,
    initialize = function(document_id) {
      self$document_id <- document_id
    },
    to_dict = function() {
      list(
        `_` = "StarGiftAttributeIdPattern",
        document_id = self$document_id
      )
    },
    bytes = function() {
      as.raw(c(0x33, 0x24, 0x16, 0x4a)) +
        pack("q", self$document_id)
    }
  ),
  private = list(
    from_reader = function(reader) {
      document_id <- reader$read_long()
      self$initialize(document_id)
      self
    }
  ),
  class = TRUE
)

#  @title StarGiftAttributeModel
#  @description Telegram API type StarGiftAttributeModel
#  @export
#  @noRd
#  @noRd
StarGiftAttributeModel <- R6::R6Class(
  "StarGiftAttributeModel",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x39d99013,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x87b581c8,
    initialize = function(name, document, rarity_permille) {
      self$name <- name
      self$document <- document
      self$rarity_permille <- rarity_permille
    },
    to_dict = function() {
      list(
        `_` = "StarGiftAttributeModel",
        name = self$name,
        document = if (inherits(self$document, "R6")) self$document$to_dict() else self$document,
        rarity_permille = self$rarity_permille
      )
    },
    bytes = function() {
      as.raw(c(0x13, 0x90, 0xd9, 0x39)) +
        self$serializebytes(self$name) +
        self$document$bytes() +
        pack("i", self$rarity_permille)
    }
  ),
  private = list(
    from_reader = function(reader) {
      name <- reader$tgread_string()
      document <- reader$tgread_object()
      rarity_permille <- reader$read_int()
      self$initialize(name, document, rarity_permille)
      self
    }
  ),
  class = TRUE
)

#  @title StarGiftAttributeOriginalDetails
#  @description Telegram API type StarGiftAttributeOriginalDetails
#  @export
#  @noRd
#  @noRd
StarGiftAttributeOriginalDetails <- R6::R6Class(
  "StarGiftAttributeOriginalDetails",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe0bff26c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x87b581c8,
    initialize = function(recipient_id, date, sender_id = NULL, message = NULL) {
      self$recipient_id <- recipient_id
      self$date <- date
      self$sender_id <- sender_id
      self$message <- message
    },
    to_dict = function() {
      list(
        `_` = "StarGiftAttributeOriginalDetails",
        recipient_id = if (inherits(self$recipient_id, "R6")) self$recipient_id$to_dict() else self$recipient_id,
        date = self$date,
        sender_id = if (inherits(self$sender_id, "R6")) self$sender_id$to_dict() else self$sender_id,
        message = if (inherits(self$message, "R6")) self$message$to_dict() else self$message
      )
    },
    bytes = function() {
      flags <- (if (is.null(self$sender_id)) 0 else 1) | (if (is.null(self$message)) 0 else 2)
      as.raw(c(0x6c, 0xf2, 0xbf, 0xe0)) +
        pack("I", flags) +
        if (is.null(self$sender_id)) {
          raw(0)
        } else {
          self$sender_id$bytes() +
            self$recipient_id$bytes() +
            self$serialize_datetime(self$date) +
            if (is.null(self$message)) raw(0) else self$message$bytes()
        }
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      sender_id <- if (bitwAnd(flags, 1) != 0) reader$tgread_object() else NULL
      recipient_id <- reader$tgread_object()
      date <- reader$tgread_date()
      message <- if (bitwAnd(flags, 2) != 0) reader$tgread_object() else NULL
      self$initialize(recipient_id, date, sender_id, message)
      self
    }
  ),
  class = TRUE
)

#  @title StarGiftAttributePattern
#  @description Telegram API type StarGiftAttributePattern
#  @export
#  @noRd
#  @noRd
StarGiftAttributePattern <- R6::R6Class(
  "StarGiftAttributePattern",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x13acff19,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x87b581c8,
    initialize = function(name, document, rarity_permille) {
      self$name <- name
      self$document <- document
      self$rarity_permille <- rarity_permille
    },
    to_dict = function() {
      list(
        `_` = "StarGiftAttributePattern",
        name = self$name,
        document = if (inherits(self$document, "R6")) self$document$to_dict() else self$document,
        rarity_permille = self$rarity_permille
      )
    },
    bytes = function() {
      as.raw(c(0x19, 0xff, 0xac, 0x13)) +
        self$serializebytes(self$name) +
        self$document$bytes() +
        pack("i", self$rarity_permille)
    }
  ),
  private = list(
    from_reader = function(reader) {
      name <- reader$tgread_string()
      document <- reader$tgread_object()
      rarity_permille <- reader$read_int()
      self$initialize(name, document, rarity_permille)
      self
    }
  ),
  class = TRUE
)

#  @title StarGiftCollection
#  @description Telegram API type StarGiftCollection
#  @export
#  @noRd
#  @noRd
StarGiftCollection <- R6::R6Class(
  "StarGiftCollection",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9d6b13b0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x43e0cb4a,
    initialize = function(collection_id, title, gifts_count, hash, icon = NULL) {
      self$collection_id <- collection_id
      self$title <- title
      self$gifts_count <- gifts_count
      self$hash <- hash
      self$icon <- icon
    },
    to_dict = function() {
      list(
        `_` = "StarGiftCollection",
        collection_id = self$collection_id,
        title = self$title,
        gifts_count = self$gifts_count,
        hash = self$hash,
        icon = if (inherits(self$icon, "R6")) self$icon$to_dict() else self$icon
      )
    },
    bytes = function() {
      flags <- if (is.null(self$icon)) 0 else 1
      as.raw(c(0xb0, 0x13, 0x6b, 0x9d)) +
        pack("I", flags) +
        pack("i", self$collection_id) +
        self$serializebytes(self$title) +
        if (is.null(self$icon)) {
          raw(0)
        } else {
          self$icon$bytes() +
            pack("i", self$gifts_count) +
            pack("q", self$hash)
        }
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      collection_id <- reader$read_int()
      title <- reader$tgread_string()
      icon <- if (bitwAnd(flags, 1) != 0) reader$tgread_object() else NULL
      gifts_count <- reader$read_int()
      hash <- reader$read_long()
      self$initialize(collection_id, title, gifts_count, hash, icon)
      self
    }
  ),
  class = TRUE
)

#  @title StarGiftUnique
#  @description Telegram API type StarGiftUnique
#  @export
#  @noRd
#  @noRd
StarGiftUnique <- R6::R6Class(
  "StarGiftUnique",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1befe865,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc31c590b,
    initialize = function(id, gift_id, title, slug, num, attributes, availability_issued, availability_total, require_premium = NULL, resale_ton_only = NULL, theme_available = NULL, owner_id = NULL, owner_name = NULL, owner_address = NULL, gift_address = NULL, resell_amount = NULL, released_by = NULL, value_amount = NULL, value_currency = NULL, themepeer = NULL) {
      self$id <- id
      self$gift_id <- gift_id
      self$title <- title
      self$slug <- slug
      self$num <- num
      self$attributes <- attributes
      self$availability_issued <- availability_issued
      self$availability_total <- availability_total
      self$require_premium <- require_premium
      self$resale_ton_only <- resale_ton_only
      self$theme_available <- theme_available
      self$owner_id <- owner_id
      self$owner_name <- owner_name
      self$owner_address <- owner_address
      self$gift_address <- gift_address
      self$resell_amount <- resell_amount
      self$released_by <- released_by
      self$value_amount <- value_amount
      self$value_currency <- value_currency
      self$themepeer <- themepeer
    },
    to_dict = function() {
      list(
        `_` = "StarGiftUnique",
        id = self$id,
        gift_id = self$gift_id,
        title = self$title,
        slug = self$slug,
        num = self$num,
        attributes = lapply(self$attributes, function(x) if (inherits(x, "R6")) x$to_dict() else x),
        availability_issued = self$availability_issued,
        availability_total = self$availability_total,
        require_premium = self$require_premium,
        resale_ton_only = self$resale_ton_only,
        theme_available = self$theme_available,
        owner_id = if (inherits(self$owner_id, "R6")) self$owner_id$to_dict() else self$owner_id,
        owner_name = self$owner_name,
        owner_address = self$owner_address,
        gift_address = self$gift_address,
        resell_amount = if (is.null(self$resell_amount)) list() else lapply(self$resell_amount, function(x) if (inherits(x, "R6")) x$to_dict() else x),
        released_by = if (inherits(self$released_by, "R6")) self$released_by$to_dict() else self$released_by,
        value_amount = self$value_amount,
        value_currency = self$value_currency,
        themepeer = if (inherits(self$themepeer, "R6")) self$themepeer$to_dict() else self$themepeer
      )
    },
    bytes = function() {
      flags <- (if (is.null(self$require_premium) || !self$require_premium) 0 else 64) |
        (if (is.null(self$resale_ton_only) || !self$resale_ton_only) 0 else 128) |
        (if (is.null(self$theme_available) || !self$theme_available) 0 else 512) |
        (if (is.null(self$owner_id)) 0 else 1) |
        (if (is.null(self$owner_name)) 0 else 2) |
        (if (is.null(self$owner_address)) 0 else 4) |
        (if (is.null(self$gift_address)) 0 else 8) |
        (if (is.null(self$resell_amount) || length(self$resell_amount) == 0) 0 else 16) |
        (if (is.null(self$released_by)) 0 else 32) |
        (if (is.null(self$value_amount)) 0 else 256) |
        (if (is.null(self$value_currency)) 0 else 256) |
        (if (is.null(self$themepeer)) 0 else 1024)
      stopifnot((!is.null(self$value_amount) && !is.null(self$value_currency)) || (is.null(self$value_amount) && is.null(self$value_currency)))
      as.raw(c(0x65, 0xe8, 0xef, 0x1b)) +
        pack("I", flags) +
        pack("q", self$id) +
        pack("q", self$gift_id) +
        self$serializebytes(self$title) +
        self$serializebytes(self$slug) +
        pack("i", self$num) +
        if (is.null(self$owner_id)) {
          raw(0)
        } else {
          self$owner_id$bytes() +
            if (is.null(self$owner_name)) {
              raw(0)
            } else {
              self$serializebytes(self$owner_name) +
                if (is.null(self$owner_address)) {
                  raw(0)
                } else {
                  self$serializebytes(self$owner_address) +
                    as.raw(c(0x15, 0xc4, 0xb5, 0x1c)) + pack("i", length(self$attributes)) + do.call(c, lapply(self$attributes, function(x) x$bytes())) +
                    pack("i", self$availability_issued) +
                    pack("i", self$availability_total) +
                    if (is.null(self$gift_address)) {
                      raw(0)
                    } else {
                      self$serializebytes(self$gift_address) +
                        if (is.null(self$resell_amount) || length(self$resell_amount) == 0) {
                          raw(0)
                        } else {
                          as.raw(c(0x15, 0xc4, 0xb5, 0x1c)) + pack("i", length(self$resell_amount)) + do.call(c, lapply(self$resell_amount, function(x) x$bytes())) +
                            if (is.null(self$released_by)) {
                              raw(0)
                            } else {
                              self$released_by$bytes() +
                                if (is.null(self$value_amount)) {
                                  raw(0)
                                } else {
                                  pack("q", self$value_amount) +
                                    if (is.null(self$value_currency)) {
                                      raw(0)
                                    } else {
                                      self$serializebytes(self$value_currency) +
                                        if (is.null(self$themepeer)) raw(0) else self$themepeer$bytes()
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      require_premium <- bitwAnd(flags, 64) != 0
      resale_ton_only <- bitwAnd(flags, 128) != 0
      theme_available <- bitwAnd(flags, 512) != 0
      id <- reader$read_long()
      gift_id <- reader$read_long()
      title <- reader$tgread_string()
      slug <- reader$tgread_string()
      num <- reader$read_int()
      owner_id <- if (bitwAnd(flags, 1) != 0) reader$tgread_object() else NULL
      owner_name <- if (bitwAnd(flags, 2) != 0) reader$tgread_string() else NULL
      owner_address <- if (bitwAnd(flags, 4) != 0) reader$tgread_string() else NULL
      reader$read_int()
      attributes <- lapply(1:reader$read_int(), function(i) reader$tgread_object())
      availability_issued <- reader$read_int()
      availability_total <- reader$read_int()
      gift_address <- if (bitwAnd(flags, 8) != 0) reader$tgread_string() else NULL
      resell_amount <- if (bitwAnd(flags, 16) != 0) {
        reader$read_int()
        lapply(1:reader$read_int(), function(i) reader$tgread_object())
      } else {
        NULL
      }
      released_by <- if (bitwAnd(flags, 32) != 0) reader$tgread_object() else NULL
      value_amount <- if (bitwAnd(flags, 256) != 0) reader$read_long() else NULL
      value_currency <- if (bitwAnd(flags, 256) != 0) reader$tgread_string() else NULL
      themepeer <- if (bitwAnd(flags, 1024) != 0) reader$tgread_object() else NULL
      self$initialize(id, gift_id, title, slug, num, attributes, availability_issued, availability_total, require_premium, resale_ton_only, theme_available, owner_id, owner_name, owner_address, gift_address, resell_amount, released_by, value_amount, value_currency, themepeer)
      self
    }
  ),
  class = TRUE
)

#  @title StarRefProgram
#  @description Telegram API type StarRefProgram
#  @export
#  @noRd
#  @noRd
StarRefProgram <- R6::R6Class(
  "StarRefProgram",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xdd0c66f2,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9888e002,
    initialize = function(bot_id, commission_permille, duration_months = NULL, end_date = NULL, daily_revenue_per_user = NULL) {
      self$bot_id <- bot_id
      self$commission_permille <- commission_permille
      self$duration_months <- duration_months
      self$end_date <- end_date
      self$daily_revenue_per_user <- daily_revenue_per_user
    },
    to_dict = function() {
      list(
        `_` = "StarRefProgram",
        bot_id = self$bot_id,
        commission_permille = self$commission_permille,
        duration_months = self$duration_months,
        end_date = self$end_date,
        daily_revenue_per_user = if (inherits(self$daily_revenue_per_user, "R6")) self$daily_revenue_per_user$to_dict() else self$daily_revenue_per_user
      )
    },
    bytes = function() {
      flags <- (if (is.null(self$duration_months)) 0 else 1) | (if (is.null(self$end_date)) 0 else 2) | (if (is.null(self$daily_revenue_per_user)) 0 else 4)
      as.raw(c(0xf2, 0x66, 0x0c, 0xdd)) +
        pack("I", flags) +
        pack("q", self$bot_id) +
        pack("i", self$commission_permille) +
        if (is.null(self$duration_months)) {
          raw(0)
        } else {
          pack("i", self$duration_months) +
            if (is.null(self$end_date)) {
              raw(0)
            } else {
              self$serialize_datetime(self$end_date) +
                if (is.null(self$daily_revenue_per_user)) raw(0) else self$daily_revenue_per_user$bytes()
            }
        }
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      bot_id <- reader$read_long()
      commission_permille <- reader$read_int()
      duration_months <- if (bitwAnd(flags, 1) != 0) reader$read_int() else NULL
      end_date <- if (bitwAnd(flags, 2) != 0) reader$tgread_date() else NULL
      daily_revenue_per_user <- if (bitwAnd(flags, 4) != 0) reader$tgread_object() else NULL
      self$initialize(bot_id, commission_permille, duration_months, end_date, daily_revenue_per_user)
      self
    }
  ),
  class = TRUE
)

#  @title StarsAmount
#  @description Telegram API type StarsAmount
#  @export
#  @noRd
#  @noRd
StarsAmount <- R6::R6Class(
  "StarsAmount",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbbb6b4a3,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x355b3240,
    initialize = function(amount, nanos) {
      self$amount <- amount
      self$nanos <- nanos
    },
    to_dict = function() {
      list(
        `_` = "StarsAmount",
        amount = self$amount,
        nanos = self$nanos
      )
    },
    bytes = function() {
      as.raw(c(0xa3, 0xb4, 0xb6, 0xbb)) +
        pack("q", self$amount) +
        pack("i", self$nanos)
    }
  ),
  private = list(
    from_reader = function(reader) {
      amount <- reader$read_long()
      nanos <- reader$read_int()
      self$initialize(amount, nanos)
      self
    }
  ),
  class = TRUE
)

#  @title StarsGiftOption
#  @description Telegram API type StarsGiftOption
#  @export
#  @noRd
#  @noRd
StarsGiftOption <- R6::R6Class(
  "StarsGiftOption",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5e0589f1,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xa9cd4bb7,
    initialize = function(stars, currency, amount, extended = NULL, store_product = NULL) {
      self$stars <- stars
      self$currency <- currency
      self$amount <- amount
      self$extended <- extended
      self$store_product <- store_product
    },
    to_dict = function() {
      list(
        `_` = "StarsGiftOption",
        stars = self$stars,
        currency = self$currency,
        amount = self$amount,
        extended = self$extended,
        store_product = self$store_product
      )
    },
    bytes = function() {
      flags <- (if (is.null(self$extended) || !self$extended) 0 else 2) | (if (is.null(self$store_product)) 0 else 1)
      as.raw(c(0xf1, 0x89, 0x05, 0x5e)) +
        pack("I", flags) +
        pack("q", self$stars) +
        if (is.null(self$store_product)) {
          raw(0)
        } else {
          self$serializebytes(self$store_product) +
            self$serializebytes(self$currency) +
            pack("q", self$amount)
        }
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      extended <- bitwAnd(flags, 2) != 0
      stars <- reader$read_long()
      store_product <- if (bitwAnd(flags, 1) != 0) reader$tgread_string() else NULL
      currency <- reader$tgread_string()
      amount <- reader$read_long()
      self$initialize(stars, currency, amount, extended, store_product)
      self
    }
  ),
  class = TRUE
)

#  @title StarsGiveawayOption
#  @description Telegram API type StarsGiveawayOption
#  @export
#  @noRd
#  @noRd
StarsGiveawayOption <- R6::R6Class("StarsGiveawayOption",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x94ce852a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x3a28a20b,
    initialize = function(stars, yearly_boosts, currency, amount, winners, extended = NULL, default = NULL, store_product = NULL) {
      self$stars <- stars
      self$yearly_boosts <- yearly_boosts
      self$currency <- currency
      self$amount <- amount
      self$winners <- winners
      self$extended <- extended
      self$default <- default
      self$store_product <- store_product
    },
    to_dict = function() {
      list(
        `_` = "StarsGiveawayOption",
        stars = self$stars,
        yearly_boosts = self$yearly_boosts,
        currency = self$currency,
        amount = self$amount,
        winners = lapply(self$winners, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        extended = self$extended,
        default = self$default,
        store_product = self$store_product
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x2a, 0x85, 0xce, 0x94)),
        pack("I", (if (is.null(self$extended) || !self$extended) 0 else 1) | (if (is.null(self$default) || !self$default) 0 else 2) | (if (is.null(self$store_product) || self$store_product == "") 0 else 4)),
        pack("q", self$stars),
        pack("i", self$yearly_boosts),
        if (is.null(self$store_product) || self$store_product == "") raw(0) else self$serializebytes(self$store_product),
        self$serializebytes(self$currency),
        pack("q", self$amount),
        as.raw(c(0x1c, 0xb5, 0xc4, 0x15)), pack("i", length(self$winners)), do.call(c, lapply(self$winners, function(x) x$bytes()))
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      extended <- bitwAnd(flags, 1) != 0
      default <- bitwAnd(flags, 2) != 0
      stars <- reader$read_long()
      yearly_boosts <- reader$read_int()
      store_product <- if (bitwAnd(flags, 4) != 0) reader$tgread_string() else NULL
      currency <- reader$tgread_string()
      amount <- reader$read_long()
      reader$read_int()
      winners <- lapply(seq_len(reader$read_int()), function(i) reader$tgread_object())
      self$initialize(stars, yearly_boosts, currency, amount, winners, extended, default, store_product)
    }
  ),
  class = TRUE
)

#  @title StarsGiveawayWinnersOption
#  @description Telegram API type StarsGiveawayWinnersOption
#  @export
#  @noRd
#  @noRd
StarsGiveawayWinnersOption <- R6::R6Class("StarsGiveawayWinnersOption",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x54236209,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xfbfaa2e4,
    initialize = function(users, per_user_stars, default = NULL) {
      self$users <- users
      self$per_user_stars <- per_user_stars
      self$default <- default
    },
    to_dict = function() {
      list(
        `_` = "StarsGiveawayWinnersOption",
        users = self$users,
        per_user_stars = self$per_user_stars,
        default = self$default
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x09, 0x62, 0x23, 0x54)),
        pack("I", if (is.null(self$default) || !self$default) 0 else 1),
        pack("i", self$users),
        pack("q", self$per_user_stars)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      default <- bitwAnd(flags, 1) != 0
      users <- reader$read_int()
      per_user_stars <- reader$read_long()
      self$initialize(users, per_user_stars, default)
    }
  ),
  class = TRUE
)

#  @title StarsRating
#  @description Telegram API type StarsRating
#  @export
#  @noRd
#  @noRd
StarsRating <- R6::R6Class("StarsRating",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1b0e4f07,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x63736420,
    initialize = function(level, current_level_stars, stars, next_level_stars = NULL) {
      self$level <- level
      self$current_level_stars <- current_level_stars
      self$stars <- stars
      self$next_level_stars <- next_level_stars
    },
    to_dict = function() {
      list(
        `_` = "StarsRating",
        level = self$level,
        current_level_stars = self$current_level_stars,
        stars = self$stars,
        next_level_stars = self$next_level_stars
      )
    },
    bytes = function() {
      do.call(c, list(
        as.raw(c(0x07, 0x4f, 0x0e, 0x1b)),
        pack("I", if (is.null(self$next_level_stars) || self$next_level_stars == 0) 0 else 1),
        pack("i", self$level),
        pack("q", self$current_level_stars),
        pack("q", self$stars),
        if (is.null(self$next_level_stars) || self$next_level_stars == 0) raw(0) else pack("q", self$next_level_stars)
      ))
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      level <- reader$read_int()
      current_level_stars <- reader$read_long()
      stars <- reader$read_long()
      next_level_stars <- if (bitwAnd(flags, 1) != 0) reader$read_long() else NULL
      self$initialize(level, current_level_stars, stars, next_level_stars)
    }
  ),
  class = TRUE
)

#  @title StarsRevenueStatus
#  @description Telegram API type StarsRevenueStatus
#  @export
#  @noRd
#  @noRd
StarsRevenueStatus <- R6::R6Class("StarsRevenueStatus",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xfebe5491,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x3d7d9ff1,
    initialize = function(current_balance, available_balance, overall_revenue, withdrawal_enabled = NULL, next_withdrawal_at = NULL) {
      self$current_balance <- current_balance
      self$available_balance <- available_balance
      self$overall_revenue <- overall_revenue
      self$withdrawal_enabled <- withdrawal_enabled
      self$next_withdrawal_at <- next_withdrawal_at
    },
    to_dict = function() {
      list(
        `_` = "StarsRevenueStatus",
        current_balance = if (inherits(self$current_balance, "TLObject")) self$current_balance$to_dict() else self$current_balance,
        available_balance = if (inherits(self$available_balance, "TLObject")) self$available_balance$to_dict() else self$available_balance,
        overall_revenue = if (inherits(self$overall_revenue, "TLObject")) self$overall_revenue$to_dict() else self$overall_revenue,
        withdrawal_enabled = self$withdrawal_enabled,
        next_withdrawal_at = self$next_withdrawal_at
      )
    },
    bytes = function() {
      do.call(c, list(
        as.raw(c(0x91, 0x54, 0xbe, 0xfe)),
        pack("I", (if (is.null(self$withdrawal_enabled) || !self$withdrawal_enabled) 0 else 1) | (if (is.null(self$next_withdrawal_at) || self$next_withdrawal_at == 0) 0 else 2)),
        self$current_balance$bytes(),
        self$available_balance$bytes(),
        self$overall_revenue$bytes(),
        if (is.null(self$next_withdrawal_at) || self$next_withdrawal_at == 0) raw(0) else pack("i", self$next_withdrawal_at)
      ))
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      withdrawal_enabled <- bitwAnd(flags, 1) != 0
      current_balance <- reader$tgread_object()
      available_balance <- reader$tgread_object()
      overall_revenue <- reader$tgread_object()
      next_withdrawal_at <- if (bitwAnd(flags, 2) != 0) reader$read_int() else NULL
      self$initialize(current_balance, available_balance, overall_revenue, withdrawal_enabled, next_withdrawal_at)
    }
  ),
  class = TRUE
)

#  @title StarsSubscription
#  @description Telegram API type StarsSubscription
#  @export
#  @noRd
#  @noRd
StarsSubscription <- R6::R6Class("StarsSubscription",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x2e6eab1a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xeced29c3,
    initialize = function(id, peer, until_date, pricing, canceled = NULL, can_refulfill = NULL, missing_balance = NULL, bot_canceled = NULL, chat_invite_hash = NULL, title = NULL, photo = NULL, invoice_slug = NULL) {
      self$id <- id
      self$peer <- peer
      self$until_date <- until_date
      self$pricing <- pricing
      self$canceled <- canceled
      self$can_refulfill <- can_refulfill
      self$missing_balance <- missing_balance
      self$bot_canceled <- bot_canceled
      self$chat_invite_hash <- chat_invite_hash
      self$title <- title
      self$photo <- photo
      self$invoice_slug <- invoice_slug
    },
    to_dict = function() {
      list(
        `_` = "StarsSubscription",
        id = self$id,
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        until_date = self$until_date,
        pricing = if (inherits(self$pricing, "TLObject")) self$pricing$to_dict() else self$pricing,
        canceled = self$canceled,
        can_refulfill = self$can_refulfill,
        missing_balance = self$missing_balance,
        bot_canceled = self$bot_canceled,
        chat_invite_hash = self$chat_invite_hash,
        title = self$title,
        photo = if (inherits(self$photo, "TLObject")) self$photo$to_dict() else self$photo,
        invoice_slug = self$invoice_slug
      )
    },
    bytes = function() {
      do.call(c, list(
        as.raw(c(0x1a, 0xab, 0x6e, 0x2e)),
        pack("I", (if (is.null(self$canceled) || !self$canceled) 0 else 1) | (if (is.null(self$can_refulfill) || !self$can_refulfill) 0 else 2) | (if (is.null(self$missing_balance) || !self$missing_balance) 0 else 4) | (if (is.null(self$bot_canceled) || !self$bot_canceled) 0 else 128) | (if (is.null(self$chat_invite_hash) || self$chat_invite_hash == "") 0 else 8) | (if (is.null(self$title) || self$title == "") 0 else 16) | (if (is.null(self$photo)) 0 else 32) | (if (is.null(self$invoice_slug) || self$invoice_slug == "") 0 else 64)),
        self$serializebytes(self$id),
        self$peer$bytes(),
        self$serialize_datetime(self$until_date),
        self$pricing$bytes(),
        if (is.null(self$chat_invite_hash) || self$chat_invite_hash == "") raw(0) else self$serializebytes(self$chat_invite_hash),
        if (is.null(self$title) || self$title == "") raw(0) else self$serializebytes(self$title),
        if (is.null(self$photo)) raw(0) else self$photo$bytes(),
        if (is.null(self$invoice_slug) || self$invoice_slug == "") raw(0) else self$serializebytes(self$invoice_slug)
      ))
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      canceled <- bitwAnd(flags, 1) != 0
      can_refulfill <- bitwAnd(flags, 2) != 0
      missing_balance <- bitwAnd(flags, 4) != 0
      bot_canceled <- bitwAnd(flags, 128) != 0
      id <- reader$tgread_string()
      peer <- reader$tgread_object()
      until_date <- reader$tgread_date()
      pricing <- reader$tgread_object()
      chat_invite_hash <- if (bitwAnd(flags, 8) != 0) reader$tgread_string() else NULL
      title <- if (bitwAnd(flags, 16) != 0) reader$tgread_string() else NULL
      photo <- NULL
      if (bitwAnd(flags, 32) != 0) {
        # Parse UserProfilePhoto safely (some constructor mappings may be missing)
        ctor <- reader$read_int(signed = FALSE)
        parse_with_class <- function(cls, reader) {
          fr <- cls$private_methods$from_reader
          fn_env <- new.env(parent = environment(fr))
          self_proxy <- new.env(parent = emptyenv())
          self_proxy$initialize <- function(...) cls$new(...)
          self_proxy$new <- function(...) cls$new(...)
          fn_env$self <- self_proxy
          environment(fr) <- fn_env
          fr(reader)
        }
        ctor_key <- .telegramR_norm_ctor_id(ctor)
        if (!is.null(UserProfilePhoto) &&
          identical(ctor_key, .telegramR_norm_ctor_id(UserProfilePhoto$public_fields$CONSTRUCTOR_ID))) {
          photo <- parse_with_class(UserProfilePhoto, reader)
        } else if (!is.null(UserProfilePhotoEmpty) &&
          identical(ctor_key, .telegramR_norm_ctor_id(UserProfilePhotoEmpty$public_fields$CONSTRUCTOR_ID))) {
          photo <- UserProfilePhotoEmpty$new()
        } else {
          # Fallback to generic parsing
          reader$set_position(reader$tell_position() - 4)
          photo <- reader$tgread_object()
        }
      }
      invoice_slug <- if (bitwAnd(flags, 64) != 0) reader$tgread_string() else NULL
      self$initialize(id, peer, until_date, pricing, canceled, can_refulfill, missing_balance, bot_canceled, chat_invite_hash, title, photo, invoice_slug)
    }
  ),
  class = TRUE
)

#  @title StarsSubscriptionPricing
#  @description Telegram API type StarsSubscriptionPricing
#  @export
#  @noRd
#  @noRd
StarsSubscriptionPricing <- R6::R6Class("StarsSubscriptionPricing",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5416d58,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbbf7b9a9,
    initialize = function(period, amount) {
      self$period <- period
      self$amount <- amount
    },
    to_dict = function() {
      list(
        `_` = "StarsSubscriptionPricing",
        period = self$period,
        amount = self$amount
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x58, 0xd5, 0x16, 0x05)),
        pack("i", self$period),
        pack("q", self$amount)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      period <- reader$read_int()
      amount <- reader$read_long()
      self$initialize(period, amount)
    }
  ),
  class = TRUE
)

#  @title StarsTonAmount
#  @description Telegram API type StarsTonAmount
#  @export
#  @noRd
#  @noRd
StarsTonAmount <- R6::R6Class("StarsTonAmount",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x74aee3e0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x355b3240,
    initialize = function(amount) {
      self$amount <- amount
    },
    to_dict = function() {
      list(
        `_` = "StarsTonAmount",
        amount = self$amount
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xe0, 0xe3, 0xae, 0x74)),
        pack("q", self$amount)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      amount <- reader$read_long()
      self$initialize(amount)
    }
  ),
  class = TRUE
)

#  @title StarsTopupOption
#  @description Telegram API type StarsTopupOption
#  @export
#  @noRd
#  @noRd
StarsTopupOption <- R6::R6Class("StarsTopupOption",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbd915c0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xe5bca5ec,
    initialize = function(stars, currency, amount, extended = NULL, store_product = NULL) {
      self$stars <- stars
      self$currency <- currency
      self$amount <- amount
      self$extended <- extended
      self$store_product <- store_product
    },
    to_dict = function() {
      list(
        `_` = "StarsTopupOption",
        stars = self$stars,
        currency = self$currency,
        amount = self$amount,
        extended = self$extended,
        store_product = self$store_product
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xc0, 0x15, 0xd9, 0x0b)),
        pack("I", (if (is.null(self$extended) || !self$extended) 0 else 2) | (if (is.null(self$store_product) || self$store_product == "") 0 else 1)),
        pack("q", self$stars),
        if (is.null(self$store_product) || self$store_product == "") raw(0) else self$serializebytes(self$store_product),
        self$serializebytes(self$currency),
        pack("q", self$amount)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      extended <- bitwAnd(flags, 2) != 0
      stars <- reader$read_long()
      store_product <- if (bitwAnd(flags, 1) != 0) reader$tgread_string() else NULL
      currency <- reader$tgread_string()
      amount <- reader$read_long()
      self$initialize(stars, currency, amount, extended, store_product)
    }
  ),
  class = TRUE
)

#  @title StarsTransaction
#  @description Telegram API type StarsTransaction
#  @export
#  @noRd
#  @noRd
StarsTransaction <- R6::R6Class("StarsTransaction",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x13659eb0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x86884772,
    initialize = function(id, amount, date, peer, refund = NULL, pending = NULL, failed = NULL, gift = NULL, reaction = NULL, stargift_upgrade = NULL, business_transfer = NULL, stargift_resale = NULL, posts_search = NULL, stargift_prepaid_upgrade = NULL, title = NULL, description = NULL, photo = NULL, transaction_date = NULL, transaction_url = NULL, bot_payload = NULL, msg_id = NULL, extended_media = NULL, subscription_period = NULL, giveaway_post_id = NULL, stargift = NULL, floodskip_number = NULL, starref_commission_permille = NULL, starrefpeer = NULL, starref_amount = NULL, paid_messages = NULL, premium_gift_months = NULL, ads_proceeds_from_date = NULL, ads_proceeds_to_date = NULL) {
      self$id <- id
      self$amount <- amount
      self$date <- date
      self$peer <- peer
      self$refund <- refund
      self$pending <- pending
      self$failed <- failed
      self$gift <- gift
      self$reaction <- reaction
      self$stargift_upgrade <- stargift_upgrade
      self$business_transfer <- business_transfer
      self$stargift_resale <- stargift_resale
      self$posts_search <- posts_search
      self$stargift_prepaid_upgrade <- stargift_prepaid_upgrade
      self$title <- title
      self$description <- description
      self$photo <- photo
      self$transaction_date <- transaction_date
      self$transaction_url <- transaction_url
      self$bot_payload <- bot_payload
      self$msg_id <- msg_id
      self$extended_media <- extended_media
      self$subscription_period <- subscription_period
      self$giveaway_post_id <- giveaway_post_id
      self$stargift <- stargift
      self$floodskip_number <- floodskip_number
      self$starref_commission_permille <- starref_commission_permille
      self$starrefpeer <- starrefpeer
      self$starref_amount <- starref_amount
      self$paid_messages <- paid_messages
      self$premium_gift_months <- premium_gift_months
      self$ads_proceeds_from_date <- ads_proceeds_from_date
      self$ads_proceeds_to_date <- ads_proceeds_to_date
    },
    to_dict = function() {
      list(
        `_` = "StarsTransaction",
        id = self$id,
        amount = if (inherits(self$amount, "TLObject")) self$amount$to_dict() else self$amount,
        date = self$date,
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        refund = self$refund,
        pending = self$pending,
        failed = self$failed,
        gift = self$gift,
        reaction = self$reaction,
        stargift_upgrade = self$stargift_upgrade,
        business_transfer = self$business_transfer,
        stargift_resale = self$stargift_resale,
        posts_search = self$posts_search,
        stargift_prepaid_upgrade = self$stargift_prepaid_upgrade,
        title = self$title,
        description = self$description,
        photo = if (inherits(self$photo, "TLObject")) self$photo$to_dict() else self$photo,
        transaction_date = self$transaction_date,
        transaction_url = self$transaction_url,
        bot_payload = self$bot_payload,
        msg_id = self$msg_id,
        extended_media = lapply(self$extended_media, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        subscription_period = self$subscription_period,
        giveaway_post_id = self$giveaway_post_id,
        stargift = if (inherits(self$stargift, "TLObject")) self$stargift$to_dict() else self$stargift,
        floodskip_number = self$floodskip_number,
        starref_commission_permille = self$starref_commission_permille,
        starrefpeer = if (inherits(self$starrefpeer, "TLObject")) self$starrefpeer$to_dict() else self$starrefpeer,
        starref_amount = if (inherits(self$starref_amount, "TLObject")) self$starref_amount$to_dict() else self$starref_amount,
        paid_messages = self$paid_messages,
        premium_gift_months = self$premium_gift_months,
        ads_proceeds_from_date = self$ads_proceeds_from_date,
        ads_proceeds_to_date = self$ads_proceeds_to_date
      )
    },
    bytes = function() {
      stopifnot((!is.null(self$transaction_date) && !is.null(self$transaction_url)) || (is.null(self$transaction_date) && is.null(self$transaction_url)))
      stopifnot((!is.null(self$starrefpeer) && !is.null(self$starref_amount)) || (is.null(self$starrefpeer) && is.null(self$starref_amount)))
      stopifnot((!is.null(self$ads_proceeds_from_date) && !is.null(self$ads_proceeds_to_date)) || (is.null(self$ads_proceeds_from_date) && is.null(self$ads_proceeds_to_date)))
      c(
        as.raw(c(0xb0, 0x9e, 0x65, 0x13)),
        pack("I", (if (is.null(self$refund) || !self$refund) 0 else 8) | (if (is.null(self$pending) || !self$pending) 0 else 16) | (if (is.null(self$failed) || !self$failed) 0 else 64) | (if (is.null(self$gift) || !self$gift) 0 else 1024) | (if (is.null(self$reaction) || !self$reaction) 0 else 2048) | (if (is.null(self$stargift_upgrade) || !self$stargift_upgrade) 0 else 262144) | (if (is.null(self$business_transfer) || !self$business_transfer) 0 else 2097152) | (if (is.null(self$stargift_resale) || !self$stargift_resale) 0 else 4194304) | (if (is.null(self$posts_search) || !self$posts_search) 0 else 16777216) | (if (is.null(self$stargift_prepaid_upgrade) || !self$stargift_prepaid_upgrade) 0 else 33554432) | (if (is.null(self$title) || self$title == "") 0 else 1) | (if (is.null(self$description) || self$description == "") 0 else 2) | (if (is.null(self$photo)) 0 else 4) | (if (is.null(self$transaction_date)) 0 else 32) | (if (is.null(self$transaction_url) || self$transaction_url == "") 0 else 32) | (if (is.null(self$bot_payload)) 0 else 128) | (if (is.null(self$msg_id)) 0 else 256) | (if (is.null(self$extended_media)) 0 else 512) | (if (is.null(self$subscription_period)) 0 else 4096) | (if (is.null(self$giveaway_post_id)) 0 else 8192) | (if (is.null(self$stargift)) 0 else 16384) | (if (is.null(self$floodskip_number)) 0 else 32768) | (if (is.null(self$starref_commission_permille)) 0 else 65536) | (if (is.null(self$starrefpeer)) 0 else 131072) | (if (is.null(self$starref_amount)) 0 else 131072) | (if (is.null(self$paid_messages)) 0 else 524288) | (if (is.null(self$premium_gift_months)) 0 else 1048576) | (if (is.null(self$ads_proceeds_from_date)) 0 else 8388608) | (if (is.null(self$ads_proceeds_to_date)) 0 else 8388608)),
        self$serializebytes(self$id),
        self$amount$bytes(),
        self$serialize_datetime(self$date),
        self$peer$bytes(),
        if (is.null(self$title) || self$title == "") raw(0) else self$serializebytes(self$title),
        if (is.null(self$description) || self$description == "") raw(0) else self$serializebytes(self$description),
        if (is.null(self$photo)) raw(0) else self$photo$bytes(),
        if (is.null(self$transaction_date)) raw(0) else self$serialize_datetime(self$transaction_date),
        if (is.null(self$transaction_url) || self$transaction_url == "") raw(0) else self$serializebytes(self$transaction_url),
        if (is.null(self$bot_payload)) raw(0) else self$serializebytes(self$bot_payload),
        if (is.null(self$msg_id)) raw(0) else pack("i", self$msg_id),
        if (is.null(self$extended_media)) raw(0) else c(as.raw(c(0x1c, 0xb5, 0xc4, 0x15)), pack("i", length(self$extended_media)), do.call(c, lapply(self$extended_media, function(x) x$bytes()))),
        if (is.null(self$subscription_period)) raw(0) else pack("i", self$subscription_period),
        if (is.null(self$giveaway_post_id)) raw(0) else pack("i", self$giveaway_post_id),
        if (is.null(self$stargift)) raw(0) else self$stargift$bytes(),
        if (is.null(self$floodskip_number)) raw(0) else pack("i", self$floodskip_number),
        if (is.null(self$starref_commission_permille)) raw(0) else pack("i", self$starref_commission_permille),
        if (is.null(self$starrefpeer)) raw(0) else self$starrefpeer$bytes(),
        if (is.null(self$starref_amount)) raw(0) else self$starref_amount$bytes(),
        if (is.null(self$paid_messages)) raw(0) else pack("i", self$paid_messages),
        if (is.null(self$premium_gift_months)) raw(0) else pack("i", self$premium_gift_months),
        if (is.null(self$ads_proceeds_from_date)) raw(0) else self$serialize_datetime(self$ads_proceeds_from_date),
        if (is.null(self$ads_proceeds_to_date)) raw(0) else self$serialize_datetime(self$ads_proceeds_to_date)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      refund <- bitwAnd(flags, 8) != 0
      pending <- bitwAnd(flags, 16) != 0
      failed <- bitwAnd(flags, 64) != 0
      gift <- bitwAnd(flags, 1024) != 0
      reaction <- bitwAnd(flags, 2048) != 0
      stargift_upgrade <- bitwAnd(flags, 262144) != 0
      business_transfer <- bitwAnd(flags, 2097152) != 0
      stargift_resale <- bitwAnd(flags, 4194304) != 0
      posts_search <- bitwAnd(flags, 16777216) != 0
      stargift_prepaid_upgrade <- bitwAnd(flags, 33554432) != 0
      id <- reader$tgread_string()
      amount <- reader$tgread_object()
      date <- reader$tgread_date()
      peer <- reader$tgread_object()
      title <- if (bitwAnd(flags, 1) != 0) reader$tgread_string() else NULL
      description <- if (bitwAnd(flags, 2) != 0) reader$tgread_string() else NULL
      photo <- if (bitwAnd(flags, 4) != 0) reader$tgread_object() else NULL
      transaction_date <- if (bitwAnd(flags, 32) != 0) reader$tgread_date() else NULL
      transaction_url <- if (bitwAnd(flags, 32) != 0) reader$tgread_string() else NULL
      bot_payload <- if (bitwAnd(flags, 128) != 0) reader$tgreadbytes() else NULL
      msg_id <- if (bitwAnd(flags, 256) != 0) reader$read_int() else NULL
      extended_media <- if (bitwAnd(flags, 512) != 0) {
        reader$read_int()
        lapply(seq_len(reader$read_int()), function(i) reader$tgread_object())
      } else {
        NULL
      }
      subscription_period <- if (bitwAnd(flags, 4096) != 0) reader$read_int() else NULL
      giveaway_post_id <- if (bitwAnd(flags, 8192) != 0) reader$read_int() else NULL
      stargift <- if (bitwAnd(flags, 16384) != 0) reader$tgread_object() else NULL
      floodskip_number <- if (bitwAnd(flags, 32768) != 0) reader$read_int() else NULL
      starref_commission_permille <- if (bitwAnd(flags, 65536) != 0) reader$read_int() else NULL
      starrefpeer <- if (bitwAnd(flags, 131072) != 0) reader$tgread_object() else NULL
      starref_amount <- if (bitwAnd(flags, 131072) != 0) reader$tgread_object() else NULL
      paid_messages <- if (bitwAnd(flags, 524288) != 0) reader$read_int() else NULL
      premium_gift_months <- if (bitwAnd(flags, 1048576) != 0) reader$read_int() else NULL
      ads_proceeds_from_date <- if (bitwAnd(flags, 8388608) != 0) reader$tgread_date() else NULL
      ads_proceeds_to_date <- if (bitwAnd(flags, 8388608) != 0) reader$tgread_date() else NULL
      self$initialize(id, amount, date, peer, refund, pending, failed, gift, reaction, stargift_upgrade, business_transfer, stargift_resale, posts_search, stargift_prepaid_upgrade, title, description, photo, transaction_date, transaction_url, bot_payload, msg_id, extended_media, subscription_period, giveaway_post_id, stargift, floodskip_number, starref_commission_permille, starrefpeer, starref_amount, paid_messages, premium_gift_months, ads_proceeds_from_date, ads_proceeds_to_date)
    }
  ),
  class = TRUE
)

#  @title StarsTransactionPeer
#  @description Telegram API type StarsTransactionPeer
#  @export
#  @noRd
#  @noRd
StarsTransactionPeer <- R6::R6Class("StarsTransactionPeer",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd80da15d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x41b69183,
    initialize = function(peer) {
      self$peer <- peer
    },
    to_dict = function() {
      list(
        `_` = "StarsTransactionPeer",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x5d, 0xa1, 0x0d, 0xd8)),
        self$peer$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      self$initialize(peer)
    }
  ),
  class = TRUE
)

#  @title StarsTransactionPeerAPI
#  @description Telegram API type StarsTransactionPeerAPI
#  @export
#  @noRd
#  @noRd
StarsTransactionPeerAPI <- R6::R6Class("StarsTransactionPeerAPI",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf9677aad,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x41b69183,
    to_dict = function() {
      list(`_` = "StarsTransactionPeerAPI")
    },
    bytes = function() {
      as.raw(c(0xad, 0x7a, 0x67, 0xf9))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title StarsTransactionPeerAds
#  @description Telegram API type StarsTransactionPeerAds
#  @export
#  @noRd
#  @noRd
StarsTransactionPeerAds <- R6::R6Class("StarsTransactionPeerAds",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x60682812,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x41b69183,
    to_dict = function() {
      list(`_` = "StarsTransactionPeerAds")
    },
    bytes = function() {
      as.raw(c(0x12, 0x28, 0x68, 0x60))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title StarsTransactionPeerAppStore
#  @description Telegram API type StarsTransactionPeerAppStore
#  @export
#  @noRd
#  @noRd
StarsTransactionPeerAppStore <- R6::R6Class("StarsTransactionPeerAppStore",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb457b375,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x41b69183,
    to_dict = function() {
      list(`_` = "StarsTransactionPeerAppStore")
    },
    bytes = function() {
      as.raw(c(0x75, 0xb3, 0x57, 0xb4))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title StarsTransactionPeerFragment
#  @description Telegram API type StarsTransactionPeerFragment
#  @export
#  @noRd
#  @noRd
StarsTransactionPeerFragment <- R6::R6Class("StarsTransactionPeerFragment",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe92fd902,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x41b69183,
    to_dict = function() {
      list(`_` = "StarsTransactionPeerFragment")
    },
    bytes = function() {
      as.raw(c(0x02, 0xd9, 0x2f, 0xe9))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title StarsTransactionPeerPlayMarket
#  @description Telegram API type StarsTransactionPeerPlayMarket
#  @export
#  @noRd
#  @noRd
StarsTransactionPeerPlayMarket <- R6::R6Class("StarsTransactionPeerPlayMarket",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7b560a0b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x41b69183,
    to_dict = function() {
      list(`_` = "StarsTransactionPeerPlayMarket")
    },
    bytes = function() {
      as.raw(c(0x0b, 0x0a, 0x56, 0x7b))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title StarsTransactionPeerPremiumBot
#  @description Telegram API type StarsTransactionPeerPremiumBot
#  @export
#  @noRd
#  @noRd
StarsTransactionPeerPremiumBot <- R6::R6Class("StarsTransactionPeerPremiumBot",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x250dbaf8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x41b69183,
    to_dict = function() {
      list(`_` = "StarsTransactionPeerPremiumBot")
    },
    bytes = function() {
      as.raw(c(0xf8, 0xba, 0x0d, 0x25))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title StarsTransactionPeerUnsupported
#  @description Telegram API type StarsTransactionPeerUnsupported
#  @export
#  @noRd
#  @noRd
StarsTransactionPeerUnsupported <- R6::R6Class("StarsTransactionPeerUnsupported",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x95f2bfe4,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x41b69183,
    to_dict = function() {
      list(`_` = "StarsTransactionPeerUnsupported")
    },
    bytes = function() {
      as.raw(c(0xe4, 0xbf, 0xf2, 0x95))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title StatsAbsValueAndPrev
#  @description Telegram API type StatsAbsValueAndPrev
#  @export
#  @noRd
#  @noRd
StatsAbsValueAndPrev <- R6::R6Class("StatsAbsValueAndPrev",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xcb43acde,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x3ebe59af,
    initialize = function(current, previous) {
      self$current <- current
      self$previous <- previous
    },
    to_dict = function() {
      list(
        `_` = "StatsAbsValueAndPrev",
        current = self$current,
        previous = self$previous
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xde, 0xac, 0x43, 0xcb)),
        pack("d", self$current),
        pack("d", self$previous)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      current <- reader$read_double()
      previous <- reader$read_double()
      self$initialize(current, previous)
    }
  ),
  class = TRUE
)

#  @title StatsDateRangeDays
#  @description Telegram API type StatsDateRangeDays
#  @export
#  @noRd
#  @noRd
StatsDateRangeDays <- R6::R6Class("StatsDateRangeDays",
  inherit = TLObject,
  public = list(
    initialize = function(min_date = NULL, max_date = NULL) {
      self$min_date <- min_date
      self$max_date <- max_date
    },
    to_dict = function() {
      list(`_` = "StatsDateRangeDays", min_date = self$min_date, max_date = self$max_date)
    },
    bytes = function() {
      as.raw(c(0xaf, 0xed, 0x37, 0xb6)) + self$serialize_datetime(self$min_date) + self$serialize_datetime(self$max_date)
    }
  ),
  private = list(
    from_reader = function(reader) {
      min_date <- reader$tgread_date()
      max_date <- reader$tgread_date()
      self$initialize(min_date = min_date, max_date = max_date)
    }
  ),
  class = TRUE
)

#  @title StatsGraph
#  @description Telegram API type StatsGraph
#  @export
#  @noRd
#  @noRd
StatsGraph <- R6::R6Class("StatsGraph",
  inherit = TLObject,
  public = list(
    initialize = function(json = NULL, zoom_token = NULL) {
      self$json <- json
      self$zoom_token <- zoom_token
    },
    to_dict = function() {
      list(`_` = "StatsGraph", json = if (is.null(self$json)) NULL else self$json$to_dict(), zoom_token = self$zoom_token)
    },
    bytes = function() {
      as.raw(c(0xb6, 0x64, 0xa4, 0x8e)) + pack("I", if (is.null(self$zoom_token) || self$zoom_token == "") 0 else 1) + self$json$bytes() + if (is.null(self$zoom_token) || self$zoom_token == "") raw(0) else self$serializebytes(self$zoom_token)
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      json <- reader$tgread_object()
      zoom_token <- if (bitwAnd(flags, 1) != 0) reader$tgread_string() else NULL
      self$initialize(json = json, zoom_token = zoom_token)
    }
  ),
  class = TRUE
)

#  @title StatsGraphAsync
#  @description Telegram API type StatsGraphAsync
#  @export
#  @noRd
#  @noRd
StatsGraphAsync <- R6::R6Class("StatsGraphAsync",
  inherit = TLObject,
  public = list(
    initialize = function(token = NULL) {
      self$token <- token
    },
    to_dict = function() {
      list(`_` = "StatsGraphAsync", token = self$token)
    },
    bytes = function() {
      as.raw(c(0x2d, 0xeb, 0x27, 0x4a)) + self$serializebytes(self$token)
    }
  ),
  private = list(
    from_reader = function(reader) {
      token <- reader$tgread_string()
      self$initialize(token = token)
    }
  ),
  class = TRUE
)

#  @title StatsGraphError
#  @description Telegram API type StatsGraphError
#  @export
#  @noRd
#  @noRd
StatsGraphError <- R6::R6Class("StatsGraphError",
  inherit = TLObject,
  public = list(
    initialize = function(error = NULL) {
      self$error <- error
    },
    to_dict = function() {
      list(`_` = "StatsGraphError", error = self$error)
    },
    bytes = function() {
      as.raw(c(0x22, 0x98, 0xdc, 0xbe)) + self$serializebytes(self$error)
    }
  ),
  private = list(
    from_reader = function(reader) {
      error <- reader$tgread_string()
      self$initialize(error = error)
    }
  ),
  class = TRUE
)

#  @title StatsGroupTopAdmin
#  @description Telegram API type StatsGroupTopAdmin
#  @export
#  @noRd
#  @noRd
StatsGroupTopAdmin <- R6::R6Class("StatsGroupTopAdmin",
  inherit = TLObject,
  public = list(
    initialize = function(user_id = NULL, deleted = NULL, kicked = NULL, banned = NULL) {
      self$user_id <- user_id
      self$deleted <- deleted
      self$kicked <- kicked
      self$banned <- banned
    },
    to_dict = function() {
      list(`_` = "StatsGroupTopAdmin", user_id = self$user_id, deleted = self$deleted, kicked = self$kicked, banned = self$banned)
    },
    bytes = function() {
      as.raw(c(0x87, 0x4c, 0x58, 0xd7)) + pack("q", self$user_id) + pack("i", self$deleted) + pack("i", self$kicked) + pack("i", self$banned)
    }
  ),
  private = list(
    from_reader = function(reader) {
      user_id <- reader$read_long()
      deleted <- reader$read_int()
      kicked <- reader$read_int()
      banned <- reader$read_int()
      self$initialize(user_id = user_id, deleted = deleted, kicked = kicked, banned = banned)
    }
  ),
  class = TRUE
)

#  @title StatsGroupTopInviter
#  @description Telegram API type StatsGroupTopInviter
#  @export
#  @noRd
#  @noRd
StatsGroupTopInviter <- R6::R6Class("StatsGroupTopInviter",
  inherit = TLObject,
  public = list(
    initialize = function(user_id = NULL, invitations = NULL) {
      self$user_id <- user_id
      self$invitations <- invitations
    },
    to_dict = function() {
      list(`_` = "StatsGroupTopInviter", user_id = self$user_id, invitations = self$invitations)
    },
    bytes = function() {
      as.raw(c(0x9d, 0x77, 0x5f, 0x53)) + pack("q", self$user_id) + pack("i", self$invitations)
    }
  ),
  private = list(
    from_reader = function(reader) {
      user_id <- reader$read_long()
      invitations <- reader$read_int()
      self$initialize(user_id = user_id, invitations = invitations)
    }
  ),
  class = TRUE
)

#  @title StatsGroupTopPoster
#  @description Telegram API type StatsGroupTopPoster
#  @export
#  @noRd
#  @noRd
StatsGroupTopPoster <- R6::R6Class("StatsGroupTopPoster",
  inherit = TLObject,
  public = list(
    initialize = function(user_id = NULL, messages = NULL, avg_chars = NULL) {
      self$user_id <- user_id
      self$messages <- messages
      self$avg_chars <- avg_chars
    },
    to_dict = function() {
      list(`_` = "StatsGroupTopPoster", user_id = self$user_id, messages = self$messages, avg_chars = self$avg_chars)
    },
    bytes = function() {
      as.raw(c(0x9b, 0xaf, 0x04, 0x9d)) + pack("q", self$user_id) + pack("i", self$messages) + pack("i", self$avg_chars)
    }
  ),
  private = list(
    from_reader = function(reader) {
      user_id <- reader$read_long()
      messages <- reader$read_int()
      avg_chars <- reader$read_int()
      self$initialize(user_id = user_id, messages = messages, avg_chars = avg_chars)
    }
  ),
  class = TRUE
)

#  @title StatsPercentValue
#  @description Telegram API type StatsPercentValue
#  @export
#  @noRd
#  @noRd
StatsPercentValue <- R6::R6Class("StatsPercentValue",
  inherit = TLObject,
  public = list(
    initialize = function(part = NULL, total = NULL) {
      self$part <- part
      self$total <- total
    },
    to_dict = function() {
      list(`_` = "StatsPercentValue", part = self$part, total = self$total)
    },
    bytes = function() {
      as.raw(c(0xe0, 0x2f, 0xce, 0xcb)) + pack("d", self$part) + pack("d", self$total)
    }
  ),
  private = list(
    from_reader = function(reader) {
      part <- reader$read_double()
      total <- reader$read_double()
      self$initialize(part = part, total = total)
    }
  ),
  class = TRUE
)

#  @title StatsURL
#  @description Telegram API type StatsURL
#  @export
#  @noRd
#  @noRd
StatsURL <- R6::R6Class("StatsURL",
  inherit = TLObject,
  public = list(
    initialize = function(url = NULL) {
      self$url <- url
    },
    to_dict = function() {
      list(`_` = "StatsURL", url = self$url)
    },
    bytes = function() {
      as.raw(c(0xe0, 0x71, 0xa9, 0x47)) + self$serializebytes(self$url)
    }
  ),
  private = list(
    from_reader = function(reader) {
      url <- reader$tgread_string()
      self$initialize(url = url)
    }
  ),
  class = TRUE
)

#  @title StickerKeyword
#  @description Telegram API type StickerKeyword
#  @export
#  @noRd
#  @noRd
StickerKeyword <- R6::R6Class("StickerKeyword",
  inherit = TLObject,
  public = list(
    initialize = function(document_id = NULL, keyword = NULL) {
      self$document_id <- document_id
      self$keyword <- keyword
    },
    to_dict = function() {
      list(`_` = "StickerKeyword", document_id = self$document_id, keyword = if (is.null(self$keyword)) list() else self$keyword)
    },
    bytes = function() {
      as.raw(c(0x9c, 0xb2, 0xfe, 0xfc)) + pack("q", self$document_id) + as.raw(c(0x1c, 0xb5, 0xc4, 0x15)) + pack("i", length(self$keyword)) + do.call(c, lapply(self$keyword, function(x) self$serializebytes(x)))
    }
  ),
  private = list(
    from_reader = function(reader) {
      document_id <- reader$read_long()
      reader$read_int()
      keyword <- list()
      for (i in 1:reader$read_int()) {
        x <- reader$tgread_string()
        keyword <- c(keyword, x)
      }
      self$initialize(document_id = document_id, keyword = keyword)
    }
  ),
  class = TRUE
)

#  @title StickerPack
#  @description Telegram API type StickerPack
#  @export
#  @noRd
#  @noRd
StickerPack <- R6::R6Class("StickerPack",
  inherit = TLObject,
  public = list(
    initialize = function(emoticon = NULL, documents = NULL) {
      self$emoticon <- emoticon
      self$documents <- documents
    },
    to_dict = function() {
      list(`_` = "StickerPack", emoticon = self$emoticon, documents = if (is.null(self$documents)) list() else self$documents)
    },
    bytes = function() {
      as.raw(c(0xd4, 0x99, 0xb2, 0x12)) + self$serializebytes(self$emoticon) + as.raw(c(0x1c, 0xb5, 0xc4, 0x15)) + pack("i", length(self$documents)) + do.call(c, lapply(self$documents, function(x) pack("q", x)))
    }
  ),
  private = list(
    from_reader = function(reader) {
      emoticon <- reader$tgread_string()
      reader$read_int()
      documents <- list()
      for (i in 1:reader$read_int()) {
        x <- reader$read_long()
        documents <- c(documents, x)
      }
      self$initialize(emoticon = emoticon, documents = documents)
    }
  ),
  class = TRUE
)

#  @title StickerSet
#  @description Telegram API type StickerSet
#  @export
#  @noRd
#  @noRd
StickerSet <- R6::R6Class("StickerSet",
  inherit = TLObject,
  public = list(
    initialize = function(id = NULL, access_hash = NULL, title = NULL, short_name = NULL, count = NULL, hash = NULL, archived = NULL, official = NULL, masks = NULL, emojis = NULL, text_color = NULL, channel_emoji_status = NULL, creator = NULL, installed_date = NULL, thumbs = NULL, thumb_dc_id = NULL, thumb_version = NULL, thumb_document_id = NULL) {
      self$id <- id
      self$access_hash <- access_hash
      self$title <- title
      self$short_name <- short_name
      self$count <- count
      self$hash <- hash
      self$archived <- archived
      self$official <- official
      self$masks <- masks
      self$emojis <- emojis
      self$text_color <- text_color
      self$channel_emoji_status <- channel_emoji_status
      self$creator <- creator
      self$installed_date <- installed_date
      self$thumbs <- thumbs
      self$thumb_dc_id <- thumb_dc_id
      self$thumb_version <- thumb_version
      self$thumb_document_id <- thumb_document_id
    },
    to_dict = function() {
      list(`_` = "StickerSet", id = self$id, access_hash = self$access_hash, title = self$title, short_name = self$short_name, count = self$count, hash = self$hash, archived = self$archived, official = self$official, masks = self$masks, emojis = self$emojis, text_color = self$text_color, channel_emoji_status = self$channel_emoji_status, creator = self$creator, installed_date = self$installed_date, thumbs = if (is.null(self$thumbs)) list() else lapply(self$thumbs, function(x) x$to_dict()), thumb_dc_id = self$thumb_dc_id, thumb_version = self$thumb_version, thumb_document_id = self$thumb_document_id)
    },
    bytes = function() {
      flags <- (if (is.null(self$archived) || !self$archived) 0 else 2) | (if (is.null(self$official) || !self$official) 0 else 4) | (if (is.null(self$masks) || !self$masks) 0 else 8) | (if (is.null(self$emojis) || !self$emojis) 0 else 128) | (if (is.null(self$text_color) || !self$text_color) 0 else 512) | (if (is.null(self$channel_emoji_status) || !self$channel_emoji_status) 0 else 1024) | (if (is.null(self$creator) || !self$creator) 0 else 2048) | (if (is.null(self$installed_date)) 0 else 1) | (if (is.null(self$thumbs)) 0 else 16) | (if (is.null(self$thumb_dc_id)) 0 else 16) | (if (is.null(self$thumb_version)) 0 else 16) | (if (is.null(self$thumb_document_id)) 0 else 256)
      as.raw(c(0xdc, 0x4e, 0xd1, 0x2d)) + pack("I", flags) + (if (is.null(self$installed_date)) raw(0) else self$serialize_datetime(self$installed_date)) + pack("q", self$id) + pack("q", self$access_hash) + self$serializebytes(self$title) + self$serializebytes(self$short_name) + (if (is.null(self$thumbs)) raw(0) else as.raw(c(0x1c, 0xb5, 0xc4, 0x15)) + pack("i", length(self$thumbs)) + do.call(c, lapply(self$thumbs, function(x) x$bytes()))) + (if (is.null(self$thumb_dc_id)) raw(0) else pack("i", self$thumb_dc_id)) + (if (is.null(self$thumb_version)) raw(0) else pack("i", self$thumb_version)) + (if (is.null(self$thumb_document_id)) raw(0) else pack("q", self$thumb_document_id)) + pack("i", self$count) + pack("i", self$hash)
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      archived <- bitwAnd(flags, 2) != 0
      official <- bitwAnd(flags, 4) != 0
      masks <- bitwAnd(flags, 8) != 0
      emojis <- bitwAnd(flags, 128) != 0
      text_color <- bitwAnd(flags, 512) != 0
      channel_emoji_status <- bitwAnd(flags, 1024) != 0
      creator <- bitwAnd(flags, 2048) != 0
      installed_date <- if (bitwAnd(flags, 1) != 0) reader$tgread_date() else NULL
      id <- reader$read_long()
      access_hash <- reader$read_long()
      title <- reader$tgread_string()
      short_name <- reader$tgread_string()
      thumbs <- if (bitwAnd(flags, 16) != 0) {
        reader$read_int()
        thumbs <- list()
        for (i in 1:reader$read_int()) {
          thumbs <- c(thumbs, reader$tgread_object())
        }
        thumbs
      } else {
        NULL
      }
      thumb_dc_id <- if (bitwAnd(flags, 16) != 0) reader$read_int() else NULL
      thumb_version <- if (bitwAnd(flags, 16) != 0) reader$read_int() else NULL
      thumb_document_id <- if (bitwAnd(flags, 256) != 0) reader$read_long() else NULL
      count <- reader$read_int()
      hash <- reader$read_int()
      self$initialize(id = id, access_hash = access_hash, title = title, short_name = short_name, count = count, hash = hash, archived = archived, official = official, masks = masks, emojis = emojis, text_color = text_color, channel_emoji_status = channel_emoji_status, creator = creator, installed_date = installed_date, thumbs = thumbs, thumb_dc_id = thumb_dc_id, thumb_version = thumb_version, thumb_document_id = thumb_document_id)
    }
  ),
  class = TRUE
)

#  @title StickerSetCovered
#  @description Telegram API type StickerSetCovered
#  @export
#  @noRd
#  @noRd
StickerSetCovered <- R6::R6Class("StickerSetCovered",
  inherit = TLObject,
  public = list(
    initialize = function(set = NULL, cover = NULL) {
      self$set <- set
      self$cover <- cover
    },
    to_dict = function() {
      list(`_` = "StickerSetCovered", set = if (is.null(self$set)) NULL else self$set$to_dict(), cover = if (is.null(self$cover)) NULL else self$cover$to_dict())
    },
    bytes = function() {
      as.raw(c(0xd2, 0xa5, 0x10, 0x64)) + self$set$bytes() + self$cover$bytes()
    }
  ),
  private = list(
    from_reader = function(reader) {
      set <- reader$tgread_object()
      cover <- reader$tgread_object()
      self$initialize(set = set, cover = cover)
    }
  ),
  class = TRUE
)

#  @title StickerSetFullCovered
#  @description Telegram API type StickerSetFullCovered
#  @export
#  @noRd
#  @noRd
StickerSetFullCovered <- R6::R6Class("StickerSetFullCovered",
  inherit = TLObject,
  public = list(
    initialize = function(set = NULL, packs = NULL, keywords = NULL, documents = NULL) {
      self$set <- set
      self$packs <- packs
      self$keywords <- keywords
      self$documents <- documents
    },
    to_dict = function() {
      list(`_` = "StickerSetFullCovered", set = if (is.null(self$set)) NULL else self$set$to_dict(), packs = if (is.null(self$packs)) list() else lapply(self$packs, function(x) x$to_dict()), keywords = if (is.null(self$keywords)) list() else lapply(self$keywords, function(x) x$to_dict()), documents = if (is.null(self$documents)) list() else lapply(self$documents, function(x) x$to_dict()))
    },
    bytes = function() {
      as.raw(c(0x0e, 0x3c, 0xd1, 0x40)) + self$set$bytes() + as.raw(c(0x1c, 0xb5, 0xc4, 0x15)) + pack("i", length(self$packs)) + do.call(c, lapply(self$packs, function(x) x$bytes())) + as.raw(c(0x1c, 0xb5, 0xc4, 0x15)) + pack("i", length(self$keywords)) + do.call(c, lapply(self$keywords, function(x) x$bytes())) + as.raw(c(0x1c, 0xb5, 0xc4, 0x15)) + pack("i", length(self$documents)) + do.call(c, lapply(self$documents, function(x) x$bytes()))
    }
  ),
  private = list(
    from_reader = function(reader) {
      set <- reader$tgread_object()
      reader$read_int()
      packs <- list()
      for (i in 1:reader$read_int()) {
        packs <- c(packs, reader$tgread_object())
      }
      reader$read_int()
      keywords <- list()
      for (i in 1:reader$read_int()) {
        keywords <- c(keywords, reader$tgread_object())
      }
      reader$read_int()
      documents <- list()
      for (i in 1:reader$read_int()) {
        documents <- c(documents, reader$tgread_object())
      }
      self$initialize(set = set, packs = packs, keywords = keywords, documents = documents)
    }
  ),
  class = TRUE
)

#  @title StickerSetMultiCovered
#  @description Telegram API type StickerSetMultiCovered
#  @export
#  @noRd
#  @noRd
StickerSetMultiCovered <- R6::R6Class("StickerSetMultiCovered",
  inherit = TLObject,
  public = list(
    initialize = function(set = NULL, covers = NULL) {
      self$set <- set
      self$covers <- covers
    },
    to_dict = function() {
      list(`_` = "StickerSetMultiCovered", set = if (is.null(self$set)) NULL else self$set$to_dict(), covers = if (is.null(self$covers)) list() else lapply(self$covers, function(x) x$to_dict()))
    },
    bytes = function() {
      as.raw(c(0x1b, 0xe5, 0x07, 0x34)) + self$set$bytes() + as.raw(c(0x1c, 0xb5, 0xc4, 0x15)) + pack("i", length(self$covers)) + do.call(c, lapply(self$covers, function(x) x$bytes()))
    }
  ),
  private = list(
    from_reader = function(reader) {
      set <- reader$tgread_object()
      reader$read_int()
      covers <- list()
      for (i in 1:reader$read_int()) {
        covers <- c(covers, reader$tgread_object())
      }
      self$initialize(set = set, covers = covers)
    }
  ),
  class = TRUE
)

#  @title StickerSetNoCovered
#  @description Telegram API type StickerSetNoCovered
#  @export
#  @noRd
#  @noRd
StickerSetNoCovered <- R6::R6Class("StickerSetNoCovered",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0x1c, 0x5d, 0xb1, 0x77)) + self$set$bytes()
  ),
  private = list(
    from_reader = function(reader) list(set = reader$tgread_object())
  ),
  class = TRUE
)

#  @title StoriesStealthMode
#  @description Telegram API type StoriesStealthMode
#  @export
#  @noRd
#  @noRd
StoriesStealthMode <- R6::R6Class("StoriesStealthMode",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0xfd, 0x27, 0x71)) + pack("I", (if (is.null(self$active_until_date)) 0 else 1) | (if (is.null(self$cooldown_until_date)) 0 else 2)) + if (!is.null(self$active_until_date)) self$serialize_datetime(self$active_until_date) else raw(0) + if (!is.null(self$cooldown_until_date)) self$serialize_datetime(self$cooldown_until_date) else raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      if (flags & 1) active_until_date <- reader$tgread_date() else active_until_date <- NULL
      if (flags & 2) cooldown_until_date <- reader$tgread_date() else cooldown_until_date <- NULL
      list(active_until_date = active_until_date, cooldown_until_date = cooldown_until_date)
    }
  ),
  class = TRUE
)

#  @title StoryAlbum
#  @description Telegram API type StoryAlbum
#  @export
#  @noRd
#  @noRd
StoryAlbum <- R6::R6Class("StoryAlbum",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0x5a, 0x25, 0x93)) + pack("I", (if (is.null(self$icon_photo)) 0 else 1) | (if (is.null(self$icon_video)) 0 else 2)) + pack("i", self$album_id) + self$serializebytes(self$title) + if (!is.null(self$icon_photo)) self$icon_photo$bytes() else raw(0) + if (!is.null(self$icon_video)) self$icon_video$bytes() else raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      album_id <- reader$read_int()
      title <- reader$tgread_string()
      if (flags & 1) icon_photo <- reader$tgread_object() else icon_photo <- NULL
      if (flags & 2) icon_video <- reader$tgread_object() else icon_video <- NULL
      list(album_id = album_id, title = title, icon_photo = icon_photo, icon_video = icon_video)
    }
  ),
  class = TRUE
)

#  @title StoryFwdHeader
#  @description Telegram API type StoryFwdHeader
#  @export
#  @noRd
#  @noRd
StoryFwdHeader <- R6::R6Class("StoryFwdHeader",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0x50, 0xe1, 0x26, 0xb8)) + pack("I", (if (is.null(self$modified)) 0 else 8) | (if (is.null(self$from_)) 0 else 1) | (if (is.null(self$from_name)) 0 else 2) | (if (is.null(self$story_id)) 0 else 4)) + if (!is.null(self$from_)) self$from_$bytes() else raw(0) + if (!is.null(self$from_name)) self$serializebytes(self$from_name) else raw(0) + if (!is.null(self$story_id)) pack("i", self$story_id) else raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      modified <- (flags & 8) != 0
      if (flags & 1) from_ <- reader$tgread_object() else from_ <- NULL
      if (flags & 2) from_name <- reader$tgread_string() else from_name <- NULL
      if (flags & 4) story_id <- reader$read_int() else story_id <- NULL
      list(modified = modified, from_ = from_, from_name = from_name, story_id = story_id)
    }
  ),
  class = TRUE
)

#  @title StoryItem
#  @description Telegram API type StoryItem
#  @export
#  @noRd
#  @noRd
StoryItem <- R6::R6Class("StoryItem",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0xf1, 0x64, 0xf1, 0xed)) + pack("I", (if (is.null(self$pinned)) 0 else 32) | (if (is.null(self$public)) 0 else 128) | (if (is.null(self$close_friends)) 0 else 256) | (if (is.null(self$min)) 0 else 512) | (if (is.null(self$noforwards)) 0 else 1024) | (if (is.null(self$edited)) 0 else 2048) | (if (is.null(self$contacts)) 0 else 4096) | (if (is.null(self$selected_contacts)) 0 else 8192) | (if (is.null(self$out)) 0 else 65536) | (if (is.null(self$from_id)) 0 else 262144) | (if (is.null(self$fwd_from)) 0 else 131072) | (if (is.null(self$caption)) 0 else 1) | (if (is.null(self$entities)) 0 else 2) | (if (is.null(self$media_areas)) 0 else 16384) | (if (is.null(self$privacy)) 0 else 4) | (if (is.null(self$views)) 0 else 8) | (if (is.null(self$sent_reaction)) 0 else 32768) | (if (is.null(self$albums)) 0 else 524288)) + pack("i", self$id) + self$serialize_datetime(self$date) + if (!is.null(self$from_id)) self$from_id$bytes() else raw(0) + if (!is.null(self$fwd_from)) self$fwd_from$bytes() else raw(0) + self$serialize_datetime(self$expire_date) + if (!is.null(self$caption)) self$serializebytes(self$caption) else raw(0) + if (!is.null(self$entities)) (as.raw(c(0x15, 0xc4, 0xb5, 0x1c)) + pack("i", length(self$entities)) + do.call(c, lapply(self$entities, function(x) x$bytes()))) else raw(0) + self$media$bytes() + if (!is.null(self$media_areas)) (as.raw(c(0x15, 0xc4, 0xb5, 0x1c)) + pack("i", length(self$media_areas)) + do.call(c, lapply(self$media_areas, function(x) x$bytes()))) else raw(0) + if (!is.null(self$privacy)) (as.raw(c(0x15, 0xc4, 0xb5, 0x1c)) + pack("i", length(self$privacy)) + do.call(c, lapply(self$privacy, function(x) x$bytes()))) else raw(0) + if (!is.null(self$views)) self$views$bytes() else raw(0) + if (!is.null(self$sent_reaction)) self$sent_reaction$bytes() else raw(0) + if (!is.null(self$albums)) (as.raw(c(0x15, 0xc4, 0xb5, 0x1c)) + pack("i", length(self$albums)) + do.call(c, lapply(self$albums, function(x) pack("i", x)))) else raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      pinned <- (flags & 32) != 0
      public <- (flags & 128) != 0
      close_friends <- (flags & 256) != 0
      min <- (flags & 512) != 0
      noforwards <- (flags & 1024) != 0
      edited <- (flags & 2048) != 0
      contacts <- (flags & 4096) != 0
      selected_contacts <- (flags & 8192) != 0
      out <- (flags & 65536) != 0
      id <- reader$read_int()
      date <- reader$tgread_date()
      if (flags & 262144) from_id <- reader$tgread_object() else from_id <- NULL
      if (flags & 131072) fwd_from <- reader$tgread_object() else fwd_from <- NULL
      expire_date <- reader$tgread_date()
      if (flags & 1) caption <- reader$tgread_string() else caption <- NULL
      if (flags & 2) {
        reader$read_int()
        entities <- list()
        for (i in 1:reader$read_int()) {
          x <- reader$tgread_object()
          entities <- c(entities, x)
        }
      } else {
        entities <- NULL
      }
      media <- reader$tgread_object()
      if (flags & 16384) {
        reader$read_int()
        media_areas <- list()
        for (i in 1:reader$read_int()) {
          x <- reader$tgread_object()
          media_areas <- c(media_areas, x)
        }
      } else {
        media_areas <- NULL
      }
      if (flags & 4) {
        reader$read_int()
        privacy <- list()
        for (i in 1:reader$read_int()) {
          x <- reader$tgread_object()
          privacy <- c(privacy, x)
        }
      } else {
        privacy <- NULL
      }
      if (flags & 8) views <- reader$tgread_object() else views <- NULL
      if (flags & 32768) sent_reaction <- reader$tgread_object() else sent_reaction <- NULL
      if (flags & 524288) {
        reader$read_int()
        albums <- list()
        for (i in 1:reader$read_int()) {
          x <- reader$read_int()
          albums <- c(albums, x)
        }
      } else {
        albums <- NULL
      }
      list(id = id, date = date, expire_date = expire_date, media = media, pinned = pinned, public = public, close_friends = close_friends, min = min, noforwards = noforwards, edited = edited, contacts = contacts, selected_contacts = selected_contacts, out = out, from_id = from_id, fwd_from = fwd_from, caption = caption, entities = entities, media_areas = media_areas, privacy = privacy, views = views, sent_reaction = sent_reaction, albums = albums)
    }
  ),
  class = TRUE
)

#  @title StoryItemDeleted
#  @description Telegram API type StoryItemDeleted
#  @export
#  @noRd
#  @noRd
StoryItemDeleted <- R6::R6Class("StoryItemDeleted",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0x4f, 0xee, 0xe6, 0x51)) + pack("i", self$id)
  ),
  private = list(
    from_reader = function(reader) list(id = reader$read_int())
  ),
  class = TRUE
)

#  @title StoryItemSkipped
#  @description Telegram API type StoryItemSkipped
#  @export
#  @noRd
#  @noRd
StoryItemSkipped <- R6::R6Class("StoryItemSkipped",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0x13, 0xc9, 0xad, 0xff)) + pack("I", (if (is.null(self$close_friends)) 0 else 256)) + pack("i", self$id) + self$serialize_datetime(self$date) + self$serialize_datetime(self$expire_date)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      close_friends <- (flags & 256) != 0
      id <- reader$read_int()
      date <- reader$tgread_date()
      expire_date <- reader$tgread_date()
      list(id = id, date = date, expire_date = expire_date, close_friends = close_friends)
    }
  ),
  class = TRUE
)

#  @title StoryReaction
#  @description Telegram API type StoryReaction
#  @export
#  @noRd
#  @noRd
StoryReaction <- R6::R6Class("StoryReaction",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0xd5, 0xd6, 0x90, 0x60)) + self$peer_id$bytes() + self$serialize_datetime(self$date) + self$reaction$bytes()
  ),
  private = list(
    from_reader = function(reader) list(peer_id = reader$tgread_object(), date = reader$tgread_date(), reaction = reader$tgread_object())
  ),
  class = TRUE
)

#  @title StoryReactionPublicForward
#  @description Telegram API type StoryReactionPublicForward
#  @export
#  @noRd
#  @noRd
StoryReactionPublicForward <- R6::R6Class("StoryReactionPublicForward",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0x43, 0x26, 0xab, 0xbb)) + self$message$bytes()
  ),
  private = list(
    from_reader = function(reader) list(message = reader$tgread_object())
  ),
  class = TRUE
)

#  @title StoryReactionPublicRepost
#  @description Telegram API type StoryReactionPublicRepost
#  @export
#  @noRd
#  @noRd
StoryReactionPublicRepost <- R6::R6Class("StoryReactionPublicRepost",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0x13, 0x0f, 0xcd, 0xcf)) + self$peer_id$bytes() + self$story$bytes()
  ),
  private = list(
    from_reader = function(reader) list(peer_id = reader$tgread_object(), story = reader$tgread_object())
  ),
  class = TRUE
)

#  @title StoryView
#  @description Telegram API type StoryView
#  @export
#  @noRd
#  @noRd
StoryView <- R6::R6Class("StoryView",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0xc5, 0xea, 0xbd, 0xb0)) + pack("I", (if (is.null(self$blocked)) 0 else 1) | (if (is.null(self$blocked_my_stories_from)) 0 else 2) | (if (is.null(self$reaction)) 0 else 4)) + pack("q", self$user_id) + self$serialize_datetime(self$date) + if (!is.null(self$reaction)) self$reaction$bytes() else raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      blocked <- (flags & 1) != 0
      blocked_my_stories_from <- (flags & 2) != 0
      user_id <- reader$read_long()
      date <- reader$tgread_date()
      if (flags & 4) reaction <- reader$tgread_object() else reaction <- NULL
      list(user_id = user_id, date = date, blocked = blocked, blocked_my_stories_from = blocked_my_stories_from, reaction = reaction)
    }
  ),
  class = TRUE
)

#  @title StoryViewPublicForward
#  @description Telegram API type StoryViewPublicForward
#  @export
#  @noRd
#  @noRd
StoryViewPublicForward <- R6::R6Class("StoryViewPublicForward",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0x0b, 0x67, 0x83, 0x90)) + pack("I", (if (is.null(self$blocked)) 0 else 1) | (if (is.null(self$blocked_my_stories_from)) 0 else 2)) + self$message$bytes()
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      blocked <- (flags & 1) != 0
      blocked_my_stories_from <- (flags & 2) != 0
      message <- reader$tgread_object()
      list(message = message, blocked = blocked, blocked_my_stories_from = blocked_my_stories_from)
    }
  ),
  class = TRUE
)

#  @title StoryViewPublicRepost
#  @description Telegram API type StoryViewPublicRepost
#  @export
#  @noRd
#  @noRd
StoryViewPublicRepost <- R6::R6Class("StoryViewPublicRepost",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0x49, 0xcf, 0x74, 0xbd)) + pack("I", (if (is.null(self$blocked)) 0 else 1) | (if (is.null(self$blocked_my_stories_from)) 0 else 2)) + self$peer_id$bytes() + self$story$bytes()
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      blocked <- (flags & 1) != 0
      blocked_my_stories_from <- (flags & 2) != 0
      peer_id <- reader$tgread_object()
      story <- reader$tgread_object()
      list(peer_id = peer_id, story = story, blocked = blocked, blocked_my_stories_from = blocked_my_stories_from)
    }
  ),
  class = TRUE
)

#  @title StoryViews
#  @description Telegram API type StoryViews
#  @export
#  @noRd
#  @noRd
StoryViews <- R6::R6Class("StoryViews",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0xd6, 0x5c, 0x59, 0x8d)) + pack("I", (if (is.null(self$has_viewers)) 0 else 2) | (if (is.null(self$forwards_count)) 0 else 4) | (if (is.null(self$reactions)) 0 else 8) | (if (is.null(self$reactions_count)) 0 else 16) | (if (is.null(self$recent_viewers)) 0 else 1)) + pack("i", self$views_count) + if (!is.null(self$forwards_count)) pack("i", self$forwards_count) else raw(0) + if (!is.null(self$reactions)) (as.raw(c(0x15, 0xc4, 0xb5, 0x1c)) + pack("i", length(self$reactions)) + do.call(c, lapply(self$reactions, function(x) x$bytes()))) else raw(0) + if (!is.null(self$reactions_count)) pack("i", self$reactions_count) else raw(0) + if (!is.null(self$recent_viewers)) (as.raw(c(0x15, 0xc4, 0xb5, 0x1c)) + pack("i", length(self$recent_viewers)) + do.call(c, lapply(self$recent_viewers, function(x) pack("q", x)))) else raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      has_viewers <- (flags & 2) != 0
      views_count <- reader$read_int()
      if (flags & 4) forwards_count <- reader$read_int() else forwards_count <- NULL
      if (flags & 8) {
        reader$read_int()
        reactions <- list()
        for (i in 1:reader$read_int()) {
          x <- reader$tgread_object()
          reactions <- c(reactions, x)
        }
      } else {
        reactions <- NULL
      }
      if (flags & 16) reactions_count <- reader$read_int() else reactions_count <- NULL
      if (flags & 1) {
        reader$read_int()
        recent_viewers <- list()
        for (i in 1:reader$read_int()) {
          x <- reader$read_long()
          recent_viewers <- c(recent_viewers, x)
        }
      } else {
        recent_viewers <- NULL
      }
      list(views_count = views_count, has_viewers = has_viewers, forwards_count = forwards_count, reactions = reactions, reactions_count = reactions_count, recent_viewers = recent_viewers)
    }
  ),
  class = TRUE
)

#  @title SuggestedPost
#  @description Telegram API type SuggestedPost
#  @export
#  @noRd
#  @noRd
SuggestedPost <- R6::R6Class("SuggestedPost",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0xe5, 0x37, 0x8e, 0x0e)) + pack("I", (if (is.null(self$accepted)) 0 else 2) | (if (is.null(self$rejected)) 0 else 4) | (if (is.null(self$price)) 0 else 8) | (if (is.null(self$schedule_date)) 0 else 1)) + if (!is.null(self$price)) self$price$bytes() else raw(0) + if (!is.null(self$schedule_date)) self$serialize_datetime(self$schedule_date) else raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      accepted <- (flags & 2) != 0
      rejected <- (flags & 4) != 0
      if (flags & 8) price <- reader$tgread_object() else price <- NULL
      if (flags & 1) schedule_date <- reader$tgread_date() else schedule_date <- NULL
      list(accepted = accepted, rejected = rejected, price = price, schedule_date = schedule_date)
    }
  ),
  class = TRUE
)

#  @title TextAnchor
#  @description Telegram API type TextAnchor
#  @export
#  @noRd
#  @noRd
TextAnchor <- R6::R6Class("TextAnchor",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0x62, 0x37, 0x55, 0x35)) + self$text$bytes() + self$serializebytes(self$name)
  ),
  private = list(
    from_reader = function(reader) list(text = reader$tgread_object(), name = reader$tgread_string())
  ),
  class = TRUE
)

#  @title TextBold
#  @description Telegram API type TextBold
#  @export
#  @noRd
#  @noRd
TextBold <- R6::R6Class("TextBold",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0xc4, 0xab, 0x24, 0x67)) + self$text$bytes()
  ),
  private = list(
    from_reader = function(reader) list(text = reader$tgread_object())
  ),
  class = TRUE
)

#  @title TextConcat
#  @description Telegram API type TextConcat
#  @export
#  @noRd
#  @noRd
TextConcat <- R6::R6Class("TextConcat",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0xd7, 0x60, 0x62, 0x7e)) + as.raw(c(0x15, 0xc4, 0xb5, 0x1c)) + pack("i", length(self$texts)) + do.call(c, lapply(self$texts, function(x) x$bytes()))
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      texts <- list()
      for (i in 1:reader$read_int()) {
        x <- reader$tgread_object()
        texts <- c(texts, x)
      }
      list(texts = texts)
    }
  ),
  class = TRUE
)

#  @title TextEmail
#  @description Telegram API type TextEmail
#  @export
#  @noRd
#  @noRd
TextEmail <- R6::R6Class("TextEmail",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0xd6, 0x0d, 0x5a, 0xde)) + self$text$bytes() + self$serializebytes(self$email)
  ),
  private = list(
    from_reader = function(reader) list(text = reader$tgread_object(), email = reader$tgread_string())
  ),
  class = TRUE
)

#  @title TextEmpty
#  @description Telegram API type TextEmpty
#  @export
#  @noRd
#  @noRd
TextEmpty <- R6::R6Class("TextEmpty",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0x4f, 0x82, 0x3d, 0xdc))
  ),
  private = list(
    from_reader = function(reader) self
  ),
  class = TRUE
)

#  @title TextFixed
#  @description Telegram API type TextFixed
#  @export
#  @noRd
#  @noRd
TextFixed <- R6::R6Class("TextFixed",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0xb9, 0x19, 0x3f, 0x6c)) + self$text$bytes()
  ),
  private = list(
    from_reader = function(reader) list(text = reader$tgread_object())
  ),
  class = TRUE
)

#  @title TlsBlockString
#  @description Telegram API type TlsBlockString
#  @export
#  @noRd
#  @noRd
TlsBlockString <- R6::R6Class("TlsBlockString",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4218a164,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf1163490,
    initialize = function(data) {
      self$data <- data
    },
    to_dict = function() {
      list(`_` = "TlsBlockString", data = self$data)
    },
    bytes = function() as.raw(c(0x64, 0xa1, 0x18, 0x42)) + self$serializebytes(self$data)
  ),
  private = list(
    from_reader = function(reader) list(data = reader$tgread_string())
  ),
  class = TRUE
)

#  @title TlsBlockZero
#  @description Telegram API type TlsBlockZero
#  @export
#  @noRd
#  @noRd
TlsBlockZero <- R6::R6Class("TlsBlockZero",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9333afb,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf1163490,
    initialize = function(length) {
      self$length <- length
    },
    to_dict = function() {
      list(`_` = "TlsBlockZero", length = self$length)
    },
    bytes = function() as.raw(c(0xfb, 0x3a, 0x33, 0x09)) + pack("i", self$length)
  ),
  private = list(
    from_reader = function(reader) list(length = reader$read_int())
  ),
  class = TRUE
)

#  @title TextImage
#  @description Telegram API type TextImage
#  @export
#  @noRd
#  @noRd
TextImage <- R6::R6Class("TextImage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x81ccf4f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf1d0b479,
    initialize = function(document_id, w, h) {
      self$document_id <- document_id
      self$w <- w
      self$h <- h
    },
    to_dict = function() {
      list(`_` = "TextImage", document_id = self$document_id, w = self$w, h = self$h)
    },
    bytes = function() as.raw(c(0x4f, 0xcf, 0x1c, 0x08)) + pack("q", self$document_id) + pack("i", self$w) + pack("i", self$h)
  ),
  private = list(
    from_reader = function(reader) list(document_id = reader$read_long(), w = reader$read_int(), h = reader$read_int())
  ),
  class = TRUE
)

#  @title TextItalic
#  @description Telegram API type TextItalic
#  @export
#  @noRd
#  @noRd
TextItalic <- R6::R6Class("TextItalic",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd912a59c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf1d0b479,
    initialize = function(text) {
      self$text <- text
    },
    to_dict = function() {
      list(`_` = "TextItalic", text = self$text$to_dict())
    },
    bytes = function() as.raw(c(0x9c, 0xa5, 0x12, 0xd9)) + self$text$bytes()
  ),
  private = list(
    from_reader = function(reader) list(text = reader$tgread_object())
  ),
  class = TRUE
)

#  @title TextMarked
#  @description Telegram API type TextMarked
#  @export
#  @noRd
#  @noRd
TextMarked <- R6::R6Class("TextMarked",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x34b8621,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf1d0b479,
    initialize = function(text) {
      self$text <- text
    },
    to_dict = function() {
      list(`_` = "TextMarked", text = self$text$to_dict())
    },
    bytes = function() as.raw(c(0x21, 0x86, 0x4b, 0x03)) + self$text$bytes()
  ),
  private = list(
    from_reader = function(reader) list(text = reader$tgread_object())
  ),
  class = TRUE
)

#  @title TextPhone
#  @description Telegram API type TextPhone
#  @export
#  @noRd
#  @noRd
TextPhone <- R6::R6Class("TextPhone",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1ccb966a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf1d0b479,
    initialize = function(text, phone) {
      self$text <- text
      self$phone <- phone
    },
    to_dict = function() {
      list(`_` = "TextPhone", text = self$text$to_dict(), phone = self$phone)
    },
    bytes = function() as.raw(c(0x6a, 0x96, 0xcb, 0x1c)) + self$text$bytes() + self$serializebytes(self$phone)
  ),
  private = list(
    from_reader = function(reader) list(text = reader$tgread_object(), phone = reader$tgread_string())
  ),
  class = TRUE
)

#  @title TextPlain
#  @description Telegram API type TextPlain
#  @export
#  @noRd
#  @noRd
TextPlain <- R6::R6Class("TextPlain",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x744694e0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf1d0b479,
    initialize = function(text) {
      self$text <- text
    },
    to_dict = function() {
      list(`_` = "TextPlain", text = self$text)
    },
    bytes = function() as.raw(c(0xe0, 0x94, 0x46, 0x74)) + self$serializebytes(self$text)
  ),
  private = list(
    from_reader = function(reader) list(text = reader$tgread_string())
  ),
  class = TRUE
)

#  @title TextStrike
#  @description Telegram API type TextStrike
#  @export
#  @noRd
#  @noRd
TextStrike <- R6::R6Class("TextStrike",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9bf8bb95,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf1d0b479,
    initialize = function(text) {
      self$text <- text
    },
    to_dict = function() {
      list(`_` = "TextStrike", text = self$text$to_dict())
    },
    bytes = function() as.raw(c(0x95, 0xbb, 0xf8, 0x9b)) + self$text$bytes()
  ),
  private = list(
    from_reader = function(reader) list(text = reader$tgread_object())
  ),
  class = TRUE
)

#  @title TextSubscript
#  @description Telegram API type TextSubscript
#  @export
#  @noRd
#  @noRd
TextSubscript <- R6::R6Class("TextSubscript",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xed6a8504,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf1d0b479,
    initialize = function(text) {
      self$text <- text
    },
    to_dict = function() {
      list(`_` = "TextSubscript", text = self$text$to_dict())
    },
    bytes = function() as.raw(c(0x04, 0x85, 0x6a, 0xed)) + self$text$bytes()
  ),
  private = list(
    from_reader = function(reader) list(text = reader$tgread_object())
  ),
  class = TRUE
)

#  @title TextSuperscript
#  @description Telegram API type TextSuperscript
#  @export
#  @noRd
#  @noRd
TextSuperscript <- R6::R6Class("TextSuperscript",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc7fb5e01,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf1d0b479,
    initialize = function(text) {
      self$text <- text
    },
    to_dict = function() {
      list(`_` = "TextSuperscript", text = self$text$to_dict())
    },
    bytes = function() as.raw(c(0x01, 0x5e, 0xfb, 0xc7)) + self$text$bytes()
  ),
  private = list(
    from_reader = function(reader) list(text = reader$tgread_object())
  ),
  class = TRUE
)

#  @title TextUnderline
#  @description Telegram API type TextUnderline
#  @export
#  @noRd
#  @noRd
TextUnderline <- R6::R6Class("TextUnderline",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc12622c4,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf1d0b479,
    initialize = function(text) {
      self$text <- text
    },
    to_dict = function() {
      list(`_` = "TextUnderline", text = self$text$to_dict())
    },
    bytes = function() as.raw(c(0xc4, 0x22, 0x26, 0xc1)) + self$text$bytes()
  ),
  private = list(
    from_reader = function(reader) list(text = reader$tgread_object())
  ),
  class = TRUE
)

#  @title TextUrl
#  @description Telegram API type TextUrl
#  @export
#  @noRd
#  @noRd
TextUrl <- R6::R6Class("TextUrl",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x3c2884c1,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf1d0b479,
    initialize = function(text, url, webpage_id) {
      self$text <- text
      self$url <- url
      self$webpage_id <- webpage_id
    },
    to_dict = function() {
      list(`_` = "TextUrl", text = self$text$to_dict(), url = self$url, webpage_id = self$webpage_id)
    },
    bytes = function() as.raw(c(0xc1, 0x84, 0x28, 0x3c)) + self$text$bytes() + self$serializebytes(self$url) + pack("q", self$webpage_id)
  ),
  private = list(
    from_reader = function(reader) list(text = reader$tgread_object(), url = reader$tgread_string(), webpage_id = reader$read_long())
  ),
  class = TRUE
)

#  @title TextWithEntities
#  @description Telegram API type TextWithEntities
#  @export
#  @noRd
#  @noRd
TextWithEntities <- R6::R6Class("TextWithEntities",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x751f3146,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x95ca4b05,
    initialize = function(text, entities) {
      self$text <- text
      self$entities <- entities
    },
    to_dict = function() {
      list(`_` = "TextWithEntities", text = self$text, entities = lapply(self$entities, function(x) x$to_dict()))
    },
    bytes = function() as.raw(c(0x46, 0x31, 0x1f, 0x75)) + self$serializebytes(self$text) + as.raw(c(0x15, 0xc4, 0xb5, 0x1c)) + pack("i", length(self$entities)) + do.call(c, lapply(self$entities, function(x) x$bytes()))
  ),
  private = list(
    from_reader = function(reader) {
      text <- reader$tgread_string()
      reader$read_int()
      entities <- lapply(seq_len(reader$read_int()), function(i) reader$tgread_object())
      list(text = text, entities = entities)
    }
  ),
  class = TRUE
)

#  @title Theme
#  @description Telegram API type Theme
#  @export
#  @noRd
#  @noRd
Theme <- R6::R6Class("Theme",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa00e67d6,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x56b4c80c,
    initialize = function(id, access_hash, slug, title, creator = NULL, default = NULL, for_chat = NULL, document = NULL, settings = NULL, emoticon = NULL, installs_count = NULL) {
      self$id <- id
      self$access_hash <- access_hash
      self$slug <- slug
      self$title <- title
      self$creator <- creator
      self$default <- default
      self$for_chat <- for_chat
      self$document <- document
      self$settings <- settings
      self$emoticon <- emoticon
      self$installs_count <- installs_count
    },
    to_dict = function() {
      list(`_` = "Theme", id = self$id, access_hash = self$access_hash, slug = self$slug, title = self$title, creator = self$creator, default = self$default, for_chat = self$for_chat, document = if (is.null(self$document)) NULL else self$document$to_dict(), settings = if (is.null(self$settings)) NULL else lapply(self$settings, function(x) x$to_dict()), emoticon = self$emoticon, installs_count = self$installs_count)
    },
    bytes = function() {
      flags <- (if (is.null(self$creator) || !self$creator) 0 else 1) | (if (is.null(self$default) || !self$default) 0 else 2) | (if (is.null(self$for_chat) || !self$for_chat) 0 else 32) | (if (is.null(self$document)) 0 else 4) | (if (is.null(self$settings)) 0 else 8) | (if (is.null(self$emoticon)) 0 else 64) | (if (is.null(self$installs_count)) 0 else 16)
      as.raw(c(0xd6, 0x67, 0x0e, 0xa0)) + pack("I", flags) + pack("q", self$id) + pack("q", self$access_hash) + self$serializebytes(self$slug) + self$serializebytes(self$title) + (if (is.null(self$document)) raw(0) else self$document$bytes()) + (if (is.null(self$settings)) raw(0) else as.raw(c(0x15, 0xc4, 0xb5, 0x1c)) + pack("i", length(self$settings)) + do.call(c, lapply(self$settings, function(x) x$bytes()))) + (if (is.null(self$emoticon)) raw(0) else self$serializebytes(self$emoticon)) + (if (is.null(self$installs_count)) raw(0) else pack("i", self$installs_count))
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      creator <- (flags & 1) != 0
      default <- (flags & 2) != 0
      for_chat <- (flags & 32) != 0
      id <- reader$read_long()
      access_hash <- reader$read_long()
      slug <- reader$tgread_string()
      title <- reader$tgread_string()
      document <- if ((flags & 4) != 0) reader$tgread_object() else NULL
      settings <- if ((flags & 8) != 0) {
        reader$read_int()
        lapply(seq_len(reader$read_int()), function(i) reader$tgread_object())
      } else {
        NULL
      }
      emoticon <- if ((flags & 64) != 0) reader$tgread_string() else NULL
      installs_count <- if ((flags & 16) != 0) reader$read_int() else NULL
      list(id = id, access_hash = access_hash, slug = slug, title = title, creator = creator, default = default, for_chat = for_chat, document = document, settings = settings, emoticon = emoticon, installs_count = installs_count)
    }
  ),
  class = TRUE
)

#  @title ThemeSettings
#  @description Telegram API type ThemeSettings
#  @export
#  @noRd
#  @noRd
ThemeSettings <- R6::R6Class("ThemeSettings",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xfa58b6d4,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x82666d38,
    initialize = function(base_theme, accent_color, message_colors_animated = NULL, outbox_accent_color = NULL, message_colors = NULL, wallpaper = NULL) {
      self$base_theme <- base_theme
      self$accent_color <- accent_color
      self$message_colors_animated <- message_colors_animated
      self$outbox_accent_color <- outbox_accent_color
      self$message_colors <- message_colors
      self$wallpaper <- wallpaper
    },
    to_dict = function() {
      list(`_` = "ThemeSettings", base_theme = self$base_theme$to_dict(), accent_color = self$accent_color, message_colors_animated = self$message_colors_animated, outbox_accent_color = self$outbox_accent_color, message_colors = self$message_colors, wallpaper = if (is.null(self$wallpaper)) NULL else self$wallpaper$to_dict())
    },
    bytes = function() {
      flags <- (if (is.null(self$message_colors_animated) || !self$message_colors_animated) 0 else 4) | (if (is.null(self$outbox_accent_color)) 0 else 8) | (if (is.null(self$message_colors)) 0 else 1) | (if (is.null(self$wallpaper)) 0 else 2)
      as.raw(c(0xd4, 0xb6, 0x58, 0xfa)) + pack("I", flags) + self$base_theme$bytes() + pack("i", self$accent_color) + (if (is.null(self$outbox_accent_color)) raw(0) else pack("i", self$outbox_accent_color)) + (if (is.null(self$message_colors)) raw(0) else as.raw(c(0x15, 0xc4, 0xb5, 0x1c)) + pack("i", length(self$message_colors)) + do.call(c, lapply(self$message_colors, function(x) pack("i", x)))) + (if (is.null(self$wallpaper)) raw(0) else self$wallpaper$bytes())
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      message_colors_animated <- (flags & 4) != 0
      base_theme <- reader$tgread_object()
      accent_color <- reader$read_int()
      outbox_accent_color <- if ((flags & 8) != 0) reader$read_int() else NULL
      message_colors <- if ((flags & 1) != 0) {
        reader$read_int()
        lapply(seq_len(reader$read_int()), function(i) reader$read_int())
      } else {
        NULL
      }
      wallpaper <- if ((flags & 2) != 0) reader$tgread_object() else NULL
      list(base_theme = base_theme, accent_color = accent_color, message_colors_animated = message_colors_animated, outbox_accent_color = outbox_accent_color, message_colors = message_colors, wallpaper = wallpaper)
    }
  ),
  class = TRUE
)

#  @title Timezone
#  @description Telegram API type Timezone
#  @export
#  @noRd
#  @noRd
Timezone <- R6::R6Class("Timezone",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xff9289f5,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xce77d0c1,
    initialize = function(id, name, utc_offset) {
      self$id <- id
      self$name <- name
      self$utc_offset <- utc_offset
    },
    to_dict = function() {
      list(`_` = "Timezone", id = self$id, name = self$name, utc_offset = self$utc_offset)
    },
    bytes = function() as.raw(c(0xf5, 0x89, 0x92, 0xff)) + self$serializebytes(self$id) + self$serializebytes(self$name) + pack("i", self$utc_offset)
  ),
  private = list(
    from_reader = function(reader) list(id = reader$tgread_string(), name = reader$tgread_string(), utc_offset = reader$read_int())
  ),
  class = TRUE
)

#  @title TlsBlockDomain
#  @description Telegram API type TlsBlockDomain
#  @export
#  @noRd
#  @noRd
TlsBlockDomain <- R6::R6Class("TlsBlockDomain",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x10e8636f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf1163490,
    to_dict = function() {
      list(`_` = "TlsBlockDomain")
    },
    bytes = function() as.raw(c(0x6f, 0x63, 0xe8, 0x10))
  ),
  private = list(
    from_reader = function(reader) self
  ),
  class = TRUE
)

#  @title TlsBlockGrease
#  @description Telegram API type TlsBlockGrease
#  @export
#  @noRd
#  @noRd
TlsBlockGrease <- R6::R6Class("TlsBlockGrease",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe675a1c1,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf1163490,
    initialize = function(seed) {
      self$seed <- seed
    },
    to_dict = function() {
      list(`_` = "TlsBlockGrease", seed = self$seed)
    },
    bytes = function() as.raw(c(0xc1, 0xa1, 0x75, 0xe6)) + pack("i", self$seed)
  ),
  private = list(
    from_reader = function(reader) list(seed = reader$read_int())
  ),
  class = TRUE
)

#  @title TlsBlockPublicKey
#  @description Telegram API type TlsBlockPublicKey
#  @export
#  @noRd
#  @noRd
TlsBlockPublicKey <- R6::R6Class("TlsBlockPublicKey",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9eb95b5c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf1163490,
    to_dict = function() {
      list(`_` = "TlsBlockPublicKey")
    },
    bytes = function() as.raw(c(0x5c, 0x5b, 0xb9, 0x9e))
  ),
  private = list(
    from_reader = function(reader) self
  ),
  class = TRUE
)

#  @title TlsBlockRandom
#  @description Telegram API type TlsBlockRandom
#  @export
#  @noRd
#  @noRd
TlsBlockRandom <- R6::R6Class("TlsBlockRandom",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4d4dc41e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf1163490,
    initialize = function(length) {
      self$length <- length
    },
    to_dict = function() {
      list(`_` = "TlsBlockRandom", length = self$length)
    },
    bytes = function() as.raw(c(0x1e, 0xc4, 0x4d, 0x4d)) + pack("i", self$length)
  ),
  private = list(
    from_reader = function(reader) list(length = reader$read_int())
  ),
  class = TRUE
)

#  @title TlsBlockScope
#  @description Telegram API type TlsBlockScope
#  @export
#  @noRd
#  @noRd
TlsBlockScope <- R6::R6Class("TlsBlockScope",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe725d44f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xf1163490,
    initialize = function(entries) {
      self$entries <- entries
    },
    to_dict = function() {
      list(`_` = "TlsBlockScope", entries = lapply(self$entries, function(x) x$to_dict()))
    },
    bytes = function() as.raw(c(0x4f, 0xd4, 0x25, 0xe7)) + as.raw(c(0x15, 0xc4, 0xb5, 0x1c)) + pack("i", length(self$entries)) + do.call(c, lapply(self$entries, function(x) x$bytes()))
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      entries <- lapply(seq_len(reader$read_int()), function(i) reader$tgread_object())
      list(entries = entries)
    }
  ),
  class = TRUE
)

#  @title TlsClientHello
#  @description Telegram API type TlsClientHello
#  @export
#  @noRd
#  @noRd
TlsClientHello <- R6::R6Class(
  "TlsClientHello",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x6c52c484,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbef20920,
    #  @field blocks Field.
    blocks = NULL,
    initialize = function(blocks) {
      self$blocks <- blocks
    },
    to_dict = function() {
      list(
        `_` = "TlsClientHello",
        blocks = if (is.null(self$blocks)) {
          list()
        } else {
          lapply(self$blocks, function(x) {
            if (inherits(x, "TLObject")) x$to_dict() else x
          })
        }
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x84, 0xc4, 0x52, 0x6c)),
        pack("i", length(self$blocks)),
        do.call(c, lapply(self$blocks, function(x) x$bytes()))
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      blocks <- vector("list", reader$read_int())
      for (i in seq_along(blocks)) {
        blocks[[i]] <- reader$tgread_object()
      }
      self$new(blocks = blocks)
    }
  )
)

#  @title TodoCompletion
#  @description Telegram API type TodoCompletion
#  @export
#  @noRd
#  @noRd
TodoCompletion <- R6::R6Class(
  "TodoCompletion",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4cc120b7,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xbae65b7b,
    #  @field id Field.
    id = NULL,
    #  @field completed_by Field.
    completed_by = NULL,
    #  @field date Field.
    date = NULL,
    initialize = function(id, completed_by, date) {
      self$id <- id
      self$completed_by <- completed_by
      self$date <- date
    },
    to_dict = function() {
      list(
        `_` = "TodoCompletion",
        id = self$id,
        completed_by = self$completed_by,
        date = self$date
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xb7, 0x20, 0xc1, 0x4c)),
        pack("i", self$id),
        pack("q", self$completed_by),
        self$serialize_datetime(self$date)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      id <- reader$read_int()
      completed_by <- reader$read_long()
      date <- reader$tgread_date()
      self$new(id = id, completed_by = completed_by, date = date)
    }
  )
)

#  @title TodoItem
#  @description Telegram API type TodoItem
#  @export
#  @noRd
#  @noRd
TodoItem <- R6::R6Class(
  "TodoItem",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xcba9a52f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xdfdae6b5,
    #  @field id Field.
    id = NULL,
    #  @field title Field.
    title = NULL,
    initialize = function(id, title) {
      self$id <- id
      self$title <- title
    },
    to_dict = function() {
      list(
        `_` = "TodoItem",
        id = self$id,
        title = if (inherits(self$title, "TLObject")) self$title$to_dict() else self$title
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x2f, 0xa5, 0xa9, 0xcb)),
        pack("i", self$id),
        self$title$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      id <- reader$read_int()
      title <- reader$tgread_object()
      self$new(id = id, title = title)
    }
  )
)

#  @title TodoList
#  @description Telegram API type TodoList
#  @export
#  @noRd
#  @noRd
TodoList <- R6::R6Class(
  "TodoList",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x49b92a26,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x84093bb3,
    #  @field title Field.
    title = NULL,
    #  @field list Field.
    list = NULL,
    #  @field others_can_append Field.
    others_can_append = NULL,
    #  @field others_can_complete Field.
    others_can_complete = NULL,
    initialize = function(title, list, others_can_append = NULL, others_can_complete = NULL) {
      self$title <- title
      self$list <- list
      self$others_can_append <- others_can_append
      self$others_can_complete <- others_can_complete
    },
    to_dict = function() {
      list(
        `_` = "TodoList",
        title = if (inherits(self$title, "TLObject")) self$title$to_dict() else self$title,
        list = if (is.null(self$list)) list() else lapply(self$list, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        others_can_append = self$others_can_append,
        others_can_complete = self$others_can_complete
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x26, 0x2a, 0xb9, 0x49)),
        pack("I", (if (is.null(self$others_can_append) || !self$others_can_append) 0 else 1) |
          (if (is.null(self$others_can_complete) || !self$others_can_complete) 0 else 2)),
        self$title$bytes(),
        as.raw(c(0x1c, 0xb5, 0xc4, 0x15)),
        pack("i", length(self$list)),
        do.call(c, lapply(self$list, function(x) x$bytes()))
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      others_can_append <- as.logical(bitwAnd(flags, 1))
      others_can_complete <- as.logical(bitwAnd(flags, 2))
      title <- reader$tgread_object()
      reader$read_int()
      list_items <- lapply(seq_len(reader$read_int()), function(x) reader$tgread_object())
      self$new(title = title, list = list_items, others_can_append = others_can_append, others_can_complete = others_can_complete)
    }
  )
)

#  @title TopPeer
#  @description Telegram API type TopPeer
#  @export
#  @noRd
#  @noRd
TopPeer <- R6::R6Class(
  "TopPeer",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xedcdc05b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x6916c601,
    #  @field peer Field.
    peer = NULL,
    #  @field rating Field.
    rating = NULL,
    initialize = function(peer, rating) {
      self$peer <- peer
      self$rating <- rating
    },
    to_dict = function() {
      list(
        `_` = "TopPeer",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        rating = self$rating
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x5b, 0xc0, 0xcd, 0xed)),
        self$peer$bytes(),
        pack("d", self$rating)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      rating <- reader$read_double()
      self$new(peer = peer, rating = rating)
    }
  )
)

#  @title TopPeerCategoryBotsApp
#  @description Telegram API type TopPeerCategoryBotsApp
#  @export
#  @noRd
#  @noRd
TopPeerCategoryBotsApp <- R6::R6Class(
  "TopPeerCategoryBotsApp",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xfd9e7bec,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xddf02502,
    to_dict = function() {
      list(`_` = "TopPeerCategoryBotsApp")
    },
    bytes = function() {
      as.raw(c(0xec, 0x7b, 0x9e, 0xfd))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$new()
    }
  ),
  class = TRUE
)

#  @title TopPeerCategoryBotsInline
#  @description Telegram API type TopPeerCategoryBotsInline
#  @export
#  @noRd
#  @noRd
TopPeerCategoryBotsInline <- R6::R6Class(
  "TopPeerCategoryBotsInline",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x148677e2,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xddf02502,
    to_dict = function() {
      list(`_` = "TopPeerCategoryBotsInline")
    },
    bytes = function() {
      as.raw(c(0xe2, 0x77, 0x86, 0x14))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$new()
    }
  ),
  class = TRUE
)

#  @title TopPeerCategoryBotsPM
#  @description Telegram API type TopPeerCategoryBotsPM
#  @export
#  @noRd
#  @noRd
TopPeerCategoryBotsPM <- R6::R6Class(
  "TopPeerCategoryBotsPM",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xab661b5b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xddf02502,
    to_dict = function() {
      list(`_` = "TopPeerCategoryBotsPM")
    },
    bytes = function() {
      as.raw(c(0x5b, 0x1b, 0x66, 0xab))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$new()
    }
  ),
  class = TRUE
)

#  @title TopPeerCategoryChannels
#  @description Telegram API type TopPeerCategoryChannels
#  @export
#  @noRd
#  @noRd
TopPeerCategoryChannels <- R6::R6Class(
  "TopPeerCategoryChannels",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x161d9628,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xddf02502,
    to_dict = function() {
      list(`_` = "TopPeerCategoryChannels")
    },
    bytes = function() {
      as.raw(c(0x28, 0x96, 0x1d, 0x16))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$new()
    }
  ),
  class = TRUE
)

#  @title TopPeerCategoryCorrespondents
#  @description Telegram API type TopPeerCategoryCorrespondents
#  @export
#  @noRd
#  @noRd
TopPeerCategoryCorrespondents <- R6::R6Class(
  "TopPeerCategoryCorrespondents",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x637b7ed,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xddf02502,
    to_dict = function() {
      list(`_` = "TopPeerCategoryCorrespondents")
    },
    bytes = function() {
      as.raw(c(0xed, 0xb7, 0x37, 0x06))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$new()
    }
  ),
  class = TRUE
)

#  @title TopPeerCategoryForwardChats
#  @description Telegram API type TopPeerCategoryForwardChats
#  @export
#  @noRd
#  @noRd
TopPeerCategoryForwardChats <- R6::R6Class(
  "TopPeerCategoryForwardChats",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xfbeec0f0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xddf02502,
    to_dict = function() {
      list(`_` = "TopPeerCategoryForwardChats")
    },
    bytes = function() {
      as.raw(c(0xf0, 0xc0, 0xee, 0xfb))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$new()
    }
  ),
  class = TRUE
)

#  @title TopPeerCategoryForwardUsers
#  @description Telegram API type TopPeerCategoryForwardUsers
#  @export
#  @noRd
#  @noRd
TopPeerCategoryForwardUsers <- R6::R6Class(
  "TopPeerCategoryForwardUsers",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa8406ca9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xddf02502,
    to_dict = function() {
      list(`_` = "TopPeerCategoryForwardUsers")
    },
    bytes = function() {
      as.raw(c(0xa9, 0x6c, 0x40, 0xa8))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$new()
    }
  ),
  class = TRUE
)

#  @title TopPeerCategoryGroups
#  @description Telegram API type TopPeerCategoryGroups
#  @export
#  @noRd
#  @noRd
TopPeerCategoryGroups <- R6::R6Class(
  "TopPeerCategoryGroups",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbd17a14a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xddf02502,
    to_dict = function() {
      list(`_` = "TopPeerCategoryGroups")
    },
    bytes = function() {
      as.raw(c(0xbd, 0x17, 0xa1, 0x4a))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$new()
    }
  ),
  class = TRUE
)

#  @title TopPeerCategoryPeers
#  @description Telegram API type TopPeerCategoryPeers
#  @export
#  @noRd
#  @noRd
TopPeerCategoryPeers <- R6::R6Class(
  "TopPeerCategoryPeers",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xfb834291,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x4aec930,
    initialize = function(category, count, peers) {
      self$category <- category
      self$count <- count
      self$peers <- peers
    },
    to_dict = function() {
      list(
        `_` = "TopPeerCategoryPeers",
        category = if (inherits(self$category, "TLObject")) self$category$to_dict() else self$category,
        count = self$count,
        peers = if (is.null(self$peers)) list() else lapply(self$peers, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x91, 0x42, 0x83, 0xfb)),
        self$category$bytes(),
        pack("i", self$count),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)),
        pack("i", length(self$peers)),
        do.call(c, lapply(self$peers, function(x) x$bytes()))
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      category <- reader$tgread_object()
      count <- reader$read_int()
      reader$read_int()
      peers <- lapply(seq_len(reader$read_int()), function(x) reader$tgread_object())
      self$new(category = category, count = count, peers = peers)
    }
  ),
  class = TRUE
)

#  @title TopPeerCategoryPhoneCalls
#  @description Telegram API type TopPeerCategoryPhoneCalls
#  @export
#  @noRd
#  @noRd
TopPeerCategoryPhoneCalls <- R6::R6Class(
  "TopPeerCategoryPhoneCalls",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1e76a78c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xddf02502,
    to_dict = function() {
      list(`_` = "TopPeerCategoryPhoneCalls")
    },
    bytes = function() {
      as.raw(c(0x8c, 0xa7, 0x76, 0x1e))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$new()
    }
  ),
  class = TRUE
)

#  @title UpdateAttachMenuBots
#  @description Telegram API type UpdateAttachMenuBots
#  @export
#  @noRd
#  @noRd
UpdateAttachMenuBots <- R6::R6Class(
  "UpdateAttachMenuBots",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x17b7a20b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    to_dict = function() {
      list(`_` = "UpdateAttachMenuBots")
    },
    bytes = function() {
      as.raw(c(0x0b, 0xa2, 0xb7, 0x17))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$new()
    }
  ),
  class = TRUE
)

#  @title UpdateAutoSaveSettings
#  @description Telegram API type UpdateAutoSaveSettings
#  @export
#  @noRd
#  @noRd
UpdateAutoSaveSettings <- R6::R6Class(
  "UpdateAutoSaveSettings",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xec05b097,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    to_dict = function() {
      list(`_` = "UpdateAutoSaveSettings")
    },
    bytes = function() {
      as.raw(c(0x97, 0xb0, 0x05, 0xec))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$new()
    }
  ),
  class = TRUE
)

#  @title UpdateBotBusinessConnect
#  @description Telegram API type UpdateBotBusinessConnect
#  @export
#  @noRd
#  @noRd
UpdateBotBusinessConnect <- R6::R6Class(
  "UpdateBotBusinessConnect",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8ae5c97a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(connection, qts) {
      self$connection <- connection
      self$qts <- qts
    },
    to_dict = function() {
      list(
        `_` = "UpdateBotBusinessConnect",
        connection = if (inherits(self$connection, "TLObject")) self$connection$to_dict() else self$connection,
        qts = self$qts
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x7a, 0xc9, 0xe5, 0x8a)),
        self$connection$bytes(),
        pack("i", self$qts)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      connection <- reader$tgread_object()
      qts <- reader$read_int()
      self$new(connection = connection, qts = qts)
    }
  ),
  class = TRUE
)

#  @title UpdateBotCallbackQuery
#  @description Telegram API type UpdateBotCallbackQuery
#  @export
#  @noRd
#  @noRd
UpdateBotCallbackQuery <- R6::R6Class(
  "UpdateBotCallbackQuery",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb9cfc48d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(query_id, user_id, peer, msg_id, chat_instance, data = NULL, game_short_name = NULL) {
      self$query_id <- query_id
      self$user_id <- user_id
      self$peer <- peer
      self$msg_id <- msg_id
      self$chat_instance <- chat_instance
      self$data <- data
      self$game_short_name <- game_short_name
    },
    to_dict = function() {
      list(
        `_` = "UpdateBotCallbackQuery",
        query_id = self$query_id,
        user_id = self$user_id,
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        msg_id = self$msg_id,
        chat_instance = self$chat_instance,
        data = self$data,
        game_short_name = self$game_short_name
      )
    },
    bytes = function() {
      as.raw(c(0x8d, 0xc4, 0xcf, 0xb9)) +
        pack("I", (if (is.null(self$data)) 0 else 1) | (if (is.null(self$game_short_name)) 0 else 2)) +
        pack("q", self$query_id) +
        pack("q", self$user_id) +
        self$peer$bytes() +
        pack("i", self$msg_id) +
        pack("q", self$chat_instance) +
        (if (!is.null(self$data)) self$serialize_bytes(self$data) else raw(0)) +
        (if (!is.null(self$game_short_name)) self$serialize_bytes(self$game_short_name) else raw(0))
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      query_id <- reader$read_long()
      user_id <- reader$read_long()
      peer <- reader$tgread_object()
      msg_id <- reader$read_int()
      chat_instance <- reader$read_long()
      data <- if (flags & 1) reader$tgread_bytes() else NULL
      game_short_name <- if (flags & 2) reader$tgread_string() else NULL
      self$new(query_id = query_id, user_id = user_id, peer = peer, msg_id = msg_id, chat_instance = chat_instance, data = data, game_short_name = game_short_name)
    }
  ),
  class = TRUE
)

#  @title UpdateBotChatBoost
#  @description Telegram API type UpdateBotChatBoost
#  @export
#  @noRd
#  @noRd
UpdateBotChatBoost <- R6::R6Class(
  "UpdateBotChatBoost",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x904dd49c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(peer, boost, qts) {
      self$peer <- peer
      self$boost <- boost
      self$qts <- qts
    },
    to_dict = function() {
      list(
        `_` = "UpdateBotChatBoost",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        boost = if (inherits(self$boost, "TLObject")) self$boost$to_dict() else self$boost,
        qts = self$qts
      )
    },
    bytes = function() {
      as.raw(c(0x9c, 0xd4, 0x4d, 0x90)) +
        self$peer$bytes() +
        self$boost$bytes() +
        pack("i", self$qts)
    }
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      boost <- reader$tgread_object()
      qts <- reader$read_int()
      self$new(peer = peer, boost = boost, qts = qts)
    }
  ),
  class = TRUE
)

#  @title UpdateBotChatInviteRequester
#  @description Telegram API type UpdateBotChatInviteRequester
#  @export
#  @noRd
#  @noRd
UpdateBotChatInviteRequester <- R6::R6Class(
  "UpdateBotChatInviteRequester",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x11dfa986,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(peer, date, user_id, about, invite, qts) {
      self$peer <- peer
      self$date <- date
      self$user_id <- user_id
      self$about <- about
      self$invite <- invite
      self$qts <- qts
    },
    to_dict = function() {
      list(
        `_` = "UpdateBotChatInviteRequester",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        date = self$date,
        user_id = self$user_id,
        about = self$about,
        invite = if (inherits(self$invite, "TLObject")) self$invite$to_dict() else self$invite,
        qts = self$qts
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x86, 0xa9, 0xdf, 0x11)),
        self$peer$bytes(),
        self$serialize_datetime(self$date),
        pack("q", self$user_id),
        self$serialize_bytes(self$about),
        self$invite$bytes(),
        pack("i", self$qts)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      date <- reader$tgread_date()
      user_id <- reader$read_long()
      about <- reader$tgread_string()
      invite <- reader$tgread_object()
      qts <- reader$read_int()
      self$new(peer = peer, date = date, user_id = user_id, about = about, invite = invite, qts = qts)
    }
  ),
  class = TRUE
)

#  @title UpdateBotCommands
#  @description Telegram API type UpdateBotCommands
#  @export
#  @noRd
#  @noRd
UpdateBotCommands <- R6::R6Class(
  "UpdateBotCommands",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4d712f2e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(peer, bot_id, commands) {
      self$peer <- peer
      self$bot_id <- bot_id
      self$commands <- commands
    },
    to_dict = function() {
      list(
        `_` = "UpdateBotCommands",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        bot_id = self$bot_id,
        commands = if (is.null(self$commands)) list() else lapply(self$commands, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x2e, 0x71, 0xd7, 0x4d)),
        self$peer$bytes(),
        pack("q", self$bot_id),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)),
        pack("i", length(self$commands)),
        do.call(c, lapply(self$commands, function(x) x$bytes()))
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      bot_id <- reader$read_long()
      reader$read_int()
      commands <- vector("list", reader$read_int())
      for (i in seq_along(commands)) {
        commands[[i]] <- reader$tgread_object()
      }
      self$new(peer = peer, bot_id = bot_id, commands = commands)
    }
  ),
  class = TRUE
)

#  @title UpdateBotDeleteBusinessMessage
#  @description Telegram API type UpdateBotDeleteBusinessMessage
#  @export
#  @noRd
#  @noRd
UpdateBotDeleteBusinessMessage <- R6::R6Class(
  "UpdateBotDeleteBusinessMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa02a982e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(connection_id, peer, messages, qts) {
      self$connection_id <- connection_id
      self$peer <- peer
      self$messages <- messages
      self$qts <- qts
    },
    to_dict = function() {
      list(
        `_` = "UpdateBotDeleteBusinessMessage",
        connection_id = self$connection_id,
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        messages = if (is.null(self$messages)) list() else self$messages,
        qts = self$qts
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xa0, 0x2a, 0x98, 0x2e)),
        self$serialize_bytes(self$connection_id),
        self$peer$bytes(),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)),
        pack("i", length(self$messages)),
        do.call(c, lapply(self$messages, function(x) pack("i", x))),
        pack("i", self$qts)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      connection_id <- reader$tgread_string()
      peer <- reader$tgread_object()
      reader$read_int()
      messages <- lapply(seq_len(reader$read_int()), function(x) reader$read_int())
      qts <- reader$read_int()
      self$new(connection_id = connection_id, peer = peer, messages = messages, qts = qts)
    }
  ),
  class = TRUE
)

#  @title UpdateBotEditBusinessMessage
#  @description Telegram API type UpdateBotEditBusinessMessage
#  @export
#  @noRd
#  @noRd
UpdateBotEditBusinessMessage <- R6::R6Class(
  "UpdateBotEditBusinessMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x07df587c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(connection_id, message, qts, reply_to_message = NULL) {
      self$connection_id <- connection_id
      self$message <- message
      self$qts <- qts
      self$reply_to_message <- reply_to_message
    },
    to_dict = function() {
      list(
        `_` = "UpdateBotEditBusinessMessage",
        connection_id = self$connection_id,
        message = if (inherits(self$message, "TLObject")) self$message$to_dict() else self$message,
        qts = self$qts,
        reply_to_message = if (!is.null(self$reply_to_message) && inherits(self$reply_to_message, "TLObject")) self$reply_to_message$to_dict() else self$reply_to_message
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x7c, 0x58, 0xdf, 0x07)),
        pack("I", if (is.null(self$reply_to_message)) 0 else 1),
        self$serialize_bytes(self$connection_id),
        self$message$bytes(),
        if (!is.null(self$reply_to_message)) self$reply_to_message$bytes() else raw(0),
        pack("i", self$qts)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      connection_id <- reader$tgread_string()
      message <- reader$tgread_object()
      reply_to_message <- if (flags & 1) reader$tgread_object() else NULL
      qts <- reader$read_int()
      self$new(connection_id = connection_id, message = message, qts = qts, reply_to_message = reply_to_message)
    }
  ),
  class = TRUE
)

#  @title UpdateBotInlineQuery
#  @description Telegram API type UpdateBotInlineQuery
#  @export
#  @noRd
#  @noRd
UpdateBotInlineQuery <- R6::R6Class("UpdateBotInlineQuery",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x496f379c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(query_id, user_id, query, offset, geo = NULL, peer_type = NULL) {
      self$query_id <- query_id
      self$user_id <- user_id
      self$query <- query
      self$offset <- offset
      self$geo <- geo
      self$peer_type <- peer_type
    },
    to_dict = function() {
      list(
        `_` = "UpdateBotInlineQuery",
        query_id = self$query_id,
        user_id = self$user_id,
        query = self$query,
        offset = self$offset,
        geo = if (is.null(self$geo)) NULL else self$geo$to_dict(),
        peer_type = if (is.null(self$peer_type)) NULL else self$peer_type$to_dict()
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x9c, 0x37, 0x6f, 0x49)),
        pack("I", (if (is.null(self$geo)) 0 else 1) | (if (is.null(self$peer_type)) 0 else 2)),
        pack("q", self$query_id),
        pack("q", self$user_id),
        self$serializebytes(self$query),
        if (!is.null(self$geo)) self$geo$bytes() else raw(0),
        if (!is.null(self$peer_type)) self$peer_type$bytes() else raw(0),
        self$serializebytes(self$offset)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      query_id <- reader$read_long()
      user_id <- reader$read_long()
      query <- reader$tgread_string()
      geo <- if (flags & 1) reader$tgread_object() else NULL
      peer_type <- if (flags & 2) reader$tgread_object() else NULL
      offset <- reader$tgread_string()
      self$initialize(query_id, user_id, query, offset, geo, peer_type)
    }
  ),
  class = TRUE
)

#  @title UpdateBotInlineSend
#  @description Telegram API type UpdateBotInlineSend
#  @export
#  @noRd
#  @noRd
UpdateBotInlineSend <- R6::R6Class("UpdateBotInlineSend",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x12f12a07,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(user_id, query, id, geo = NULL, msg_id = NULL) {
      self$user_id <- user_id
      self$query <- query
      self$id <- id
      self$geo <- geo
      self$msg_id <- msg_id
    },
    to_dict = function() {
      list(
        `_` = "UpdateBotInlineSend",
        user_id = self$user_id,
        query = self$query,
        id = self$id,
        geo = if (is.null(self$geo)) NULL else self$geo$to_dict(),
        msg_id = if (is.null(self$msg_id)) NULL else self$msg_id$to_dict()
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x07, 0x2a, 0xf1, 0x12)),
        pack("I", (if (is.null(self$geo)) 0 else 1) | (if (is.null(self$msg_id)) 0 else 2)),
        pack("q", self$user_id),
        self$serializebytes(self$query),
        if (!is.null(self$geo)) self$geo$bytes() else raw(0),
        self$serializebytes(self$id),
        if (!is.null(self$msg_id)) self$msg_id$bytes() else raw(0)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      user_id <- reader$read_long()
      query <- reader$tgread_string()
      geo <- if (flags & 1) reader$tgread_object() else NULL
      id <- reader$tgread_string()
      msg_id <- if (flags & 2) reader$tgread_object() else NULL
      self$initialize(user_id, query, id, geo, msg_id)
    }
  ),
  class = TRUE
)

#  @title UpdateBotMenuButton
#  @description Telegram API type UpdateBotMenuButton
#  @export
#  @noRd
#  @noRd
UpdateBotMenuButton <- R6::R6Class("UpdateBotMenuButton",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x14b85813,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(bot_id, button) {
      self$bot_id <- bot_id
      self$button <- button
    },
    to_dict = function() {
      list(
        `_` = "UpdateBotMenuButton",
        bot_id = self$bot_id,
        button = if (is.null(self$button)) NULL else self$button$to_dict()
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x13, 0x58, 0xb8, 0x14)),
        pack("q", self$bot_id),
        self$button$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      bot_id <- reader$read_long()
      button <- reader$tgread_object()
      self$initialize(bot_id, button)
    }
  ),
  class = TRUE
)

#  @title UpdateBotMessageReaction
#  @description Telegram API type UpdateBotMessageReaction
#  @export
#  @noRd
#  @noRd
UpdateBotMessageReaction <- R6::R6Class("UpdateBotMessageReaction",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xac21d3ce,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(peer, msg_id, date, actor, old_reactions, new_reactions, qts) {
      self$peer <- peer
      self$msg_id <- msg_id
      self$date <- date
      self$actor <- actor
      self$old_reactions <- old_reactions
      self$new_reactions <- new_reactions
      self$qts <- qts
    },
    to_dict = function() {
      list(
        `_` = "UpdateBotMessageReaction",
        peer = if (is.null(self$peer)) NULL else self$peer$to_dict(),
        msg_id = self$msg_id,
        date = self$date,
        actor = if (is.null(self$actor)) NULL else self$actor$to_dict(),
        old_reactions = if (is.null(self$old_reactions)) list() else lapply(self$old_reactions, function(x) x$to_dict()),
        new_reactions = if (is.null(self$new_reactions)) list() else lapply(self$new_reactions, function(x) x$to_dict()),
        qts = self$qts
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xce, 0xd3, 0x21, 0xac)),
        self$peer$bytes(),
        pack("i", self$msg_id),
        self$serialize_datetime(self$date),
        self$actor$bytes(),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$old_reactions)), do.call(c, lapply(self$old_reactions, function(x) x$bytes())),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$new_reactions)), do.call(c, lapply(self$new_reactions, function(x) x$bytes())),
        pack("i", self$qts)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      msg_id <- reader$read_int()
      date <- reader$tgread_date()
      actor <- reader$tgread_object()
      reader$read_int()
      old_reactions <- list()
      for (i in 1:reader$read_int()) {
        old_reactions <- c(old_reactions, list(reader$tgread_object()))
      }
      reader$read_int()
      new_reactions <- list()
      for (i in 1:reader$read_int()) {
        new_reactions <- c(new_reactions, list(reader$tgread_object()))
      }
      qts <- reader$read_int()
      self$initialize(peer, msg_id, date, actor, old_reactions, new_reactions, qts)
    }
  ),
  class = TRUE
)

#  @title UpdateBotMessageReactions
#  @description Telegram API type UpdateBotMessageReactions
#  @export
#  @noRd
#  @noRd
UpdateBotMessageReactions <- R6::R6Class("UpdateBotMessageReactions",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9cb7759,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(peer, msg_id, date, reactions, qts) {
      self$peer <- peer
      self$msg_id <- msg_id
      self$date <- date
      self$reactions <- reactions
      self$qts <- qts
    },
    to_dict = function() {
      list(
        `_` = "UpdateBotMessageReactions",
        peer = if (is.null(self$peer)) NULL else self$peer$to_dict(),
        msg_id = self$msg_id,
        date = self$date,
        reactions = if (is.null(self$reactions)) list() else lapply(self$reactions, function(x) x$to_dict()),
        qts = self$qts
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x59, 0xb7, 0xcb, 0x09)),
        self$peer$bytes(),
        pack("i", self$msg_id),
        self$serialize_datetime(self$date),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$reactions)), do.call(c, lapply(self$reactions, function(x) x$bytes())),
        pack("i", self$qts)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      msg_id <- reader$read_int()
      date <- reader$tgread_date()
      reader$read_int()
      reactions <- list()
      for (i in 1:reader$read_int()) {
        reactions <- c(reactions, list(reader$tgread_object()))
      }
      qts <- reader$read_int()
      self$initialize(peer, msg_id, date, reactions, qts)
    }
  ),
  class = TRUE
)

#  @title UpdateBotNewBusinessMessage
#  @description Telegram API type UpdateBotNewBusinessMessage
#  @export
#  @noRd
#  @noRd
UpdateBotNewBusinessMessage <- R6::R6Class("UpdateBotNewBusinessMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9ddb347c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(connection_id, message, qts, reply_to_message = NULL) {
      self$connection_id <- connection_id
      self$message <- message
      self$qts <- qts
      self$reply_to_message <- reply_to_message
    },
    to_dict = function() {
      list(
        `_` = "UpdateBotNewBusinessMessage",
        connection_id = self$connection_id,
        message = if (is.null(self$message)) NULL else self$message$to_dict(),
        qts = self$qts,
        reply_to_message = if (is.null(self$reply_to_message)) NULL else self$reply_to_message$to_dict()
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x7c, 0x34, 0xdb, 0x9d)),
        pack("I", if (is.null(self$reply_to_message)) 0 else 1),
        self$serializebytes(self$connection_id),
        self$message$bytes(),
        if (!is.null(self$reply_to_message)) self$reply_to_message$bytes() else raw(0),
        pack("i", self$qts)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      connection_id <- reader$tgread_string()
      message <- reader$tgread_object()
      reply_to_message <- if (flags & 1) reader$tgread_object() else NULL
      qts <- reader$read_int()
      self$initialize(connection_id, message, qts, reply_to_message)
    }
  ),
  class = TRUE
)

#  @title UpdateBotPrecheckoutQuery
#  @description Telegram API type UpdateBotPrecheckoutQuery
#  @export
#  @noRd
#  @noRd
UpdateBotPrecheckoutQuery <- R6::R6Class("UpdateBotPrecheckoutQuery",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8caa9a96,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(query_id, user_id, payload, currency, total_amount, info = NULL, shipping_option_id = NULL) {
      self$query_id <- query_id
      self$user_id <- user_id
      self$payload <- payload
      self$currency <- currency
      self$total_amount <- total_amount
      self$info <- info
      self$shipping_option_id <- shipping_option_id
    },
    to_dict = function() {
      list(
        `_` = "UpdateBotPrecheckoutQuery",
        query_id = self$query_id,
        user_id = self$user_id,
        payload = self$payload,
        currency = self$currency,
        total_amount = self$total_amount,
        info = if (is.null(self$info)) NULL else self$info$to_dict(),
        shipping_option_id = self$shipping_option_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x96, 0x9a, 0xaa, 0x8c)),
        pack("I", (if (is.null(self$info)) 0 else 1) | (if (is.null(self$shipping_option_id)) 0 else 2)),
        pack("q", self$query_id),
        pack("q", self$user_id),
        self$serializebytes(self$payload),
        if (!is.null(self$info)) self$info$bytes() else raw(0),
        if (!is.null(self$shipping_option_id)) self$serializebytes(self$shipping_option_id) else raw(0),
        self$serializebytes(self$currency),
        pack("q", self$total_amount)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      query_id <- reader$read_long()
      user_id <- reader$read_long()
      payload <- reader$tgreadbytes()
      info <- if (flags & 1) reader$tgread_object() else NULL
      shipping_option_id <- if (flags & 2) reader$tgread_string() else NULL
      currency <- reader$tgread_string()
      total_amount <- reader$read_long()
      self$initialize(query_id, user_id, payload, currency, total_amount, info, shipping_option_id)
    }
  ),
  class = TRUE
)

#  @title UpdateBotPurchasedPaidMedia
#  @description Telegram API type UpdateBotPurchasedPaidMedia
#  @export
#  @noRd
#  @noRd
UpdateBotPurchasedPaidMedia <- R6::R6Class("UpdateBotPurchasedPaidMedia",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x283bd312,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(user_id, payload, qts) {
      self$user_id <- user_id
      self$payload <- payload
      self$qts <- qts
    },
    to_dict = function() {
      list(
        `_` = "UpdateBotPurchasedPaidMedia",
        user_id = self$user_id,
        payload = self$payload,
        qts = self$qts
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x12, 0xd3, 0x3b, 0x28)),
        pack("q", self$user_id),
        self$serializebytes(self$payload),
        pack("i", self$qts)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      user_id <- reader$read_long()
      payload <- reader$tgread_string()
      qts <- reader$read_int()
      self$initialize(user_id, payload, qts)
    }
  ),
  class = TRUE
)

#  @title UpdateBotShippingQuery
#  @description Telegram API type UpdateBotShippingQuery
#  @export
#  @noRd
#  @noRd
UpdateBotShippingQuery <- R6::R6Class("UpdateBotShippingQuery",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb5aefd7d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(query_id, user_id, payload, shipping_address) {
      self$query_id <- query_id
      self$user_id <- user_id
      self$payload <- payload
      self$shipping_address <- shipping_address
    },
    to_dict = function() {
      list(
        `_` = "UpdateBotShippingQuery",
        query_id = self$query_id,
        user_id = self$user_id,
        payload = self$payload,
        shipping_address = if (is.null(self$shipping_address)) NULL else self$shipping_address$to_dict()
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x7d, 0xfd, 0xae, 0xb5)),
        pack("q", self$query_id),
        pack("q", self$user_id),
        self$serializebytes(self$payload),
        self$shipping_address$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      query_id <- reader$read_long()
      user_id <- reader$read_long()
      payload <- reader$tgreadbytes()
      shipping_address <- reader$tgread_object()
      self$initialize(query_id, user_id, payload, shipping_address)
    }
  ),
  class = TRUE
)

#  @title UpdateBotStopped
#  @description Telegram API type UpdateBotStopped
#  @export
#  @noRd
#  @noRd
UpdateBotStopped <- R6::R6Class("UpdateBotStopped",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc4870a49,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(user_id, date, stopped, qts) {
      self$user_id <- user_id
      self$date <- date
      self$stopped <- stopped
      self$qts <- qts
    },
    to_dict = function() {
      list(
        `_` = "UpdateBotStopped",
        user_id = self$user_id,
        date = self$date,
        stopped = self$stopped,
        qts = self$qts
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x49, 0x0a, 0x87, 0xc4)),
        pack("q", self$user_id),
        self$serialize_datetime(self$date),
        if (self$stopped) as.raw(0xb5) else as.raw(0x37),
        pack("i", self$qts)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      user_id <- reader$read_long()
      date <- reader$tgread_date()
      stopped <- reader$tgread_bool()
      qts <- reader$read_int()
      self$initialize(user_id, date, stopped, qts)
    }
  ),
  class = TRUE
)

#  @title UpdateBotWebhookJSON
#  @description Telegram API type UpdateBotWebhookJSON
#  @export
#  @noRd
#  @noRd
UpdateBotWebhookJSON <- R6::R6Class("UpdateBotWebhookJSON",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8317c0c3,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(data) {
      self$data <- data
    },
    to_dict = function() {
      list(
        `_` = "UpdateBotWebhookJSON",
        data = if (is.null(self$data)) NULL else self$data$to_dict()
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xc3, 0xc0, 0x17, 0x83)),
        self$data$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      data <- reader$tgread_object()
      self$initialize(data)
    }
  ),
  class = TRUE
)

#  @title UpdateBotWebhookJSONQuery
#  @description Telegram API type UpdateBotWebhookJSONQuery
#  @export
#  @noRd
#  @noRd
UpdateBotWebhookJSONQuery <- R6::R6Class("UpdateBotWebhookJSONQuery",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9b9240a6,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(query_id, data, timeout) {
      self$query_id <- query_id
      self$data <- data
      self$timeout <- timeout
    },
    to_dict = function() {
      list(
        `_` = "UpdateBotWebhookJSONQuery",
        query_id = self$query_id,
        data = if (is.null(self$data)) NULL else self$data$to_dict(),
        timeout = self$timeout
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xa6, 0x40, 0x92, 0x9b)),
        pack("q", self$query_id),
        self$data$bytes(),
        pack("i", self$timeout)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      query_id <- reader$read_long()
      data <- reader$tgread_object()
      timeout <- reader$read_int()
      self$initialize(query_id, data, timeout)
    }
  ),
  class = TRUE
)

#  @title UpdateBusinessBotCallbackQuery
#  @description Telegram API type UpdateBusinessBotCallbackQuery
#  @export
#  @noRd
#  @noRd
UpdateBusinessBotCallbackQuery <- R6::R6Class("UpdateBusinessBotCallbackQuery",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1ea2fda7,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(query_id, user_id, connection_id, message, chat_instance, reply_to_message = NULL, data = NULL) {
      self$query_id <- query_id
      self$user_id <- user_id
      self$connection_id <- connection_id
      self$message <- message
      self$chat_instance <- chat_instance
      self$reply_to_message <- reply_to_message
      self$data <- data
    },
    to_dict = function() {
      list(
        `_` = "UpdateBusinessBotCallbackQuery",
        query_id = self$query_id,
        user_id = self$user_id,
        connection_id = self$connection_id,
        message = if (is.null(self$message)) NULL else self$message$to_dict(),
        chat_instance = self$chat_instance,
        reply_to_message = if (is.null(self$reply_to_message)) NULL else self$reply_to_message$to_dict(),
        data = self$data
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xa7, 0xfd, 0xa2, 0x1e)),
        pack("I", (if (is.null(self$reply_to_message)) 0 else 4) | (if (is.null(self$data)) 0 else 1)),
        pack("q", self$query_id),
        pack("q", self$user_id),
        self$serializebytes(self$connection_id),
        self$message$bytes(),
        if (!is.null(self$reply_to_message)) self$reply_to_message$bytes() else raw(0),
        pack("q", self$chat_instance),
        if (!is.null(self$data)) self$serializebytes(self$data) else raw(0)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      query_id <- reader$read_long()
      user_id <- reader$read_long()
      connection_id <- reader$tgread_string()
      message <- reader$tgread_object()
      reply_to_message <- if (flags & 4) reader$tgread_object() else NULL
      chat_instance <- reader$read_long()
      data <- if (flags & 1) reader$tgreadbytes() else NULL
      self$initialize(query_id, user_id, connection_id, message, chat_instance, reply_to_message, data)
    }
  ),
  class = TRUE
)

#  @title UpdateChannel
#  @description Telegram API type UpdateChannel
#  @export
#  @noRd
#  @noRd
UpdateChannel <- R6::R6Class("UpdateChannel",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x635b4c09,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(channel_id) {
      self$channel_id <- channel_id
    },
    to_dict = function() {
      list(
        `_` = "UpdateChannel",
        channel_id = self$channel_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x09, 0x4c, 0x5b, 0x63)),
        pack("q", self$channel_id)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      channel_id <- reader$read_long()
      self$initialize(channel_id)
    }
  ),
  class = TRUE
)

#  @title UpdateChannelAvailableMessages
#  @description Telegram API type UpdateChannelAvailableMessages
#  @export
#  @noRd
#  @noRd
UpdateChannelAvailableMessages <- R6::R6Class("UpdateChannelAvailableMessages",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb23fc698,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(channel_id, available_min_id) {
      self$channel_id <- channel_id
      self$available_min_id <- available_min_id
    },
    to_dict = function() {
      list(
        `_` = "UpdateChannelAvailableMessages",
        channel_id = self$channel_id,
        available_min_id = self$available_min_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x98, 0xc6, 0x3f, 0xb2)),
        pack("q", self$channel_id),
        pack("i", self$available_min_id)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      channel_id <- reader$read_long()
      available_min_id <- reader$read_int()
      self$initialize(channel_id, available_min_id)
    }
  ),
  class = TRUE
)

#  @title UpdateChannelMessageForwards
#  @description Telegram API type UpdateChannelMessageForwards
#  @export
#  @noRd
#  @noRd
UpdateChannelMessageForwards <- R6::R6Class("UpdateChannelMessageForwards",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd29a27f4,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(channel_id, id, forwards) {
      self$channel_id <- channel_id
      self$id <- id
      self$forwards <- forwards
    },
    to_dict = function() {
      list(
        `_` = "UpdateChannelMessageForwards",
        channel_id = self$channel_id,
        id = self$id,
        forwards = self$forwards
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xf4, 0x27, 0x9a, 0xd2)),
        pack("q", self$channel_id),
        pack("i", self$id),
        pack("i", self$forwards)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      channel_id <- reader$read_long()
      id <- reader$read_int()
      forwards <- reader$read_int()
      self$initialize(channel_id, id, forwards)
    }
  ),
  class = TRUE
)

#  @title UpdateChannelMessageViews
#  @description Telegram API type UpdateChannelMessageViews
#  @export
#  @noRd
#  @noRd
UpdateChannelMessageViews <- R6::R6Class("UpdateChannelMessageViews",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf226ac08,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(channel_id, id, views) {
      self$channel_id <- channel_id
      self$id <- id
      self$views <- views
    },
    to_dict = function() {
      list(
        `_` = "UpdateChannelMessageViews",
        channel_id = self$channel_id,
        id = self$id,
        views = self$views
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x08, 0xac, 0x26, 0xf2)),
        pack("q", self$channel_id),
        pack("i", self$id),
        pack("i", self$views)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      channel_id <- reader$read_long()
      id <- reader$read_int()
      views <- reader$read_int()
      self$initialize(channel_id, id, views)
    }
  ),
  class = TRUE
)

#  @title UpdateChannelParticipant
#  @description Telegram API type UpdateChannelParticipant
#  @export
#  @noRd
#  @noRd
UpdateChannelParticipant <- R6::R6Class("UpdateChannelParticipant",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x985d3abb,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(channel_id, date, actor_id, user_id, qts, via_chatlist = NULL, prev_participant = NULL, new_participant = NULL, invite = NULL) {
      self$channel_id <- channel_id
      self$date <- date
      self$actor_id <- actor_id
      self$user_id <- user_id
      self$qts <- qts
      self$via_chatlist <- via_chatlist
      self$prev_participant <- prev_participant
      self$new_participant <- new_participant
      self$invite <- invite
    },
    to_dict = function() {
      list(
        `_` = "UpdateChannelParticipant",
        channel_id = self$channel_id,
        date = self$date,
        actor_id = self$actor_id,
        user_id = self$user_id,
        qts = self$qts,
        via_chatlist = self$via_chatlist,
        prev_participant = if (is.null(self$prev_participant)) NULL else self$prev_participant$to_dict(),
        new_participant = if (is.null(self$new_participant)) NULL else self$new_participant$to_dict(),
        invite = if (is.null(self$invite)) NULL else self$invite$to_dict()
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xbb, 0x3a, 0x5d, 0x98)),
        pack("I", (if (is.null(self$via_chatlist) || !self$via_chatlist) 0 else 8) | (if (is.null(self$prev_participant)) 0 else 1) | (if (is.null(self$new_participant)) 0 else 2) | (if (is.null(self$invite)) 0 else 4)),
        pack("q", self$channel_id),
        self$serialize_datetime(self$date),
        pack("q", self$actor_id),
        pack("q", self$user_id),
        if (!is.null(self$prev_participant)) self$prev_participant$bytes() else raw(0),
        if (!is.null(self$new_participant)) self$new_participant$bytes() else raw(0),
        if (!is.null(self$invite)) self$invite$bytes() else raw(0),
        pack("i", self$qts)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      via_chatlist <- (flags & 8) != 0
      channel_id <- reader$read_long()
      date <- reader$tgread_date()
      actor_id <- reader$read_long()
      user_id <- reader$read_long()
      prev_participant <- if (flags & 1) reader$tgread_object() else NULL
      new_participant <- if (flags & 2) reader$tgread_object() else NULL
      invite <- if (flags & 4) reader$tgread_object() else NULL
      qts <- reader$read_int()
      self$initialize(channel_id, date, actor_id, user_id, qts, via_chatlist, prev_participant, new_participant, invite)
    }
  ),
  class = TRUE
)

#  @title UpdateChannelPinnedTopic
#  @description Telegram API type UpdateChannelPinnedTopic
#  @export
#  @noRd
#  @noRd
UpdateChannelPinnedTopic <- R6::R6Class("UpdateChannelPinnedTopic",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x192efbe3,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(channel_id, topic_id, pinned = NULL) {
      self$channel_id <- channel_id
      self$topic_id <- topic_id
      self$pinned <- pinned
    },
    to_dict = function() {
      list(
        `_` = "UpdateChannelPinnedTopic",
        channel_id = self$channel_id,
        topic_id = self$topic_id,
        pinned = self$pinned
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xe3, 0xfb, 0x2e, 0x19)),
        pack("I", if (is.null(self$pinned)) 0 else 1),
        pack("q", self$channel_id),
        pack("i", self$topic_id)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      pinned <- if (flags & 1) TRUE else NULL
      channel_id <- reader$read_long()
      topic_id <- reader$read_int()
      self$initialize(channel_id, topic_id, pinned)
    }
  ),
  class = TRUE
)

#  @title UpdateChannelPinnedTopics
#  @description Telegram API type UpdateChannelPinnedTopics
#  @export
#  @noRd
#  @noRd
UpdateChannelPinnedTopics <- R6::R6Class("UpdateChannelPinnedTopics",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xfe198602,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(channel_id, order = NULL) {
      self$channel_id <- channel_id
      self$order <- order
    },
    to_dict = function() {
      list(
        `_` = "UpdateChannelPinnedTopics",
        channel_id = self$channel_id,
        order = self$order
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x02, 0x86, 0x19, 0xfe)),
        pack("q", self$channel_id),
        if (!is.null(self$order)) c(as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$order)), do.call(c, lapply(self$order, function(x) pack("i", x)))) else raw(0)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      channel_id <- reader$read_long()
      if (flags & 1) {
        reader$read_int()
        order <- list()
        for (i in 1:reader$read_int()) {
          order <- c(order, list(reader$read_int()))
        }
      } else {
        order <- NULL
      }
      self$initialize(channel_id, order)
    }
  ),
  class = TRUE
)

#  @title UpdateChannelReadMessagesContents
#  @description Telegram API type UpdateChannelReadMessagesContents
#  @export
#  @noRd
#  @noRd
UpdateChannelReadMessagesContents <- R6::R6Class("UpdateChannelReadMessagesContents",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x25f324f7,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(channel_id, messages, top_msg_id = NULL, savedpeer_id = NULL) {
      self$channel_id <- channel_id
      self$messages <- messages
      self$top_msg_id <- top_msg_id
      self$savedpeer_id <- savedpeer_id
    },
    to_dict = function() {
      list(
        `_` = "UpdateChannelReadMessagesContents",
        channel_id = self$channel_id,
        messages = self$messages,
        top_msg_id = self$top_msg_id,
        savedpeer_id = if (is.null(self$savedpeer_id)) NULL else self$savedpeer_id$to_dict()
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xf7, 0x24, 0xf3, 0x25)),
        pack("I", (if (is.null(self$top_msg_id)) 0 else 1) | (if (is.null(self$savedpeer_id)) 0 else 2)),
        pack("q", self$channel_id),
        if (!is.null(self$top_msg_id)) pack("i", self$top_msg_id) else raw(0),
        if (!is.null(self$savedpeer_id)) self$savedpeer_id$bytes() else raw(0),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$messages)), do.call(c, lapply(self$messages, function(x) pack("i", x)))
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      channel_id <- reader$read_long()
      top_msg_id <- if (flags & 1) reader$read_int() else NULL
      savedpeer_id <- if (flags & 2) reader$tgread_object() else NULL
      reader$read_int()
      messages <- list()
      for (i in 1:reader$read_int()) {
        messages <- c(messages, list(reader$read_int()))
      }
      self$initialize(channel_id, messages, top_msg_id, savedpeer_id)
    }
  ),
  class = TRUE
)

#  @title UpdateChannelTooLong
#  @description Telegram API type UpdateChannelTooLong
#  @export
#  @noRd
#  @noRd
UpdateChannelTooLong <- R6::R6Class("UpdateChannelTooLong",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x108d941f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(channel_id, pts = NULL) {
      self$channel_id <- channel_id
      self$pts <- pts
    },
    to_dict = function() {
      list(
        `_` = "UpdateChannelTooLong",
        channel_id = self$channel_id,
        pts = self$pts
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x1f, 0x94, 0x8d, 0x10)),
        pack("q", self$channel_id),
        if (!is.null(self$pts)) pack("i", self$pts) else raw(0)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      channel_id <- reader$read_long()
      pts <- if (flags & 1) reader$read_int() else NULL
      self$initialize(channel_id, pts)
    }
  ),
  class = TRUE
)

#  @title UpdateChannelUserTyping
#  @description Telegram API type UpdateChannelUserTyping
#  @export
#  @noRd
#  @noRd
UpdateChannelUserTyping <- R6::R6Class("UpdateChannelUserTyping",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8c88c923,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(channel_id, from_id, action, top_msg_id = NULL) {
      self$channel_id <- channel_id
      self$from_id <- from_id
      self$action <- action
      self$top_msg_id <- top_msg_id
    },
    to_dict = function() {
      list(
        `_` = "UpdateChannelUserTyping",
        channel_id = self$channel_id,
        from_id = if (is.null(self$from_id)) NULL else self$from_id$to_dict(),
        action = if (is.null(self$action)) NULL else self$action$to_dict(),
        top_msg_id = self$top_msg_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x23, 0xc9, 0x88, 0x8c)),
        pack("q", self$channel_id),
        if (!is.null(self$top_msg_id)) pack("i", self$top_msg_id) else raw(0),
        self$from_id$bytes(),
        self$action$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      channel_id <- reader$read_long()
      top_msg_id <- if (flags & 1) reader$read_int() else NULL
      from_id <- reader$tgread_object()
      action <- reader$tgread_object()
      self$initialize(channel_id, from_id, action, top_msg_id)
    }
  ),
  class = TRUE
)

#  @title UpdateChannelViewForumAsMessages
#  @description Telegram API type UpdateChannelViewForumAsMessages
#  @export
#  @noRd
#  @noRd
UpdateChannelViewForumAsMessages <- R6::R6Class("UpdateChannelViewForumAsMessages",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7b68920,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(channel_id, enabled) {
      self$channel_id <- channel_id
      self$enabled <- enabled
    },
    to_dict = function() {
      list(
        `_` = "UpdateChannelViewForumAsMessages",
        channel_id = self$channel_id,
        enabled = self$enabled
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x20, 0x89, 0xb6, 0x07)),
        pack("q", self$channel_id),
        if (self$enabled) as.raw(0xb5) else as.raw(0x37)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      channel_id <- reader$read_long()
      enabled <- reader$tgread_bool()
      self$initialize(channel_id, enabled)
    }
  ),
  class = TRUE
)

#  @title UpdateChannelWebPage
#  @description Telegram API type UpdateChannelWebPage
#  @export
#  @noRd
#  @noRd
UpdateChannelWebPage <- R6::R6Class("UpdateChannelWebPage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x2f2ba99f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(channel_id, webpage, pts, pts_count) {
      self$channel_id <- channel_id
      self$webpage <- webpage
      self$pts <- pts
      self$pts_count <- pts_count
    },
    to_dict = function() {
      list(
        `_` = "UpdateChannelWebPage",
        channel_id = self$channel_id,
        webpage = if (is.null(self$webpage)) NULL else self$webpage$to_dict(),
        pts = self$pts,
        pts_count = self$pts_count
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x9f, 0xa9, 0x2b, 0x2f)),
        pack("q", self$channel_id),
        self$webpage$bytes(),
        pack("i", self$pts),
        pack("i", self$pts_count)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      channel_id <- reader$read_long()
      webpage <- reader$tgread_object()
      pts <- reader$read_int()
      pts_count <- reader$read_int()
      self$initialize(channel_id, webpage, pts, pts_count)
    }
  ),
  class = TRUE
)

#  @title UpdateChat
#  @description Telegram API type UpdateChat
#  @export
#  @noRd
#  @noRd
UpdateChat <- R6::R6Class("UpdateChat",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf89a6a4e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(chat_id) {
      self$chat_id <- chat_id
    },
    to_dict = function() {
      list(
        `_` = "UpdateChat",
        chat_id = self$chat_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x4e, 0x6a, 0x9a, 0xf8)),
        pack("q", self$chat_id)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      chat_id <- reader$read_long()
      self$initialize(chat_id)
    }
  ),
  class = TRUE
)

#  @title UpdateChatDefaultBannedRights
#  @description Telegram API type UpdateChatDefaultBannedRights
#  @export
#  @noRd
#  @noRd
UpdateChatDefaultBannedRights <- R6::R6Class("UpdateChatDefaultBannedRights",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x54c01850,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(peer, default_banned_rights, version) {
      self$peer <- peer
      self$default_banned_rights <- default_banned_rights
      self$version <- version
    },
    to_dict = function() {
      list(
        `_` = "UpdateChatDefaultBannedRights",
        peer = if (is.null(self$peer)) NULL else self$peer$to_dict(),
        default_banned_rights = if (is.null(self$default_banned_rights)) NULL else self$default_banned_rights$to_dict(),
        version = self$version
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x50, 0x18, 0xc0, 0x54)),
        self$peer$bytes(),
        self$default_banned_rights$bytes(),
        pack("i", self$version)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      default_banned_rights <- reader$tgread_object()
      version <- reader$read_int()
      self$initialize(peer, default_banned_rights, version)
    }
  ),
  class = TRUE
)

#  @title UpdateChatParticipant
#  @description Telegram API type UpdateChatParticipant
#  @export
#  @noRd
#  @noRd
UpdateChatParticipant <- R6::R6Class("UpdateChatParticipant",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd087663a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(chat_id, date, actor_id, user_id, qts, prev_participant = NULL, new_participant = NULL, invite = NULL) {
      self$chat_id <- chat_id
      self$date <- date
      self$actor_id <- actor_id
      self$user_id <- user_id
      self$qts <- qts
      self$prev_participant <- prev_participant
      self$new_participant <- new_participant
      self$invite <- invite
    },
    to_dict = function() {
      list(
        `_` = "UpdateChatParticipant",
        chat_id = self$chat_id,
        date = self$date,
        actor_id = self$actor_id,
        user_id = self$user_id,
        qts = self$qts,
        prev_participant = if (is.null(self$prev_participant)) NULL else self$prev_participant$to_dict(),
        new_participant = if (is.null(self$new_participant)) NULL else self$new_participant$to_dict(),
        invite = if (is.null(self$invite)) NULL else self$invite$to_dict()
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x3a, 0x66, 0x87, 0xd0)),
        pack("q", self$chat_id),
        self$serialize_datetime(self$date),
        pack("q", self$actor_id),
        pack("q", self$user_id),
        if (!is.null(self$prev_participant)) self$prev_participant$bytes() else raw(0),
        if (!is.null(self$new_participant)) self$new_participant$bytes() else raw(0),
        if (!is.null(self$invite)) self$invite$bytes() else raw(0),
        pack("i", self$qts)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      chat_id <- reader$read_long()
      date <- reader$tgread_date()
      actor_id <- reader$read_long()
      user_id <- reader$read_long()
      prev_participant <- if (flags & 1) reader$tgread_object() else NULL
      new_participant <- if (flags & 2) reader$tgread_object() else NULL
      invite <- if (flags & 4) reader$tgread_object() else NULL
      qts <- reader$read_int()
      self$initialize(chat_id, date, actor_id, user_id, qts, prev_participant, new_participant, invite)
    }
  ),
  class = TRUE
)

#  @title UpdateChatParticipantAdd
#  @description Telegram API type UpdateChatParticipantAdd
#  @export
#  @noRd
#  @noRd
UpdateChatParticipantAdd <- R6::R6Class("UpdateChatParticipantAdd",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x3dda5451,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(chat_id, user_id, inviter_id, date, version) {
      self$chat_id <- chat_id
      self$user_id <- user_id
      self$inviter_id <- inviter_id
      self$date <- date
      self$version <- version
    },
    to_dict = function() {
      list(
        `_` = "UpdateChatParticipantAdd",
        chat_id = self$chat_id,
        user_id = self$user_id,
        inviter_id = self$inviter_id,
        date = self$date,
        version = self$version
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x51, 0x54, 0xda, 0x3d)),
        pack("q", self$chat_id),
        pack("q", self$user_id),
        pack("q", self$inviter_id),
        self$serialize_datetime(self$date),
        pack("i", self$version)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      chat_id <- reader$read_long()
      user_id <- reader$read_long()
      inviter_id <- reader$read_long()
      date <- reader$tgread_date()
      version <- reader$read_int()
      self$initialize(chat_id, user_id, inviter_id, date, version)
    }
  ),
  class = TRUE
)

#  @title UpdateChatParticipantAdmin
#  @description Telegram API type UpdateChatParticipantAdmin
#  @export
#  @noRd
#  @noRd
UpdateChatParticipantAdmin <- R6::R6Class("UpdateChatParticipantAdmin",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd7ca61a2,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(chat_id, user_id, is_admin, version) {
      self$chat_id <- chat_id
      self$user_id <- user_id
      self$is_admin <- is_admin
      self$version <- version
    },
    to_dict = function() {
      list(
        `_` = "UpdateChatParticipantAdmin",
        chat_id = self$chat_id,
        user_id = self$user_id,
        is_admin = self$is_admin,
        version = self$version
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xa2, 0x61, 0xca, 0xd7)),
        pack("q", self$chat_id),
        pack("q", self$user_id),
        if (self$is_admin) as.raw(0xb5) else as.raw(0x37),
        pack("i", self$version)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      chat_id <- reader$read_long()
      user_id <- reader$read_long()
      is_admin <- reader$tgread_bool()
      version <- reader$read_int()
      self$initialize(chat_id, user_id, is_admin, version)
    }
  ),
  class = TRUE
)

#  @title UpdateBotInlineQuery
#  @description Telegram API type UpdateBotInlineQuery
#  @export
#  @noRd
#  @noRd
UpdateBotInlineQuery <- R6::R6Class("UpdateBotInlineQuery",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0x9c, 0x37, 0x6f, 0x49)) + pack("I", (if (is.null(self$geo)) 0 else 1) | (if (is.null(self$peer_type)) 0 else 2)) + pack("q", self$query_id) + pack("q", self$user_id) + self$serializebytes(self$query) + if (!is.null(self$geo)) self$geo$bytes() else raw(0) + if (!is.null(self$peer_type)) self$peer_type$bytes() else raw(0) + self$serializebytes(self$offset)
  ),
  private = list(
    from_reader = function(reader) list(flags = reader$read_int(), query_id = reader$read_long(), user_id = reader$read_long(), query = reader$tgread_string(), geo = if (flags & 1) reader$tgread_object() else NULL, peer_type = if (flags & 2) reader$tgread_object() else NULL, offset = reader$tgread_string())
  ),
  class = TRUE
)

#  @title UpdateBotInlineSend
#  @description Telegram API type UpdateBotInlineSend
#  @export
#  @noRd
#  @noRd
UpdateBotInlineSend <- R6::R6Class("UpdateBotInlineSend",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0x07, 0x2a, 0xf1, 0x12)) + pack("I", (if (is.null(self$geo)) 0 else 1) | (if (is.null(self$msg_id)) 0 else 2)) + pack("q", self$user_id) + self$serializebytes(self$query) + if (!is.null(self$geo)) self$geo$bytes() else raw(0) + self$serializebytes(self$id) + if (!is.null(self$msg_id)) self$msg_id$bytes() else raw(0)
  ),
  private = list(
    from_reader = function(reader) list(flags = reader$read_int(), user_id = reader$read_long(), query = reader$tgread_string(), geo = if (flags & 1) reader$tgread_object() else NULL, id = reader$tgread_string(), msg_id = if (flags & 2) reader$tgread_object() else NULL)
  ),
  class = TRUE
)

#  @title UpdateBotMenuButton
#  @description Telegram API type UpdateBotMenuButton
#  @export
#  @noRd
#  @noRd
UpdateBotMenuButton <- R6::R6Class("UpdateBotMenuButton",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0x13, 0x58, 0xb8, 0x14)) + pack("q", self$bot_id) + self$button$bytes()
  ),
  private = list(
    from_reader = function(reader) list(bot_id = reader$read_long(), button = reader$tgread_object())
  ),
  class = TRUE
)

#  @title UpdateBotMessageReaction
#  @description Telegram API type UpdateBotMessageReaction
#  @export
#  @noRd
#  @noRd
UpdateBotMessageReaction <- R6::R6Class("UpdateBotMessageReaction",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0xce, 0xd3, 0x21, 0xac)) + self$peer$bytes() + pack("i", self$msg_id) + self$serialize_datetime(self$date) + self$actor$bytes() + (as.raw(c(0x15, 0xc4, 0xb5, 0x1c)) + pack("i", length(self$old_reactions)) + do.call(c, lapply(self$old_reactions, function(x) x$bytes()))) + (as.raw(c(0x15, 0xc4, 0xb5, 0x1c)) + pack("i", length(self$new_reactions)) + do.call(c, lapply(self$new_reactions, function(x) x$bytes()))) + pack("i", self$qts)
  ),
  private = list(
    from_reader = function(reader) {
      list(peer = reader$tgread_object(), msg_id = reader$read_int(), date = reader$tgread_date(), actor = reader$tgread_object(), old_reactions = {
        reader$read_int()
        lapply(seq_len(reader$read_int()), function(x) reader$tgread_object())
      }, new_reactions = {
        reader$read_int()
        lapply(seq_len(reader$read_int()), function(x) reader$tgread_object())
      }, qts = reader$read_int())
    }
  ),
  class = TRUE
)

#  @title UpdateBotMessageReactions
#  @description Telegram API type UpdateBotMessageReactions
#  @export
#  @noRd
#  @noRd
UpdateBotMessageReactions <- R6::R6Class("UpdateBotMessageReactions",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0x59, 0xcb, 0x0b)) + self$peer$bytes() + pack("i", self$msg_id) + self$serialize_datetime(self$date) + (as.raw(c(0x15, 0xc4, 0xb5, 0x1c)) + pack("i", length(self$reactions)) + do.call(c, lapply(self$reactions, function(x) x$bytes()))) + pack("i", self$qts)
  ),
  private = list(
    from_reader = function(reader) {
      list(peer = reader$tgread_object(), msg_id = reader$read_int(), date = reader$tgread_date(), reactions = {
        reader$read_int()
        lapply(seq_len(reader$read_int()), function(x) reader$tgread_object())
      }, qts = reader$read_int())
    }
  ),
  class = TRUE
)

#  @title UpdateBotNewBusinessMessage
#  @description Telegram API type UpdateBotNewBusinessMessage
#  @export
#  @noRd
#  @noRd
UpdateBotNewBusinessMessage <- R6::R6Class("UpdateBotNewBusinessMessage",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0x7c, 0x34, 0xdb, 0x9d)) + pack("I", (if (is.null(self$reply_to_message)) 0 else 1)) + self$serializebytes(self$connection_id) + self$message$bytes() + if (!is.null(self$reply_to_message)) self$reply_to_message$bytes() else raw(0) + pack("i", self$qts)
  ),
  private = list(
    from_reader = function(reader) list(flags = reader$read_int(), connection_id = reader$tgread_string(), message = reader$tgread_object(), reply_to_message = if (flags & 1) reader$tgread_object() else NULL, qts = reader$read_int())
  ),
  class = TRUE
)

#  @title UpdateBotPrecheckoutQuery
#  @description Telegram API type UpdateBotPrecheckoutQuery
#  @export
#  @noRd
#  @noRd
UpdateBotPrecheckoutQuery <- R6::R6Class("UpdateBotPrecheckoutQuery",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0x96, 0x9a, 0xaa, 0x8c)) + pack("I", (if (is.null(self$info)) 0 else 1) | (if (is.null(self$shipping_option_id)) 0 else 2)) + pack("q", self$query_id) + pack("q", self$user_id) + self$serializebytes(self$payload) + if (!is.null(self$info)) self$info$bytes() else raw(0) + if (!is.null(self$shipping_option_id)) self$serializebytes(self$shipping_option_id) else raw(0) + self$serializebytes(self$currency) + pack("q", self$total_amount)
  ),
  private = list(
    from_reader = function(reader) list(flags = reader$read_int(), query_id = reader$read_long(), user_id = reader$read_long(), payload = reader$tgreadbytes(), info = if (flags & 1) reader$tgread_object() else NULL, shipping_option_id = if (flags & 2) reader$tgread_string() else NULL, currency = reader$tgread_string(), total_amount = reader$read_long())
  ),
  class = TRUE
)

#  @title UpdateBotPurchasedPaidMedia
#  @description Telegram API type UpdateBotPurchasedPaidMedia
#  @export
#  @noRd
#  @noRd
UpdateBotPurchasedPaidMedia <- R6::R6Class("UpdateBotPurchasedPaidMedia",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0x12, 0xd3, 0x3b, 0x28)) + pack("q", self$user_id) + self$serializebytes(self$payload) + pack("i", self$qts)
  ),
  private = list(
    from_reader = function(reader) list(user_id = reader$read_long(), payload = reader$tgread_string(), qts = reader$read_int())
  ),
  class = TRUE
)

#  @title UpdateBotShippingQuery
#  @description Telegram API type UpdateBotShippingQuery
#  @export
#  @noRd
#  @noRd
UpdateBotShippingQuery <- R6::R6Class("UpdateBotShippingQuery",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0x7d, 0xfd, 0xae, 0xb5)) + pack("q", self$query_id) + pack("q", self$user_id) + self$serializebytes(self$payload) + self$shipping_address$bytes()
  ),
  private = list(
    from_reader = function(reader) list(query_id = reader$read_long(), user_id = reader$read_long(), payload = reader$tgreadbytes(), shipping_address = reader$tgread_object())
  ),
  class = TRUE
)

#  @title UpdateBotStopped
#  @description Telegram API type UpdateBotStopped
#  @export
#  @noRd
#  @noRd
UpdateBotStopped <- R6::R6Class("UpdateBotStopped",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0x49, 0x0a, 0x87, 0xc4)) + pack("q", self$user_id) + self$serialize_datetime(self$date) + (if (self$stopped) as.raw(c(0xb5, 0x75, 0x72, 0x99)) else as.raw(c(0x37, 0x97, 0x79, 0xbc))) + pack("i", self$qts)
  ),
  private = list(
    from_reader = function(reader) list(user_id = reader$read_long(), date = reader$tgread_date(), stopped = reader$tgread_bool(), qts = reader$read_int())
  ),
  class = TRUE
)

#  @title UpdateBotWebhookJSON
#  @description Telegram API type UpdateBotWebhookJSON
#  @export
#  @noRd
#  @noRd
UpdateBotWebhookJSON <- R6::R6Class("UpdateBotWebhookJSON",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0xc3, 0xc0, 0x17, 0x83)) + self$data$bytes()
  ),
  private = list(
    from_reader = function(reader) list(data = reader$tgread_object())
  ),
  class = TRUE
)

#  @title UpdateBotWebhookJSONQuery
#  @description Telegram API type UpdateBotWebhookJSONQuery
#  @export
#  @noRd
#  @noRd
UpdateBotWebhookJSONQuery <- R6::R6Class("UpdateBotWebhookJSONQuery",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0xa6, 0x40, 0x92, 0x9b)) + pack("q", self$query_id) + self$data$bytes() + pack("i", self$timeout)
  ),
  private = list(
    from_reader = function(reader) list(query_id = reader$read_long(), data = reader$tgread_object(), timeout = reader$read_int())
  ),
  class = TRUE
)

#  @title UpdateBusinessBotCallbackQuery
#  @description Telegram API type UpdateBusinessBotCallbackQuery
#  @export
#  @noRd
#  @noRd
UpdateBusinessBotCallbackQuery <- R6::R6Class("UpdateBusinessBotCallbackQuery",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0xa7, 0xfd, 0xa2, 0x1e)) + pack("I", (if (is.null(self$reply_to_message)) 0 else 4) | (if (is.null(self$data)) 0 else 1)) + pack("q", self$query_id) + pack("q", self$user_id) + self$serializebytes(self$connection_id) + self$message$bytes() + if (!is.null(self$reply_to_message)) self$reply_to_message$bytes() else raw(0) + pack("q", self$chat_instance) + if (!is.null(self$data)) self$serializebytes(self$data) else raw(0)
  ),
  private = list(
    from_reader = function(reader) list(flags = reader$read_int(), query_id = reader$read_long(), user_id = reader$read_long(), connection_id = reader$tgread_string(), message = reader$tgread_object(), reply_to_message = if (flags & 4) reader$tgread_object() else NULL, chat_instance = reader$read_long(), data = if (flags & 1) reader$tgreadbytes() else NULL)
  ),
  class = TRUE
)

#  @title UpdateChannel
#  @description Telegram API type UpdateChannel
#  @export
#  @noRd
#  @noRd
UpdateChannel <- R6::R6Class("UpdateChannel",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0x09, 0x4c, 0x5b, 0x63)) + pack("q", self$channel_id)
  ),
  private = list(
    from_reader = function(reader) list(channel_id = reader$read_long())
  ),
  class = TRUE
)

#  @title UpdateChannelAvailableMessages
#  @description Telegram API type UpdateChannelAvailableMessages
#  @export
#  @noRd
#  @noRd
UpdateChannelAvailableMessages <- R6::R6Class("UpdateChannelAvailableMessages",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0x98, 0xc6, 0x3f, 0xb2)) + pack("q", self$channel_id) + pack("i", self$available_min_id)
  ),
  private = list(
    from_reader = function(reader) list(channel_id = reader$read_long(), available_min_id = reader$read_int())
  ),
  class = TRUE
)

#  @title UpdateChannelMessageForwards
#  @description Telegram API type UpdateChannelMessageForwards
#  @export
#  @noRd
#  @noRd
UpdateChannelMessageForwards <- R6::R6Class("UpdateChannelMessageForwards",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0xf4, 0x27, 0x9a, 0xd2)) + pack("q", self$channel_id) + pack("i", self$id) + pack("i", self$forwards)
  ),
  private = list(
    from_reader = function(reader) list(channel_id = reader$read_long(), id = reader$read_int(), forwards = reader$read_int())
  ),
  class = TRUE
)

#  @title UpdateChannelMessageViews
#  @description Telegram API type UpdateChannelMessageViews
#  @export
#  @noRd
#  @noRd
UpdateChannelMessageViews <- R6::R6Class("UpdateChannelMessageViews",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0x08, 0xac, 0x26, 0xf2)) + pack("q", self$channel_id) + pack("i", self$id) + pack("i", self$views)
  ),
  private = list(
    from_reader = function(reader) list(channel_id = reader$read_long(), id = reader$read_int(), views = reader$read_int())
  ),
  class = TRUE
)

#  @title UpdateChannelParticipant
#  @description Telegram API type UpdateChannelParticipant
#  @export
#  @noRd
#  @noRd
UpdateChannelParticipant <- R6::R6Class("UpdateChannelParticipant",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0xbb, 0x3a, 0x5d, 0x98)) + pack("I", (if (is.null(self$via_chatlist)) 0 else 8) | (if (is.null(self$prev_participant)) 0 else 1) | (if (is.null(self$new_participant)) 0 else 2) | (if (is.null(self$invite)) 0 else 4)) + pack("q", self$channel_id) + self$serialize_datetime(self$date) + pack("q", self$actor_id) + pack("q", self$user_id) + if (!is.null(self$prev_participant)) self$prev_participant$bytes() else raw(0) + if (!is.null(self$new_participant)) self$new_participant$bytes() else raw(0) + if (!is.null(self$invite)) self$invite$bytes() else raw(0) + pack("i", self$qts)
  ),
  private = list(
    from_reader = function(reader) list(flags = reader$read_int(), via_chatlist = (flags & 8) != 0, channel_id = reader$read_long(), date = reader$tgread_date(), actor_id = reader$read_long(), user_id = reader$read_long(), prev_participant = if (flags & 1) reader$tgread_object() else NULL, new_participant = if (flags & 2) reader$tgread_object() else NULL, invite = if (flags & 4) reader$tgread_object() else NULL, qts = reader$read_int())
  ),
  class = TRUE
)

#  @title UpdateChannelPinnedTopic
#  @description Telegram API type UpdateChannelPinnedTopic
#  @export
#  @noRd
#  @noRd
UpdateChannelPinnedTopic <- R6::R6Class("UpdateChannelPinnedTopic",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0xe3, 0xfb, 0x2e, 0x19)) + pack("I", (if (is.null(self$pinned)) 0 else 1)) + pack("q", self$channel_id) + pack("i", self$topic_id)
  ),
  private = list(
    from_reader = function(reader) list(flags = reader$read_int(), pinned = (flags & 1) != 0, channel_id = reader$read_long(), topic_id = reader$read_int())
  ),
  class = TRUE
)

#  @title UpdateChannelPinnedTopics
#  @description Telegram API type UpdateChannelPinnedTopics
#  @export
#  @noRd
#  @noRd
UpdateChannelPinnedTopics <- R6::R6Class("UpdateChannelPinnedTopics",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0x02, 0x86, 0x19, 0xfe)) + pack("I", (if (is.null(self$order)) 0 else 1)) + pack("q", self$channel_id) + if (!is.null(self$order)) (as.raw(c(0x15, 0xc4, 0xb5, 0x1c)) + pack("i", length(self$order)) + do.call(c, lapply(self$order, function(x) pack("i", x)))) else raw(0)
  ),
  private = list(
    from_reader = function(reader) {
      list(flags = reader$read_int(), channel_id = reader$read_long(), order = if (flags & 1) {
        reader$read_int()
        lapply(seq_len(reader$read_int()), function(x) reader$read_int())
      } else {
        NULL
      })
    }
  ),
  class = TRUE
)

#  @title UpdateChannelReadMessagesContents
#  @description Telegram API type UpdateChannelReadMessagesContents
#  @export
#  @noRd
#  @noRd
UpdateChannelReadMessagesContents <- R6::R6Class("UpdateChannelReadMessagesContents",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0xf7, 0x24, 0xf3, 0x25)) + pack("I", (if (is.null(self$top_msg_id)) 0 else 1) | (if (is.null(self$savedpeer_id)) 0 else 2)) + pack("q", self$channel_id) + if (!is.null(self$top_msg_id)) pack("i", self$top_msg_id) else raw(0) + if (!is.null(self$savedpeer_id)) self$savedpeer_id$bytes() else raw(0) + (as.raw(c(0x15, 0xc4, 0xb5, 0x1c)) + pack("i", length(self$messages)) + do.call(c, lapply(self$messages, function(x) pack("i", x))))
  ),
  private = list(
    from_reader = function(reader) {
      list(flags = reader$read_int(), channel_id = reader$read_long(), top_msg_id = if (flags & 1) reader$read_int() else NULL, savedpeer_id = if (flags & 2) reader$tgread_object() else NULL, messages = {
        reader$read_int()
        lapply(seq_len(reader$read_int()), function(x) reader$read_int())
      })
    }
  ),
  class = TRUE
)

#  @title UpdateChannelTooLong
#  @description Telegram API type UpdateChannelTooLong
#  @export
#  @noRd
#  @noRd
UpdateChannelTooLong <- R6::R6Class("UpdateChannelTooLong",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0x1f, 0x94, 0x8d, 0x10)) + pack("I", (if (is.null(self$pts)) 0 else 1)) + pack("q", self$channel_id) + if (!is.null(self$pts)) pack("i", self$pts) else raw(0)
  ),
  private = list(
    from_reader = function(reader) list(flags = reader$read_int(), channel_id = reader$read_long(), pts = if (flags & 1) reader$read_int() else NULL)
  ),
  class = TRUE
)

#  @title UpdateChannelUserTyping
#  @description Telegram API type UpdateChannelUserTyping
#  @export
#  @noRd
#  @noRd
UpdateChannelUserTyping <- R6::R6Class("UpdateChannelUserTyping",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0x23, 0xc9, 0x88, 0x8c)) + pack("I", (if (is.null(self$top_msg_id)) 0 else 1)) + pack("q", self$channel_id) + if (!is.null(self$top_msg_id)) pack("i", self$top_msg_id) else raw(0) + self$from_id$bytes() + self$action$bytes()
  ),
  private = list(
    from_reader = function(reader) list(flags = reader$read_int(), channel_id = reader$read_long(), top_msg_id = if (flags & 1) reader$read_int() else NULL, from_id = reader$tgread_object(), action = reader$tgread_object())
  ),
  class = TRUE
)

#  @title UpdateChannelViewForumAsMessages
#  @description Telegram API type UpdateChannelViewForumAsMessages
#  @export
#  @noRd
#  @noRd
UpdateChannelViewForumAsMessages <- R6::R6Class("UpdateChannelViewForumAsMessages",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0x20, 0x89, 0xb6, 0x07)) + pack("q", self$channel_id) + (if (self$enabled) as.raw(c(0xb5, 0x75, 0x72, 0x99)) else as.raw(c(0x37, 0x97, 0x79, 0xbc)))
  ),
  private = list(
    from_reader = function(reader) list(channel_id = reader$read_long(), enabled = reader$tgread_bool())
  ),
  class = TRUE
)

#  @title UpdateChannelWebPage
#  @description Telegram API type UpdateChannelWebPage
#  @export
#  @noRd
#  @noRd
UpdateChannelWebPage <- R6::R6Class("UpdateChannelWebPage",
  inherit = TLObject,
  public = list(
    bytes = function() as.raw(c(0x9f, 0xa9, 0x2b, 0x2f)) + pack("q", self$channel_id) + self$webpage$bytes() + pack("i", self$pts) + pack("i", self$pts_count)
  ),
  private = list(
    from_reader = function(reader) list(channel_id = reader$read_long(), webpage = reader$tgread_object(), pts = reader$read_int(), pts_count = reader$read_int())
  ),
  class = TRUE
)

#  @title UpdateChat
#  @description Telegram API type UpdateChat
#  @export
#  @noRd
#  @noRd
UpdateChat <- R6::R6Class("UpdateChat",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf89a6a4e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(chat_id) {
      self$chat_id <- chat_id
    },
    to_dict = function() {
      list(`_` = "UpdateChat", chat_id = self$chat_id)
    },
    bytes = function() {
      c(as.raw(c(0x4e, 0x6a, 0x9a, 0xf8)), pack("q", self$chat_id))
    }
  ),
  private = list(
    from_reader = function(reader) {
      chat_id <- reader$read_long()
      self$initialize(chat_id)
    }
  ),
  class = TRUE
)

#  @title UpdateChatDefaultBannedRights
#  @description Telegram API type UpdateChatDefaultBannedRights
#  @export
#  @noRd
#  @noRd
UpdateChatDefaultBannedRights <- R6::R6Class("UpdateChatDefaultBannedRights",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x54c01850,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(peer, default_banned_rights, version) {
      self$peer <- peer
      self$default_banned_rights <- default_banned_rights
      self$version <- version
    },
    to_dict = function() {
      list(`_` = "UpdateChatDefaultBannedRights", peer = if (is.null(self$peer)) NULL else self$peer$to_dict(), default_banned_rights = if (is.null(self$default_banned_rights)) NULL else self$default_banned_rights$to_dict(), version = self$version)
    },
    bytes = function() {
      c(as.raw(c(0x50, 0x18, 0xc0, 0x54)), self$peer$bytes(), self$default_banned_rights$bytes(), pack("i", self$version))
    }
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      default_banned_rights <- reader$tgread_object()
      version <- reader$read_int()
      self$initialize(peer, default_banned_rights, version)
    }
  ),
  class = TRUE
)

#  @title UpdateChatParticipant
#  @description Telegram API type UpdateChatParticipant
#  @export
#  @noRd
#  @noRd
UpdateChatParticipant <- R6::R6Class("UpdateChatParticipant",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd087663a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(chat_id, date, actor_id, user_id, qts, prev_participant = NULL, new_participant = NULL, invite = NULL) {
      self$chat_id <- chat_id
      self$date <- date
      self$actor_id <- actor_id
      self$user_id <- user_id
      self$qts <- qts
      self$prev_participant <- prev_participant
      self$new_participant <- new_participant
      self$invite <- invite
    },
    to_dict = function() {
      list(`_` = "UpdateChatParticipant", chat_id = self$chat_id, date = self$date, actor_id = self$actor_id, user_id = self$user_id, qts = self$qts, prev_participant = if (is.null(self$prev_participant)) NULL else self$prev_participant$to_dict(), new_participant = if (is.null(self$new_participant)) NULL else self$new_participant$to_dict(), invite = if (is.null(self$invite)) NULL else self$invite$to_dict())
    },
    bytes = function() {
      flags <- (if (is.null(self$prev_participant)) 0 else 1) | (if (is.null(self$new_participant)) 0 else 2) | (if (is.null(self$invite)) 0 else 4)
      c(as.raw(c(0x3a, 0x66, 0x87, 0xd0)), pack("I", flags), pack("q", self$chat_id), self$serialize_datetime(self$date), pack("q", self$actor_id), pack("q", self$user_id), if (!is.null(self$prev_participant)) self$prev_participant$bytes() else raw(0), if (!is.null(self$new_participant)) self$new_participant$bytes() else raw(0), if (!is.null(self$invite)) self$invite$bytes() else raw(0), pack("i", self$qts))
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      chat_id <- reader$read_long()
      date <- reader$tgread_date()
      actor_id <- reader$read_long()
      user_id <- reader$read_long()
      prev_participant <- if (flags & 1) reader$tgread_object() else NULL
      new_participant <- if (flags & 2) reader$tgread_object() else NULL
      invite <- if (flags & 4) reader$tgread_object() else NULL
      qts <- reader$read_int()
      self$initialize(chat_id, date, actor_id, user_id, qts, prev_participant, new_participant, invite)
    }
  ),
  class = TRUE
)

#  @title UpdateChatParticipantAdd
#  @description Telegram API type UpdateChatParticipantAdd
#  @export
#  @noRd
#  @noRd
UpdateChatParticipantAdd <- R6::R6Class("UpdateChatParticipantAdd",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x3dda5451,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(chat_id, user_id, inviter_id, date, version) {
      self$chat_id <- chat_id
      self$user_id <- user_id
      self$inviter_id <- inviter_id
      self$date <- date
      self$version <- version
    },
    to_dict = function() {
      list(`_` = "UpdateChatParticipantAdd", chat_id = self$chat_id, user_id = self$user_id, inviter_id = self$inviter_id, date = self$date, version = self$version)
    },
    bytes = function() {
      c(as.raw(c(0x51, 0x54, 0xda, 0x3d)), pack("q", self$chat_id), pack("q", self$user_id), pack("q", self$inviter_id), self$serialize_datetime(self$date), pack("i", self$version))
    }
  ),
  private = list(
    from_reader = function(reader) {
      chat_id <- reader$read_long()
      user_id <- reader$read_long()
      inviter_id <- reader$read_long()
      date <- reader$tgread_date()
      version <- reader$read_int()
      self$initialize(chat_id, user_id, inviter_id, date, version)
    }
  ),
  class = TRUE
)

#  @title UpdateChatParticipantAdmin
#  @description Telegram API type UpdateChatParticipantAdmin
#  @export
#  @noRd
#  @noRd
UpdateChatParticipantAdmin <- R6::R6Class("UpdateChatParticipantAdmin",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd7ca61a2,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(chat_id, user_id, is_admin, version) {
      self$chat_id <- chat_id
      self$user_id <- user_id
      self$is_admin <- is_admin
      self$version <- version
    },
    to_dict = function() {
      list(`_` = "UpdateChatParticipantAdmin", chat_id = self$chat_id, user_id = self$user_id, is_admin = self$is_admin, version = self$version)
    },
    bytes = function() {
      c(as.raw(c(0xa2, 0x61, 0xca, 0xd7)), pack("q", self$chat_id), pack("q", self$user_id), if (self$is_admin) as.raw(c(0xb5, 0x75, 0x72, 0x99)) else as.raw(c(0x37, 0x97, 0x79, 0xbc)), pack("i", self$version))
    }
  ),
  private = list(
    from_reader = function(reader) {
      chat_id <- reader$read_long()
      user_id <- reader$read_long()
      is_admin <- reader$tgread_bool()
      version <- reader$read_int()
      self$initialize(chat_id, user_id, is_admin, version)
    }
  ),
  class = TRUE
)

#  @title UpdateChatParticipantDelete
#  @description Telegram API type UpdateChatParticipantDelete
#  @export
#  @noRd
#  @noRd
UpdateChatParticipantDelete <- R6::R6Class("UpdateChatParticipantDelete",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe32f3d77,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(chat_id, user_id, version) {
      self$chat_id <- chat_id
      self$user_id <- user_id
      self$version <- version
    },
    to_dict = function() {
      list(`_` = "UpdateChatParticipantDelete", chat_id = self$chat_id, user_id = self$user_id, version = self$version)
    },
    bytes = function() {
      c(as.raw(c(0x77, 0x3d, 0x2f, 0xe3)), pack("q", self$chat_id), pack("q", self$user_id), pack("i", self$version))
    }
  ),
  private = list(
    from_reader = function(reader) {
      chat_id <- reader$read_long()
      user_id <- reader$read_long()
      version <- reader$read_int()
      self$initialize(chat_id, user_id, version)
    }
  ),
  class = TRUE
)

#  @title UpdateChatParticipants
#  @description Telegram API type UpdateChatParticipants
#  @export
#  @noRd
#  @noRd
UpdateChatParticipants <- R6::R6Class("UpdateChatParticipants",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7761198,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(participants) {
      self$participants <- participants
    },
    to_dict = function() {
      list(
        `_` = "UpdateChatParticipants",
        participants = if (inherits(self$participants, "TLObject")) self$participants$to_dict() else self$participants
      )
    },
    bytes = function() {
      c(as.raw(c(0x98, 0x11, 0x76, 0x07)), self$participants$bytes())
    }
  ),
  private = list(
    from_reader = function(reader) {
      participants <- reader$tgread_object()
      self$initialize(participants)
    }
  ),
  class = TRUE
)

#  @title UpdateChatUserTyping
#  @description Telegram API type UpdateChatUserTyping
#  @export
#  @noRd
#  @noRd
UpdateChatUserTyping <- R6::R6Class("UpdateChatUserTyping",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x83487af0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(chat_id, from_id, action) {
      self$chat_id <- chat_id
      self$from_id <- from_id
      self$action <- action
    },
    to_dict = function() {
      list(
        `_` = "UpdateChatUserTyping",
        chat_id = self$chat_id,
        from_id = if (inherits(self$from_id, "TLObject")) self$from_id$to_dict() else self$from_id,
        action = if (inherits(self$action, "TLObject")) self$action$to_dict() else self$action
      )
    },
    bytes = function() {
      c(as.raw(c(0xf0, 0x7a, 0x48, 0x83)), pack("q", self$chat_id), self$from_id$bytes(), self$action$bytes())
    }
  ),
  private = list(
    from_reader = function(reader) {
      chat_id <- reader$read_long()
      from_id <- reader$tgread_object()
      action <- reader$tgread_object()
      self$initialize(chat_id, from_id, action)
    }
  ),
  class = TRUE
)

#  @title UpdateConfig
#  @description Telegram API type UpdateConfig
#  @export
#  @noRd
#  @noRd
UpdateConfig <- R6::R6Class("UpdateConfig",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa229dd06,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    to_dict = function() {
      list(`_` = "UpdateConfig")
    },
    bytes = function() {
      as.raw(c(0x06, 0xdd, 0x29, 0xa2))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title UpdateContactsReset
#  @description Telegram API type UpdateContactsReset
#  @export
#  @noRd
#  @noRd
UpdateContactsReset <- R6::R6Class("UpdateContactsReset",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7084a7be,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    to_dict = function() {
      list(`_` = "UpdateContactsReset")
    },
    bytes = function() {
      as.raw(c(0xbe, 0xa7, 0x84, 0x70))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title UpdateDcOptions
#  @description Telegram API type UpdateDcOptions
#  @export
#  @noRd
#  @noRd
UpdateDcOptions <- R6::R6Class("UpdateDcOptions",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8e5e9873,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(dc_options) {
      self$dc_options <- dc_options
    },
    to_dict = function() {
      list(
        `_` = "UpdateDcOptions",
        dc_options = lapply(self$dc_options, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      )
    },
    bytes = function() {
      c(as.raw(c(0x73, 0x98, 0x5e, 0x8e)), as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$dc_options)), do.call(c, lapply(self$dc_options, function(x) x$bytes())))
    }
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      dc_options <- lapply(seq_len(reader$read_int()), function(x) reader$tgread_object())
      self$initialize(dc_options)
    }
  ),
  class = TRUE
)

#  @title UpdateDeleteChannelMessages
#  @description Telegram API type UpdateDeleteChannelMessages
#  @export
#  @noRd
#  @noRd
UpdateDeleteChannelMessages <- R6::R6Class("UpdateDeleteChannelMessages",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc32d5b12,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(channel_id, messages, pts, pts_count) {
      self$channel_id <- channel_id
      self$messages <- messages
      self$pts <- pts
      self$pts_count <- pts_count
    },
    to_dict = function() {
      list(
        `_` = "UpdateDeleteChannelMessages",
        channel_id = self$channel_id,
        messages = self$messages,
        pts = self$pts,
        pts_count = self$pts_count
      )
    },
    bytes = function() {
      c(as.raw(c(0x12, 0x5b, 0x2d, 0xc3)), pack("q", self$channel_id), as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$messages)), do.call(c, lapply(self$messages, function(x) pack("i", x))), pack("i", self$pts), pack("i", self$pts_count))
    }
  ),
  private = list(
    from_reader = function(reader) {
      channel_id <- reader$read_long()
      reader$read_int()
      messages <- lapply(seq_len(reader$read_int()), function(x) reader$read_int())
      pts <- reader$read_int()
      pts_count <- reader$read_int()
      self$initialize(channel_id, messages, pts, pts_count)
    }
  ),
  class = TRUE
)

#  @title UpdateDeleteMessages
#  @description Telegram API type UpdateDeleteMessages
#  @export
#  @noRd
#  @noRd
UpdateDeleteMessages <- R6::R6Class("UpdateDeleteMessages",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa20db0e5,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(messages, pts, pts_count) {
      self$messages <- messages
      self$pts <- pts
      self$pts_count <- pts_count
    },
    to_dict = function() {
      list(
        `_` = "UpdateDeleteMessages",
        messages = self$messages,
        pts = self$pts,
        pts_count = self$pts_count
      )
    },
    bytes = function() {
      c(as.raw(c(0xe5, 0xb0, 0x0d, 0xa2)), as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$messages)), do.call(c, lapply(self$messages, function(x) pack("i", x))), pack("i", self$pts), pack("i", self$pts_count))
    }
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      messages <- lapply(seq_len(reader$read_int()), function(x) reader$read_int())
      pts <- reader$read_int()
      pts_count <- reader$read_int()
      self$initialize(messages, pts, pts_count)
    }
  ),
  class = TRUE
)

#  @title UpdateDeleteQuickReply
#  @description Telegram API type UpdateDeleteQuickReply
#  @export
#  @noRd
#  @noRd
UpdateDeleteQuickReply <- R6::R6Class("UpdateDeleteQuickReply",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x53e6f1ec,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(shortcut_id) {
      self$shortcut_id <- shortcut_id
    },
    to_dict = function() {
      list(
        `_` = "UpdateDeleteQuickReply",
        shortcut_id = self$shortcut_id
      )
    },
    bytes = function() {
      c(as.raw(c(0xec, 0xf1, 0xe6, 0x53)), pack("i", self$shortcut_id))
    }
  ),
  private = list(
    from_reader = function(reader) {
      shortcut_id <- reader$read_int()
      self$initialize(shortcut_id)
    }
  ),
  class = TRUE
)

#  @title UpdateDeleteQuickReplyMessages
#  @description Telegram API type UpdateDeleteQuickReplyMessages
#  @export
#  @noRd
#  @noRd
UpdateDeleteQuickReplyMessages <- R6::R6Class("UpdateDeleteQuickReplyMessages",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x566fe7cd,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(shortcut_id, messages) {
      self$shortcut_id <- shortcut_id
      self$messages <- messages
    },
    to_dict = function() {
      list(
        `_` = "UpdateDeleteQuickReplyMessages",
        shortcut_id = self$shortcut_id,
        messages = self$messages
      )
    },
    bytes = function() {
      c(as.raw(c(0xcd, 0xe7, 0x6f, 0x56)), pack("i", self$shortcut_id), as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$messages)), do.call(c, lapply(self$messages, function(x) pack("i", x))))
    }
  ),
  private = list(
    from_reader = function(reader) {
      shortcut_id <- reader$read_int()
      reader$read_int()
      messages <- lapply(seq_len(reader$read_int()), function(x) reader$read_int())
      self$initialize(shortcut_id, messages)
    }
  ),
  class = TRUE
)

#  @title UpdateDeleteScheduledMessages
#  @description Telegram API type UpdateDeleteScheduledMessages
#  @export
#  @noRd
#  @noRd
UpdateDeleteScheduledMessages <- R6::R6Class("UpdateDeleteScheduledMessages",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf2a71983,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(peer, messages, sent_messages = NULL) {
      self$peer <- peer
      self$messages <- messages
      self$sent_messages <- sent_messages
    },
    to_dict = function() {
      list(
        `_` = "UpdateDeleteScheduledMessages",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        messages = self$messages,
        sent_messages = self$sent_messages
      )
    },
    bytes = function() {
      flags <- if (is.null(self$sent_messages)) 0 else 1
      c(as.raw(c(0x83, 0x19, 0xa7, 0xf2)), pack("I", flags), self$peer$bytes(), as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$messages)), do.call(c, lapply(self$messages, function(x) pack("i", x))), if (!is.null(self$sent_messages)) c(as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$sent_messages)), do.call(c, lapply(self$sent_messages, function(x) pack("i", x)))) else raw(0))
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      peer <- reader$tgread_object()
      reader$read_int()
      messages <- lapply(seq_len(reader$read_int()), function(x) reader$read_int())
      sent_messages <- if (flags & 1) {
        reader$read_int()
        lapply(seq_len(reader$read_int()), function(x) reader$read_int())
      } else {
        NULL
      }
      self$initialize(peer, messages, sent_messages)
    }
  ),
  class = TRUE
)

#  @title UpdateDialogFilter
#  @description Telegram API type UpdateDialogFilter
#  @export
#  @noRd
#  @noRd
UpdateDialogFilter <- R6::R6Class("UpdateDialogFilter",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x26ffde7d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(id, filter = NULL) {
      self$id <- id
      self$filter <- filter
    },
    to_dict = function() {
      list(
        `_` = "UpdateDialogFilter",
        id = self$id,
        filter = if (inherits(self$filter, "TLObject")) self$filter$to_dict() else self$filter
      )
    },
    bytes = function() {
      flags <- if (is.null(self$filter)) 0 else 1
      c(as.raw(c(0x7d, 0xde, 0xff, 0x26)), pack("I", flags), pack("i", self$id), if (!is.null(self$filter)) self$filter$bytes() else raw(0))
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      id <- reader$read_int()
      filter <- if (flags & 1) reader$tgread_object() else NULL
      self$initialize(id, filter)
    }
  ),
  class = TRUE
)

#  @title UpdateDialogFilterOrder
#  @description Telegram API type UpdateDialogFilterOrder
#  @export
#  @noRd
#  @noRd
UpdateDialogFilterOrder <- R6::R6Class("UpdateDialogFilterOrder",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa5d72105,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(order) {
      self$order <- order
    },
    to_dict = function() {
      list(
        `_` = "UpdateDialogFilterOrder",
        order = self$order
      )
    },
    bytes = function() {
      c(as.raw(c(0x05, 0x21, 0xd7, 0xa5)), as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$order)), do.call(c, lapply(self$order, function(x) pack("i", x))))
    }
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      order <- lapply(seq_len(reader$read_int()), function(x) reader$read_int())
      self$initialize(order)
    }
  ),
  class = TRUE
)

#  @title UpdateDialogFilters
#  @description Telegram API type UpdateDialogFilters
#  @export
#  @noRd
#  @noRd
UpdateDialogFilters <- R6::R6Class("UpdateDialogFilters",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x3504914f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    to_dict = function() {
      list(`_` = "UpdateDialogFilters")
    },
    bytes = function() {
      as.raw(c(0x4f, 0x91, 0x04, 0x35))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title UpdateDialogPinned
#  @description Telegram API type UpdateDialogPinned
#  @export
#  @noRd
#  @noRd
UpdateDialogPinned <- R6::R6Class("UpdateDialogPinned",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x6e6fe51c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(peer, pinned = NULL, folder_id = NULL) {
      self$peer <- peer
      self$pinned <- pinned
      self$folder_id <- folder_id
    },
    to_dict = function() {
      list(
        `_` = "UpdateDialogPinned",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        pinned = self$pinned,
        folder_id = self$folder_id
      )
    },
    bytes = function() {
      flags <- (if (is.null(self$pinned) || !self$pinned) 0 else 1) | (if (is.null(self$folder_id)) 0 else 2)
      c(as.raw(c(0x1c, 0xe5, 0x6f, 0x6e)), pack("I", flags), if (!is.null(self$folder_id)) pack("i", self$folder_id) else raw(0), self$peer$bytes())
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      pinned <- (flags & 1) != 0
      folder_id <- if (flags & 2) reader$read_int() else NULL
      peer <- reader$tgread_object()
      self$initialize(peer, pinned, folder_id)
    }
  ),
  class = TRUE
)

#  @title UpdateDialogUnreadMark
#  @description Telegram API type UpdateDialogUnreadMark
#  @export
#  @noRd
#  @noRd
UpdateDialogUnreadMark <- R6::R6Class("UpdateDialogUnreadMark",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb658f23e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(peer, unread = NULL, savedpeer_id = NULL) {
      self$peer <- peer
      self$unread <- unread
      self$savedpeer_id <- savedpeer_id
    },
    to_dict = function() {
      list(
        `_` = "UpdateDialogUnreadMark",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        unread = self$unread,
        savedpeer_id = if (inherits(self$savedpeer_id, "TLObject")) self$savedpeer_id$to_dict() else self$savedpeer_id
      )
    },
    bytes = function() {
      flags <- (if (is.null(self$unread) || !self$unread) 0 else 1) | (if (is.null(self$savedpeer_id)) 0 else 2)
      c(as.raw(c(0x3e, 0xf2, 0x58, 0xb6)), pack("I", flags), self$peer$bytes(), if (!is.null(self$savedpeer_id)) self$savedpeer_id$bytes() else raw(0))
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      unread <- (flags & 1) != 0
      peer <- reader$tgread_object()
      savedpeer_id <- if (flags & 2) reader$tgread_object() else NULL
      self$initialize(peer, unread, savedpeer_id)
    }
  ),
  class = TRUE
)

#  @title UpdateDraftMessage
#  @description Telegram API type UpdateDraftMessage
#  @export
#  @noRd
#  @noRd
UpdateDraftMessage <- R6::R6Class("UpdateDraftMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xedfc111e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(peer, draft, top_msg_id = NULL, savedpeer_id = NULL) {
      self$peer <- peer
      self$draft <- draft
      self$top_msg_id <- top_msg_id
      self$savedpeer_id <- savedpeer_id
    },
    to_dict = function() {
      list(`_` = "UpdateDraftMessage", peer = if (is.null(self$peer)) NULL else self$peer$to_dict(), draft = if (is.null(self$draft)) NULL else self$draft$to_dict(), top_msg_id = self$top_msg_id, savedpeer_id = if (is.null(self$savedpeer_id)) NULL else self$savedpeer_id$to_dict())
    },
    bytes = function() {
      c(as.raw(c(0x1e, 0x11, 0xfc, 0xed)), pack("I", (if (is.null(self$top_msg_id)) 0 else 1) | (if (is.null(self$savedpeer_id)) 0 else 2)), self$peer$bytes(), if (!is.null(self$top_msg_id)) pack("i", self$top_msg_id) else raw(0), if (!is.null(self$savedpeer_id)) self$savedpeer_id$bytes() else raw(0), self$draft$bytes())
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      peer <- reader$tgread_object()
      top_msg_id <- if (flags & 1) reader$read_int() else NULL
      savedpeer_id <- if (flags & 2) reader$tgread_object() else NULL
      draft <- reader$tgread_object()
      list(peer = peer, draft = draft, top_msg_id = top_msg_id, savedpeer_id = savedpeer_id)
    }
  ),
  class = TRUE
)

#  @title UpdateEditChannelMessage
#  @description Telegram API type UpdateEditChannelMessage
#  @export
#  @noRd
#  @noRd
UpdateEditChannelMessage <- R6::R6Class("UpdateEditChannelMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1b3f4df7,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(message, pts, pts_count) {
      self$message <- message
      self$pts <- pts
      self$pts_count <- pts_count
    },
    to_dict = function() {
      list(`_` = "UpdateEditChannelMessage", message = if (is.null(self$message)) NULL else self$message$to_dict(), pts = self$pts, pts_count = self$pts_count)
    },
    bytes = function() {
      c(as.raw(c(0xf7, 0x4d, 0x3f, 0x1b)), self$message$bytes(), pack("i", self$pts), pack("i", self$pts_count))
    }
  ),
  private = list(
    from_reader = function(reader) {
      message <- reader$tgread_object()
      pts <- reader$read_int()
      pts_count <- reader$read_int()
      list(message = message, pts = pts, pts_count = pts_count)
    }
  ),
  class = TRUE
)

#  @title UpdateEditMessage
#  @description Telegram API type UpdateEditMessage
#  @export
#  @noRd
#  @noRd
UpdateEditMessage <- R6::R6Class("UpdateEditMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe40370a3,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(message, pts, pts_count) {
      self$message <- message
      self$pts <- pts
      self$pts_count <- pts_count
    },
    to_dict = function() {
      list(`_` = "UpdateEditMessage", message = if (is.null(self$message)) NULL else self$message$to_dict(), pts = self$pts, pts_count = self$pts_count)
    },
    bytes = function() {
      c(as.raw(c(0xa3, 0x70, 0x03, 0xe4)), self$message$bytes(), pack("i", self$pts), pack("i", self$pts_count))
    }
  ),
  private = list(
    from_reader = function(reader) {
      message <- reader$tgread_object()
      pts <- reader$read_int()
      pts_count <- reader$read_int()
      list(message = message, pts = pts, pts_count = pts_count)
    }
  ),
  class = TRUE
)

#  @title UpdateEncryptedChatTyping
#  @description Telegram API type UpdateEncryptedChatTyping
#  @export
#  @noRd
#  @noRd
UpdateEncryptedChatTyping <- R6::R6Class("UpdateEncryptedChatTyping",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1710f156,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(chat_id) {
      self$chat_id <- chat_id
    },
    to_dict = function() {
      list(`_` = "UpdateEncryptedChatTyping", chat_id = self$chat_id)
    },
    bytes = function() {
      c(as.raw(c(0x56, 0xf1, 0x10, 0x17)), pack("i", self$chat_id))
    }
  ),
  private = list(
    from_reader = function(reader) {
      chat_id <- reader$read_int()
      list(chat_id = chat_id)
    }
  ),
  class = TRUE
)

#  @title UpdateEncryptedMessagesRead
#  @description Telegram API type UpdateEncryptedMessagesRead
#  @export
#  @noRd
#  @noRd
UpdateEncryptedMessagesRead <- R6::R6Class("UpdateEncryptedMessagesRead",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x38fe25b7,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(chat_id, max_date, date) {
      self$chat_id <- chat_id
      self$max_date <- max_date
      self$date <- date
    },
    to_dict = function() {
      list(`_` = "UpdateEncryptedMessagesRead", chat_id = self$chat_id, max_date = self$max_date, date = self$date)
    },
    bytes = function() {
      c(as.raw(c(0xb7, 0x25, 0xfe, 0x38)), pack("i", self$chat_id), self$serialize_datetime(self$max_date), self$serialize_datetime(self$date))
    }
  ),
  private = list(
    from_reader = function(reader) {
      chat_id <- reader$read_int()
      max_date <- reader$tgread_date()
      date <- reader$tgread_date()
      list(chat_id = chat_id, max_date = max_date, date = date)
    }
  ),
  class = TRUE
)

#  @title UpdateEncryption
#  @description Telegram API type UpdateEncryption
#  @export
#  @noRd
#  @noRd
UpdateEncryption <- R6::R6Class("UpdateEncryption",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb4a2e88d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(chat, date) {
      self$chat <- chat
      self$date <- date
    },
    to_dict = function() {
      list(`_` = "UpdateEncryption", chat = if (is.null(self$chat)) NULL else self$chat$to_dict(), date = self$date)
    },
    bytes = function() {
      c(as.raw(c(0x8d, 0xe8, 0xa2, 0xb4)), self$chat$bytes(), self$serialize_datetime(self$date))
    }
  ),
  private = list(
    from_reader = function(reader) {
      chat <- reader$tgread_object()
      date <- reader$tgread_date()
      list(chat = chat, date = date)
    }
  ),
  class = TRUE
)

#  @title UpdateFavedStickers
#  @description Telegram API type UpdateFavedStickers
#  @export
#  @noRd
#  @noRd
UpdateFavedStickers <- R6::R6Class("UpdateFavedStickers",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe511996d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    to_dict = function() {
      list(`_` = "UpdateFavedStickers")
    },
    bytes = function() {
      as.raw(c(0x6d, 0x99, 0x11, 0xe5))
    }
  ),
  private = list(
    from_reader = function(reader) self$new()
  ),
  class = TRUE
)

#  @title UpdateFolderPeers
#  @description Telegram API type UpdateFolderPeers
#  @export
#  @noRd
#  @noRd
UpdateFolderPeers <- R6::R6Class("UpdateFolderPeers",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x19360dc0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(folderpeers, pts, pts_count) {
      self$folderpeers <- folderpeers
      self$pts <- pts
      self$pts_count <- pts_count
    },
    to_dict = function() {
      list(`_` = "UpdateFolderPeers", folderpeers = lapply(self$folderpeers, function(x) if (is.null(x)) NULL else x$to_dict()), pts = self$pts, pts_count = self$pts_count)
    },
    bytes = function() {
      c(as.raw(c(0xc0, 0x0d, 0x36, 0x19)), as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$folderpeers)), do.call(c, lapply(self$folderpeers, function(x) x$bytes())), pack("i", self$pts), pack("i", self$pts_count))
    }
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      folderpeers <- lapply(seq_len(reader$read_int()), function(x) reader$tgread_object())
      pts <- reader$read_int()
      pts_count <- reader$read_int()
      list(folderpeers = folderpeers, pts = pts, pts_count = pts_count)
    }
  ),
  class = TRUE
)

#  @title UpdateGeoLiveViewed
#  @description Telegram API type UpdateGeoLiveViewed
#  @export
#  @noRd
#  @noRd
UpdateGeoLiveViewed <- R6::R6Class("UpdateGeoLiveViewed",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x871fb939,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(peer, msg_id) {
      self$peer <- peer
      self$msg_id <- msg_id
    },
    to_dict = function() {
      list(`_` = "UpdateGeoLiveViewed", peer = if (is.null(self$peer)) NULL else self$peer$to_dict(), msg_id = self$msg_id)
    },
    bytes = function() {
      c(as.raw(c(0x39, 0xb9, 0x1f, 0x87)), self$peer$bytes(), pack("i", self$msg_id))
    }
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      msg_id <- reader$read_int()
      list(peer = peer, msg_id = msg_id)
    }
  ),
  class = TRUE
)

#  @title UpdateGroupCall
#  @description Telegram API type UpdateGroupCall
#  @export
#  @noRd
#  @noRd
UpdateGroupCall <- R6::R6Class("UpdateGroupCall",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x97d64341,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(call, chat_id = NULL) {
      self$call <- call
      self$chat_id <- chat_id
    },
    to_dict = function() {
      list(`_` = "UpdateGroupCall", call = if (is.null(self$call)) NULL else self$call$to_dict(), chat_id = self$chat_id)
    },
    bytes = function() {
      c(as.raw(c(0x41, 0x43, 0xd6, 0x97)), pack("I", if (is.null(self$chat_id)) 0 else 1), if (!is.null(self$chat_id)) pack("q", self$chat_id) else raw(0), self$call$bytes())
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      chat_id <- if (flags & 1) reader$read_long() else NULL
      call <- reader$tgread_object()
      list(call = call, chat_id = chat_id)
    }
  ),
  class = TRUE
)

#  @title UpdateGroupCallChainBlocks
#  @description Telegram API type UpdateGroupCallChainBlocks
#  @export
#  @noRd
#  @noRd
UpdateGroupCallChainBlocks <- R6::R6Class("UpdateGroupCallChainBlocks",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa477288f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(call, sub_chain_id, blocks, next_offset) {
      self$call <- call
      self$sub_chain_id <- sub_chain_id
      self$blocks <- blocks
      self$next_offset <- next_offset
    },
    to_dict = function() {
      list(
        `_` = "UpdateGroupCallChainBlocks",
        call = if (inherits(self$call, "TLObject")) self$call$to_dict() else self$call,
        sub_chain_id = self$sub_chain_id,
        blocks = if (is.null(self$blocks)) list() else self$blocks,
        next_offset = self$next_offset
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x8f, 0x28, 0x77, 0xa4)),
        self$call$bytes(),
        pack("i", self$sub_chain_id),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$blocks)), do.call(c, lapply(self$blocks, self$serializebytes)),
        pack("i", self$next_offset)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      call <- reader$tgread_object()
      sub_chain_id <- reader$read_int()
      reader$read_int()
      blocks <- list()
      for (i in seq_len(reader$read_int())) {
        x <- reader$tgreadbytes()
        blocks <- c(blocks, x)
      }
      next_offset <- reader$read_int()
      self$initialize(call = call, sub_chain_id = sub_chain_id, blocks = blocks, next_offset = next_offset)
      self
    }
  ),
  class = TRUE
)

#  @title UpdateGroupCallConnection
#  @description Telegram API type UpdateGroupCallConnection
#  @export
#  @noRd
#  @noRd
UpdateGroupCallConnection <- R6::R6Class("UpdateGroupCallConnection",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb783982,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(params, presentation = NULL) {
      self$params <- params
      self$presentation <- presentation
    },
    to_dict = function() {
      list(
        `_` = "UpdateGroupCallConnection",
        params = if (inherits(self$params, "TLObject")) self$params$to_dict() else self$params,
        presentation = self$presentation
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x82, 0x39, 0x83, 0x0b)),
        pack("I", if (is.null(self$presentation) || !self$presentation) 0 else 1),
        self$params$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      presentation <- (flags & 1) != 0
      params <- reader$tgread_object()
      self$initialize(params = params, presentation = presentation)
      self
    }
  ),
  class = TRUE
)

#  @title UpdateGroupCallParticipants
#  @description Telegram API type UpdateGroupCallParticipants
#  @export
#  @noRd
#  @noRd
UpdateGroupCallParticipants <- R6::R6Class("UpdateGroupCallParticipants",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf2ebdb4e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(call, participants, version) {
      self$call <- call
      self$participants <- participants
      self$version <- version
    },
    to_dict = function() {
      list(
        `_` = "UpdateGroupCallParticipants",
        call = if (inherits(self$call, "TLObject")) self$call$to_dict() else self$call,
        participants = if (is.null(self$participants)) list() else lapply(self$participants, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        version = self$version
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x4e, 0xdb, 0xeb, 0xf2)),
        self$call$bytes(),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$participants)), do.call(c, lapply(self$participants, function(x) x$bytes())),
        pack("i", self$version)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      call <- reader$tgread_object()
      reader$read_int()
      participants <- list()
      for (i in seq_len(reader$read_int())) {
        x <- reader$tgread_object()
        participants <- c(participants, x)
      }
      version <- reader$read_int()
      self$initialize(call = call, participants = participants, version = version)
      self
    }
  ),
  class = TRUE
)

#  @title UpdateInlineBotCallbackQuery
#  @description Telegram API type UpdateInlineBotCallbackQuery
#  @export
#  @noRd
#  @noRd
UpdateInlineBotCallbackQuery <- R6::R6Class("UpdateInlineBotCallbackQuery",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x691e9052,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(query_id, user_id, msg_id, chat_instance, data = NULL, game_short_name = NULL) {
      self$query_id <- query_id
      self$user_id <- user_id
      self$msg_id <- msg_id
      self$chat_instance <- chat_instance
      self$data <- data
      self$game_short_name <- game_short_name
    },
    to_dict = function() {
      list(
        `_` = "UpdateInlineBotCallbackQuery",
        query_id = self$query_id,
        user_id = self$user_id,
        msg_id = if (inherits(self$msg_id, "TLObject")) self$msg_id$to_dict() else self$msg_id,
        chat_instance = self$chat_instance,
        data = self$data,
        game_short_name = self$game_short_name
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x52, 0x90, 0x1e, 0x69)),
        pack("I", (if (is.null(self$data)) 0 else 1) | (if (is.null(self$game_short_name)) 0 else 2)),
        pack("q", self$query_id),
        pack("q", self$user_id),
        self$msg_id$bytes(),
        pack("q", self$chat_instance),
        if (!is.null(self$data)) self$serializebytes(self$data) else raw(0),
        if (!is.null(self$game_short_name)) self$serializebytes(self$game_short_name) else raw(0)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      query_id <- reader$read_long()
      user_id <- reader$read_long()
      msg_id <- reader$tgread_object()
      chat_instance <- reader$read_long()
      data <- if (flags & 1) reader$tgreadbytes() else NULL
      game_short_name <- if (flags & 2) reader$tgread_string() else NULL
      self$initialize(query_id = query_id, user_id = user_id, msg_id = msg_id, chat_instance = chat_instance, data = data, game_short_name = game_short_name)
      self
    }
  ),
  class = TRUE
)

#  @title UpdateLangPack
#  @description Telegram API type UpdateLangPack
#  @export
#  @noRd
#  @noRd
UpdateLangPack <- R6::R6Class("UpdateLangPack",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x56022f4d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(difference) {
      self$difference <- difference
    },
    to_dict = function() {
      list(
        `_` = "UpdateLangPack",
        difference = if (inherits(self$difference, "TLObject")) self$difference$to_dict() else self$difference
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x4d, 0x2f, 0x02, 0x56)),
        self$difference$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      difference <- reader$tgread_object()
      self$initialize(difference = difference)
      self
    }
  ),
  class = TRUE
)

#  @title UpdateLangPackTooLong
#  @description Telegram API type UpdateLangPackTooLong
#  @export
#  @noRd
#  @noRd
UpdateLangPackTooLong <- R6::R6Class("UpdateLangPackTooLong",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x46560264,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(lang_code) {
      self$lang_code <- lang_code
    },
    to_dict = function() {
      list(
        `_` = "UpdateLangPackTooLong",
        lang_code = self$lang_code
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x64, 0x02, 0x56, 0x46)),
        self$serializebytes(self$lang_code)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      lang_code <- reader$tgread_string()
      self$initialize(lang_code = lang_code)
      self
    }
  ),
  class = TRUE
)

#  @title UpdateLoginToken
#  @description Telegram API type UpdateLoginToken
#  @export
#  @noRd
#  @noRd
UpdateLoginToken <- R6::R6Class("UpdateLoginToken",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x564fe691,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    to_dict = function() {
      list(`_` = "UpdateLoginToken")
    },
    bytes = function() {
      as.raw(c(0x91, 0xe6, 0x4f, 0x56))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title UpdateMessageExtendedMedia
#  @description Telegram API type UpdateMessageExtendedMedia
#  @export
#  @noRd
#  @noRd
UpdateMessageExtendedMedia <- R6::R6Class("UpdateMessageExtendedMedia",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd5a41724,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(peer, msg_id, extended_media) {
      self$peer <- peer
      self$msg_id <- msg_id
      self$extended_media <- extended_media
    },
    to_dict = function() {
      list(
        `_` = "UpdateMessageExtendedMedia",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        msg_id = self$msg_id,
        extended_media = if (is.null(self$extended_media)) list() else lapply(self$extended_media, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x24, 0x17, 0xa4, 0xd5)),
        self$peer$bytes(),
        pack("i", self$msg_id),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$extended_media)), do.call(c, lapply(self$extended_media, function(x) x$bytes()))
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      msg_id <- reader$read_int()
      reader$read_int()
      extended_media <- list()
      for (i in seq_len(reader$read_int())) {
        x <- reader$tgread_object()
        extended_media <- c(extended_media, x)
      }
      self$initialize(peer = peer, msg_id = msg_id, extended_media = extended_media)
      self
    }
  ),
  class = TRUE
)

#  @title UpdateMessageID
#  @description Telegram API type UpdateMessageID
#  @export
#  @noRd
#  @noRd
UpdateMessageID <- R6::R6Class("UpdateMessageID",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4e90bfd6,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(id, random_id = NULL) {
      self$id <- id
      self$random_id <- if (is.null(random_id)) as.integer(runif(1, min = -2^63, max = 2^63 - 1)) else random_id
    },
    to_dict = function() {
      list(
        `_` = "UpdateMessageID",
        id = self$id,
        random_id = self$random_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xd6, 0xbf, 0x90, 0x4e)),
        pack("i", self$id),
        pack("q", self$random_id)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      id <- reader$read_int()
      random_id <- reader$read_long()
      self$initialize(id = id, random_id = random_id)
      self
    }
  ),
  class = TRUE
)

#  @title UpdateMessagePoll
#  @description Telegram API type UpdateMessagePoll
#  @export
#  @noRd
#  @noRd
UpdateMessagePoll <- R6::R6Class("UpdateMessagePoll",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xaca1657b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(poll_id, results, poll = NULL) {
      self$poll_id <- poll_id
      self$results <- results
      self$poll <- poll
    },
    to_dict = function() {
      list(
        `_` = "UpdateMessagePoll",
        poll_id = self$poll_id,
        results = if (inherits(self$results, "TLObject")) self$results$to_dict() else self$results,
        poll = if (inherits(self$poll, "TLObject")) self$poll$to_dict() else self$poll
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x7b, 0x65, 0xa1, 0xac)),
        pack("I", if (is.null(self$poll)) 0 else 1),
        pack("q", self$poll_id),
        if (!is.null(self$poll)) self$poll$bytes() else raw(0),
        self$results$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      poll_id <- reader$read_long()
      poll <- if (flags & 1) reader$tgread_object() else NULL
      results <- reader$tgread_object()
      self$initialize(poll_id = poll_id, results = results, poll = poll)
      self
    }
  ),
  class = TRUE
)

#  @title UpdateMessagePollVote
#  @description Telegram API type UpdateMessagePollVote
#  @export
#  @noRd
#  @noRd
UpdateMessagePollVote <- R6::R6Class("UpdateMessagePollVote",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x24f40e77,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(poll_id, peer, options, qts) {
      self$poll_id <- poll_id
      self$peer <- peer
      self$options <- options
      self$qts <- qts
    },
    to_dict = function() {
      list(
        `_` = "UpdateMessagePollVote",
        poll_id = self$poll_id,
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        options = if (is.null(self$options)) list() else self$options,
        qts = self$qts
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x77, 0x0e, 0xf4, 0x24)),
        pack("q", self$poll_id),
        self$peer$bytes(),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$options)), do.call(c, lapply(self$options, self$serializebytes)),
        pack("i", self$qts)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      poll_id <- reader$read_long()
      peer <- reader$tgread_object()
      reader$read_int()
      options <- list()
      for (i in seq_len(reader$read_int())) {
        x <- reader$tgreadbytes()
        options <- c(options, x)
      }
      qts <- reader$read_int()
      self$initialize(poll_id = poll_id, peer = peer, options = options, qts = qts)
      self
    }
  ),
  class = TRUE
)

#  @title UpdateMessageReactions
#  @description Telegram API type UpdateMessageReactions
#  @export
#  @noRd
#  @noRd
UpdateMessageReactions <- R6::R6Class("UpdateMessageReactions",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1e297bfa,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(peer, msg_id, reactions, top_msg_id = NULL, savedpeer_id = NULL) {
      self$peer <- peer
      self$msg_id <- msg_id
      self$reactions <- reactions
      self$top_msg_id <- top_msg_id
      self$savedpeer_id <- savedpeer_id
    },
    to_dict = function() {
      list(
        `_` = "UpdateMessageReactions",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        msg_id = self$msg_id,
        reactions = if (inherits(self$reactions, "TLObject")) self$reactions$to_dict() else self$reactions,
        top_msg_id = self$top_msg_id,
        savedpeer_id = if (inherits(self$savedpeer_id, "TLObject")) self$savedpeer_id$to_dict() else self$savedpeer_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xfa, 0x7b, 0x29, 0x1e)),
        pack("I", (if (is.null(self$top_msg_id)) 0 else 1) | (if (is.null(self$savedpeer_id)) 0 else 2)),
        self$peer$bytes(),
        pack("i", self$msg_id),
        if (!is.null(self$top_msg_id)) pack("i", self$top_msg_id) else raw(0),
        if (!is.null(self$savedpeer_id)) self$savedpeer_id$bytes() else raw(0),
        self$reactions$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      peer <- reader$tgread_object()
      msg_id <- reader$read_int()
      top_msg_id <- if (flags & 1) reader$read_int() else NULL
      savedpeer_id <- if (flags & 2) reader$tgread_object() else NULL
      reactions <- reader$tgread_object()
      self$initialize(peer = peer, msg_id = msg_id, reactions = reactions, top_msg_id = top_msg_id, savedpeer_id = savedpeer_id)
      self
    }
  ),
  class = TRUE
)

#  @title UpdateMonoForumNoPaidException
#  @description Telegram API type UpdateMonoForumNoPaidException
#  @export
#  @noRd
#  @noRd
UpdateMonoForumNoPaidException <- R6::R6Class("UpdateMonoForumNoPaidException",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9f812b08,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(channel_id, savedpeer_id, exception = NULL) {
      self$channel_id <- channel_id
      self$savedpeer_id <- savedpeer_id
      self$exception <- exception
    },
    to_dict = function() {
      list(
        `_` = "UpdateMonoForumNoPaidException",
        channel_id = self$channel_id,
        savedpeer_id = if (inherits(self$savedpeer_id, "TLObject")) self$savedpeer_id$to_dict() else self$savedpeer_id,
        exception = self$exception
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x08, 0x2b, 0x81, 0x9f)),
        pack("I", if (is.null(self$exception) || !self$exception) 0 else 1),
        pack("q", self$channel_id),
        self$savedpeer_id$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      exception <- (flags & 1) != 0
      channel_id <- reader$read_long()
      savedpeer_id <- reader$tgread_object()
      self$initialize(channel_id = channel_id, savedpeer_id = savedpeer_id, exception = exception)
      self
    }
  ),
  class = TRUE
)

#  @title UpdateMoveStickerSetToTop
#  @description Telegram API type UpdateMoveStickerSetToTop
#  @export
#  @noRd
#  @noRd
UpdateMoveStickerSetToTop <- R6::R6Class("UpdateMoveStickerSetToTop",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x86fccf85,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(stickerset, masks = NULL, emojis = NULL) {
      self$stickerset <- stickerset
      self$masks <- masks
      self$emojis <- emojis
    },
    to_dict = function() {
      list(
        `_` = "UpdateMoveStickerSetToTop",
        stickerset = self$stickerset,
        masks = self$masks,
        emojis = self$emojis
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x85, 0xcf, 0xfc, 0x86)),
        pack("I", (if (is.null(self$masks) || !self$masks) 0 else 1) | (if (is.null(self$emojis) || !self$emojis) 0 else 2)),
        pack("q", self$stickerset)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      masks <- (flags & 1) != 0
      emojis <- (flags & 2) != 0
      stickerset <- reader$read_long()
      self$initialize(stickerset = stickerset, masks = masks, emojis = emojis)
      self
    }
  ),
  class = TRUE
)

#  @title UpdateNewAuthorization
#  @description Telegram API type UpdateNewAuthorization
#  @export
#  @noRd
#  @noRd
UpdateNewAuthorization <- R6::R6Class("UpdateNewAuthorization",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8951abef,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(hash, unconfirmed = NULL, date = NULL, device = NULL, location = NULL) {
      self$hash <- hash
      self$unconfirmed <- unconfirmed
      self$date <- date
      self$device <- device
      self$location <- location
    },
    to_dict = function() {
      list(
        `_` = "UpdateNewAuthorization",
        hash = self$hash,
        unconfirmed = self$unconfirmed,
        date = self$date,
        device = self$device,
        location = self$location
      )
    },
    bytes = function() {
      flags <- (if (is.null(self$unconfirmed) || !self$unconfirmed) 0 else 1) | (if (is.null(self$date)) 0 else 1) | (if (is.null(self$device)) 0 else 1) | (if (is.null(self$location)) 0 else 1)
      c(
        as.raw(c(0xef, 0xab, 0x51, 0x89)),
        pack("I", flags),
        pack("q", self$hash),
        if (!is.null(self$date)) self$serialize_datetime(self$date) else raw(0),
        if (!is.null(self$device)) self$serializebytes(self$device) else raw(0),
        if (!is.null(self$location)) self$serializebytes(self$location) else raw(0)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      unconfirmed <- (flags & 1) != 0
      hash <- reader$read_long()
      date <- if (flags & 1) reader$tgread_date() else NULL
      device <- if (flags & 1) reader$tgread_string() else NULL
      location <- if (flags & 1) reader$tgread_string() else NULL
      self$initialize(hash = hash, unconfirmed = unconfirmed, date = date, device = device, location = location)
      self
    }
  ),
  class = TRUE
)

#  @title UpdateNewChannelMessage
#  @description Telegram API type UpdateNewChannelMessage
#  @export
#  @noRd
#  @noRd
UpdateNewChannelMessage <- R6::R6Class("UpdateNewChannelMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x62ba04d9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(message, pts, pts_count) {
      self$message <- message
      self$pts <- pts
      self$pts_count <- pts_count
    },
    to_dict = function() {
      list(
        `_` = "UpdateNewChannelMessage",
        message = if (inherits(self$message, "TLObject")) self$message$to_dict() else self$message,
        pts = self$pts,
        pts_count = self$pts_count
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xd9, 0x04, 0xba, 0x62)),
        self$message$bytes(),
        pack("i", self$pts),
        pack("i", self$pts_count)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      message <- reader$tgread_object()
      pts <- reader$read_int()
      pts_count <- reader$read_int()
      self$initialize(message = message, pts = pts, pts_count = pts_count)
      self
    }
  ),
  class = TRUE
)

#  @title UpdateNewEncryptedMessage
#  @description Telegram API type UpdateNewEncryptedMessage
#  @export
#  @noRd
#  @noRd
UpdateNewEncryptedMessage <- R6::R6Class("UpdateNewEncryptedMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x12bcbd9a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(message, qts) {
      self$message <- message
      self$qts <- qts
    },
    to_dict = function() {
      list(
        `_` = "UpdateNewEncryptedMessage",
        message = if (inherits(self$message, "TLObject")) self$message$to_dict() else self$message,
        qts = self$qts
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x9a, 0xbd, 0xbc, 0x12)),
        self$message$bytes(),
        pack("i", self$qts)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      message <- reader$tgread_object()
      qts <- reader$read_int()
      self$initialize(message = message, qts = qts)
      self
    }
  ),
  class = TRUE
)

#  @title UpdateNewMessage
#  @description Telegram API type UpdateNewMessage
#  @export
#  @noRd
#  @noRd
UpdateNewMessage <- R6::R6Class("UpdateNewMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1f2b0afd,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(message, pts, pts_count) {
      self$message <- message
      self$pts <- pts
      self$pts_count <- pts_count
    },
    to_dict = function() {
      list(
        `_` = "UpdateNewMessage",
        message = if (inherits(self$message, "TLObject")) self$message$to_dict() else self$message,
        pts = self$pts,
        pts_count = self$pts_count
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xfd, 0x0a, 0x2b, 0x1f)),
        self$message$bytes(),
        pack("i", self$pts),
        pack("i", self$pts_count)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      message <- reader$tgread_object()
      pts <- reader$read_int()
      pts_count <- reader$read_int()
      self$initialize(message = message, pts = pts, pts_count = pts_count)
      self
    }
  ),
  class = TRUE
)

#  @title UpdateNewQuickReply
#  @description Telegram API type UpdateNewQuickReply
#  @export
#  @noRd
#  @noRd
UpdateNewQuickReply <- R6::R6Class("UpdateNewQuickReply",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf53da717,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(quick_reply) {
      self$quick_reply <- quick_reply
    },
    to_dict = function() {
      list(
        `_` = "UpdateNewQuickReply",
        quick_reply = if (inherits(self$quick_reply, "TLObject")) self$quick_reply$to_dict() else self$quick_reply
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x17, 0xa7, 0x3d, 0xf5)),
        self$quick_reply$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      quick_reply <- reader$tgread_object()
      self$initialize(quick_reply = quick_reply)
      self
    }
  ),
  class = TRUE
)

#  @title UpdateNewScheduledMessage
#  @description Telegram API type UpdateNewScheduledMessage
#  @export
#  @noRd
#  @noRd
UpdateNewScheduledMessage <- R6::R6Class("UpdateNewScheduledMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x39a51dfb,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(message) {
      self$message <- message
    },
    to_dict = function() {
      list(
        `_` = "UpdateNewScheduledMessage",
        message = if (inherits(self$message, "TLObject")) self$message$to_dict() else self$message
      )
    },
    bytes = function() {
      c(as.raw(c(0xfb, 0x1d, 0xa5, 0x39)), self$message$bytes())
    }
  ),
  private = list(
    from_reader = function(reader) {
      message <- reader$tgread_object()
      self$new(message = message)
    }
  ),
  class = TRUE
)

#  @title UpdateNewStickerSet
#  @description Telegram API type UpdateNewStickerSet
#  @export
#  @noRd
#  @noRd
UpdateNewStickerSet <- R6::R6Class("UpdateNewStickerSet",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x688a30aa,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(stickerset) {
      self$stickerset <- stickerset
    },
    to_dict = function() {
      list(
        `_` = "UpdateNewStickerSet",
        stickerset = if (inherits(self$stickerset, "TLObject")) self$stickerset$to_dict() else self$stickerset
      )
    },
    bytes = function() {
      c(as.raw(c(0xaa, 0x30, 0x8a, 0x68)), self$stickerset$bytes())
    }
  ),
  private = list(
    from_reader = function(reader) {
      stickerset <- reader$tgread_object()
      self$new(stickerset = stickerset)
    }
  ),
  class = TRUE
)

#  @title UpdateNewStoryReaction
#  @description Telegram API type UpdateNewStoryReaction
#  @export
#  @noRd
#  @noRd
UpdateNewStoryReaction <- R6::R6Class("UpdateNewStoryReaction",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1824e40b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(story_id, peer, reaction) {
      self$story_id <- story_id
      self$peer <- peer
      self$reaction <- reaction
    },
    to_dict = function() {
      list(
        `_` = "UpdateNewStoryReaction",
        story_id = self$story_id,
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        reaction = if (inherits(self$reaction, "TLObject")) self$reaction$to_dict() else self$reaction
      )
    },
    bytes = function() {
      c(as.raw(c(0x0b, 0xe4, 0x24, 0x18)), pack("i", self$story_id), self$peer$bytes(), self$reaction$bytes())
    }
  ),
  private = list(
    from_reader = function(reader) {
      story_id <- reader$read_int()
      peer <- reader$tgread_object()
      reaction <- reader$tgread_object()
      self$new(story_id = story_id, peer = peer, reaction = reaction)
    }
  ),
  class = TRUE
)

#  @title UpdateNotifySettings
#  @description Telegram API type UpdateNotifySettings
#  @export
#  @noRd
#  @noRd
UpdateNotifySettings <- R6::R6Class("UpdateNotifySettings",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbec268ef,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(peer, notify_settings) {
      self$peer <- peer
      self$notify_settings <- notify_settings
    },
    to_dict = function() {
      list(
        `_` = "UpdateNotifySettings",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        notify_settings = if (inherits(self$notify_settings, "TLObject")) self$notify_settings$to_dict() else self$notify_settings
      )
    },
    bytes = function() {
      c(as.raw(c(0xef, 0x68, 0xc2, 0xbe)), self$peer$bytes(), self$notify_settings$bytes())
    }
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      notify_settings <- reader$tgread_object()
      self$new(peer = peer, notify_settings = notify_settings)
    }
  ),
  class = TRUE
)

#  @title UpdatePaidReactionPrivacy
#  @description Telegram API type UpdatePaidReactionPrivacy
#  @export
#  @noRd
#  @noRd
UpdatePaidReactionPrivacy <- R6::R6Class("UpdatePaidReactionPrivacy",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8b725fce,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(private) {
      self$private <- private
    },
    to_dict = function() {
      list(
        `_` = "UpdatePaidReactionPrivacy",
        private = if (inherits(self$private, "TLObject")) self$private$to_dict() else self$private
      )
    },
    bytes = function() {
      c(as.raw(c(0xce, 0x5f, 0x72, 0x8b)), self$private$bytes())
    }
  ),
  private = list(
    from_reader = function(reader) {
      private <- reader$tgread_object()
      self$new(private = private)
    }
  ),
  class = TRUE
)

#  @title UpdatePeerBlocked
#  @description Telegram API type UpdatePeerBlocked
#  @export
#  @noRd
#  @noRd
UpdatePeerBlocked <- R6::R6Class("UpdatePeerBlocked",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xebe07752,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(peer_id, blocked = NULL, blocked_my_stories_from = NULL) {
      self$peer_id <- peer_id
      self$blocked <- blocked
      self$blocked_my_stories_from <- blocked_my_stories_from
    },
    to_dict = function() {
      list(
        `_` = "UpdatePeerBlocked",
        peer_id = if (inherits(self$peer_id, "TLObject")) self$peer_id$to_dict() else self$peer_id,
        blocked = self$blocked,
        blocked_my_stories_from = self$blocked_my_stories_from
      )
    },
    bytes = function() {
      flags <- (if (is.null(self$blocked) || !self$blocked) 0 else 1) | (if (is.null(self$blocked_my_stories_from) || !self$blocked_my_stories_from) 0 else 2)
      c(pack("I", flags), self$peer_id$bytes())
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      blocked <- (flags & 1) != 0
      blocked_my_stories_from <- (flags & 2) != 0
      peer_id <- reader$tgread_object()
      self$new(peer_id = peer_id, blocked = blocked, blocked_my_stories_from = blocked_my_stories_from)
    }
  ),
  class = TRUE
)

#  @title UpdatePeerHistoryTTL
#  @description Telegram API type UpdatePeerHistoryTTL
#  @export
#  @noRd
#  @noRd
UpdatePeerHistoryTTL <- R6::R6Class("UpdatePeerHistoryTTL",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbb9bb9a5,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(peer, ttl_period = NULL) {
      self$peer <- peer
      self$ttl_period <- ttl_period
    },
    to_dict = function() {
      list(
        `_` = "UpdatePeerHistoryTTL",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        ttl_period = self$ttl_period
      )
    },
    bytes = function() {
      flags <- if (is.null(self$ttl_period)) 0 else 1
      c(as.raw(c(0xa5, 0xb9, 0x9b, 0xbb)), pack("I", flags), self$peer$bytes(), if (!is.null(self$ttl_period)) pack("i", self$ttl_period) else raw(0))
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      peer <- reader$tgread_object()
      ttl_period <- if (flags & 1) reader$read_int() else NULL
      self$new(peer = peer, ttl_period = ttl_period)
    }
  ),
  class = TRUE
)

#  @title UpdatePeerLocated
#  @description Telegram API type UpdatePeerLocated
#  @export
#  @noRd
#  @noRd
UpdatePeerLocated <- R6::R6Class("UpdatePeerLocated",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb4afcfb0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(peers) {
      self$peers <- peers
    },
    to_dict = function() {
      list(
        `_` = "UpdatePeerLocated",
        peers = lapply(self$peers, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      )
    },
    bytes = function() {
      c(as.raw(c(0xb0, 0xcf, 0xaf, 0xb4)), as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$peers)), do.call(c, lapply(self$peers, function(x) x$bytes())))
    }
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      peers <- lapply(seq_len(reader$read_int()), function(x) reader$tgread_object())
      self$new(peers = peers)
    }
  ),
  class = TRUE
)

#  @title UpdatePeerSettings
#  @description Telegram API type UpdatePeerSettings
#  @export
#  @noRd
#  @noRd
UpdatePeerSettings <- R6::R6Class("UpdatePeerSettings",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x6a7e7366,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(peer, settings) {
      self$peer <- peer
      self$settings <- settings
    },
    to_dict = function() {
      list(
        `_` = "UpdatePeerSettings",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        settings = if (inherits(self$settings, "TLObject")) self$settings$to_dict() else self$settings
      )
    },
    bytes = function() {
      c(as.raw(c(0x66, 0x73, 0x7e, 0x6a)), self$peer$bytes(), self$settings$bytes())
    }
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      settings <- reader$tgread_object()
      self$new(peer = peer, settings = settings)
    }
  ),
  class = TRUE
)

#  @title UpdatePeerWallpaper
#  @description Telegram API type UpdatePeerWallpaper
#  @export
#  @noRd
#  @noRd
UpdatePeerWallpaper <- R6::R6Class("UpdatePeerWallpaper",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xae3f101d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(peer, wallpaper_overridden = NULL, wallpaper = NULL) {
      self$peer <- peer
      self$wallpaper_overridden <- wallpaper_overridden
      self$wallpaper <- wallpaper
    },
    to_dict = function() {
      list(
        `_` = "UpdatePeerWallpaper",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        wallpaper_overridden = self$wallpaper_overridden,
        wallpaper = if (inherits(self$wallpaper, "TLObject")) self$wallpaper$to_dict() else self$wallpaper
      )
    },
    bytes = function() {
      flags <- (if (is.null(self$wallpaper_overridden) || !self$wallpaper_overridden) 0 else 2) | (if (is.null(self$wallpaper)) 0 else 1)
      c(as.raw(c(0x1d, 0x10, 0x3f, 0xae)), pack("I", flags), self$peer$bytes(), if (!is.null(self$wallpaper)) self$wallpaper$bytes() else raw(0))
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      wallpaper_overridden <- (flags & 2) != 0
      peer <- reader$tgread_object()
      wallpaper <- if (flags & 1) reader$tgread_object() else NULL
      self$new(peer = peer, wallpaper_overridden = wallpaper_overridden, wallpaper = wallpaper)
    }
  ),
  class = TRUE
)

#  @title UpdatePendingJoinRequests
#  @description Telegram API type UpdatePendingJoinRequests
#  @export
#  @noRd
#  @noRd
UpdatePendingJoinRequests <- R6::R6Class("UpdatePendingJoinRequests",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7063c3db,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(peer, requests_pending, recent_requesters) {
      self$peer <- peer
      self$requests_pending <- requests_pending
      self$recent_requesters <- recent_requesters
    },
    to_dict = function() {
      list(
        `_` = "UpdatePendingJoinRequests",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        requests_pending = self$requests_pending,
        recent_requesters = self$recent_requesters
      )
    },
    bytes = function() {
      c(as.raw(c(0xdb, 0xc3, 0x63, 0x70)), self$peer$bytes(), pack("i", self$requests_pending), as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$recent_requesters)), do.call(c, lapply(self$recent_requesters, function(x) pack("q", x))))
    }
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      requests_pending <- reader$read_int()
      reader$read_int()
      recent_requesters <- lapply(seq_len(reader$read_int()), function(x) reader$read_long())
      self$new(peer = peer, requests_pending = requests_pending, recent_requesters = recent_requesters)
    }
  ),
  class = TRUE
)

#  @title UpdatePhoneCall
#  @description Telegram API type UpdatePhoneCall
#  @export
#  @noRd
#  @noRd
UpdatePhoneCall <- R6::R6Class("UpdatePhoneCall",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xab0f6b1e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(phone_call) {
      self$phone_call <- phone_call
    },
    to_dict = function() {
      list(
        `_` = "UpdatePhoneCall",
        phone_call = if (inherits(self$phone_call, "TLObject")) self$phone_call$to_dict() else self$phone_call
      )
    },
    bytes = function() {
      c(as.raw(c(0x1e, 0x6b, 0x0f, 0xab)), self$phone_call$bytes())
    }
  ),
  private = list(
    from_reader = function(reader) {
      phone_call <- reader$tgread_object()
      self$new(phone_call = phone_call)
    }
  ),
  class = TRUE
)

#  @title UpdatePhoneCallSignalingData
#  @description Telegram API type UpdatePhoneCallSignalingData
#  @export
#  @noRd
#  @noRd
UpdatePhoneCallSignalingData <- R6::R6Class("UpdatePhoneCallSignalingData",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x2661bf09,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(phone_call_id, data) {
      self$phone_call_id <- phone_call_id
      self$data <- data
    },
    to_dict = function() {
      list(
        `_` = "UpdatePhoneCallSignalingData",
        phone_call_id = self$phone_call_id,
        data = self$data
      )
    },
    bytes = function() {
      c(as.raw(c(0x09, 0xbf, 0x61, 0x26)), pack("q", self$phone_call_id), self$serializebytes(self$data))
    }
  ),
  private = list(
    from_reader = function(reader) {
      phone_call_id <- reader$read_long()
      data <- reader$tgreadbytes()
      self$new(phone_call_id = phone_call_id, data = data)
    }
  ),
  class = TRUE
)

#  @title UpdatePinnedChannelMessages
#  @description Telegram API type UpdatePinnedChannelMessages
#  @export
#  @noRd
#  @noRd
UpdatePinnedChannelMessages <- R6::R6Class("UpdatePinnedChannelMessages",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5bb98608,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(channel_id, messages, pts, pts_count, pinned = NULL) {
      self$channel_id <- channel_id
      self$messages <- messages
      self$pts <- pts
      self$pts_count <- pts_count
      self$pinned <- pinned
    },
    to_dict = function() {
      list(
        `_` = "UpdatePinnedChannelMessages",
        channel_id = self$channel_id,
        messages = self$messages,
        pts = self$pts,
        pts_count = self$pts_count,
        pinned = self$pinned
      )
    },
    bytes = function() {
      flags <- if (is.null(self$pinned) || !self$pinned) 0 else 1
      c(as.raw(c(0x08, 0x86, 0xb9, 0x5b)), pack("I", flags), pack("q", self$channel_id), as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$messages)), do.call(c, lapply(self$messages, function(x) pack("i", x))), pack("i", self$pts), pack("i", self$pts_count))
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      pinned <- (flags & 1) != 0
      channel_id <- reader$read_long()
      reader$read_int()
      messages <- lapply(seq_len(reader$read_int()), function(x) reader$read_int())
      pts <- reader$read_int()
      pts_count <- reader$read_int()
      self$new(channel_id = channel_id, messages = messages, pts = pts, pts_count = pts_count, pinned = pinned)
    }
  ),
  class = TRUE
)

#  @title UpdatePinnedDialogs
#  @description Telegram API type UpdatePinnedDialogs
#  @export
#  @noRd
#  @noRd
UpdatePinnedDialogs <- R6::R6Class("UpdatePinnedDialogs",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xfa0f3ca2,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(folder_id = NULL, order = NULL) {
      self$folder_id <- folder_id
      self$order <- order
    },
    to_dict = function() {
      list(
        `_` = "UpdatePinnedDialogs",
        folder_id = self$folder_id,
        order = if (!is.null(self$order)) lapply(self$order, function(x) if (inherits(x, "TLObject")) x$to_dict() else x) else NULL
      )
    },
    bytes = function() {
      flags <- (if (is.null(self$folder_id)) 0 else 2) | (if (is.null(self$order)) 0 else 1)
      c(as.raw(c(0xa2, 0x3c, 0x0f, 0xfa)), pack("I", flags), if (!is.null(self$folder_id)) pack("i", self$folder_id) else raw(0), if (!is.null(self$order)) c(as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$order)), do.call(c, lapply(self$order, function(x) x$bytes()))) else raw(0))
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      folder_id <- if (flags & 2) reader$read_int() else NULL
      order <- if (flags & 1) {
        reader$read_int()
        lapply(seq_len(reader$read_int()), function(x) reader$tgread_object())
      } else {
        NULL
      }
      self$new(folder_id = folder_id, order = order)
    }
  ),
  class = TRUE
)

#  @title UpdatePinnedMessages
#  @description Telegram API type UpdatePinnedMessages
#  @export
#  @noRd
#  @noRd
UpdatePinnedMessages <- R6::R6Class("UpdatePinnedMessages",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xed85eab5,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(peer, messages, pts, pts_count, pinned = NULL) {
      self$peer <- peer
      self$messages <- messages
      self$pts <- pts
      self$pts_count <- pts_count
      self$pinned <- pinned
    },
    to_dict = function() {
      list(
        `_` = "UpdatePinnedMessages",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        messages = self$messages,
        pts = self$pts,
        pts_count = self$pts_count,
        pinned = self$pinned
      )
    },
    bytes = function() {
      flags <- if (is.null(self$pinned) || !self$pinned) 0 else 1
      c(as.raw(c(0xb5, 0xea, 0x85, 0xed)), pack("I", flags), self$peer$bytes(), as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$messages)), do.call(c, lapply(self$messages, function(x) pack("i", x))), pack("i", self$pts), pack("i", self$pts_count))
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      pinned <- (flags & 1) != 0
      peer <- reader$tgread_object()
      reader$read_int()
      messages <- lapply(seq_len(reader$read_int()), function(x) reader$read_int())
      pts <- reader$read_int()
      pts_count <- reader$read_int()
      self$new(peer = peer, messages = messages, pts = pts, pts_count = pts_count, pinned = pinned)
    }
  ),
  class = TRUE
)

#  @title UpdatePinnedSavedDialogs
#  @description Telegram API type UpdatePinnedSavedDialogs
#  @export
#  @noRd
#  @noRd
UpdatePinnedSavedDialogs <- R6::R6Class("UpdatePinnedSavedDialogs",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x686c85a6,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(order = NULL) {
      self$order <- order
    },
    to_dict = function() {
      list(
        `_` = "UpdatePinnedSavedDialogs",
        order = if (!is.null(self$order)) lapply(self$order, function(x) if (inherits(x, "TLObject")) x$to_dict() else x) else NULL
      )
    },
    bytes = function() {
      flags <- if (is.null(self$order)) 0 else 1
      c(as.raw(c(0xa6, 0x85, 0x6c, 0x68)), pack("I", flags), if (!is.null(self$order)) c(as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$order)), do.call(c, lapply(self$order, function(x) x$bytes()))) else raw(0))
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      order <- if (flags & 1) {
        reader$read_int()
        lapply(seq_len(reader$read_int()), function(x) reader$tgread_object())
      } else {
        NULL
      }
      self$new(order = order)
    }
  ),
  class = TRUE
)

#  @title UpdatePrivacy
#  @description Telegram API type UpdatePrivacy
#  @export
#  @noRd
#  @noRd
UpdatePrivacy <- R6::R6Class("UpdatePrivacy",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xee3b272a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(key, rules) {
      self$key <- key
      self$rules <- rules
    },
    to_dict = function() {
      list(
        `_` = "UpdatePrivacy",
        key = if (inherits(self$key, "TLObject")) self$key$to_dict() else self$key,
        rules = lapply(self$rules, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      )
    },
    bytes = function() {
      c(as.raw(c(0x2a, 0x27, 0x3b, 0xee)), self$key$bytes(), as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$rules)), do.call(c, lapply(self$rules, function(x) x$bytes())))
    }
  ),
  private = list(
    from_reader = function(reader) {
      key <- reader$tgread_object()
      reader$read_int()
      rules <- lapply(seq_len(reader$read_int()), function(x) reader$tgread_object())
      self$new(key = key, rules = rules)
    }
  ),
  class = TRUE
)

#  @title UpdatePtsChanged
#  @description Telegram API type UpdatePtsChanged
#  @export
#  @noRd
#  @noRd
UpdatePtsChanged <- R6::R6Class("UpdatePtsChanged",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x3354678f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    to_dict = function() {
      list(`_` = "UpdatePtsChanged")
    },
    bytes = function() {
      as.raw(c(0x8f, 0x67, 0x54, 0x33))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self$new()
    }
  ),
  class = TRUE
)

#  @title UpdateQuickReplies
#  @description Telegram API type UpdateQuickReplies
#  @export
#  @noRd
#  @noRd
UpdateQuickReplies <- R6::R6Class("UpdateQuickReplies",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf9470ab2,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(quick_replies) {
      self$quick_replies <- quick_replies
    },
    to_dict = function() {
      list(
        `_` = "UpdateQuickReplies",
        quick_replies = if (is.null(self$quick_replies)) list() else lapply(self$quick_replies, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xb2, 0x0a, 0x47, 0xf9)),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)),
        pack("i", length(self$quick_replies)),
        do.call(c, lapply(self$quick_replies, function(x) x$bytes()))
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      quick_replies <- list()
      for (i in seq_len(reader$read_int())) {
        x <- reader$tgread_object()
        quick_replies <- c(quick_replies, list(x))
      }
      self$initialize(quick_replies)
    }
  ),
  class = TRUE
)

#  @title UpdateQuickReplyMessage
#  @description Telegram API type UpdateQuickReplyMessage
#  @export
#  @noRd
#  @noRd
UpdateQuickReplyMessage <- R6::R6Class("UpdateQuickReplyMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x3e050d0f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(message) {
      self$message <- message
    },
    to_dict = function() {
      list(
        `_` = "UpdateQuickReplyMessage",
        message = if (inherits(self$message, "TLObject")) self$message$to_dict() else self$message
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x0f, 0x0d, 0x05, 0x3e)),
        self$message$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      message <- reader$tgread_object()
      self$initialize(message)
    }
  ),
  class = TRUE
)

#  @title UpdateReadChannelDiscussionInbox
#  @description Telegram API type UpdateReadChannelDiscussionInbox
#  @export
#  @noRd
#  @noRd
UpdateReadChannelDiscussionInbox <- R6::R6Class("UpdateReadChannelDiscussionInbox",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd6b19546,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(channel_id, top_msg_id, read_max_id, broadcast_id = NULL, broadcast_post = NULL) {
      self$channel_id <- channel_id
      self$top_msg_id <- top_msg_id
      self$read_max_id <- read_max_id
      self$broadcast_id <- broadcast_id
      self$broadcast_post <- broadcast_post
    },
    to_dict = function() {
      list(
        `_` = "UpdateReadChannelDiscussionInbox",
        channel_id = self$channel_id,
        top_msg_id = self$top_msg_id,
        read_max_id = self$read_max_id,
        broadcast_id = self$broadcast_id,
        broadcast_post = self$broadcast_post
      )
    },
    bytes = function() {
      flags <- (if (is.null(self$broadcast_id)) 0 else 1) | (if (is.null(self$broadcast_post)) 0 else 1)
      c(
        as.raw(c(0x46, 0x95, 0xb1, 0xd6)),
        pack("I", flags),
        pack("q", self$channel_id),
        pack("i", self$top_msg_id),
        pack("i", self$read_max_id),
        if (!is.null(self$broadcast_id)) pack("q", self$broadcast_id) else raw(0),
        if (!is.null(self$broadcast_post)) pack("i", self$broadcast_post) else raw(0)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      channel_id <- reader$read_long()
      top_msg_id <- reader$read_int()
      read_max_id <- reader$read_int()
      broadcast_id <- if (flags & 1) reader$read_long() else NULL
      broadcast_post <- if (flags & 1) reader$read_int() else NULL
      self$initialize(channel_id, top_msg_id, read_max_id, broadcast_id, broadcast_post)
    }
  ),
  class = TRUE
)

#  @title UpdateReadChannelDiscussionOutbox
#  @description Telegram API type UpdateReadChannelDiscussionOutbox
#  @export
#  @noRd
#  @noRd
UpdateReadChannelDiscussionOutbox <- R6::R6Class("UpdateReadChannelDiscussionOutbox",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x695c9e7c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(channel_id, top_msg_id, read_max_id) {
      self$channel_id <- channel_id
      self$top_msg_id <- top_msg_id
      self$read_max_id <- read_max_id
    },
    to_dict = function() {
      list(
        `_` = "UpdateReadChannelDiscussionOutbox",
        channel_id = self$channel_id,
        top_msg_id = self$top_msg_id,
        read_max_id = self$read_max_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x7c, 0x9e, 0x5c, 0x69)),
        pack("q", self$channel_id),
        pack("i", self$top_msg_id),
        pack("i", self$read_max_id)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      channel_id <- reader$read_long()
      top_msg_id <- reader$read_int()
      read_max_id <- reader$read_int()
      self$initialize(channel_id, top_msg_id, read_max_id)
    }
  ),
  class = TRUE
)

#  @title UpdateReadChannelInbox
#  @description Telegram API type UpdateReadChannelInbox
#  @export
#  @noRd
#  @noRd
UpdateReadChannelInbox <- R6::R6Class("UpdateReadChannelInbox",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x922e6e10,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(channel_id, max_id, still_unread_count, pts, folder_id = NULL) {
      self$channel_id <- channel_id
      self$max_id <- max_id
      self$still_unread_count <- still_unread_count
      self$pts <- pts
      self$folder_id <- folder_id
    },
    to_dict = function() {
      list(
        `_` = "UpdateReadChannelInbox",
        channel_id = self$channel_id,
        max_id = self$max_id,
        still_unread_count = self$still_unread_count,
        pts = self$pts,
        folder_id = self$folder_id
      )
    },
    bytes = function() {
      flags <- if (is.null(self$folder_id)) 0 else 1
      c(
        as.raw(c(0x10, 0x6e, 0x2e, 0x92)),
        pack("I", flags),
        if (!is.null(self$folder_id)) pack("i", self$folder_id) else raw(0),
        pack("q", self$channel_id),
        pack("i", self$max_id),
        pack("i", self$still_unread_count),
        pack("i", self$pts)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      folder_id <- if (flags & 1) reader$read_int() else NULL
      channel_id <- reader$read_long()
      max_id <- reader$read_int()
      still_unread_count <- reader$read_int()
      pts <- reader$read_int()
      self$initialize(channel_id, max_id, still_unread_count, pts, folder_id)
    }
  ),
  class = TRUE
)

#  @title UpdateReadChannelOutbox
#  @description Telegram API type UpdateReadChannelOutbox
#  @export
#  @noRd
#  @noRd
UpdateReadChannelOutbox <- R6::R6Class("UpdateReadChannelOutbox",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb75f99a9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(channel_id, max_id) {
      self$channel_id <- channel_id
      self$max_id <- max_id
    },
    to_dict = function() {
      list(
        `_` = "UpdateReadChannelOutbox",
        channel_id = self$channel_id,
        max_id = self$max_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xa9, 0x99, 0x5f, 0xb7)),
        pack("q", self$channel_id),
        pack("i", self$max_id)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      channel_id <- reader$read_long()
      max_id <- reader$read_int()
      self$initialize(channel_id, max_id)
    }
  ),
  class = TRUE
)

#  @title UpdateReadFeaturedEmojiStickers
#  @description Telegram API type UpdateReadFeaturedEmojiStickers
#  @export
#  @noRd
#  @noRd
UpdateReadFeaturedEmojiStickers <- R6::R6Class("UpdateReadFeaturedEmojiStickers",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xfb4c496c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    to_dict = function() {
      list(`_` = "UpdateReadFeaturedEmojiStickers")
    },
    bytes = function() {
      as.raw(c(0x6c, 0x49, 0x4c, 0xfb))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title UpdateReadFeaturedStickers
#  @description Telegram API type UpdateReadFeaturedStickers
#  @export
#  @noRd
#  @noRd
UpdateReadFeaturedStickers <- R6::R6Class("UpdateReadFeaturedStickers",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x571d2742,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    to_dict = function() {
      list(`_` = "UpdateReadFeaturedStickers")
    },
    bytes = function() {
      as.raw(c(0x42, 0x27, 0x1d, 0x57))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title UpdateReadHistoryInbox
#  @description Telegram API type UpdateReadHistoryInbox
#  @export
#  @noRd
#  @noRd
UpdateReadHistoryInbox <- R6::R6Class("UpdateReadHistoryInbox",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9c974fdf,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(peer, max_id, still_unread_count, pts, pts_count, folder_id = NULL) {
      self$peer <- peer
      self$max_id <- max_id
      self$still_unread_count <- still_unread_count
      self$pts <- pts
      self$pts_count <- pts_count
      self$folder_id <- folder_id
    },
    to_dict = function() {
      list(
        `_` = "UpdateReadHistoryInbox",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        max_id = self$max_id,
        still_unread_count = self$still_unread_count,
        pts = self$pts,
        pts_count = self$pts_count,
        folder_id = self$folder_id
      )
    },
    bytes = function() {
      flags <- if (is.null(self$folder_id)) 0 else 1
      c(
        as.raw(c(0xdf, 0x4f, 0x97, 0x9c)),
        pack("I", flags),
        if (!is.null(self$folder_id)) pack("i", self$folder_id) else raw(0),
        self$peer$bytes(),
        pack("i", self$max_id),
        pack("i", self$still_unread_count),
        pack("i", self$pts),
        pack("i", self$pts_count)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      folder_id <- if (flags & 1) reader$read_int() else NULL
      peer <- reader$tgread_object()
      max_id <- reader$read_int()
      still_unread_count <- reader$read_int()
      pts <- reader$read_int()
      pts_count <- reader$read_int()
      self$initialize(peer, max_id, still_unread_count, pts, pts_count, folder_id)
    }
  ),
  class = TRUE
)

#  @title UpdateReadHistoryOutbox
#  @description Telegram API type UpdateReadHistoryOutbox
#  @export
#  @noRd
#  @noRd
UpdateReadHistoryOutbox <- R6::R6Class("UpdateReadHistoryOutbox",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x2f2f21bf,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(peer, max_id, pts, pts_count) {
      self$peer <- peer
      self$max_id <- max_id
      self$pts <- pts
      self$pts_count <- pts_count
    },
    to_dict = function() {
      list(
        `_` = "UpdateReadHistoryOutbox",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        max_id = self$max_id,
        pts = self$pts,
        pts_count = self$pts_count
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xbf, 0x21, 0x2f, 0x2f)),
        self$peer$bytes(),
        pack("i", self$max_id),
        pack("i", self$pts),
        pack("i", self$pts_count)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      max_id <- reader$read_int()
      pts <- reader$read_int()
      pts_count <- reader$read_int()
      self$initialize(peer, max_id, pts, pts_count)
    }
  ),
  class = TRUE
)

#  @title UpdateReadMessagesContents
#  @description Telegram API type UpdateReadMessagesContents
#  @export
#  @noRd
#  @noRd
UpdateReadMessagesContents <- R6::R6Class("UpdateReadMessagesContents",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf8227181,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(messages, pts, pts_count, date = NULL) {
      self$messages <- messages
      self$pts <- pts
      self$pts_count <- pts_count
      self$date <- date
    },
    to_dict = function() {
      list(
        `_` = "UpdateReadMessagesContents",
        messages = if (is.null(self$messages)) list() else self$messages,
        pts = self$pts,
        pts_count = self$pts_count,
        date = self$date
      )
    },
    bytes = function() {
      flags <- if (is.null(self$date)) 0 else 1
      c(
        as.raw(c(0x81, 0x71, 0x22, 0xf8)),
        pack("I", flags),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)),
        pack("i", length(self$messages)),
        do.call(c, lapply(self$messages, function(x) pack("i", x))),
        pack("i", self$pts),
        pack("i", self$pts_count),
        if (!is.null(self$date)) self$serialize_datetime(self$date) else raw(0)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      reader$read_int()
      messages <- list()
      for (i in seq_len(reader$read_int())) {
        x <- reader$read_int()
        messages <- c(messages, list(x))
      }
      pts <- reader$read_int()
      pts_count <- reader$read_int()
      date <- if (flags & 1) reader$tgread_date() else NULL
      self$initialize(messages, pts, pts_count, date)
    }
  ),
  class = TRUE
)

#  @title UpdateReadMonoForumInbox
#  @description Telegram API type UpdateReadMonoForumInbox
#  @export
#  @noRd
#  @noRd
UpdateReadMonoForumInbox <- R6::R6Class("UpdateReadMonoForumInbox",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x77b0e372,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(channel_id, savedpeer_id, read_max_id) {
      self$channel_id <- channel_id
      self$savedpeer_id <- savedpeer_id
      self$read_max_id <- read_max_id
    },
    to_dict = function() {
      list(
        `_` = "UpdateReadMonoForumInbox",
        channel_id = self$channel_id,
        savedpeer_id = if (inherits(self$savedpeer_id, "TLObject")) self$savedpeer_id$to_dict() else self$savedpeer_id,
        read_max_id = self$read_max_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x72, 0xe3, 0xb0, 0x77)),
        pack("q", self$channel_id),
        self$savedpeer_id$bytes(),
        pack("i", self$read_max_id)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      channel_id <- reader$read_long()
      savedpeer_id <- reader$tgread_object()
      read_max_id <- reader$read_int()
      self$initialize(channel_id, savedpeer_id, read_max_id)
    }
  ),
  class = TRUE
)

#  @title UpdateReadMonoForumOutbox
#  @description Telegram API type UpdateReadMonoForumOutbox
#  @export
#  @noRd
#  @noRd
UpdateReadMonoForumOutbox <- R6::R6Class("UpdateReadMonoForumOutbox",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa4a79376,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(channel_id, savedpeer_id, read_max_id) {
      self$channel_id <- channel_id
      self$savedpeer_id <- savedpeer_id
      self$read_max_id <- read_max_id
    },
    to_dict = function() {
      list(
        `_` = "UpdateReadMonoForumOutbox",
        channel_id = self$channel_id,
        savedpeer_id = if (inherits(self$savedpeer_id, "TLObject")) self$savedpeer_id$to_dict() else self$savedpeer_id,
        read_max_id = self$read_max_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x76, 0x93, 0xa7, 0xa4)),
        pack("q", self$channel_id),
        self$savedpeer_id$bytes(),
        pack("i", self$read_max_id)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      channel_id <- reader$read_long()
      savedpeer_id <- reader$tgread_object()
      read_max_id <- reader$read_int()
      self$initialize(channel_id, savedpeer_id, read_max_id)
    }
  ),
  class = TRUE
)

#  @title UpdateReadStories
#  @description Telegram API type UpdateReadStories
#  @export
#  @noRd
#  @noRd
UpdateReadStories <- R6::R6Class("UpdateReadStories",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf74e932b,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(peer, max_id) {
      self$peer <- peer
      self$max_id <- max_id
    },
    to_dict = function() {
      list(
        `_` = "UpdateReadStories",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        max_id = self$max_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x2b, 0x93, 0x4e, 0xf7)),
        self$peer$bytes(),
        pack("i", self$max_id)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      max_id <- reader$read_int()
      self$initialize(peer, max_id)
    }
  ),
  class = TRUE
)

#  @title UpdateRecentEmojiStatuses
#  @description Telegram API type UpdateRecentEmojiStatuses
#  @export
#  @noRd
#  @noRd
UpdateRecentEmojiStatuses <- R6::R6Class("UpdateRecentEmojiStatuses",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x30f443db,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    to_dict = function() {
      list(`_` = "UpdateRecentEmojiStatuses")
    },
    bytes = function() {
      as.raw(c(0xdb, 0x43, 0xf4, 0x30))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title UpdateRecentReactions
#  @description Telegram API type UpdateRecentReactions
#  @export
#  @noRd
#  @noRd
UpdateRecentReactions <- R6::R6Class("UpdateRecentReactions",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x6f7863f4,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    to_dict = function() {
      list(`_` = "UpdateRecentReactions")
    },
    bytes = function() {
      as.raw(c(0xf4, 0x63, 0x78, 0x6f))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title UpdateRecentStickers
#  @description Telegram API type UpdateRecentStickers
#  @export
#  @noRd
#  @noRd
UpdateRecentStickers <- R6::R6Class("UpdateRecentStickers",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9a422c20,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    to_dict = function() {
      list(`_` = "UpdateRecentStickers")
    },
    bytes = function() {
      as.raw(c(0x20, 0x2c, 0x42, 0x9a))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title UpdateSavedDialogPinned
#  @description Telegram API type UpdateSavedDialogPinned
#  @export
#  @noRd
#  @noRd
UpdateSavedDialogPinned <- R6::R6Class("UpdateSavedDialogPinned",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xaeaf9e74,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(peer, pinned = NULL) {
      self$peer <- peer
      self$pinned <- pinned
    },
    to_dict = function() {
      list(
        `_` = "UpdateSavedDialogPinned",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        pinned = self$pinned
      )
    },
    bytes = function() {
      flags <- if (is.null(self$pinned)) 0 else 1
      c(
        as.raw(c(0x74, 0x9e, 0xaf, 0xae)),
        pack("I", flags),
        self$peer$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      pinned <- (flags & 1) != 0
      peer <- reader$tgread_object()
      self$initialize(peer, pinned)
    }
  ),
  class = TRUE
)

#  @title UpdateSavedGifs
#  @description Telegram API type UpdateSavedGifs
#  @export
#  @noRd
#  @noRd
UpdateSavedGifs <- R6::R6Class("UpdateSavedGifs",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9375341e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    to_dict = function() {
      list(`_` = "UpdateSavedGifs")
    },
    bytes = function() {
      as.raw(c(0x1e, 0x34, 0x75, 0x93))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title UpdateSavedReactionTags
#  @description Telegram API type UpdateSavedReactionTags
#  @export
#  @noRd
#  @noRd
UpdateSavedReactionTags <- R6::R6Class("UpdateSavedReactionTags",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x39c67432,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    to_dict = function() {
      list(`_` = "UpdateSavedReactionTags")
    },
    bytes = function() {
      as.raw(c(0x32, 0x74, 0xc6, 0x39))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title UpdateSavedRingtones
#  @description Telegram API type UpdateSavedRingtones
#  @export
#  @noRd
#  @noRd
UpdateSavedRingtones <- R6::R6Class("UpdateSavedRingtones",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x74d8be99,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    to_dict = function() {
      list(`_` = "UpdateSavedRingtones")
    },
    bytes = function() {
      as.raw(c(0x99, 0xbe, 0xd8, 0x74))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title UpdateSentPhoneCode
#  @description Telegram API type UpdateSentPhoneCode
#  @export
#  @noRd
#  @noRd
UpdateSentPhoneCode <- R6::R6Class("UpdateSentPhoneCode",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x504aa18f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(sent_code) {
      self$sent_code <- sent_code
    },
    to_dict = function() {
      list(
        `_` = "UpdateSentPhoneCode",
        sent_code = if (inherits(self$sent_code, "TLObject")) self$sent_code$to_dict() else self$sent_code
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x8f, 0xa1, 0x4a, 0x50)),
        self$sent_code$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      sent_code <- reader$tgread_object()
      self$initialize(sent_code)
    }
  ),
  class = TRUE
)

#  @title UpdateSentStoryReaction
#  @description Telegram API type UpdateSentStoryReaction
#  @export
#  @noRd
#  @noRd
UpdateSentStoryReaction <- R6::R6Class("UpdateSentStoryReaction",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7d627683,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(peer, story_id, reaction) {
      self$peer <- peer
      self$story_id <- story_id
      self$reaction <- reaction
    },
    to_dict = function() {
      list(
        `_` = "UpdateSentStoryReaction",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        story_id = self$story_id,
        reaction = if (inherits(self$reaction, "TLObject")) self$reaction$to_dict() else self$reaction
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x83, 0x76, 0x62, 0x7d)),
        self$peer$bytes(),
        pack("i", self$story_id),
        self$reaction$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      story_id <- reader$read_int()
      reaction <- reader$tgread_object()
      self$initialize(peer, story_id, reaction)
    }
  ),
  class = TRUE
)

#  @title UpdateServiceNotification
#  @description Telegram API type UpdateServiceNotification
#  @export
#  @noRd
#  @noRd
UpdateServiceNotification <- R6::R6Class("UpdateServiceNotification",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xebe46819,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(type, message, media, entities, popup = NULL, invert_media = NULL, inbox_date = NULL) {
      self$type <- type
      self$message <- message
      self$media <- media
      self$entities <- entities
      self$popup <- popup
      self$invert_media <- invert_media
      self$inbox_date <- inbox_date
    },
    to_dict = function() {
      list(
        `_` = "UpdateServiceNotification",
        type = self$type,
        message = self$message,
        media = if (inherits(self$media, "TLObject")) self$media$to_dict() else self$media,
        entities = if (is.null(self$entities)) list() else lapply(self$entities, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        popup = self$popup,
        invert_media = self$invert_media,
        inbox_date = self$inbox_date
      )
    },
    bytes = function() {
      flags <- (if (is.null(self$popup)) 0 else 1) | (if (is.null(self$invert_media)) 0 else 4) | (if (is.null(self$inbox_date)) 0 else 2)
      c(
        as.raw(c(0x19, 0x68, 0xe4, 0xeb)),
        pack("I", flags),
        if (!is.null(self$inbox_date)) self$serialize_datetime(self$inbox_date) else raw(0),
        self$serializebytes(self$type),
        self$serializebytes(self$message),
        self$media$bytes(),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)),
        pack("i", length(self$entities)),
        do.call(c, lapply(self$entities, function(x) x$bytes()))
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      popup <- (flags & 1) != 0
      invert_media <- (flags & 4) != 0
      inbox_date <- if (flags & 2) reader$tgread_date() else NULL
      type <- reader$tgread_string()
      message <- reader$tgread_string()
      media <- reader$tgread_object()
      reader$read_int()
      entities <- list()
      for (i in seq_len(reader$read_int())) {
        x <- reader$tgread_object()
        entities <- c(entities, list(x))
      }
      self$initialize(type, message, media, entities, popup, invert_media, inbox_date)
    }
  ),
  class = TRUE
)

#  @title UpdateShort
#  @description Telegram API type UpdateShort
#  @export
#  @noRd
#  @noRd
UpdateShort <- R6::R6Class("UpdateShort",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x78d4dec1,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8af52aac,
    initialize = function(update, date) {
      self$update <- update
      self$date <- date
    },
    to_dict = function() {
      list(
        `_` = "UpdateShort",
        update = if (inherits(self$update, "TLObject")) self$update$to_dict() else self$update,
        date = self$date
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xc1, 0xde, 0xd4, 0x78)),
        self$update$bytes(),
        self$serialize_datetime(self$date)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      update <- reader$tgread_object()
      date <- reader$tgread_date()
      list(update = update, date = date)
    }
  ),
  class = TRUE
)

#  @title UpdateShortChatMessage
#  @description Telegram API type UpdateShortChatMessage
#  @export
#  @noRd
#  @noRd
UpdateShortChatMessage <- R6::R6Class("UpdateShortChatMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4d6deea5,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8af52aac,
    initialize = function(id, from_id, chat_id, message, pts, pts_count, date, out = NULL, mentioned = NULL, media_unread = NULL, silent = NULL, fwd_from = NULL, via_bot_id = NULL, reply_to = NULL, entities = NULL, ttl_period = NULL) {
      self$id <- id
      self$from_id <- from_id
      self$chat_id <- chat_id
      self$message <- message
      self$pts <- pts
      self$pts_count <- pts_count
      self$date <- date
      self$out <- out
      self$mentioned <- mentioned
      self$media_unread <- media_unread
      self$silent <- silent
      self$fwd_from <- fwd_from
      self$via_bot_id <- via_bot_id
      self$reply_to <- reply_to
      self$entities <- entities
      self$ttl_period <- ttl_period
    },
    to_dict = function() {
      list(
        `_` = "UpdateShortChatMessage",
        id = self$id,
        from_id = self$from_id,
        chat_id = self$chat_id,
        message = self$message,
        pts = self$pts,
        pts_count = self$pts_count,
        date = self$date,
        out = self$out,
        mentioned = self$mentioned,
        media_unread = self$media_unread,
        silent = self$silent,
        fwd_from = if (inherits(self$fwd_from, "TLObject")) self$fwd_from$to_dict() else self$fwd_from,
        via_bot_id = self$via_bot_id,
        reply_to = if (inherits(self$reply_to, "TLObject")) self$reply_to$to_dict() else self$reply_to,
        entities = if (is.null(self$entities)) list() else lapply(self$entities, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        ttl_period = self$ttl_period
      )
    },
    bytes = function() {
      flags <- (if (is.null(self$out)) 0 else 2) | (if (is.null(self$mentioned)) 0 else 16) | (if (is.null(self$media_unread)) 0 else 32) | (if (is.null(self$silent)) 0 else 8192) | (if (is.null(self$fwd_from)) 0 else 4) | (if (is.null(self$via_bot_id)) 0 else 2048) | (if (is.null(self$reply_to)) 0 else 8) | (if (is.null(self$entities)) 0 else 128) | (if (is.null(self$ttl_period)) 0 else 33554432)
      c(
        as.raw(c(0xa5, 0xee, 0x6d, 0x4d)),
        pack("I", flags),
        pack("i", self$id),
        pack("q", self$from_id),
        pack("q", self$chat_id),
        self$serializebytes(self$message),
        pack("i", self$pts),
        pack("i", self$pts_count),
        self$serialize_datetime(self$date),
        if (!is.null(self$fwd_from)) self$fwd_from$bytes() else raw(0),
        if (!is.null(self$via_bot_id)) pack("q", self$via_bot_id) else raw(0),
        if (!is.null(self$reply_to)) self$reply_to$bytes() else raw(0),
        if (!is.null(self$entities)) c(as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$entities)), do.call(c, lapply(self$entities, function(x) x$bytes()))) else raw(0),
        if (!is.null(self$ttl_period)) pack("i", self$ttl_period) else raw(0)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      out <- (flags & 2) != 0
      mentioned <- (flags & 16) != 0
      media_unread <- (flags & 32) != 0
      silent <- (flags & 8192) != 0
      id <- reader$read_int()
      from_id <- reader$read_long()
      chat_id <- reader$read_long()
      message <- reader$tgread_string()
      pts <- reader$read_int()
      pts_count <- reader$read_int()
      date <- reader$tgread_date()
      fwd_from <- if (flags & 4) reader$tgread_object() else NULL
      via_bot_id <- if (flags & 2048) reader$read_long() else NULL
      reply_to <- if (flags & 8) reader$tgread_object() else NULL
      entities <- if (flags & 128) {
        reader$read_int()
        ents <- list()
        for (i in seq_len(reader$read_int())) {
          x <- reader$tgread_object()
          ents <- c(ents, list(x))
        }
        ents
      } else {
        NULL
      }
      ttl_period <- if (flags & 33554432) reader$read_int() else NULL
      list(
        id = id,
        from_id = from_id,
        chat_id = chat_id,
        message = message,
        pts = pts,
        pts_count = pts_count,
        date = date,
        out = out,
        mentioned = mentioned,
        media_unread = media_unread,
        silent = silent,
        fwd_from = fwd_from,
        via_bot_id = via_bot_id,
        reply_to = reply_to,
        entities = entities,
        ttl_period = ttl_period
      )
    }
  ),
  class = TRUE
)

#  @title UpdateShortMessage
#  @description Telegram API type UpdateShortMessage
#  @export
#  @noRd
#  @noRd
UpdateShortMessage <- R6::R6Class("UpdateShortMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x313bc7f8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8af52aac,
    initialize = function(id, user_id, message, pts, pts_count, date, out = NULL, mentioned = NULL, media_unread = NULL, silent = NULL, fwd_from = NULL, via_bot_id = NULL, reply_to = NULL, entities = NULL, ttl_period = NULL) {
      self$id <- id
      self$user_id <- user_id
      self$message <- message
      self$pts <- pts
      self$pts_count <- pts_count
      self$date <- date
      self$out <- out
      self$mentioned <- mentioned
      self$media_unread <- media_unread
      self$silent <- silent
      self$fwd_from <- fwd_from
      self$via_bot_id <- via_bot_id
      self$reply_to <- reply_to
      self$entities <- entities
      self$ttl_period <- ttl_period
    },
    to_dict = function() {
      list(
        `_` = "UpdateShortMessage",
        id = self$id,
        user_id = self$user_id,
        message = self$message,
        pts = self$pts,
        pts_count = self$pts_count,
        date = self$date,
        out = self$out,
        mentioned = self$mentioned,
        media_unread = self$media_unread,
        silent = self$silent,
        fwd_from = if (inherits(self$fwd_from, "TLObject")) self$fwd_from$to_dict() else self$fwd_from,
        via_bot_id = self$via_bot_id,
        reply_to = if (inherits(self$reply_to, "TLObject")) self$reply_to$to_dict() else self$reply_to,
        entities = if (is.null(self$entities)) list() else lapply(self$entities, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        ttl_period = self$ttl_period
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xf8, 0xc7, 0x3b, 0x31)),
        pack("I", (if (is.null(self$out) || !self$out) 0 else 2) | (if (is.null(self$mentioned) || !self$mentioned) 0 else 16) | (if (is.null(self$media_unread) || !self$media_unread) 0 else 32) | (if (is.null(self$silent) || !self$silent) 0 else 8192) | (if (is.null(self$fwd_from)) 0 else 4) | (if (is.null(self$via_bot_id)) 0 else 2048) | (if (is.null(self$reply_to)) 0 else 8) | (if (is.null(self$entities)) 0 else 128) | (if (is.null(self$ttl_period)) 0 else 33554432)),
        pack("i", self$id),
        pack("q", self$user_id),
        self$serializebytes(self$message),
        pack("i", self$pts),
        pack("i", self$pts_count),
        self$serialize_datetime(self$date),
        if (!is.null(self$fwd_from)) self$fwd_from$bytes() else raw(0),
        if (!is.null(self$via_bot_id)) pack("q", self$via_bot_id) else raw(0),
        if (!is.null(self$reply_to)) self$reply_to$bytes() else raw(0),
        if (!is.null(self$entities)) c(as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$entities)), do.call(c, lapply(self$entities, function(x) x$bytes()))) else raw(0),
        if (!is.null(self$ttl_period)) pack("i", self$ttl_period) else raw(0)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      out <- bitwAnd(flags, 2) != 0
      mentioned <- bitwAnd(flags, 16) != 0
      media_unread <- bitwAnd(flags, 32) != 0
      silent <- bitwAnd(flags, 8192) != 0
      id <- reader$read_int()
      user_id <- reader$read_long()
      message <- reader$tgread_string()
      pts <- reader$read_int()
      pts_count <- reader$read_int()
      date <- reader$tgread_date()
      fwd_from <- if (bitwAnd(flags, 4) != 0) reader$tgread_object() else NULL
      via_bot_id <- if (bitwAnd(flags, 2048) != 0) reader$read_long() else NULL
      reply_to <- if (bitwAnd(flags, 8) != 0) reader$tgread_object() else NULL
      entities <- if (bitwAnd(flags, 128) != 0) {
        reader$read_int()
        lapply(seq_len(reader$read_int()), function(x) reader$tgread_object())
      } else {
        NULL
      }
      ttl_period <- if (bitwAnd(flags, 33554432) != 0) reader$read_int() else NULL
      list(flags = flags, id = id, user_id = user_id, message = message, pts = pts, pts_count = pts_count, date = date, out = out, mentioned = mentioned, media_unread = media_unread, silent = silent, fwd_from = fwd_from, via_bot_id = via_bot_id, reply_to = reply_to, entities = entities, ttl_period = ttl_period)
    }
  ),
  class = TRUE
)

#  @title UpdateShortSentMessage
#  @description Telegram API type UpdateShortSentMessage
#  @export
#  @noRd
#  @noRd
UpdateShortSentMessage <- R6::R6Class("UpdateShortSentMessage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9015e101,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8af52aac,
    initialize = function(id, pts, pts_count, date, out = NULL, media = NULL, entities = NULL, ttl_period = NULL) {
      self$id <- id
      self$pts <- pts
      self$pts_count <- pts_count
      self$date <- date
      self$out <- out
      self$media <- media
      self$entities <- entities
      self$ttl_period <- ttl_period
    },
    to_dict = function() {
      list(
        `_` = "UpdateShortSentMessage",
        id = self$id,
        pts = self$pts,
        pts_count = self$pts_count,
        date = self$date,
        out = self$out,
        media = if (inherits(self$media, "TLObject")) self$media$to_dict() else self$media,
        entities = if (is.null(self$entities)) list() else lapply(self$entities, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        ttl_period = self$ttl_period
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x01, 0xe1, 0x15, 0x90)),
        pack("I", (if (is.null(self$out) || !self$out) 0 else 2) | (if (is.null(self$media)) 0 else 512) | (if (is.null(self$entities)) 0 else 128) | (if (is.null(self$ttl_period)) 0 else 33554432)),
        pack("i", self$id),
        pack("i", self$pts),
        pack("i", self$pts_count),
        self$serialize_datetime(self$date),
        if (!is.null(self$media)) self$media$bytes() else raw(0),
        if (!is.null(self$entities)) c(as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$entities)), do.call(c, lapply(self$entities, function(x) x$bytes()))) else raw(0),
        if (!is.null(self$ttl_period)) pack("i", self$ttl_period) else raw(0)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      out <- bitwAnd(flags, 2) != 0
      id <- reader$read_int()
      pts <- reader$read_int()
      pts_count <- reader$read_int()
      date <- reader$tgread_date()
      media <- if (bitwAnd(flags, 512) != 0) reader$tgread_object() else NULL
      entities <- if (bitwAnd(flags, 128) != 0) {
        reader$read_int()
        lapply(seq_len(reader$read_int()), function(x) reader$tgread_object())
      } else {
        NULL
      }
      ttl_period <- if (bitwAnd(flags, 33554432) != 0) reader$read_int() else NULL
      list(flags = flags, id = id, pts = pts, pts_count = pts_count, date = date, out = out, media = media, entities = entities, ttl_period = ttl_period)
    }
  ),
  class = TRUE
)

#  @title UpdateSmsJob
#  @description Telegram API type UpdateSmsJob
#  @export
#  @noRd
#  @noRd
UpdateSmsJob <- R6::R6Class("UpdateSmsJob",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf16269d4,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(job_id) {
      self$job_id <- job_id
    },
    to_dict = function() {
      list(
        `_` = "UpdateSmsJob",
        job_id = self$job_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xd4, 0x69, 0x62, 0xf1)),
        self$serializebytes(self$job_id)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      job_id <- reader$tgread_string()
      list(job_id = job_id)
    }
  ),
  class = TRUE
)

#  @title UpdateStarsBalance
#  @description Telegram API type UpdateStarsBalance
#  @export
#  @noRd
#  @noRd
UpdateStarsBalance <- R6::R6Class("UpdateStarsBalance",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4e80a379,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(balance) {
      self$balance <- balance
    },
    to_dict = function() {
      list(
        `_` = "UpdateStarsBalance",
        balance = if (inherits(self$balance, "TLObject")) self$balance$to_dict() else self$balance
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x79, 0xa3, 0x80, 0x4e)),
        self$balance$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      balance <- reader$tgread_object()
      list(balance = balance)
    }
  ),
  class = TRUE
)

#  @title UpdateStarsRevenueStatus
#  @description Telegram API type UpdateStarsRevenueStatus
#  @export
#  @noRd
#  @noRd
UpdateStarsRevenueStatus <- R6::R6Class("UpdateStarsRevenueStatus",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa584b019,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(peer, status) {
      self$peer <- peer
      self$status <- status
    },
    to_dict = function() {
      list(
        `_` = "UpdateStarsRevenueStatus",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        status = if (inherits(self$status, "TLObject")) self$status$to_dict() else self$status
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x19, 0xb0, 0x84, 0xa5)),
        self$peer$bytes(),
        self$status$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      status <- reader$tgread_object()
      list(peer = peer, status = status)
    }
  ),
  class = TRUE
)

#  @title UpdateStickerSets
#  @description Telegram API type UpdateStickerSets
#  @export
#  @noRd
#  @noRd
UpdateStickerSets <- R6::R6Class("UpdateStickerSets",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x31c24808,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(masks = NULL, emojis = NULL) {
      self$masks <- masks
      self$emojis <- emojis
    },
    to_dict = function() {
      list(
        `_` = "UpdateStickerSets",
        masks = self$masks,
        emojis = self$emojis
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x08, 0x48, 0xc2, 0x31)),
        pack("I", (if (is.null(self$masks) || !self$masks) 0 else 1) | (if (is.null(self$emojis) || !self$emojis) 0 else 2))
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      masks <- bitwAnd(flags, 1) != 0
      emojis <- bitwAnd(flags, 2) != 0
      list(flags = flags, masks = masks, emojis = emojis)
    }
  ),
  class = TRUE
)

#  @title UpdateStickerSetsOrder
#  @description Telegram API type UpdateStickerSetsOrder
#  @export
#  @noRd
#  @noRd
UpdateStickerSetsOrder <- R6::R6Class("UpdateStickerSetsOrder",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xbb2d201,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(order, masks = NULL, emojis = NULL) {
      self$order <- order
      self$masks <- masks
      self$emojis <- emojis
    },
    to_dict = function() {
      list(
        `_` = "UpdateStickerSetsOrder",
        order = if (is.null(self$order)) list() else self$order,
        masks = self$masks,
        emojis = self$emojis
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x01, 0xd2, 0xb2, 0x0b)),
        pack("I", (if (is.null(self$masks) || !self$masks) 0 else 1) | (if (is.null(self$emojis) || !self$emojis) 0 else 2)),
        c(as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$order)), do.call(c, lapply(self$order, function(x) pack("q", x))))
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      masks <- bitwAnd(flags, 1) != 0
      emojis <- bitwAnd(flags, 2) != 0
      reader$read_int()
      order <- lapply(seq_len(reader$read_int()), function(x) reader$read_long())
      list(flags = flags, order = order, masks = masks, emojis = emojis)
    }
  ),
  class = TRUE
)

#  @title UpdateStoriesStealthMode
#  @description Telegram API type UpdateStoriesStealthMode
#  @export
#  @noRd
#  @noRd
UpdateStoriesStealthMode <- R6::R6Class("UpdateStoriesStealthMode",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x2c084dc1,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(stealth_mode) {
      self$stealth_mode <- stealth_mode
    },
    to_dict = function() {
      list(
        `_` = "UpdateStoriesStealthMode",
        stealth_mode = if (inherits(self$stealth_mode, "TLObject")) self$stealth_mode$to_dict() else self$stealth_mode
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xc1, 0x4d, 0x08, 0x2c)),
        self$stealth_mode$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      stealth_mode <- reader$tgread_object()
      list(stealth_mode = stealth_mode)
    }
  ),
  class = TRUE
)

#  @title UpdateStory
#  @description Telegram API type UpdateStory
#  @export
#  @noRd
#  @noRd
UpdateStory <- R6::R6Class("UpdateStory",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x75b3b798,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(peer, story) {
      self$peer <- peer
      self$story <- story
    },
    to_dict = function() {
      list(
        `_` = "UpdateStory",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        story = if (inherits(self$story, "TLObject")) self$story$to_dict() else self$story
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x98, 0xb7, 0xb3, 0x75)),
        self$peer$bytes(),
        self$story$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      peer <- reader$tgread_object()
      story <- reader$tgread_object()
      list(peer = peer, story = story)
    }
  ),
  class = TRUE
)

#  @title UpdateStoryID
#  @description Telegram API type UpdateStoryID
#  @export
#  @noRd
#  @noRd
UpdateStoryID <- R6::R6Class("UpdateStoryID",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1bf335b9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(id, random_id = NULL) {
      self$id <- id
      self$random_id <- if (is.null(random_id)) as.integer(runif(1, min = -2^63, max = 2^63 - 1)) else random_id
    },
    to_dict = function() {
      list(
        `_` = "UpdateStoryID",
        id = self$id,
        random_id = self$random_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xb9, 0x35, 0xf3, 0x1b)),
        pack("i", self$id),
        pack("q", self$random_id)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      id <- reader$read_int()
      random_id <- reader$read_long()
      list(id = id, random_id = random_id)
    }
  ),
  class = TRUE
)

#  @title UpdateTheme
#  @description Telegram API type UpdateTheme
#  @export
#  @noRd
#  @noRd
UpdateTheme <- R6::R6Class("UpdateTheme",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8216fba3,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(theme) {
      self$theme <- theme
    },
    to_dict = function() {
      list(
        `_` = "UpdateTheme",
        theme = if (inherits(self$theme, "TLObject")) self$theme$to_dict() else self$theme
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xa3, 0xfb, 0x16, 0x82)),
        self$theme$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      theme <- reader$tgread_object()
      list(theme = theme)
    }
  ),
  class = TRUE
)

#  @title UpdateTranscribedAudio
#  @description Telegram API type UpdateTranscribedAudio
#  @export
#  @noRd
#  @noRd
UpdateTranscribedAudio <- R6::R6Class("UpdateTranscribedAudio",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x84cd5a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(peer, msg_id, transcription_id, text, pending = NULL) {
      self$peer <- peer
      self$msg_id <- msg_id
      self$transcription_id <- transcription_id
      self$text <- text
      self$pending <- pending
    },
    to_dict = function() {
      list(
        `_` = "UpdateTranscribedAudio",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        msg_id = self$msg_id,
        transcription_id = self$transcription_id,
        text = self$text,
        pending = self$pending
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x5a, 0xcd, 0x84, 0x00)),
        pack("I", if (is.null(self$pending) || !self$pending) 0 else 1),
        self$peer$bytes(),
        pack("i", self$msg_id),
        pack("q", self$transcription_id),
        self$serializebytes(self$text)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      pending <- bitwAnd(flags, 1) != 0
      peer <- reader$tgread_object()
      msg_id <- reader$read_int()
      transcription_id <- reader$read_long()
      text <- reader$tgread_string()
      list(flags = flags, peer = peer, msg_id = msg_id, transcription_id = transcription_id, text = text, pending = pending)
    }
  ),
  class = TRUE
)

#  @title UpdateUser
#  @description Telegram API type UpdateUser
#  @export
#  @noRd
#  @noRd
UpdateUser <- R6::R6Class("UpdateUser",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x20529438,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(user_id) {
      self$user_id <- user_id
    },
    to_dict = function() {
      list(
        `_` = "UpdateUser",
        user_id = self$user_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x38, 0x94, 0x52, 0x20)),
        pack("q", self$user_id)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      user_id <- reader$read_long()
      list(user_id = user_id)
    }
  ),
  class = TRUE
)

#  @title UpdateUserEmojiStatus
#  @description Telegram API type UpdateUserEmojiStatus
#  @export
#  @noRd
#  @noRd
UpdateUserEmojiStatus <- R6::R6Class("UpdateUserEmojiStatus",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x28373599,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(user_id, emoji_status) {
      self$user_id <- user_id
      self$emoji_status <- emoji_status
    },
    to_dict = function() {
      list(
        `_` = "UpdateUserEmojiStatus",
        user_id = self$user_id,
        emoji_status = if (inherits(self$emoji_status, "TLObject")) self$emoji_status$to_dict() else self$emoji_status
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x99, 0x35, 0x37, 0x28)),
        pack("q", self$user_id),
        self$emoji_status$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      user_id <- reader$read_long()
      emoji_status <- reader$tgread_object()
      list(user_id = user_id, emoji_status = emoji_status)
    }
  ),
  class = TRUE
)

#  @title UpdateUserName
#  @description Telegram API type UpdateUserName
#  @export
#  @noRd
#  @noRd
UpdateUserName <- R6::R6Class("UpdateUserName",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa7848924,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(user_id, first_name, last_name, usernames) {
      self$user_id <- user_id
      self$first_name <- first_name
      self$last_name <- last_name
      self$usernames <- usernames
    },
    to_dict = function() {
      list(
        `_` = "UpdateUserName",
        user_id = self$user_id,
        first_name = self$first_name,
        last_name = self$last_name,
        usernames = if (is.null(self$usernames)) list() else lapply(self$usernames, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x24, 0x89, 0x84, 0xa7)),
        pack("q", self$user_id),
        self$serializebytes(self$first_name),
        self$serializebytes(self$last_name),
        c(as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$usernames)), do.call(c, lapply(self$usernames, function(x) x$bytes())))
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      user_id <- reader$read_long()
      first_name <- reader$tgread_string()
      last_name <- reader$tgread_string()
      reader$read_int()
      usernames <- lapply(seq_len(reader$read_int()), function(x) reader$tgread_object())
      list(user_id = user_id, first_name = first_name, last_name = last_name, usernames = usernames)
    }
  ),
  class = TRUE
)

#  @title UpdateUserPhone
#  @description Telegram API type UpdateUserPhone
#  @export
#  @noRd
#  @noRd
UpdateUserPhone <- R6::R6Class("UpdateUserPhone",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x5492a13,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(user_id, phone) {
      self$user_id <- user_id
      self$phone <- phone
    },
    to_dict = function() {
      list(
        `_` = "UpdateUserPhone",
        user_id = self$user_id,
        phone = self$phone
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x13, 0x2a, 0x49, 0x05)),
        pack("q", self$user_id),
        self$serializebytes(self$phone)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      user_id <- reader$read_long()
      phone <- reader$tgread_string()
      list(user_id = user_id, phone = phone)
    }
  ),
  class = TRUE
)

#  @title UpdateUserStatus
#  @description Telegram API type UpdateUserStatus
#  @export
#  @noRd
#  @noRd
UpdateUserStatus <- R6::R6Class("UpdateUserStatus",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe5bdf8de,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(user_id, status) {
      self$user_id <- user_id
      self$status <- status
    },
    to_dict = function() {
      list(
        `_` = "UpdateUserStatus",
        user_id = self$user_id,
        status = if (inherits(self$status, "TLObject")) self$status$to_dict() else self$status
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xde, 0xf8, 0xbd, 0xe5)),
        pack("q", self$user_id),
        self$status$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      user_id <- reader$read_long()
      status <- reader$tgread_object()
      list(user_id = user_id, status = status)
    }
  ),
  class = TRUE
)

#  @title UpdateUserTyping
#  @description Telegram API type UpdateUserTyping
#  @export
#  @noRd
#  @noRd
UpdateUserTyping <- R6::R6Class("UpdateUserTyping",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc01e857f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(user_id, action) {
      self$user_id <- user_id
      self$action <- action
    },
    to_dict = function() {
      list(
        `_` = "UpdateUserTyping",
        user_id = self$user_id,
        action = if (inherits(self$action, "TLObject")) self$action$to_dict() else self$action
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x7f, 0x85, 0x1e, 0xc0)),
        pack("q", self$user_id),
        self$action$bytes()
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      list(user_id = reader$read_long(), action = reader$tgread_object())
    }
  ),
  class = TRUE
)

#  @title UpdateWebPage
#  @description Telegram API type UpdateWebPage
#  @export
#  @noRd
#  @noRd
UpdateWebPage <- R6::R6Class("UpdateWebPage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7f891213,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(webpage, pts, pts_count) {
      self$webpage <- webpage
      self$pts <- pts
      self$pts_count <- pts_count
    },
    to_dict = function() {
      list(
        `_` = "UpdateWebPage",
        webpage = if (inherits(self$webpage, "TLObject")) self$webpage$to_dict() else self$webpage,
        pts = self$pts,
        pts_count = self$pts_count
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x13, 0x12, 0x89, 0x7f)),
        self$webpage$bytes(),
        pack("i", self$pts),
        pack("i", self$pts_count)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      list(webpage = reader$tgread_object(), pts = reader$read_int(), pts_count = reader$read_int())
    }
  ),
  class = TRUE
)

#  @title UpdateWebViewResultSent
#  @description Telegram API type UpdateWebViewResultSent
#  @export
#  @noRd
#  @noRd
UpdateWebViewResultSent <- R6::R6Class("UpdateWebViewResultSent",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1592b79d,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x9f89304e,
    initialize = function(query_id) {
      self$query_id <- query_id
    },
    to_dict = function() {
      list(
        `_` = "UpdateWebViewResultSent",
        query_id = self$query_id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x9d, 0xb7, 0x92, 0x15)),
        pack("q", self$query_id)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      list(query_id = reader$read_long())
    }
  ),
  class = TRUE
)

#  @title Updates
#  @description Telegram API type Updates
#  @export
#  @noRd
#  @noRd
Updates <- R6::R6Class("Updates",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x74ae4240,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8af52aac,
    initialize = function(updates, users, chats, date, seq) {
      self$updates <- updates
      self$users <- users
      self$chats <- chats
      self$date <- date
      self$seq <- seq
    },
    to_dict = function() {
      list(
        `_` = "Updates",
        updates = if (is.null(self$updates)) list() else lapply(self$updates, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        users = if (is.null(self$users)) list() else lapply(self$users, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        chats = if (is.null(self$chats)) list() else lapply(self$chats, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        date = self$date,
        seq = self$seq
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x40, 0x42, 0xae, 0x74)),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$updates)), do.call(c, lapply(self$updates, function(x) x$bytes())),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$users)), do.call(c, lapply(self$users, function(x) x$bytes())),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$chats)), do.call(c, lapply(self$chats, function(x) x$bytes())),
        self$serialize_datetime(self$date),
        pack("i", self$seq)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      updates <- lapply(seq_len(reader$read_int()), function(x) reader$tgread_object())
      reader$read_int()
      users <- lapply(seq_len(reader$read_int()), function(x) reader$tgread_object())
      reader$read_int()
      chats <- lapply(seq_len(reader$read_int()), function(x) reader$tgread_object())
      date <- reader$tgread_date()
      seq <- reader$read_int()
      list(updates = updates, users = users, chats = chats, date = date, seq = seq)
    }
  ),
  class = TRUE
)

#  @title UpdatesCombined
#  @description Telegram API type UpdatesCombined
#  @export
#  @noRd
#  @noRd
UpdatesCombined <- R6::R6Class("UpdatesCombined",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x725b04c3,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8af52aac,
    initialize = function(updates, users, chats, date, seq_start, seq) {
      self$updates <- updates
      self$users <- users
      self$chats <- chats
      self$date <- date
      self$seq_start <- seq_start
      self$seq <- seq
    },
    to_dict = function() {
      list(
        `_` = "UpdatesCombined",
        updates = if (is.null(self$updates)) list() else lapply(self$updates, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        users = if (is.null(self$users)) list() else lapply(self$users, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        chats = if (is.null(self$chats)) list() else lapply(self$chats, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        date = self$date,
        seq_start = self$seq_start,
        seq = self$seq
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xc3, 0x04, 0x5b, 0x72)),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$updates)), do.call(c, lapply(self$updates, function(x) x$bytes())),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$users)), do.call(c, lapply(self$users, function(x) x$bytes())),
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)), pack("i", length(self$chats)), do.call(c, lapply(self$chats, function(x) x$bytes())),
        self$serialize_datetime(self$date),
        pack("i", self$seq_start),
        pack("i", self$seq)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      updates <- lapply(seq_len(reader$read_int()), function(x) reader$tgread_object())
      reader$read_int()
      users <- lapply(seq_len(reader$read_int()), function(x) reader$tgread_object())
      reader$read_int()
      chats <- lapply(seq_len(reader$read_int()), function(x) reader$tgread_object())
      date <- reader$tgread_date()
      seq_start <- reader$read_int()
      seq <- reader$read_int()
      list(updates = updates, users = users, chats = chats, date = date, seq_start = seq_start, seq = seq)
    }
  ),
  class = TRUE
)

#  @title UpdatesTooLong
#  @description Telegram API type UpdatesTooLong
#  @export
#  @noRd
#  @noRd
UpdatesTooLong <- R6::R6Class("UpdatesTooLong",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe317af7e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x8af52aac,
    to_dict = function() {
      list(`_` = "UpdatesTooLong")
    },
    bytes = function() {
      as.raw(c(0x7e, 0xaf, 0x17, 0xe3))
    }
  ),
  private = list(
    from_reader = function(reader) {
      list()
    }
  ),
  class = TRUE
)

#  @title UrlAuthResultAccepted
#  @description Telegram API type UrlAuthResultAccepted
#  @export
#  @noRd
#  @noRd
UrlAuthResultAccepted <- R6::R6Class("UrlAuthResultAccepted",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8f8c0e4e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x7765cb1e,
    initialize = function(url) {
      self$url <- url
    },
    to_dict = function() {
      list(
        `_` = "UrlAuthResultAccepted",
        url = self$url
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x4e, 0x0e, 0x8c, 0x8f)),
        self$serializebytes(self$url)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      list(url = reader$tgread_string())
    }
  ),
  class = TRUE
)

#  @title UrlAuthResultDefault
#  @description Telegram API type UrlAuthResultDefault
#  @export
#  @noRd
#  @noRd
UrlAuthResultDefault <- R6::R6Class("UrlAuthResultDefault",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa9d6db1f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x7765cb1e,
    to_dict = function() {
      list(`_` = "UrlAuthResultDefault")
    },
    bytes = function() {
      as.raw(c(0x1f, 0xdb, 0xd6, 0xa9))
    }
  ),
  private = list(
    from_reader = function(reader) {
      list()
    }
  ),
  class = TRUE
)

#  @title UrlAuthResultRequest
#  @description Telegram API type UrlAuthResultRequest
#  @export
#  @noRd
#  @noRd
UrlAuthResultRequest <- R6::R6Class("UrlAuthResultRequest",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x92d33a0e,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x7765cb1e,
    initialize = function(bot, domain, request_write_access = NULL) {
      self$bot <- bot
      self$domain <- domain
      self$request_write_access <- request_write_access
    },
    to_dict = function() {
      list(
        `_` = "UrlAuthResultRequest",
        bot = if (inherits(self$bot, "TLObject")) self$bot$to_dict() else self$bot,
        domain = self$domain,
        request_write_access = self$request_write_access
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x0e, 0x3a, 0xd3, 0x92)),
        pack("I", if (is.null(self$request_write_access) || !self$request_write_access) 0 else 1),
        self$bot$bytes(),
        self$serializebytes(self$domain)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      request_write_access <- (flags & 1) != 0
      bot <- reader$tgread_object()
      domain <- reader$tgread_string()
      list(bot = bot, domain = domain, request_write_access = request_write_access)
    }
  ),
  class = TRUE
)

#  @title User
#  @description Telegram API type User
#  @export
#  @noRd
#  @noRd
User <- R6::R6Class("User",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x20b1422,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x2da17977,
    initialize = function(id, is_self = NULL, contact = NULL, mutual_contact = NULL, deleted = NULL, bot = NULL, bot_chat_history = NULL, bot_nochats = NULL, verified = NULL, restricted = NULL, min = NULL, bot_inline_geo = NULL, support = NULL, scam = NULL, apply_min_photo = NULL, fake = NULL, bot_attach_menu = NULL, premium = NULL, attach_menu_enabled = NULL, bot_can_edit = NULL, close_friend = NULL, stories_hidden = NULL, stories_unavailable = NULL, contact_require_premium = NULL, bot_business = NULL, bot_has_main_app = NULL, bot_forum_view = NULL, access_hash = NULL, first_name = NULL, last_name = NULL, username = NULL, phone = NULL, photo = NULL, status = NULL, bot_info_version = NULL, restriction_reason = NULL, bot_inline_placeholder = NULL, lang_code = NULL, emoji_status = NULL, usernames = NULL, stories_max_id = NULL, color = NULL, profile_color = NULL, bot_active_users = NULL, bot_verification_icon = NULL, send_paid_messages_stars = NULL) {
      self$id <- id
      self$is_self <- is_self
      self$contact <- contact
      self$mutual_contact <- mutual_contact
      self$deleted <- deleted
      self$bot <- bot
      self$bot_chat_history <- bot_chat_history
      self$bot_nochats <- bot_nochats
      self$verified <- verified
      self$restricted <- restricted
      self$min <- min
      self$bot_inline_geo <- bot_inline_geo
      self$support <- support
      self$scam <- scam
      self$apply_min_photo <- apply_min_photo
      self$fake <- fake
      self$bot_attach_menu <- bot_attach_menu
      self$premium <- premium
      self$attach_menu_enabled <- attach_menu_enabled
      self$bot_can_edit <- bot_can_edit
      self$close_friend <- close_friend
      self$stories_hidden <- stories_hidden
      self$stories_unavailable <- stories_unavailable
      self$contact_require_premium <- contact_require_premium
      self$bot_business <- bot_business
      self$bot_has_main_app <- bot_has_main_app
      self$bot_forum_view <- bot_forum_view
      self$access_hash <- access_hash
      self$first_name <- first_name
      self$last_name <- last_name
      self$username <- username
      self$phone <- phone
      self$photo <- photo
      self$status <- status
      self$bot_info_version <- bot_info_version
      self$restriction_reason <- restriction_reason
      self$bot_inline_placeholder <- bot_inline_placeholder
      self$lang_code <- lang_code
      self$emoji_status <- emoji_status
      self$usernames <- usernames
      self$stories_max_id <- stories_max_id
      self$color <- color
      self$profile_color <- profile_color
      self$bot_active_users <- bot_active_users
      self$bot_verification_icon <- bot_verification_icon
      self$send_paid_messages_stars <- send_paid_messages_stars
    },
    to_dict = function() {
      list(
        `_` = "User",
        id = self$id,
        is_self = self$is_self,
        contact = self$contact,
        mutual_contact = self$mutual_contact,
        deleted = self$deleted,
        bot = self$bot,
        bot_chat_history = self$bot_chat_history,
        bot_nochats = self$bot_nochats,
        verified = self$verified,
        restricted = self$restricted,
        min = self$min,
        bot_inline_geo = self$bot_inline_geo,
        support = self$support,
        scam = self$scam,
        apply_min_photo = self$apply_min_photo,
        fake = self$fake,
        bot_attach_menu = self$bot_attach_menu,
        premium = self$premium,
        attach_menu_enabled = self$attach_menu_enabled,
        bot_can_edit = self$bot_can_edit,
        close_friend = self$close_friend,
        stories_hidden = self$stories_hidden,
        stories_unavailable = self$stories_unavailable,
        contact_require_premium = self$contact_require_premium,
        bot_business = self$bot_business,
        bot_has_main_app = self$bot_has_main_app,
        bot_forum_view = self$bot_forum_view,
        access_hash = self$access_hash,
        first_name = self$first_name,
        last_name = self$last_name,
        username = self$username,
        phone = self$phone,
        photo = if (inherits(self$photo, "TLObject")) self$photo$to_dict() else self$photo,
        status = if (inherits(self$status, "TLObject")) self$status$to_dict() else self$status,
        bot_info_version = self$bot_info_version,
        restriction_reason = if (is.null(self$restriction_reason)) list() else lapply(self$restriction_reason, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        bot_inline_placeholder = self$bot_inline_placeholder,
        lang_code = self$lang_code,
        emoji_status = if (inherits(self$emoji_status, "TLObject")) self$emoji_status$to_dict() else self$emoji_status,
        usernames = if (is.null(self$usernames)) list() else lapply(self$usernames, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        stories_max_id = self$stories_max_id,
        color = if (inherits(self$color, "TLObject")) self$color$to_dict() else self$color,
        profile_color = if (inherits(self$profile_color, "TLObject")) self$profile_color$to_dict() else self$profile_color,
        bot_active_users = self$bot_active_users,
        bot_verification_icon = self$bot_verification_icon,
        send_paid_messages_stars = self$send_paid_messages_stars
      )
    },
    bytes = function() {
      stop("Not implemented")
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      is_self <- bitwAnd(flags, 1024) != 0
      contact <- bitwAnd(flags, 2048) != 0
      mutual_contact <- bitwAnd(flags, 4096) != 0
      deleted <- bitwAnd(flags, 8192) != 0
      bot <- bitwAnd(flags, 16384) != 0
      bot_chat_history <- bitwAnd(flags, 32768) != 0
      bot_nochats <- bitwAnd(flags, 65536) != 0
      verified <- bitwAnd(flags, 131072) != 0
      restricted <- bitwAnd(flags, 262144) != 0
      min <- bitwAnd(flags, 1048576) != 0
      bot_inline_geo <- bitwAnd(flags, 2097152) != 0
      support <- bitwAnd(flags, 8388608) != 0
      scam <- bitwAnd(flags, 16777216) != 0
      apply_min_photo <- bitwAnd(flags, 33554432) != 0
      fake <- bitwAnd(flags, 67108864) != 0
      bot_attach_menu <- bitwAnd(flags, 134217728) != 0
      premium <- bitwAnd(flags, 268435456) != 0
      attach_menu_enabled <- bitwAnd(flags, 536870912) != 0
      
      flags2 <- reader$read_int()
      bot_can_edit <- bitwAnd(flags2, 2) != 0
      close_friend <- bitwAnd(flags2, 4) != 0
      stories_hidden <- bitwAnd(flags2, 8) != 0
      stories_unavailable <- bitwAnd(flags2, 16) != 0
      contact_require_premium <- bitwAnd(flags2, 1024) != 0
      bot_business <- bitwAnd(flags2, 2048) != 0
      bot_has_main_app <- bitwAnd(flags2, 8192) != 0
      bot_forum_view <- bitwAnd(flags2, 65536) != 0

      id <- reader$read_long()
      access_hash <- if (bitwAnd(flags, 1) != 0) reader$read_long() else NULL
      first_name <- if (bitwAnd(flags, 2) != 0) reader$tgread_string() else NULL
      last_name <- if (bitwAnd(flags, 4) != 0) reader$tgread_string() else NULL
      username <- if (bitwAnd(flags, 8) != 0) reader$tgread_string() else NULL
      phone <- if (bitwAnd(flags, 16) != 0) reader$tgread_string() else NULL
      photo <- if (bitwAnd(flags, 32) != 0) reader$tgread_object() else NULL
      status <- NULL
      if (bitwAnd(flags, 64) != 0) {
        status <- tryCatch(reader$tgread_object(), error = function(e) NULL)
      }
      bot_info_version <- if (bitwAnd(flags, 16384) != 0) reader$read_int() else NULL
      
      restriction_reason <- if (bitwAnd(flags, 262144) != 0) {
        # Vector<RestrictionReason>
        reader$read_int() # constructor
        sapply(seq_len(reader$read_int()), function(i) reader$tgread_object())
      } else {
        NULL
      }
      
      bot_inline_placeholder <- if (bitwAnd(flags, 524288) != 0) reader$tgread_string() else NULL
      lang_code <- if (bitwAnd(flags, 4194304) != 0) reader$tgread_string() else NULL
      emoji_status <- if (bitwAnd(flags, 1073741824) != 0) reader$tgread_object() else NULL
      
      usernames <- if (bitwAnd(flags2, 1) != 0) {
        # Vector<Username>
        reader$read_int() # constructor
        sapply(seq_len(reader$read_int()), function(i) reader$tgread_object())
      } else {
        NULL
      }
      
      stories_max_id <- if (bitwAnd(flags2, 32) != 0) reader$read_int() else NULL
      color <- if (bitwAnd(flags2, 256) != 0) reader$tgread_object() else NULL
      profile_color <- if (bitwAnd(flags2, 512) != 0) reader$tgread_object() else NULL
      bot_active_users <- if (bitwAnd(flags2, 4096) != 0) reader$read_int() else NULL
      bot_verification_icon <- if (bitwAnd(flags2, 16384) != 0) reader$read_long() else NULL
      send_paid_messages_stars <- if (bitwAnd(flags2, 32768) != 0) reader$read_long() else NULL
      
      # For simplicity, returning a list of fields.
      # The caller in tgread_object will use do.call(cls$new, ...)
      list(
        id = id, is_self = is_self, contact = contact, mutual_contact = mutual_contact,
        deleted = deleted, bot = bot, bot_chat_history = bot_chat_history,
        bot_nochats = bot_nochats, verified = verified, restricted = restricted,
        min = min, bot_inline_geo = bot_inline_geo, support = support, scam = scam,
        apply_min_photo = apply_min_photo, fake = fake, bot_attach_menu = bot_attach_menu,
        premium = premium, attach_menu_enabled = attach_menu_enabled,
        bot_can_edit = bot_can_edit, close_friend = close_friend,
        stories_hidden = stories_hidden, stories_unavailable = stories_unavailable,
        contact_require_premium = contact_require_premium, bot_business = bot_business,
        bot_has_main_app = bot_has_main_app, bot_forum_view = bot_forum_view, access_hash = access_hash,
        first_name = first_name, last_name = last_name, username = username,
        phone = phone, photo = photo, status = status,
        bot_info_version = bot_info_version,
        restriction_reason = restriction_reason,
        bot_inline_placeholder = bot_inline_placeholder, lang_code = lang_code,
        emoji_status = emoji_status, usernames = usernames,
        stories_max_id = stories_max_id, color = color, profile_color = profile_color,
        bot_active_users = bot_active_users, bot_verification_icon = bot_verification_icon,
        send_paid_messages_stars = send_paid_messages_stars
      )
    }
  ),
  class = TRUE,
  lock_objects = FALSE
)

#  @title UserEmpty
#  @description Telegram API type UserEmpty
#  @export
#  @noRd
#  @noRd
UserEmpty <- R6::R6Class("UserEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xd3bc4b7a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x2da17977,
    initialize = function(id) {
      self$id <- id
    },
    to_dict = function() {
      list(
        `_` = "UserEmpty",
        id = self$id
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x7a, 0x4b, 0xbc, 0xd3)),
        pack("q", self$id)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      list(id = reader$read_long())
    }
  ),
  class = TRUE,
  lock_objects = FALSE
)

#  @title UserFull
#  @description Telegram API type UserFull
#  @export
#  @noRd
#  @noRd
UserFull <- R6::R6Class("UserFull",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc577b5ad,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1f4661b9,
    initialize = function(id, settings, notify_settings, common_chats_count, blocked = NULL, phone_calls_available = NULL, phone_calls_private = NULL, can_pin_message = NULL, has_scheduled = NULL, video_calls_available = NULL, voice_messages_forbidden = NULL, translations_disabled = NULL, stories_pinned_available = NULL, blocked_my_stories_from = NULL, wallpaper_overridden = NULL, contact_require_premium = NULL, read_dates_private = NULL, sponsored_enabled = NULL, can_view_revenue = NULL, bot_can_manage_emoji_status = NULL, display_gifts_button = NULL, about = NULL, personal_photo = NULL, profile_photo = NULL, fallback_photo = NULL, bot_info = NULL, pinned_msg_id = NULL, folder_id = NULL, ttl_period = NULL, theme = NULL, private_forward_name = NULL, bot_group_admin_rights = NULL, bot_broadcast_admin_rights = NULL, wallpaper = NULL, stories = NULL, business_work_hours = NULL, business_location = NULL, business_greeting_message = NULL, business_away_message = NULL, business_intro = NULL, birthday = NULL, personal_channel_id = NULL, personal_channel_message = NULL, stargifts_count = NULL, starref_program = NULL, bot_verification = NULL, send_paid_messages_stars = NULL, disallowed_gifts = NULL, stars_rating = NULL, stars_my_pending_rating = NULL, stars_my_pending_rating_date = NULL, main_tab = NULL, saved_music = NULL) {
      self$id <- id
      self$settings <- settings
      self$notify_settings <- notify_settings
      self$common_chats_count <- common_chats_count
      self$blocked <- blocked
      self$phone_calls_available <- phone_calls_available
      self$phone_calls_private <- phone_calls_private
      self$can_pin_message <- can_pin_message
      self$has_scheduled <- has_scheduled
      self$video_calls_available <- video_calls_available
      self$voice_messages_forbidden <- voice_messages_forbidden
      self$translations_disabled <- translations_disabled
      self$stories_pinned_available <- stories_pinned_available
      self$blocked_my_stories_from <- blocked_my_stories_from
      self$wallpaper_overridden <- wallpaper_overridden
      self$contact_require_premium <- contact_require_premium
      self$read_dates_private <- read_dates_private
      self$sponsored_enabled <- sponsored_enabled
      self$can_view_revenue <- can_view_revenue
      self$bot_can_manage_emoji_status <- bot_can_manage_emoji_status
      self$display_gifts_button <- display_gifts_button
      self$about <- about
      self$personal_photo <- personal_photo
      self$profile_photo <- profile_photo
      self$fallback_photo <- fallback_photo
      self$bot_info <- bot_info
      self$pinned_msg_id <- pinned_msg_id
      self$folder_id <- folder_id
      self$ttl_period <- ttl_period
      self$theme <- theme
      self$private_forward_name <- private_forward_name
      self$bot_group_admin_rights <- bot_group_admin_rights
      self$bot_broadcast_admin_rights <- bot_broadcast_admin_rights
      self$wallpaper <- wallpaper
      self$stories <- stories
      self$business_work_hours <- business_work_hours
      self$business_location <- business_location
      self$business_greeting_message <- business_greeting_message
      self$business_away_message <- business_away_message
      self$business_intro <- business_intro
      self$birthday <- birthday
      self$personal_channel_id <- personal_channel_id
      self$personal_channel_message <- personal_channel_message
      self$stargifts_count <- stargifts_count
      self$starref_program <- starref_program
      self$bot_verification <- bot_verification
      self$send_paid_messages_stars <- send_paid_messages_stars
      self$disallowed_gifts <- disallowed_gifts
      self$stars_rating <- stars_rating
      self$stars_my_pending_rating <- stars_my_pending_rating
      self$stars_my_pending_rating_date <- stars_my_pending_rating_date
      self$main_tab <- main_tab
      self$saved_music <- saved_music
    },
    to_dict = function() {
      list(
        `_` = "UserFull",
        id = self$id,
        settings = if (inherits(self$settings, "TLObject")) self$settings$to_dict() else self$settings,
        notify_settings = if (inherits(self$notify_settings, "TLObject")) self$notify_settings$to_dict() else self$notify_settings,
        common_chats_count = self$common_chats_count,
        blocked = self$blocked,
        phone_calls_available = self$phone_calls_available,
        phone_calls_private = self$phone_calls_private,
        can_pin_message = self$can_pin_message,
        has_scheduled = self$has_scheduled,
        video_calls_available = self$video_calls_available,
        voice_messages_forbidden = self$voice_messages_forbidden,
        translations_disabled = self$translations_disabled,
        stories_pinned_available = self$stories_pinned_available,
        blocked_my_stories_from = self$blocked_my_stories_from,
        wallpaper_overridden = self$wallpaper_overridden,
        contact_require_premium = self$contact_require_premium,
        read_dates_private = self$read_dates_private,
        sponsored_enabled = self$sponsored_enabled,
        can_view_revenue = self$can_view_revenue,
        bot_can_manage_emoji_status = self$bot_can_manage_emoji_status,
        display_gifts_button = self$display_gifts_button,
        about = self$about,
        personal_photo = if (inherits(self$personal_photo, "TLObject")) self$personal_photo$to_dict() else self$personal_photo,
        profile_photo = if (inherits(self$profile_photo, "TLObject")) self$profile_photo$to_dict() else self$profile_photo,
        fallback_photo = if (inherits(self$fallback_photo, "TLObject")) self$fallback_photo$to_dict() else self$fallback_photo,
        bot_info = if (inherits(self$bot_info, "TLObject")) self$bot_info$to_dict() else self$bot_info,
        pinned_msg_id = self$pinned_msg_id,
        folder_id = self$folder_id,
        ttl_period = self$ttl_period,
        theme = if (inherits(self$theme, "TLObject")) self$theme$to_dict() else self$theme,
        private_forward_name = self$private_forward_name,
        bot_group_admin_rights = if (inherits(self$bot_group_admin_rights, "TLObject")) self$bot_group_admin_rights$to_dict() else self$bot_group_admin_rights,
        bot_broadcast_admin_rights = if (inherits(self$bot_broadcast_admin_rights, "TLObject")) self$bot_broadcast_admin_rights$to_dict() else self$bot_broadcast_admin_rights,
        wallpaper = if (inherits(self$wallpaper, "TLObject")) self$wallpaper$to_dict() else self$wallpaper,
        stories = if (inherits(self$stories, "TLObject")) self$stories$to_dict() else self$stories,
        business_work_hours = if (inherits(self$business_work_hours, "TLObject")) self$business_work_hours$to_dict() else self$business_work_hours,
        business_location = if (inherits(self$business_location, "TLObject")) self$business_location$to_dict() else self$business_location,
        business_greeting_message = if (inherits(self$business_greeting_message, "TLObject")) self$business_greeting_message$to_dict() else self$business_greeting_message,
        business_away_message = if (inherits(self$business_away_message, "TLObject")) self$business_away_message$to_dict() else self$business_away_message,
        business_intro = if (inherits(self$business_intro, "TLObject")) self$business_intro$to_dict() else self$business_intro,
        birthday = if (inherits(self$birthday, "TLObject")) self$birthday$to_dict() else self$birthday,
        personal_channel_id = self$personal_channel_id,
        personal_channel_message = self$personal_channel_message,
        stargifts_count = self$stargifts_count,
        starref_program = if (inherits(self$starref_program, "TLObject")) self$starref_program$to_dict() else self$starref_program,
        bot_verification = if (inherits(self$bot_verification, "TLObject")) self$bot_verification$to_dict() else self$bot_verification,
        send_paid_messages_stars = self$send_paid_messages_stars,
        disallowed_gifts = if (inherits(self$disallowed_gifts, "TLObject")) self$disallowed_gifts$to_dict() else self$disallowed_gifts,
        stars_rating = if (inherits(self$stars_rating, "TLObject")) self$stars_rating$to_dict() else self$stars_rating,
        stars_my_pending_rating = if (inherits(self$stars_my_pending_rating, "TLObject")) self$stars_my_pending_rating$to_dict() else self$stars_my_pending_rating,
        stars_my_pending_rating_date = self$stars_my_pending_rating_date,
        main_tab = if (inherits(self$main_tab, "TLObject")) self$main_tab$to_dict() else self$main_tab,
        saved_music = if (inherits(self$saved_music, "TLObject")) self$saved_music$to_dict() else self$saved_music
      )
    },
    bytes = function() {
      stopifnot((!is.null(self$personal_channel_id) && !is.null(self$personal_channel_message)) || (is.null(self$personal_channel_id) && is.null(self$personal_channel_message)), "personal_channel_id, personal_channel_message parameters must all be NULL or all not NULL")
      stopifnot((!is.null(self$stars_my_pending_rating) && !is.null(self$stars_my_pending_rating_date)) || (is.null(self$stars_my_pending_rating) && is.null(self$stars_my_pending_rating_date)), "stars_my_pending_rating, stars_my_pending_rating_date parameters must all be NULL or all not NULL")
      c(
        as.raw(c(0xad, 0xb5, 0x77, 0xc5)),
        pack("I", (if (is.null(self$blocked) || !self$blocked) 0 else 1) | (if (is.null(self$phone_calls_available) || !self$phone_calls_available) 0 else 16) | (if (is.null(self$phone_calls_private) || !self$phone_calls_private) 0 else 32) | (if (is.null(self$can_pin_message) || !self$can_pin_message) 0 else 128) | (if (is.null(self$has_scheduled) || !self$has_scheduled) 0 else 4096) | (if (is.null(self$video_calls_available) || !self$video_calls_available) 0 else 8192) | (if (is.null(self$voice_messages_forbidden) || !self$voice_messages_forbidden) 0 else 1048576) | (if (is.null(self$translations_disabled) || !self$translations_disabled) 0 else 8388608) | (if (is.null(self$stories_pinned_available) || !self$stories_pinned_available) 0 else 67108864) | (if (is.null(self$blocked_my_stories_from) || !self$blocked_my_stories_from) 0 else 134217728) | (if (is.null(self$wallpaper_overridden) || !self$wallpaper_overridden) 0 else 268435456) | (if (is.null(self$contact_require_premium) || !self$contact_require_premium) 0 else 536870912) | (if (is.null(self$read_dates_private) || !self$read_dates_private) 0 else 1073741824) | (if (is.null(self$about)) 0 else 2) | (if (is.null(self$personal_photo)) 0 else 2097152) | (if (is.null(self$profile_photo)) 0 else 4) | (if (is.null(self$fallback_photo)) 0 else 4194304) | (if (is.null(self$bot_info)) 0 else 8) | (if (is.null(self$pinned_msg_id)) 0 else 64) | (if (is.null(self$folder_id)) 0 else 2048) | (if (is.null(self$ttl_period)) 0 else 16384) | (if (is.null(self$theme)) 0 else 32768) | (if (is.null(self$private_forward_name)) 0 else 65536) | (if (is.null(self$bot_group_admin_rights)) 0 else 131072) | (if (is.null(self$bot_broadcast_admin_rights)) 0 else 262144) | (if (is.null(self$wallpaper)) 0 else 16777216) | (if (is.null(self$stories)) 0 else 33554432)),
        pack("I", (if (is.null(self$sponsored_enabled) || !self$sponsored_enabled) 0 else 128) | (if (is.null(self$can_view_revenue) || !self$can_view_revenue) 0 else 512) | (if (is.null(self$bot_can_manage_emoji_status) || !self$bot_can_manage_emoji_status) 0 else 1024) | (if (is.null(self$display_gifts_button) || !self$display_gifts_button) 0 else 65536) | (if (is.null(self$business_work_hours)) 0 else 1) | (if (is.null(self$business_location)) 0 else 2) | (if (is.null(self$business_greeting_message)) 0 else 4) | (if (is.null(self$business_away_message)) 0 else 8) | (if (is.null(self$business_intro)) 0 else 16) | (if (is.null(self$birthday)) 0 else 32) | (if (is.null(self$personal_channel_id)) 0 else 64) | (if (is.null(self$personal_channel_message)) 0 else 64) | (if (is.null(self$stargifts_count)) 0 else 256) | (if (is.null(self$starref_program)) 0 else 2048) | (if (is.null(self$bot_verification)) 0 else 4096) | (if (is.null(self$send_paid_messages_stars)) 0 else 16384) | (if (is.null(self$disallowed_gifts)) 0 else 32768) | (if (is.null(self$stars_rating)) 0 else 131072) | (if (is.null(self$stars_my_pending_rating)) 0 else 262144) | (if (is.null(self$stars_my_pending_rating_date)) 0 else 262144) | (if (is.null(self$main_tab)) 0 else 1048576) | (if (is.null(self$saved_music)) 0 else 2097152)),
        pack("q", self$id),
        if (!is.null(self$about)) self$serializebytes(self$about) else raw(0),
        self$settings$bytes(),
        if (!is.null(self$personal_photo)) self$personal_photo$bytes() else raw(0),
        if (!is.null(self$profile_photo)) self$profile_photo$bytes() else raw(0),
        if (!is.null(self$fallback_photo)) self$fallback_photo$bytes() else raw(0),
        self$notify_settings$bytes(),
        if (!is.null(self$bot_info)) self$bot_info$bytes() else raw(0),
        if (!is.null(self$pinned_msg_id)) pack("i", self$pinned_msg_id) else raw(0),
        pack("i", self$common_chats_count),
        if (!is.null(self$folder_id)) pack("i", self$folder_id) else raw(0),
        if (!is.null(self$ttl_period)) pack("i", self$ttl_period) else raw(0),
        if (!is.null(self$theme)) self$theme$bytes() else raw(0),
        if (!is.null(self$private_forward_name)) self$serializebytes(self$private_forward_name) else raw(0),
        if (!is.null(self$bot_group_admin_rights)) self$bot_group_admin_rights$bytes() else raw(0),
        if (!is.null(self$bot_broadcast_admin_rights)) self$bot_broadcast_admin_rights$bytes() else raw(0),
        if (!is.null(self$wallpaper)) self$wallpaper$bytes() else raw(0),
        if (!is.null(self$stories)) self$stories$bytes() else raw(0),
        if (!is.null(self$business_work_hours)) self$business_work_hours$bytes() else raw(0),
        if (!is.null(self$business_location)) self$business_location$bytes() else raw(0),
        if (!is.null(self$business_greeting_message)) self$business_greeting_message$bytes() else raw(0),
        if (!is.null(self$business_away_message)) self$business_away_message$bytes() else raw(0),
        if (!is.null(self$business_intro)) self$business_intro$bytes() else raw(0),
        if (!is.null(self$birthday)) self$birthday$bytes() else raw(0),
        if (!is.null(self$personal_channel_id)) pack("q", self$personal_channel_id) else raw(0),
        if (!is.null(self$personal_channel_message)) pack("i", self$personal_channel_message) else raw(0),
        if (!is.null(self$stargifts_count)) pack("i", self$stargifts_count) else raw(0),
        if (!is.null(self$starref_program)) self$starref_program$bytes() else raw(0),
        if (!is.null(self$bot_verification)) self$bot_verification$bytes() else raw(0),
        if (!is.null(self$send_paid_messages_stars)) pack("q", self$send_paid_messages_stars) else raw(0),
        if (!is.null(self$disallowed_gifts)) self$disallowed_gifts$bytes() else raw(0),
        if (!is.null(self$stars_rating)) self$stars_rating$bytes() else raw(0),
        if (!is.null(self$stars_my_pending_rating)) self$stars_my_pending_rating$bytes() else raw(0),
        if (!is.null(self$stars_my_pending_rating_date)) self$serialize_datetime(self$stars_my_pending_rating_date) else raw(0),
        if (!is.null(self$main_tab)) self$main_tab$bytes() else raw(0),
        if (!is.null(self$saved_music)) self$saved_music$bytes() else raw(0)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      blocked <- bitwAnd(flags, 1) != 0
      phone_calls_available <- bitwAnd(flags, 16) != 0
      phone_calls_private <- bitwAnd(flags, 32) != 0
      can_pin_message <- bitwAnd(flags, 128) != 0
      has_scheduled <- bitwAnd(flags, 4096) != 0
      video_calls_available <- bitwAnd(flags, 8192) != 0
      voice_messages_forbidden <- bitwAnd(flags, 1048576) != 0
      translations_disabled <- bitwAnd(flags, 8388608) != 0
      stories_pinned_available <- bitwAnd(flags, 67108864) != 0
      blocked_my_stories_from <- bitwAnd(flags, 134217728) != 0
      wallpaper_overridden <- bitwAnd(flags, 268435456) != 0
      contact_require_premium <- bitwAnd(flags, 536870912) != 0
      read_dates_private <- bitwAnd(flags, 1073741824) != 0
      flags2 <- reader$read_int()
      sponsored_enabled <- bitwAnd(flags2, 128) != 0
      can_view_revenue <- bitwAnd(flags2, 512) != 0
      bot_can_manage_emoji_status <- bitwAnd(flags2, 1024) != 0
      display_gifts_button <- bitwAnd(flags2, 65536) != 0
      id <- reader$read_long()
      about <- if (bitwAnd(flags, 2)) reader$tgread_string() else NULL
      settings <- reader$tgread_object()
      personal_photo <- if (bitwAnd(flags, 2097152)) reader$tgread_object() else NULL
      profile_photo <- if (bitwAnd(flags, 4)) reader$tgread_object() else NULL
      fallback_photo <- if (bitwAnd(flags, 4194304)) reader$tgread_object() else NULL
      notify_settings <- reader$tgread_object()
      bot_info <- if (bitwAnd(flags, 8)) reader$tgread_object() else NULL
      pinned_msg_id <- if (bitwAnd(flags, 64)) reader$read_int() else NULL
      common_chats_count <- reader$read_int()
      folder_id <- if (bitwAnd(flags, 2048)) reader$read_int() else NULL
      ttl_period <- if (bitwAnd(flags, 16384)) reader$read_int() else NULL
      theme <- if (bitwAnd(flags, 32768)) reader$tgread_object() else NULL
      private_forward_name <- if (bitwAnd(flags, 65536)) reader$tgread_string() else NULL
      bot_group_admin_rights <- if (bitwAnd(flags, 131072)) reader$tgread_object() else NULL
      bot_broadcast_admin_rights <- if (bitwAnd(flags, 262144)) reader$tgread_object() else NULL
      wallpaper <- if (bitwAnd(flags, 16777216)) reader$tgread_object() else NULL
      stories <- if (bitwAnd(flags, 33554432)) reader$tgread_object() else NULL
      business_work_hours <- if (bitwAnd(flags2, 1)) reader$tgread_object() else NULL
      business_location <- if (bitwAnd(flags2, 2)) reader$tgread_object() else NULL
      business_greeting_message <- if (bitwAnd(flags2, 4)) reader$tgread_object() else NULL
      business_away_message <- if (bitwAnd(flags2, 8)) reader$tgread_object() else NULL
      business_intro <- if (bitwAnd(flags2, 16)) reader$tgread_object() else NULL
      birthday <- if (bitwAnd(flags2, 32)) reader$tgread_object() else NULL
      personal_channel_id <- if (bitwAnd(flags2, 64)) reader$read_long() else NULL
      personal_channel_message <- if (bitwAnd(flags2, 64)) reader$read_int() else NULL
      stargifts_count <- if (bitwAnd(flags2, 256)) reader$read_int() else NULL
      starref_program <- if (bitwAnd(flags2, 2048)) reader$tgread_object() else NULL
      bot_verification <- if (bitwAnd(flags2, 4096)) reader$tgread_object() else NULL
      send_paid_messages_stars <- if (bitwAnd(flags2, 16384)) reader$read_long() else NULL
      disallowed_gifts <- if (bitwAnd(flags2, 32768)) reader$tgread_object() else NULL
      stars_rating <- if (bitwAnd(flags2, 131072)) reader$tgread_object() else NULL
      stars_my_pending_rating <- if (bitwAnd(flags2, 262144)) reader$tgread_object() else NULL
      stars_my_pending_rating_date <- if (bitwAnd(flags2, 262144)) reader$tgread_date() else NULL
      main_tab <- if (bitwAnd(flags2, 1048576)) reader$tgread_object() else NULL
      saved_music <- if (bitwAnd(flags2, 2097152)) reader$tgread_object() else NULL
      self$initialize(id = id, settings = settings, notify_settings = notify_settings, common_chats_count = common_chats_count, blocked = blocked, phone_calls_available = phone_calls_available, phone_calls_private = phone_calls_private, can_pin_message = can_pin_message, has_scheduled = has_scheduled, video_calls_available = video_calls_available, voice_messages_forbidden = voice_messages_forbidden, translations_disabled = translations_disabled, stories_pinned_available = stories_pinned_available, blocked_my_stories_from = blocked_my_stories_from, wallpaper_overridden = wallpaper_overridden, contact_require_premium = contact_require_premium, read_dates_private = read_dates_private, sponsored_enabled = sponsored_enabled, can_view_revenue = can_view_revenue, bot_can_manage_emoji_status = bot_can_manage_emoji_status, display_gifts_button = display_gifts_button, about = about, personal_photo = personal_photo, profile_photo = profile_photo, fallback_photo = fallback_photo, bot_info = bot_info, pinned_msg_id = pinned_msg_id, folder_id = folder_id, ttl_period = ttl_period, theme = theme, private_forward_name = private_forward_name, bot_group_admin_rights = bot_group_admin_rights, bot_broadcast_admin_rights = bot_broadcast_admin_rights, wallpaper = wallpaper, stories = stories, business_work_hours = business_work_hours, business_location = business_location, business_greeting_message = business_greeting_message, business_away_message = business_away_message, business_intro = business_intro, birthday = birthday, personal_channel_id = personal_channel_id, personal_channel_message = personal_channel_message, stargifts_count = stargifts_count, starref_program = starref_program, bot_verification = bot_verification, send_paid_messages_stars = send_paid_messages_stars, disallowed_gifts = disallowed_gifts, stars_rating = stars_rating, stars_my_pending_rating = stars_my_pending_rating, stars_my_pending_rating_date = stars_my_pending_rating_date, main_tab = main_tab, saved_music = saved_music)
    }
  ),
  class = TRUE
)

#  @title UserProfilePhoto
#  @description Telegram API type UserProfilePhoto
#  @export
#  @noRd
#  @noRd
UserProfilePhoto <- R6::R6Class("UserProfilePhoto",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x82d1f706,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc6338f7d,
    #  @field photo_id Field.
    photo_id = NULL,
    #  @field dc_id Field.
    dc_id = NULL,
    #  @field has_video Field.
    has_video = NULL,
    #  @field personal Field.
    personal = NULL,
    #  @field stripped_thumb Field.
    stripped_thumb = NULL,
    initialize = function(photo_id, dc_id, has_video = NULL, personal = NULL, stripped_thumb = NULL) {
      self$photo_id <- photo_id
      self$dc_id <- dc_id
      self$has_video <- has_video
      self$personal <- personal
      self$stripped_thumb <- stripped_thumb
    },
    to_dict = function() {
      list(
        `_` = "UserProfilePhoto",
        photo_id = self$photo_id,
        dc_id = self$dc_id,
        has_video = self$has_video,
        personal = self$personal,
        stripped_thumb = self$stripped_thumb
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x06, 0xf7, 0xd1, 0x82)),
        pack("I", (if (is.null(self$has_video) || !self$has_video) 0 else 1) | (if (is.null(self$personal) || !self$personal) 0 else 4) | (if (is.null(self$stripped_thumb)) 0 else 2)),
        pack("q", self$photo_id),
        if (!is.null(self$stripped_thumb)) self$serializebytes(self$stripped_thumb) else raw(0),
        pack("i", self$dc_id)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      has_video <- bitwAnd(flags, 1) != 0
      personal <- bitwAnd(flags, 4) != 0
      photo_id <- reader$read_long()
      stripped_thumb <- if (bitwAnd(flags, 2) != 0) reader$tgread_bytes() else NULL
      dc_id <- reader$read_int()
      self$initialize(photo_id = photo_id, dc_id = dc_id, has_video = has_video, personal = personal, stripped_thumb = stripped_thumb)
    }
  ),
  class = TRUE
)

#  @title UserProfilePhotoEmpty
#  @description Telegram API type UserProfilePhotoEmpty
#  @export
#  @noRd
#  @noRd
UserProfilePhotoEmpty <- R6::R6Class("UserProfilePhotoEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4f11bae1,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xc6338f7d,
    to_dict = function() {
      list(`_` = "UserProfilePhotoEmpty")
    },
    bytes = function() {
      as.raw(c(0xe1, 0xba, 0x11, 0x4f))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title UserStatusEmpty
#  @description Telegram API type UserStatusEmpty
#  @export
#  @noRd
#  @noRd
UserStatusEmpty <- R6::R6Class("UserStatusEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x9d05049,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5b0b743e,
    to_dict = function() {
      list(`_` = "UserStatusEmpty")
    },
    bytes = function() {
      as.raw(c(0x49, 0x50, 0xd0, 0x09))
    }
  ),
  private = list(
    from_reader = function(reader) {
      self
    }
  ),
  class = TRUE
)

#  @title UserStatusLastMonth
#  @description Telegram API type UserStatusLastMonth
#  @export
#  @noRd
#  @noRd
UserStatusLastMonth <- R6::R6Class("UserStatusLastMonth",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x65899777,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5b0b743e,
    initialize = function(by_me = NULL) {
      self$by_me <- by_me
    },
    to_dict = function() {
      list(
        `_` = "UserStatusLastMonth",
        by_me = self$by_me
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x77, 0x97, 0x89, 0x65)),
        pack("I", if (is.null(self$by_me) || !self$by_me) 0 else 1)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      by_me <- bitwAnd(flags, 1) != 0
      self$initialize(by_me = by_me)
    }
  ),
  class = TRUE
)

#  @title UserStatusLastWeek
#  @description Telegram API type UserStatusLastWeek
#  @export
#  @noRd
#  @noRd
UserStatusLastWeek <- R6::R6Class("UserStatusLastWeek",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x541a1d1a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5b0b743e,
    initialize = function(by_me = NULL) {
      self$by_me <- by_me
    },
    to_dict = function() {
      list(
        `_` = "UserStatusLastWeek",
        by_me = self$by_me
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x1a, 0x1d, 0x1a, 0x54)),
        pack("I", if (is.null(self$by_me) || !self$by_me) 0 else 1)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      by_me <- bitwAnd(flags, 1) != 0
      self$initialize(by_me = by_me)
    }
  ),
  class = TRUE
)

#  @title UserStatusOffline
#  @description Telegram API type UserStatusOffline
#  @export
#  @noRd
#  @noRd
UserStatusOffline <- R6::R6Class("UserStatusOffline",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8c703f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5b0b743e,
    initialize = function(was_online = NULL) {
      self$was_online <- was_online
    },
    to_dict = function() {
      list(
        `_` = "UserStatusOffline",
        was_online = self$was_online
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x3f, 0x70, 0x8c, 0x00)),
        self$serialize_datetime(self$was_online)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      was_online <- reader$tgread_date()
      self$initialize(was_online = was_online)
    }
  ),
  class = TRUE
)

#  @title UserStatusOnline
#  @description Telegram API type UserStatusOnline
#  @export
#  @noRd
#  @noRd
UserStatusOnline <- R6::R6Class("UserStatusOnline",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xedb93949,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5b0b743e,
    initialize = function(expires = NULL) {
      self$expires <- expires
    },
    to_dict = function() {
      list(
        `_` = "UserStatusOnline",
        expires = self$expires
      )
    },
    bytes = function() {
      c(
        as.raw(c(0x49, 0x39, 0xb9, 0xed)),
        self$serialize_datetime(self$expires)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      expires <- reader$tgread_date()
      self$initialize(expires = expires)
    }
  ),
  class = TRUE
)

#  @title UserStatusRecently
#  @description Telegram API type UserStatusRecently
#  @export
#  @noRd
#  @noRd
UserStatusRecently <- R6::R6Class("UserStatusRecently",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7b197dc8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5b0b743e,
    initialize = function(by_me = NULL) {
      self$by_me <- by_me
    },
    to_dict = function() {
      list(
        `_` = "UserStatusRecently",
        by_me = self$by_me
      )
    },
    bytes = function() {
      c(
        as.raw(c(0xc8, 0x7d, 0x19, 0x7b)),
        pack("I", if (is.null(self$by_me) || !self$by_me) 0 else 1)
      )
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      by_me <- bitwAnd(flags, 1) != 0
      self$initialize(by_me = by_me)
    }
  ),
  class = TRUE
)

#  @title UserStatusLastMonth
#  @description Telegram API type UserStatusLastMonth
#  @export
#  @noRd
#  @noRd
UserStatusLastMonth <- R6::R6Class("UserStatusLastMonth",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x65899777,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5b0b743e,
    initialize = function(by_me = NULL) {
      self$by_me <- by_me
    },
    to_dict = function() {
      list(`_` = "UserStatusLastMonth", by_me = self$by_me)
    },
    bytes = function() {
      as.raw(c(0x77, 0x97, 0x89, 0x65)) + pack("I", (if (is.null(self$by_me)) 0 else 1))
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      by_me <- (flags & 1) != 0
      self$initialize(by_me = by_me)
    }
  ),
  class = TRUE
)

#  @title UserStatusLastWeek
#  @description Telegram API type UserStatusLastWeek
#  @export
#  @noRd
#  @noRd
UserStatusLastWeek <- R6::R6Class("UserStatusLastWeek",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x541a1d1a,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5b0b743e,
    initialize = function(by_me = NULL) {
      self$by_me <- by_me
    },
    to_dict = function() {
      list(`_` = "UserStatusLastWeek", by_me = self$by_me)
    },
    bytes = function() {
      as.raw(c(0x1a, 0x1d, 0x1a, 0x54)) + pack("I", (if (is.null(self$by_me)) 0 else 1))
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      by_me <- (flags & 1) != 0
      self$initialize(by_me = by_me)
    }
  ),
  class = TRUE
)

#  @title UserStatusOffline
#  @description Telegram API type UserStatusOffline
#  @export
#  @noRd
#  @noRd
UserStatusOffline <- R6::R6Class("UserStatusOffline",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x8c703f,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5b0b743e,
    initialize = function(was_online = NULL) {
      self$was_online <- was_online
    },
    to_dict = function() {
      list(`_` = "UserStatusOffline", was_online = self$was_online)
    },
    bytes = function() {
      as.raw(c(0x3f, 0x70, 0x8c, 0x00)) + self$serialize_datetime(self$was_online)
    }
  ),
  private = list(
    from_reader = function(reader) {
      was_online <- reader$tgread_date()
      self$initialize(was_online = was_online)
    }
  ),
  class = TRUE
)

#  @title UserStatusOnline
#  @description Telegram API type UserStatusOnline
#  @export
#  @noRd
#  @noRd
UserStatusOnline <- R6::R6Class("UserStatusOnline",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xedb93949,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5b0b743e,
    initialize = function(expires = NULL) {
      self$expires <- expires
    },
    to_dict = function() {
      list(`_` = "UserStatusOnline", expires = self$expires)
    },
    bytes = function() {
      as.raw(c(0x49, 0x39, 0xb9, 0xed)) + self$serialize_datetime(self$expires)
    }
  ),
  private = list(
    from_reader = function(reader) {
      expires <- reader$tgread_date()
      self$initialize(expires = expires)
    }
  ),
  class = TRUE
)

#  @title UserStatusRecently
#  @description Telegram API type UserStatusRecently
#  @export
#  @noRd
#  @noRd
UserStatusRecently <- R6::R6Class("UserStatusRecently",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7b197dc8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x5b0b743e,
    initialize = function(by_me = NULL) {
      self$by_me <- by_me
    },
    to_dict = function() {
      list(`_` = "UserStatusRecently", by_me = self$by_me)
    },
    bytes = function() {
      as.raw(c(0xc8, 0x7d, 0x19, 0x7b)) + pack("I", (if (is.null(self$by_me)) 0 else 1))
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      by_me <- (flags & 1) != 0
      self$initialize(by_me = by_me)
    }
  ),
  class = TRUE
)

#  @title Username
#  @description Telegram API type Username
#  @export
#  @noRd
#  @noRd
Username <- R6::R6Class("Username",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb4073647,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x1286421,
    initialize = function(username, editable = NULL, active = NULL) {
      self$username <- username
      self$editable <- editable
      self$active <- active
    },
    to_dict = function() {
      list(`_` = "Username", username = self$username, editable = self$editable, active = self$active)
    },
    bytes = function() {
      as.raw(c(0x47, 0x36, 0x07, 0xb4)) + pack("I", (if (is.null(self$editable)) 0 else 1) | (if (is.null(self$active)) 0 else 2)) + self$serializebytes(self$username)
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      editable <- (flags & 1) != 0
      active <- (flags & 2) != 0
      username <- reader$tgread_string()
      self$initialize(username = username, editable = editable, active = active)
    }
  ),
  class = TRUE
)

#  @title VideoSize
#  @description Telegram API type VideoSize
#  @export
#  @noRd
#  @noRd
VideoSize <- R6::R6Class("VideoSize",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xde33b094,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x62f1d509,
    initialize = function(type, w, h, size, video_start_ts = NULL) {
      self$type <- type
      self$w <- w
      self$h <- h
      self$size <- size
      self$video_start_ts <- video_start_ts
    },
    to_dict = function() {
      list(`_` = "VideoSize", type = self$type, w = self$w, h = self$h, size = self$size, video_start_ts = self$video_start_ts)
    },
    bytes = function() {
      as.raw(c(0x94, 0xb0, 0x33, 0xde)) + pack("I", (if (is.null(self$video_start_ts)) 0 else 1)) + self$serializebytes(self$type) + pack("i", self$w) + pack("i", self$h) + pack("i", self$size) + if (!is.null(self$video_start_ts)) pack("d", self$video_start_ts) else raw(0)
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      type <- reader$tgread_string()
      w <- reader$read_int()
      h <- reader$read_int()
      size <- reader$read_int()
      if (flags & 1) {
        video_start_ts <- reader$read_double()
      } else {
        video_start_ts <- NULL
      }
      self$initialize(type = type, w = w, h = h, size = size, video_start_ts = video_start_ts)
    }
  ),
  class = TRUE
)

#  @title VideoSizeEmojiMarkup
#  @description Telegram API type VideoSizeEmojiMarkup
#  @export
#  @noRd
#  @noRd
VideoSizeEmojiMarkup <- R6::R6Class("VideoSizeEmojiMarkup",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf85c413c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x62f1d509,
    initialize = function(emoji_id, background_colors) {
      self$emoji_id <- emoji_id
      self$background_colors <- background_colors
    },
    to_dict = function() {
      list(`_` = "VideoSizeEmojiMarkup", emoji_id = self$emoji_id, background_colors = self$background_colors)
    },
    bytes = function() {
      as.raw(c(0x3c, 0x41, 0x5c, 0xf8)) + pack("q", self$emoji_id) + as.raw(c(0x15, 0xc4, 0xb5, 0x1c)) + pack("i", length(self$background_colors)) + do.call(c, lapply(self$background_colors, function(x) pack("i", x)))
    }
  ),
  private = list(
    from_reader = function(reader) {
      emoji_id <- reader$read_long()
      reader$read_int()
      background_colors <- lapply(seq_len(reader$read_int()), function(x) reader$read_int())
      self$initialize(emoji_id = emoji_id, background_colors = background_colors)
    }
  ),
  class = TRUE
)

#  @title VideoSizeStickerMarkup
#  @description Telegram API type VideoSizeStickerMarkup
#  @export
#  @noRd
#  @noRd
VideoSizeStickerMarkup <- R6::R6Class("VideoSizeStickerMarkup",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xda082fe,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x62f1d509,
    initialize = function(stickerset, sticker_id, background_colors) {
      self$stickerset <- stickerset
      self$sticker_id <- sticker_id
      self$background_colors <- background_colors
    },
    to_dict = function() {
      list(`_` = "VideoSizeStickerMarkup", stickerset = self$stickerset$to_dict(), sticker_id = self$sticker_id, background_colors = self$background_colors)
    },
    bytes = function() {
      as.raw(c(0xfe, 0x82, 0xa0, 0x0d)) + self$stickerset$bytes() + pack("q", self$sticker_id) + as.raw(c(0x15, 0xc4, 0xb5, 0x1c)) + pack("i", length(self$background_colors)) + do.call(c, lapply(self$background_colors, function(x) pack("i", x)))
    }
  ),
  private = list(
    from_reader = function(reader) {
      stickerset <- reader$tgread_object()
      sticker_id <- reader$read_long()
      reader$read_int()
      background_colors <- lapply(seq_len(reader$read_int()), function(x) reader$read_int())
      self$initialize(stickerset = stickerset, sticker_id = sticker_id, background_colors = background_colors)
    }
  ),
  class = TRUE
)

#  @title WallPaper
#  @description Telegram API type WallPaper
#  @export
#  @noRd
#  @noRd
WallPaper <- R6::R6Class("WallPaper",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa437c3ed,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x96a2c98b,
    initialize = function(id, access_hash, slug, document, creator = NULL, default = NULL, pattern = NULL, dark = NULL, settings = NULL) {
      self$id <- id
      self$access_hash <- access_hash
      self$slug <- slug
      self$document <- document
      self$creator <- creator
      self$default <- default
      self$pattern <- pattern
      self$dark <- dark
      self$settings <- settings
    },
    to_dict = function() {
      list(`_` = "WallPaper", id = self$id, access_hash = self$access_hash, slug = self$slug, document = self$document$to_dict(), creator = self$creator, default = self$default, pattern = self$pattern, dark = self$dark, settings = if (!is.null(self$settings)) self$settings$to_dict() else NULL)
    },
    bytes = function() {
      as.raw(c(0xed, 0xc3, 0x37, 0xa4)) + pack("q", self$id) + pack("I", (if (is.null(self$creator)) 0 else 1) | (if (is.null(self$default)) 0 else 2) | (if (is.null(self$pattern)) 0 else 8) | (if (is.null(self$dark)) 0 else 16) | (if (is.null(self$settings)) 0 else 4)) + pack("q", self$access_hash) + self$serializebytes(self$slug) + self$document$bytes() + if (!is.null(self$settings)) self$settings$bytes() else raw(0)
    }
  ),
  private = list(
    from_reader = function(reader) {
      id <- reader$read_long()
      flags <- reader$read_int()
      creator <- (flags & 1) != 0
      default <- (flags & 2) != 0
      pattern <- (flags & 8) != 0
      dark <- (flags & 16) != 0
      access_hash <- reader$read_long()
      slug <- reader$tgread_string()
      document <- reader$tgread_object()
      if (flags & 4) {
        settings <- reader$tgread_object()
      } else {
        settings <- NULL
      }
      self$initialize(id = id, access_hash = access_hash, slug = slug, document = document, creator = creator, default = default, pattern = pattern, dark = dark, settings = settings)
    }
  ),
  class = TRUE
)

#  @title WallPaperNoFile
#  @description Telegram API type WallPaperNoFile
#  @export
#  @noRd
#  @noRd
WallPaperNoFile <- R6::R6Class("WallPaperNoFile",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe0804116,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x96a2c98b,
    initialize = function(id, default = NULL, dark = NULL, settings = NULL) {
      self$id <- id
      self$default <- default
      self$dark <- dark
      self$settings <- settings
    },
    to_dict = function() {
      list(`_` = "WallPaperNoFile", id = self$id, default = self$default, dark = self$dark, settings = if (!is.null(self$settings)) self$settings$to_dict() else NULL)
    },
    bytes = function() {
      as.raw(c(0x16, 0x41, 0x80, 0xe0)) + pack("q", self$id) + pack("I", (if (is.null(self$default)) 0 else 2) | (if (is.null(self$dark)) 0 else 16) | (if (is.null(self$settings)) 0 else 4)) + if (!is.null(self$settings)) self$settings$bytes() else raw(0)
    }
  ),
  private = list(
    from_reader = function(reader) {
      id <- reader$read_long()
      flags <- reader$read_int()
      default <- (flags & 2) != 0
      dark <- (flags & 16) != 0
      if (flags & 4) {
        settings <- reader$tgread_object()
      } else {
        settings <- NULL
      }
      self$initialize(id = id, default = default, dark = dark, settings = settings)
    }
  ),
  class = TRUE
)

#  @title WallPaperSettings
#  @description Telegram API type WallPaperSettings
#  @export
#  @noRd
#  @noRd
WallPaperSettings <- R6::R6Class("WallPaperSettings",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x372efcd0,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x4175e312,
    initialize = function(blur = NULL, motion = NULL, background_color = NULL, second_background_color = NULL, third_background_color = NULL, fourth_background_color = NULL, intensity = NULL, rotation = NULL, emoticon = NULL) {
      self$blur <- blur
      self$motion <- motion
      self$background_color <- background_color
      self$second_background_color <- second_background_color
      self$third_background_color <- third_background_color
      self$fourth_background_color <- fourth_background_color
      self$intensity <- intensity
      self$rotation <- rotation
      self$emoticon <- emoticon
    },
    to_dict = function() {
      list(`_` = "WallPaperSettings", blur = self$blur, motion = self$motion, background_color = self$background_color, second_background_color = self$second_background_color, third_background_color = self$third_background_color, fourth_background_color = self$fourth_background_color, intensity = self$intensity, rotation = self$rotation, emoticon = self$emoticon)
    },
    bytes = function() {
      as.raw(c(0xd0, 0xfc, 0x2e, 0x37)) + pack("I", (if (is.null(self$blur)) 0 else 2) | (if (is.null(self$motion)) 0 else 4) | (if (is.null(self$background_color)) 0 else 1) | (if (is.null(self$second_background_color)) 0 else 16) | (if (is.null(self$third_background_color)) 0 else 32) | (if (is.null(self$fourth_background_color)) 0 else 64) | (if (is.null(self$intensity)) 0 else 8) | (if (is.null(self$rotation)) 0 else 16) | (if (is.null(self$emoticon)) 0 else 128)) + if (!is.null(self$background_color)) pack("i", self$background_color) else raw(0) + if (!is.null(self$second_background_color)) pack("i", self$second_background_color) else raw(0) + if (!is.null(self$third_background_color)) pack("i", self$third_background_color) else raw(0) + if (!is.null(self$fourth_background_color)) pack("i", self$fourth_background_color) else raw(0) + if (!is.null(self$intensity)) pack("i", self$intensity) else raw(0) + if (!is.null(self$rotation)) pack("i", self$rotation) else raw(0) + if (!is.null(self$emoticon)) self$serializebytes(self$emoticon) else raw(0)
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      blur <- (flags & 2) != 0
      motion <- (flags & 4) != 0
      if (flags & 1) {
        background_color <- reader$read_int()
      } else {
        background_color <- NULL
      }
      if (flags & 16) {
        second_background_color <- reader$read_int()
      } else {
        second_background_color <- NULL
      }
      if (flags & 32) {
        third_background_color <- reader$read_int()
      } else {
        third_background_color <- NULL
      }
      if (flags & 64) {
        fourth_background_color <- reader$read_int()
      } else {
        fourth_background_color <- NULL
      }
      if (flags & 8) {
        intensity <- reader$read_int()
      } else {
        intensity <- NULL
      }
      if (flags & 16) {
        rotation <- reader$read_int()
      } else {
        rotation <- NULL
      }
      if (flags & 128) {
        emoticon <- reader$tgread_string()
      } else {
        emoticon <- NULL
      }
      self$initialize(blur = blur, motion = motion, background_color = background_color, second_background_color = second_background_color, third_background_color = third_background_color, fourth_background_color = fourth_background_color, intensity = intensity, rotation = rotation, emoticon = emoticon)
    }
  ),
  class = TRUE
)

#  @title WebAuthorization
#  @description Telegram API type WebAuthorization
#  @export
#  @noRd
#  @noRd
WebAuthorization <- R6::R6Class("WebAuthorization",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xa6f8f452,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x3764d30,
    initialize = function(hash, bot_id, domain, browser, platform, date_created = NULL, date_active = NULL, ip, region) {
      self$hash <- hash
      self$bot_id <- bot_id
      self$domain <- domain
      self$browser <- browser
      self$platform <- platform
      self$date_created <- date_created
      self$date_active <- date_active
      self$ip <- ip
      self$region <- region
    },
    to_dict = function() {
      list(
        "_" = "WebAuthorization",
        hash = self$hash,
        bot_id = self$bot_id,
        domain = self$domain,
        browser = self$browser,
        platform = self$platform,
        date_created = self$date_created,
        date_active = self$date_active,
        ip = self$ip,
        region = self$region
      )
    },
    bytes = function() {
      as.raw(c(0x52, 0xf4, 0xf8, 0xa6)) + pack("q", self$hash) + pack("q", self$bot_id) + self$serializebytes(self$domain) + self$serializebytes(self$browser) + self$serializebytes(self$platform) + self$serialize_datetime(self$date_created) + self$serialize_datetime(self$date_active) + self$serializebytes(self$ip) + self$serializebytes(self$region)
    }
  ),
  private = list(
    from_reader = function(reader) {
      hash <- reader$read_long()
      bot_id <- reader$read_long()
      domain <- reader$tgread_string()
      browser <- reader$tgread_string()
      platform <- reader$tgread_string()
      date_created <- reader$tgread_date()
      date_active <- reader$tgread_date()
      ip <- reader$tgread_string()
      region <- reader$tgread_string()
      return(self$new(hash = hash, bot_id = bot_id, domain = domain, browser = browser, platform = platform, date_created = date_created, date_active = date_active, ip = ip, region = region))
    }
  ),
  class = TRUE
)

#  @title WebDocument
#  @description Telegram API type WebDocument
#  @export
#  @noRd
#  @noRd
WebDocument <- R6::R6Class("WebDocument",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x1c570ed1,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x3b642814,
    initialize = function(url, access_hash, size, mime_type, attributes) {
      self$url <- url
      self$access_hash <- access_hash
      self$size <- size
      self$mime_type <- mime_type
      self$attributes <- attributes
    },
    to_dict = function() {
      list(
        "_" = "WebDocument",
        url = self$url,
        access_hash = self$access_hash,
        size = self$size,
        mime_type = self$mime_type,
        attributes = lapply(self$attributes, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      )
    },
    bytes = function() {
      as.raw(c(0xd1, 0x0e, 0x57, 0x1c)) + self$serializebytes(self$url) + pack("q", self$access_hash) + pack("i", self$size) + self$serializebytes(self$mime_type) + as.raw(c(0x15, 0xc4, 0xb5, 0x1c)) + pack("i", length(self$attributes)) + do.call(c, lapply(self$attributes, function(x) x$bytes()))
    }
  ),
  private = list(
    from_reader = function(reader) {
      url <- reader$tgread_string()
      access_hash <- reader$read_long()
      size <- reader$read_int()
      mime_type <- reader$tgread_string()
      reader$read_int()
      attributes <- lapply(seq_len(reader$read_int()), function(x) reader$tgread_object())
      return(self$new(url = url, access_hash = access_hash, size = size, mime_type = mime_type, attributes = attributes))
    }
  ),
  class = TRUE
)

#  @title WebDocumentNoProxy
#  @description Telegram API type WebDocumentNoProxy
#  @export
#  @noRd
#  @noRd
WebDocumentNoProxy <- R6::R6Class("WebDocumentNoProxy",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xf9c8bcc6,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x3b642814,
    initialize = function(url, size, mime_type, attributes) {
      self$url <- url
      self$size <- size
      self$mime_type <- mime_type
      self$attributes <- attributes
    },
    to_dict = function() {
      list(
        "_" = "WebDocumentNoProxy",
        url = self$url,
        size = self$size,
        mime_type = self$mime_type,
        attributes = lapply(self$attributes, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      )
    },
    bytes = function() {
      as.raw(c(0xc6, 0xbc, 0xc8, 0xf9)) + self$serializebytes(self$url) + pack("i", self$size) + self$serializebytes(self$mime_type) + as.raw(c(0x15, 0xc4, 0xb5, 0x1c)) + pack("i", length(self$attributes)) + do.call(c, lapply(self$attributes, function(x) x$bytes()))
    }
  ),
  private = list(
    from_reader = function(reader) {
      url <- reader$tgread_string()
      size <- reader$read_int()
      mime_type <- reader$tgread_string()
      reader$read_int()
      attributes <- lapply(seq_len(reader$read_int()), function(x) reader$tgread_object())
      return(self$new(url = url, size = size, mime_type = mime_type, attributes = attributes))
    }
  ),
  class = TRUE
)

#  @title WebPage
#  @description Telegram API type WebPage
#  @export
#  @noRd
#  @noRd
WebPage <- R6::R6Class("WebPage",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xe89c45b2,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x55a97481,
    initialize = function(id, url, display_url, hash, has_large_media = NULL, video_cover_photo = NULL, type = NULL, site_name = NULL, title = NULL, description = NULL, photo = NULL, embed_url = NULL, embed_type = NULL, embed_width = NULL, embed_height = NULL, duration = NULL, author = NULL, document = NULL, cached_page = NULL, attributes = NULL) {
      self$id <- id
      self$url <- url
      self$display_url <- display_url
      self$hash <- hash
      self$has_large_media <- has_large_media
      self$video_cover_photo <- video_cover_photo
      self$type <- type
      self$site_name <- site_name
      self$title <- title
      self$description <- description
      self$photo <- photo
      self$embed_url <- embed_url
      self$embed_type <- embed_type
      self$embed_width <- embed_width
      self$embed_height <- embed_height
      self$duration <- duration
      self$author <- author
      self$document <- document
      self$cached_page <- cached_page
      self$attributes <- attributes
    },
    to_dict = function() {
      list(
        `_` = "WebPage",
        id = self$id,
        url = self$url,
        display_url = self$display_url,
        hash = self$hash,
        has_large_media = self$has_large_media,
        video_cover_photo = self$video_cover_photo,
        type = self$type,
        site_name = self$site_name,
        title = self$title,
        description = self$description,
        photo = if (!is.null(self$photo) && inherits(self$photo, "TLObject")) self$photo$to_dict() else self$photo,
        embed_url = self$embed_url,
        embed_type = self$embed_type,
        embed_width = self$embed_width,
        embed_height = self$embed_height,
        duration = self$duration,
        author = self$author,
        document = if (!is.null(self$document) && inherits(self$document, "TLObject")) self$document$to_dict() else self$document,
        cached_page = if (!is.null(self$cached_page) && inherits(self$cached_page, "TLObject")) self$cached_page$to_dict() else self$cached_page,
        attributes = if (is.null(self$attributes)) list() else lapply(self$attributes, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      )
    },
    bytes = function() {
      stopifnot(((is.null(self$embed_url) || self$embed_url == "") && (is.null(self$embed_type) || self$embed_type == "")) || ((!is.null(self$embed_url) && self$embed_url != "") && (!is.null(self$embed_type) && self$embed_type != "")), "embed_url, embed_type parameters must all be False-y (like NULL or empty) or all be True-y")
      stopifnot(((is.null(self$embed_width) || self$embed_width == 0) && (is.null(self$embed_height) || self$embed_height == 0)) || ((!is.null(self$embed_width) && self$embed_width != 0) && (!is.null(self$embed_height) && self$embed_height != 0)), "embed_width, embed_height parameters must all be False-y (like NULL or 0) or all be True-y")
      as.raw(c(0xe8, 0x9c, 0x45, 0xb2)) +
        pack("I", (if (is.null(self$has_large_media)) 0 else 8192) | (if (is.null(self$video_cover_photo)) 0 else 16384) | (if (is.null(self$type)) 0 else 1) | (if (is.null(self$site_name)) 0 else 2) | (if (is.null(self$title)) 0 else 4) | (if (is.null(self$description)) 0 else 8) | (if (is.null(self$photo)) 0 else 16) | (if (is.null(self$embed_url)) 0 else 32) | (if (is.null(self$embed_type)) 0 else 32) | (if (is.null(self$embed_width)) 0 else 64) | (if (is.null(self$embed_height)) 0 else 64) | (if (is.null(self$duration)) 0 else 128) | (if (is.null(self$author)) 0 else 256) | (if (is.null(self$document)) 0 else 512) | (if (is.null(self$cached_page)) 0 else 1024) | (if (is.null(self$attributes)) 0 else 4096)) +
        pack("q", self$id) +
        self$serializebytes(self$url) +
        self$serializebytes(self$display_url) +
        pack("i", self$hash) +
        if (!is.null(self$type)) {
          self$serializebytes(self$type)
        } else {
          raw(0) +
            if (!is.null(self$site_name)) {
              self$serializebytes(self$site_name)
            } else {
              raw(0) +
                if (!is.null(self$title)) {
                  self$serializebytes(self$title)
                } else {
                  raw(0) +
                    if (!is.null(self$description)) {
                      self$serializebytes(self$description)
                    } else {
                      raw(0) +
                        if (!is.null(self$photo)) {
                          self$photo$bytes()
                        } else {
                          raw(0) +
                            if (!is.null(self$embed_url)) {
                              self$serializebytes(self$embed_url)
                            } else {
                              raw(0) +
                                if (!is.null(self$embed_type)) {
                                  self$serializebytes(self$embed_type)
                                } else {
                                  raw(0) +
                                    if (!is.null(self$embed_width)) {
                                      pack("i", self$embed_width)
                                    } else {
                                      raw(0) +
                                        if (!is.null(self$embed_height)) {
                                          pack("i", self$embed_height)
                                        } else {
                                          raw(0) +
                                            if (!is.null(self$duration)) {
                                              pack("i", self$duration)
                                            } else {
                                              raw(0) +
                                                if (!is.null(self$author)) {
                                                  self$serializebytes(self$author)
                                                } else {
                                                  raw(0) +
                                                    if (!is.null(self$document)) {
                                                      self$document$bytes()
                                                    } else {
                                                      raw(0) +
                                                        if (!is.null(self$cached_page)) {
                                                          self$cached_page$bytes()
                                                        } else {
                                                          raw(0) +
                                                            if (!is.null(self$attributes)) (as.raw(c(0x15, 0xc4, 0xb5, 0x1c)) + pack("i", length(self$attributes)) + do.call(c, lapply(self$attributes, function(x) x$bytes()))) else raw(0)
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      has_large_media <- (flags & 8192) != 0
      video_cover_photo <- (flags & 16384) != 0
      id <- reader$read_long()
      url <- reader$tgread_string()
      display_url <- reader$tgread_string()
      hash <- reader$read_int()
      type <- if ((flags & 1) != 0) reader$tgread_string() else NULL
      site_name <- if ((flags & 2) != 0) reader$tgread_string() else NULL
      title <- if ((flags & 4) != 0) reader$tgread_string() else NULL
      description <- if ((flags & 8) != 0) reader$tgread_string() else NULL
      photo <- if ((flags & 16) != 0) reader$tgread_object() else NULL
      embed_url <- if ((flags & 32) != 0) reader$tgread_string() else NULL
      embed_type <- if ((flags & 32) != 0) reader$tgread_string() else NULL
      embed_width <- if ((flags & 64) != 0) reader$read_int() else NULL
      embed_height <- if ((flags & 64) != 0) reader$read_int() else NULL
      duration <- if ((flags & 128) != 0) reader$read_int() else NULL
      author <- if ((flags & 256) != 0) reader$tgread_string() else NULL
      document <- if ((flags & 512) != 0) reader$tgread_object() else NULL
      cached_page <- if ((flags & 1024) != 0) reader$tgread_object() else NULL
      attributes <- if ((flags & 4096) != 0) {
        reader$read_int()
        lapply(seq_len(reader$read_int()), function(x) reader$tgread_object())
      } else {
        NULL
      }
      self$initialize(id = id, url = url, display_url = display_url, hash = hash, has_large_media = has_large_media, video_cover_photo = video_cover_photo, type = type, site_name = site_name, title = title, description = description, photo = photo, embed_url = embed_url, embed_type = embed_type, embed_width = embed_width, embed_height = embed_height, duration = duration, author = author, document = document, cached_page = cached_page, attributes = attributes)
    }
  ),
  class = TRUE
)

#  @title WebPageAttributeStarGiftCollection
#  @description Telegram API type WebPageAttributeStarGiftCollection
#  @export
#  @noRd
#  @noRd
WebPageAttributeStarGiftCollection <- R6::R6Class("WebPageAttributeStarGiftCollection",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x31cad303,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xafcfe9c7,
    initialize = function(icons) {
      self$icons <- icons
    },
    to_dict = function() {
      list(
        `_` = "WebPageAttributeStarGiftCollection",
        icons = if (is.null(self$icons)) list() else lapply(self$icons, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      )
    },
    bytes = function() {
      as.raw(c(0x31, 0xca, 0xd3, 0x03)) +
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)) + pack("i", length(self$icons)) + do.call(c, lapply(self$icons, function(x) x$bytes()))
    }
  ),
  private = list(
    from_reader = function(reader) {
      reader$read_int()
      icons <- lapply(seq_len(reader$read_int()), function(x) reader$tgread_object())
      self$initialize(icons = icons)
    }
  ),
  class = TRUE
)

#  @title WebPageAttributeStickerSet
#  @description Telegram API type WebPageAttributeStickerSet
#  @export
#  @noRd
#  @noRd
WebPageAttributeStickerSet <- R6::R6Class("WebPageAttributeStickerSet",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x50cc03d3,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xafcfe9c7,
    initialize = function(stickers, emojis = NULL, text_color = NULL) {
      self$stickers <- stickers
      self$emojis <- emojis
      self$text_color <- text_color
    },
    to_dict = function() {
      list(
        `_` = "WebPageAttributeStickerSet",
        stickers = if (is.null(self$stickers)) list() else lapply(self$stickers, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        emojis = self$emojis,
        text_color = self$text_color
      )
    },
    bytes = function() {
      as.raw(c(0x50, 0xcc, 0x03, 0xd3)) +
        pack("I", (if (is.null(self$emojis)) 0 else 1) | (if (is.null(self$text_color)) 0 else 2)) +
        as.raw(c(0x15, 0xc4, 0xb5, 0x1c)) + pack("i", length(self$stickers)) + do.call(c, lapply(self$stickers, function(x) x$bytes()))
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      emojis <- (flags & 1) != 0
      text_color <- (flags & 2) != 0
      reader$read_int()
      stickers <- lapply(seq_len(reader$read_int()), function(x) reader$tgread_object())
      self$initialize(stickers = stickers, emojis = emojis, text_color = text_color)
    }
  ),
  class = TRUE
)

#  @title WebPageAttributeStory
#  @description Telegram API type WebPageAttributeStory
#  @export
#  @noRd
#  @noRd
WebPageAttributeStory <- R6::R6Class("WebPageAttributeStory",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x2e94c3e7,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xafcfe9c7,
    initialize = function(peer, id, story = NULL) {
      self$peer <- peer
      self$id <- id
      self$story <- story
    },
    to_dict = function() {
      list(
        `_` = "WebPageAttributeStory",
        peer = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        id = self$id,
        story = if (inherits(self$story, "TLObject")) self$story$to_dict() else self$story
      )
    },
    bytes = function() {
      as.raw(c(0x2e, 0x94, 0xc3, 0xe7)) +
        pack("I", if (is.null(self$story)) 0 else 1) +
        self$peer$bytes() +
        pack("i", self$id) +
        if (is.null(self$story)) raw(0) else self$story$bytes()
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      peer <- reader$tgread_object()
      id <- reader$read_int()
      story <- if (bitwAnd(flags, 1)) reader$tgread_object() else NULL
      self$initialize(peer = peer, id = id, story = story)
    }
  ),
  class = TRUE
)

#  @title WebPageAttributeTheme
#  @description Telegram API type WebPageAttributeTheme
#  @export
#  @noRd
#  @noRd
WebPageAttributeTheme <- R6::R6Class("WebPageAttributeTheme",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x54b56617,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xafcfe9c7,
    initialize = function(documents = NULL, settings = NULL) {
      self$documents <- documents
      self$settings <- settings
    },
    to_dict = function() {
      list(
        `_` = "WebPageAttributeTheme",
        documents = if (is.null(self$documents)) list() else lapply(self$documents, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        settings = if (inherits(self$settings, "TLObject")) self$settings$to_dict() else self$settings
      )
    },
    bytes = function() {
      flags <- (if (is.null(self$documents)) 0 else 1) | (if (is.null(self$settings)) 0 else 2)
      as.raw(c(0x54, 0xb5, 0x66, 0x17)) +
        pack("I", flags) +
        if (is.null(self$documents)) {
          raw(0)
        } else {
          (as.raw(c(0x15, 0xc4, 0xb5, 0x1c)) + pack("i", length(self$documents)) + do.call(c, lapply(self$documents, function(x) x$bytes()))) +
            if (is.null(self$settings)) raw(0) else self$settings$bytes()
        }
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      documents <- if (bitwAnd(flags, 1)) {
        reader$read_int()
        lapply(seq_len(reader$read_int()), function(x) reader$tgread_object())
      } else {
        NULL
      }
      settings <- if (bitwAnd(flags, 2)) reader$tgread_object() else NULL
      self$initialize(documents = documents, settings = settings)
    }
  ),
  class = TRUE
)

#  @title WebPageAttributeUniqueStarGift
#  @description Telegram API type WebPageAttributeUniqueStarGift
#  @export
#  @noRd
#  @noRd
WebPageAttributeUniqueStarGift <- R6::R6Class("WebPageAttributeUniqueStarGift",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xcf6f6db8,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0xafcfe9c7,
    initialize = function(gift) {
      self$gift <- gift
    },
    to_dict = function() {
      list(
        `_` = "WebPageAttributeUniqueStarGift",
        gift = if (inherits(self$gift, "TLObject")) self$gift$to_dict() else self$gift
      )
    },
    bytes = function() {
      as.raw(c(0xcf, 0x6f, 0x6d, 0xb8)) + self$gift$bytes()
    }
  ),
  private = list(
    from_reader = function(reader) {
      gift <- reader$tgread_object()
      self$initialize(gift = gift)
    }
  ),
  class = TRUE
)

#  @title WebPageEmpty
#  @description Telegram API type WebPageEmpty
#  @export
#  @noRd
#  @noRd
WebPageEmpty <- R6::R6Class("WebPageEmpty",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x211a1788,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x55a97481,
    initialize = function(id, url = NULL) {
      self$id <- id
      self$url <- url
    },
    to_dict = function() {
      list(
        `_` = "WebPageEmpty",
        id = self$id,
        url = self$url
      )
    },
    bytes = function() {
      as.raw(c(0x21, 0x1a, 0x17, 0x88)) +
        pack("I", if (is.null(self$url)) 0 else 1) +
        pack("q", self$id) +
        if (is.null(self$url)) raw(0) else self$serializebytes(self$url)
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      id <- reader$read_long()
      url <- if (bitwAnd(flags, 1)) reader$tgread_string() else NULL
      self$initialize(id = id, url = url)
    }
  ),
  class = TRUE
)

#  @title WebPageNotModified
#  @description Telegram API type WebPageNotModified
#  @export
#  @noRd
#  @noRd
WebPageNotModified <- R6::R6Class("WebPageNotModified",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7311ca11,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x55a97481,
    initialize = function(cached_page_views = NULL) {
      self$cached_page_views <- cached_page_views
    },
    to_dict = function() {
      list(
        `_` = "WebPageNotModified",
        cached_page_views = self$cached_page_views
      )
    },
    bytes = function() {
      as.raw(c(0x73, 0x11, 0xca, 0x11)) +
        pack("I", if (is.null(self$cached_page_views)) 0 else 1) +
        if (is.null(self$cached_page_views)) raw(0) else pack("i", self$cached_page_views)
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      cached_page_views <- if (bitwAnd(flags, 1)) reader$read_int() else NULL
      self$initialize(cached_page_views = cached_page_views)
    }
  ),
  class = TRUE
)

#  @title WebPagePending
#  @description Telegram API type WebPagePending
#  @export
#  @noRd
#  @noRd
WebPagePending <- R6::R6Class("WebPagePending",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xb0d13e47,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x55a97481,
    initialize = function(id, date, url = NULL) {
      self$id <- id
      self$date <- date
      self$url <- url
    },
    to_dict = function() {
      list(
        `_` = "WebPagePending",
        id = self$id,
        date = self$date,
        url = self$url
      )
    },
    bytes = function() {
      as.raw(c(0xb0, 0xd1, 0x3e, 0x47)) +
        pack("I", if (is.null(self$url)) 0 else 1) +
        pack("q", self$id) +
        if (is.null(self$url)) {
          raw(0)
        } else {
          self$serializebytes(self$url) +
            self$serialize_datetime(self$date)
        }
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      id <- reader$read_long()
      url <- if (bitwAnd(flags, 1)) reader$tgread_string() else NULL
      date <- reader$tgread_date()
      self$initialize(id = id, date = date, url = url)
    }
  ),
  class = TRUE
)

#  @title WebViewMessageSent
#  @description Telegram API type WebViewMessageSent
#  @export
#  @noRd
#  @noRd
WebViewMessageSent <- R6::R6Class("WebViewMessageSent",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0xc94511c,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x75e49312,
    initialize = function(msg_id = NULL) {
      self$msg_id <- msg_id
    },
    to_dict = function() {
      list(
        `_` = "WebViewMessageSent",
        msg_id = if (inherits(self$msg_id, "TLObject")) self$msg_id$to_dict() else self$msg_id
      )
    },
    bytes = function() {
      as.raw(c(0x0c, 0x94, 0x51, 0x0c)) +
        pack("I", if (is.null(self$msg_id)) 0 else 1) +
        if (is.null(self$msg_id)) raw(0) else self$msg_id$bytes()
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      msg_id <- if (bitwAnd(flags, 1)) reader$tgread_object() else NULL
      self$initialize(msg_id = msg_id)
    }
  ),
  class = TRUE
)

#  @title WebViewResultUrl
#  @description Telegram API type WebViewResultUrl
#  @export
#  @noRd
#  @noRd
WebViewResultUrl <- R6::R6Class("WebViewResultUrl",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x4d22ff98,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x93cea746,
    initialize = function(url, fullsize = NULL, fullscreen = NULL, query_id = NULL) {
      self$url <- url
      self$fullsize <- fullsize
      self$fullscreen <- fullscreen
      self$query_id <- query_id
    },
    to_dict = function() {
      list(
        `_` = "WebViewResultUrl",
        url = self$url,
        fullsize = self$fullsize,
        fullscreen = self$fullscreen,
        query_id = self$query_id
      )
    },
    bytes = function() {
      flags <- (if (is.null(self$fullsize) || !self$fullsize) 0 else 2) |
        (if (is.null(self$fullscreen) || !self$fullscreen) 0 else 4) |
        (if (is.null(self$query_id)) 0 else 1)
      as.raw(c(0x4d, 0x22, 0xff, 0x98)) +
        pack("I", flags) +
        if (is.null(self$query_id)) {
          raw(0)
        } else {
          pack("q", self$query_id) +
            self$serializebytes(self$url)
        }
    }
  ),
  private = list(
    from_reader = function(reader) {
      flags <- reader$read_int()
      fullsize <- bitwAnd(flags, 2) != 0
      fullscreen <- bitwAnd(flags, 4) != 0
      query_id <- if (bitwAnd(flags, 1)) reader$read_long() else NULL
      url <- reader$tgread_string()
      self$initialize(url = url, fullsize = fullsize, fullscreen = fullscreen, query_id = query_id)
    }
  ),
  class = TRUE
)

#  @title ContactsResolvedPeer
#  @description Telegram API type contacts.ResolvedPeer (response to ResolveUsernameRequest).
#  Fields: peer (Peer), users (Vector<User>), chats (Vector<Chat>).
#  @export
#  @noRd
#  @noRd
ContactsResolvedPeer <- R6::R6Class("ContactsResolvedPeer",
  inherit = TLObject,
  public = list(
    #  @field CONSTRUCTOR_ID Constructor identifier for this TL object.
    CONSTRUCTOR_ID = 0x7f077ad9,
    #  @field SUBCLASS_OF_ID Subclass identifier for this TL object.
    SUBCLASS_OF_ID = 0x0,
    #  @field peer The resolved peer (Peer).
    peer = NULL,
    #  @field users Vector of users returned by the resolution.
    users = NULL,
    #  @field chats Vector of chats returned by the resolution.
    chats = NULL,
    initialize = function(peer = NULL, users = NULL, chats = NULL) {
      self$peer  <- peer
      self$users <- if (is.null(users)) list() else users
      self$chats <- if (is.null(chats)) list() else chats
    },
    to_dict = function() {
      list(
        `_`    = "ContactsResolvedPeer",
        peer   = if (inherits(self$peer, "TLObject")) self$peer$to_dict() else self$peer,
        users  = lapply(self$users, function(x) if (inherits(x, "TLObject")) x$to_dict() else x),
        chats  = lapply(self$chats, function(x) if (inherits(x, "TLObject")) x$to_dict() else x)
      )
    },
    bytes = function() {
      raw(0) # read-only type; serialization not needed
    }
  ),
  private = list(
    from_reader = function(reader) {
      peer  <- reader$tgread_object()
      # read Vector<User>
      reader$read_int() # skip vector constructor id (0x1cb5c415)
      n_users <- reader$read_int()
      users <- lapply(seq_len(n_users), function(i) reader$tgread_object())
      # read Vector<Chat>
      reader$read_int() # skip vector constructor id
      n_chats <- reader$read_int()
      chats <- lapply(seq_len(n_chats), function(i) reader$tgread_object())
      self$initialize(peer = peer, users = users, chats = chats)
    }
  ),
  class = TRUE
)

TypeAccessPointRule <- AccessPointRule
TypeAccountDaysTTL <- AccountDaysTTL
TypeAttachMenuBot <- AttachMenuBot
TypeAttachMenuBotIcon <- AttachMenuBotIcon
TypeAttachMenuBotIconColor <- AttachMenuBotIconColor
TypeAttachMenuBots <- list(AttachMenuBotsNotModified, AttachMenuBots)
TypeAttachMenuPeerType <- list(AttachMenuPeerTypeSameBotPM, AttachMenuPeerTypeBotPM, AttachMenuPeerTypePM, AttachMenuPeerTypeChat, AttachMenuPeerTypeBroadcast)
TypeAuthorization <- Authorization
TypeAutoDownloadSettings <- AutoDownloadSettings
TypeAutoSaveException <- AutoSaveException
TypeAutoSaveSettings <- AutoSaveSettings
TypeAvailableEffect <- AvailableEffect
TypeAvailableReaction <- AvailableReaction
TypeBadMsgNotification <- list(BadMsgNotification, BadServerSalt)
TypeBankCardOpenUrl <- BankCardOpenUrl
TypeBaseTheme <- list(BaseThemeClassic, BaseThemeDay, BaseThemeNight, BaseThemeTinted, BaseThemeArctic)
TypeBindAuthKeyInner <- BindAuthKeyInner
TypeBirthday <- Birthday
TypeBoost <- Boost
TypeBotApp <- list(BotAppNotModified, BotApp)
TypeBotAppSettings <- BotAppSettings
TypeBotBusinessConnection <- BotBusinessConnection
TypeBotCommand <- BotCommand
TypeBotCommandScope <- list(BotCommandScopeDefault, BotCommandScopeUsers, BotCommandScopeChats, BotCommandScopeChatAdmins, BotCommandScopePeer, BotCommandScopePeerAdmins, BotCommandScopePeerUser)
TypeBotInfo <- BotInfo
TypeBotInlineResult <- list(BotInlineResult, BotInlineMediaResult)
TypeBotInlineMessage <- list(BotInlineMessageMediaAuto, BotInlineMessageText, BotInlineMessageMediaGeo, BotInlineMessageMediaVenue, BotInlineMessageMediaContact, BotInlineMessageMediaInvoice, BotInlineMessageMediaWebPage)
TypeBotMenuButton <- list(BotMenuButtonDefault, BotMenuButtonCommands, BotMenuButton)
TypeBotPreviewMedia <- BotPreviewMedia
TypeBotVerification <- BotVerification
TypeBotVerifierSettings <- BotVerifierSettings
TypeBusinessAwayMessage <- BusinessAwayMessage
TypeBusinessAwayMessageSchedule <- list(BusinessAwayMessageScheduleAlways, BusinessAwayMessageScheduleOutsideWorkHours, BusinessAwayMessageScheduleCustom)
TypeBusinessBotRecipients <- BusinessBotRecipients
TypeBusinessBotRights <- BusinessBotRights
TypeBusinessChatLink <- BusinessChatLink
TypeBusinessGreetingMessage <- BusinessGreetingMessage
TypeBusinessIntro <- BusinessIntro
TypeBusinessLocation <- BusinessLocation
TypeBusinessRecipients <- BusinessRecipients
TypeBusinessWeeklyOpen <- BusinessWeeklyOpen
TypeBusinessWorkHours <- BusinessWorkHours
TypeCdnConfig <- CdnConfig
TypeCdnPublicKey <- CdnPublicKey
TypeChannelAdminLogEvent <- ChannelAdminLogEvent
TypeChannelAdminLogEventAction <- list(ChannelAdminLogEventActionChangeTitle, ChannelAdminLogEventActionChangeAbout, ChannelAdminLogEventActionChangeUsername, ChannelAdminLogEventActionChangePhoto, ChannelAdminLogEventActionToggleInvites, ChannelAdminLogEventActionToggleSignatures, ChannelAdminLogEventActionUpdatePinned, ChannelAdminLogEventActionEditMessage, ChannelAdminLogEventActionDeleteMessage, ChannelAdminLogEventActionParticipantJoin, ChannelAdminLogEventActionParticipantLeave, ChannelAdminLogEventActionParticipantInvite, ChannelAdminLogEventActionParticipantToggleBan, ChannelAdminLogEventActionParticipantToggleAdmin, ChannelAdminLogEventActionChangeStickerSet, ChannelAdminLogEventActionTogglePreHistoryHidden, ChannelAdminLogEventActionDefaultBannedRights, ChannelAdminLogEventActionStopPoll, ChannelAdminLogEventActionChangeLinkedChat, ChannelAdminLogEventActionChangeLocation, ChannelAdminLogEventActionToggleSlowMode, ChannelAdminLogEventActionStartGroupCall, ChannelAdminLogEventActionDiscardGroupCall, ChannelAdminLogEventActionParticipantMute, ChannelAdminLogEventActionParticipantUnmute, ChannelAdminLogEventActionToggleGroupCallSetting, ChannelAdminLogEventActionParticipantJoinByInvite, ChannelAdminLogEventActionExportedInviteDelete, ChannelAdminLogEventActionExportedInviteRevoke, ChannelAdminLogEventActionExportedInviteEdit, ChannelAdminLogEventActionParticipantVolume, ChannelAdminLogEventActionChangeHistoryTTL, ChannelAdminLogEventActionParticipantJoinByRequest, ChannelAdminLogEventActionToggleNoForwards, ChannelAdminLogEventActionSendMessage, ChannelAdminLogEventActionChangeAvailableReactions, ChannelAdminLogEventActionChangeUsernames, ChannelAdminLogEventActionToggleForum, ChannelAdminLogEventActionCreateTopic, ChannelAdminLogEventActionEditTopic, ChannelAdminLogEventActionDeleteTopic, ChannelAdminLogEventActionPinTopic, ChannelAdminLogEventActionToggleAntiSpam, ChannelAdminLogEventActionChangePeerColor, ChannelAdminLogEventActionChangeProfilePeerColor, ChannelAdminLogEventActionChangeWallpaper, ChannelAdminLogEventActionChangeEmojiStatus, ChannelAdminLogEventActionChangeEmojiStickerSet, ChannelAdminLogEventActionToggleSignatureProfiles, ChannelAdminLogEventActionParticipantSubExtend, ChannelAdminLogEventActionToggleAutotranslation)
TypeChannelAdminLogEventsFilter <- ChannelAdminLogEventsFilter
TypeChatFull <- list(ChatFull, ChannelFull)
TypeChannelLocation <- list(ChannelLocationEmpty, ChannelLocation)
TypeChannelMessagesFilter <- list(ChannelMessagesFilterEmpty, ChannelMessagesFilter)
TypeChannelParticipant <- list(ChannelParticipant, ChannelParticipantSelf, ChannelParticipantCreator, ChannelParticipantAdmin, ChannelParticipantBanned, ChannelParticipantLeft)
TypeChannelParticipantsFilter <- list(ChannelParticipantsRecent, ChannelParticipantsAdmins, ChannelParticipantsKicked, ChannelParticipantsBots, ChannelParticipantsBanned, ChannelParticipantsSearch, ChannelParticipantsContacts, ChannelParticipantsMentions)
TypeChatAdminRights <- ChatAdminRights
TypeChatAdminWithInvites <- ChatAdminWithInvites
TypeChatBannedRights <- ChatBannedRights
TypeChatInvite <- list(ChatInviteAlready, ChatInvite, ChatInvitePeek)
TypeExportedChatInvite <- list(ChatInviteExported, ChatInvitePublicJoinRequests)
TypeChatInviteImporter <- ChatInviteImporter
TypeChatOnlines <- ChatOnlines
TypeChatParticipant <- list(ChatParticipant, ChatParticipantCreator, ChatParticipantAdmin)
TypeChatParticipants <- list(ChatParticipantsForbidden, ChatParticipants)
TypeChatPhoto <- list(ChatPhotoEmpty, ChatPhoto)
TypeChatReactions <- list(ChatReactionsNone, ChatReactionsAll, ChatReactionsSome)
TypeChatTheme <- list(ChatTheme, ChatThemeUniqueGift)
TypeClient_DH_Innerdata <- ClientDHInnerData
TypeCodeSettings <- CodeSettings
TypeConfig <- Config
TypeConnectedBot <- ConnectedBot
TypeConnectedBotStarRef <- ConnectedBotStarRef
TypeContact <- Contact
TypeContactBirthday <- ContactBirthday
TypeContactStatus <- ContactStatus
TypeDataJSON <- DataJSON
TypeDcOption <- DcOption
TypeDefaultHistoryTTL <- DefaultHistoryTTL
TypeDestroyAuthKeyRes <- list(DestroyAuthKeyOk, DestroyAuthKeyNone, DestroyAuthKeyFail)
TypeDestroySessionRes <- list(DestroySessionOk, DestroySessionNone)
TypeSet_client_DH_params_answer <- list(DhGenOk, DhGenRetry, DhGenFail)
TypeDialog <- list(Dialog, DialogFolder)
TypeDialogFilter <- list(DialogFilter, DialogFilterDefault, DialogFilterChatlist)
TypeDialogFilterSuggested <- DialogFilterSuggested
TypeDialogPeer <- list(DialogPeer, DialogPeerFolder)
TypeDisallowedGiftsSettings <- DisallowedGiftsSettings
TypeDocument <- list(DocumentEmpty, Document)
TypeDocumentAttribute <- list(DocumentAttributeImageSize, DocumentAttributeAnimated, DocumentAttributeSticker, DocumentAttributeVideo, DocumentAttributeAudio, DocumentAttributeFilename, DocumentAttributeHasStickers, DocumentAttributeCustomEmoji)
TypeDraftMessage <- list(DraftMessageEmpty, DraftMessage)
TypeEmailVerification <- list(EmailVerificationCode, EmailVerificationGoogle, EmailVerificationApple)
TypeEmailVerifyPurpose <- list(EmailVerifyPurposeLoginSetup, EmailVerifyPurposeLoginChange, EmailVerifyPurposePassport)
TypeEmojiGroup <- list(EmojiGroup, EmojiGroupGreeting, EmojiGroupPremium)
TypeEmojiKeyword <- list(EmojiKeyword, EmojiKeywordDeleted)
TypeEmojiKeywordsDifference <- EmojiKeywordsDifference
TypeEmojiLanguage <- EmojiLanguage
TypeEmojiList <- list(EmojiListNotModified, EmojiList)
TypeEmojiStatus <- list(EmojiStatusEmpty, EmojiStatus, EmojiStatusCollectible, InputEmojiStatusCollectible)
TypeEmojiURL <- EmojiURL
TypeEncryptedChat <- list(EncryptedChatEmpty, EncryptedChatWaiting, EncryptedChatRequested, EncryptedChat, EncryptedChatDiscarded)
TypeEncryptedFile <- list(EncryptedFileEmpty, EncryptedFile)
TypeEncryptedMessage <- list(EncryptedMessage, EncryptedMessageService)
TypeExportedChatlistInvite <- ExportedChatlistInvite
TypeExportedContactToken <- ExportedContactToken
TypeExportedMessageLink <- ExportedMessageLink
TypeExportedStoryLink <- ExportedStoryLink
TypeFactCheck <- FactCheck
TypeFileHash <- FileHash
TypeFolder <- Folder
TypeFolderPeer <- FolderPeer
TypeForumTopic <- list(ForumTopicDeleted, ForumTopic)
TypeFoundStory <- FoundStory
TypeFutureSalt <- FutureSalt
TypeFutureSalts <- FutureSalts
TypeGame <- Game
TypeGeoPoint <- list(GeoPointEmpty, GeoPoint)
TypeGeoPointAddress <- GeoPointAddress
TypeGlobalPrivacySettings <- GlobalPrivacySettings
TypeGroupCall <- list(GroupCallDiscarded, GroupCall)
TypeGroupCallParticipant <- GroupCallParticipant
TypeGroupCallParticipantVideo <- GroupCallParticipantVideo
TypeGroupCallParticipantVideoSourceGroup <- GroupCallParticipantVideoSourceGroup
TypeGroupCallStreamChannel <- GroupCallStreamChannel
TypeHighScore <- HighScore
TypeHttpWait <- HttpWait
TypeImportedContact <- ImportedContact
TypeInlineBotSwitchPM <- InlineBotSwitchPM
TypeInlineBotWebView <- InlineBotWebView
TypeInlineQueryPeerType <- list(InlineQueryPeerTypeSameBotPM, InlineQueryPeerTypePM, InlineQueryPeerTypeChat, InlineQueryPeerTypeMegagroup, InlineQueryPeerTypeBroadcast, InlineQueryPeerTypeBotPM)
TypeInputAppEvent <- InputAppEvent
TypeInputBotApp <- list(InputBotAppID, InputBotAppShortName)
TypeInputBotInlineMessage <- list(InputBotInlineMessageMediaAuto, InputBotInlineMessageText, InputBotInlineMessageMediaGeo, InputBotInlineMessageMediaVenue, InputBotInlineMessageMediaContact, InputBotInlineMessageGame, InputBotInlineMessageMediaInvoice, InputBotInlineMessageMediaWebPage)
TypeInputBotInlineMessageID <- list(InputBotInlineMessageID, InputBotInlineMessageID64)
TypeInputBotInlineResult <- list(InputBotInlineResult, InputBotInlineResultPhoto, InputBotInlineResultDocument, InputBotInlineResultGame)
TypeInputBusinessAwayMessage <- InputBusinessAwayMessage
TypeInputBusinessBotRecipients <- InputBusinessBotRecipients
TypeInputBusinessChatLink <- InputBusinessChatLink
TypeInputBusinessGreetingMessage <- InputBusinessGreetingMessage
TypeInputBusinessIntro <- InputBusinessIntro
TypeInputBusinessRecipients <- InputBusinessRecipients
TypeInputChannel <- list(InputChannelEmpty, InputChannel, InputChannelFromMessage)
TypeInputChatPhoto <- list(InputChatPhotoEmpty, InputChatUploadedPhoto, InputChatPhoto)
TypeInputChatTheme <- list(InputChatThemeEmpty, InputChatTheme, InputChatThemeUniqueGift)
TypeInputChatlist <- InputChatlistDialogFilter
TypeInputCheckPasswordSRP <- list(InputCheckPasswordEmpty, InputCheckPasswordSRP)
TypeInputClientProxy <- InputClientProxy
TypeInputCollectible <- list(InputCollectibleUsername, InputCollectiblePhone)
TypeInputDialogPeer <- list(InputDialogPeer, InputDialogPeerFolder)
TypeInputDocument <- list(InputDocumentEmpty, InputDocument)
TypeInputFileLocation <- list(InputFileLocation, InputEncryptedFileLocation, InputDocumentFileLocation, InputSecureFileLocation, InputTakeoutFileLocation, InputPhotoFileLocation, InputPhotoLegacyFileLocation, InputPeerPhotoFileLocation, InputStickerSetThumb, InputGroupCallStream)
TypeInputEncryptedChat <- InputEncryptedChat
TypeInputEncryptedFile <- list(InputEncryptedFileEmpty, InputEncryptedFileUploaded, InputEncryptedFile, InputEncryptedFileBigUploaded)
TypeInputFile <- list(InputFile, InputFileBig, InputFileStoryDocument)
TypeInputFolderPeer <- InputFolderPeer
TypeInputGame <- list(InputGameID, InputGameShortName)
TypeInputGeoPoint <- list(InputGeoPointEmpty, InputGeoPoint)
TypeInputGroupCall <- list(InputGroupCall, InputGroupCallSlug, InputGroupCallInviteMessage)
TypeInputInvoice <- list(InputInvoiceMessage, InputInvoiceSlug, InputInvoicePremiumGiftCode, InputInvoiceStars, InputInvoiceChatInviteSubscription, InputInvoiceStarGift, InputInvoiceStarGiftUpgrade, InputInvoiceStarGiftTransfer, InputInvoicePremiumGiftStars, InputInvoiceBusinessBotTransferStars, InputInvoiceStarGiftResale, InputInvoiceStarGiftPrepaidUpgrade)
TypeKeyboardButton <- list(KeyboardButton, KeyboardButtonUrl, KeyboardButtonCallback, KeyboardButtonRequestPhone, KeyboardButtonRequestGeoLocation, KeyboardButtonSwitchInline, KeyboardButtonGame, KeyboardButtonBuy, KeyboardButtonUrlAuth, InputKeyboardButtonUrlAuth, KeyboardButtonRequestPoll, InputKeyboardButtonUserProfile, KeyboardButtonUserProfile, KeyboardButtonWebView, KeyboardButtonSimpleWebView, KeyboardButtonRequestPeer, InputKeyboardButtonRequestPeer, KeyboardButtonCopy)
TypeMediaArea <- list(MediaAreaVenue, InputMediaAreaVenue, MediaAreaGeoPoint, MediaAreaSuggestedReaction, MediaAreaChannelPost, InputMediaAreaChannelPost, MediaAreaUrl, MediaAreaWeather, MediaAreaStarGift)
TypeInputMedia <- list(InputMediaEmpty, InputMediaUploadedPhoto, InputMediaPhoto, InputMediaGeoPoint, InputMediaContact, InputMediaUploadedDocument, InputMediaDocument, InputMediaVenue, InputMediaPhotoExternal, InputMediaDocumentExternal, InputMediaGame, InputMediaInvoice, InputMediaGeoLive, InputMediaPoll, InputMediaDice, InputMediaStory, InputMediaWebPage, InputMediaPaidMedia, InputMediaTodo)
TypeInputMessage <- list(InputMessageID, InputMessageReplyTo, InputMessagePinned, InputMessageCallbackQuery)
TypeMessageEntity <- list(MessageEntityUnknown, MessageEntityMention, MessageEntityHashtag, MessageEntityBotCommand, MessageEntityUrl, MessageEntityEmail, MessageEntityBold, MessageEntityItalic, MessageEntityCode, MessageEntityPre, MessageEntityTextUrl, MessageEntityMentionName, InputMessageEntityMentionName, MessageEntityPhone, MessageEntityCashtag, MessageEntityUnderline, MessageEntityStrike, MessageEntityBankCard, MessageEntitySpoiler, MessageEntityCustomEmoji, MessageEntityBlockquote)
TypeMessagesFilter <- list(InputMessagesFilterEmpty, InputMessagesFilterPhotos, InputMessagesFilterVideo, InputMessagesFilterPhotoVideo, InputMessagesFilterDocument, InputMessagesFilterUrl, InputMessagesFilterGif, InputMessagesFilterVoice, InputMessagesFilterMusic, InputMessagesFilterChatPhotos, InputMessagesFilterPhoneCalls, InputMessagesFilterRoundVoice, InputMessagesFilterRoundVideo, InputMessagesFilterMyMentions, InputMessagesFilterGeo, InputMessagesFilterContacts, InputMessagesFilterPinned)
TypeInputNotifyPeer <- list(InputNotifyPeer, InputNotifyUsers, InputNotifyChats, InputNotifyBroadcasts, InputNotifyForumTopic)
TypeInputPaymentCredentials <- list(InputPaymentCredentialsSaved, InputPaymentCredentials, InputPaymentCredentialsApplePay, InputPaymentCredentialsGooglePay)
TypeInputPeer <- list(InputPeerEmpty, InputPeerSelf, InputPeerChat, InputPeerUser, InputPeerChannel, InputPeerUserFromMessage, InputPeerChannelFromMessage)
TypeInputPeerNotifySettings <- InputPeerNotifySettings
TypeInputPhoneCall <- InputPhoneCall
TypeInputContact <- InputPhoneContact
TypeInputPhoto <- list(InputPhotoEmpty, InputPhoto)
TypeInputPrivacyKey <- list(InputPrivacyKeyStatusTimestamp, InputPrivacyKeyChatInvite, InputPrivacyKeyPhoneCall, InputPrivacyKeyPhoneP2P, InputPrivacyKeyForwards, InputPrivacyKeyProfilePhoto, InputPrivacyKeyPhoneNumber, InputPrivacyKeyAddedByPhone, InputPrivacyKeyVoiceMessages, InputPrivacyKeyAbout, InputPrivacyKeyBirthday, InputPrivacyKeyStarGiftsAutoSave, InputPrivacyKeyNoPaidMessages)
TypeInputPrivacyRule <- list(InputPrivacyValueAllowContacts, InputPrivacyValueAllowAll, InputPrivacyValueAllowUsers, InputPrivacyValueDisallowContacts, InputPrivacyValueDisallowAll, InputPrivacyValueDisallowUsers, InputPrivacyValueAllowChatParticipants, InputPrivacyValueDisallowChatParticipants, InputPrivacyValueAllowCloseFriends, InputPrivacyValueAllowPremium, InputPrivacyValueAllowBots, InputPrivacyValueDisallowBots)
TypeInputQuickReplyShortcut <- list(InputQuickReplyShortcut, InputQuickReplyShortcutId)
TypeInputReplyTo <- list(InputReplyToMessage, InputReplyToStory, InputReplyToMonoForum)
TypeReportReason <- list(InputReportReasonSpam, InputReportReasonViolence, InputReportReasonPornography, InputReportReasonChildAbuse, InputReportReasonOther, InputReportReasonCopyright, InputReportReasonGeoIrrelevant, InputReportReasonFake, InputReportReasonIllegalDrugs, InputReportReasonPersonalDetails)
TypeInputSavedStarGift <- list(InputSavedStarGiftUser, InputSavedStarGiftChat, InputSavedStarGiftSlug)
TypeInputSecureFile <- list(InputSecureFileUploaded, InputSecureFile)
TypeInputSecureValue <- InputSecureValue
TypeInputSingleMedia <- InputSingleMedia
TypeInputStarsTransaction <- InputStarsTransaction
TypeInputStickerSet <- list(InputStickerSetEmpty, InputStickerSetID, InputStickerSetShortName, InputStickerSetAnimatedEmoji, InputStickerSetDice, InputStickerSetAnimatedEmojiAnimations, InputStickerSetPremiumGifts, InputStickerSetEmojiGenericAnimations, InputStickerSetEmojiDefaultStatuses, InputStickerSetEmojiDefaultTopicIcons, InputStickerSetEmojiChannelDefaultStatuses, InputStickerSetTonGifts)
TypeInputStickerSetItem <- InputStickerSetItem
TypeInputStickeredMedia <- list(InputStickeredMediaPhoto, InputStickeredMediaDocument)
TypeInputStorePaymentPurpose <- list(InputStorePaymentPremiumSubscription, InputStorePaymentGiftPremium, InputStorePaymentPremiumGiftCode, InputStorePaymentPremiumGiveaway, InputStorePaymentStarsTopup, InputStorePaymentStarsGift, InputStorePaymentStarsGiveaway, InputStorePaymentAuthCode)
TypeInputTheme <- list(InputTheme, InputThemeSlug)
TypeInputThemeSettings <- InputThemeSettings
TypeInputUser <- list(InputUserEmpty, InputUserSelf, InputUser, InputUserFromMessage)
TypeInputWallPaper <- list(InputWallPaper, InputWallPaperSlug, InputWallPaperNoFile)
TypeInputWebDocument <- InputWebDocument
TypeInputWebFileLocation <- list(InputWebFileLocation, InputWebFileGeoPointLocation, InputWebFileAudioAlbumThumbLocation)
TypeInvoice <- Invoice
TypeIpPort <- list(IpPort, IpPortSecret)
TypeJSONValue <- list(JsonNull, JsonBool, JsonNumber, JsonString, JsonArray, JsonObject)
TypeJSONObjectValue <- JsonObjectValue
TypeKeyboardButtonRow <- KeyboardButtonRow
TypeLabeledPrice <- LabeledPrice
TypeLangPackDifference <- LangPackDifference
TypeLangPackLanguage <- LangPackLanguage
TypeLangPackString <- list(LangPackString, LangPackStringPluralized, LangPackStringDeleted)
TypeMaskCoords <- MaskCoords
TypeMediaAreaCoordinates <- MediaAreaCoordinates
TypeMessage <- list(MessageEmpty, Message, MessageService)
TypeMessageAction <- list(MessageActionEmpty, MessageActionChatCreate, MessageActionChatEditTitle, MessageActionChatEditPhoto, MessageActionChatDeletePhoto, MessageActionChatAddUser, MessageActionChatDeleteUser, MessageActionChatJoinedByLink, MessageActionChannelCreate, MessageActionChatMigrateTo, MessageActionChannelMigrateFrom, MessageActionPinMessage, MessageActionHistoryClear, MessageActionGameScore, MessageActionPaymentSentMe, MessageActionPaymentSent, MessageActionPhoneCall, MessageActionScreenshotTaken, MessageActionCustomAction, MessageActionBotAllowed, MessageActionSecureValuesSentMe, MessageActionSecureValuesSent, MessageActionContactSignUp, MessageActionGeoProximityReached, MessageActionGroupCall, MessageActionInviteToGroupCall, MessageActionSetMessagesTTL, MessageActionGroupCallScheduled, MessageActionSetChatTheme, MessageActionChatJoinedByRequest, MessageActionWebViewDataSentMe, MessageActionWebViewDataSent, MessageActionGiftPremium, MessageActionTopicCreate, MessageActionTopicEdit, MessageActionSuggestProfilePhoto, MessageActionRequestedPeer, MessageActionSetChatWallPaper, MessageActionGiftCode, MessageActionGiveawayLaunch, MessageActionGiveawayResults, MessageActionBoostApply, MessageActionRequestedPeerSentMe, MessageActionPaymentRefunded, MessageActionGiftStars, MessageActionPrizeStars, MessageActionStarGift, MessageActionStarGiftUnique, MessageActionPaidMessagesRefunded, MessageActionPaidMessagesPrice, MessageActionConferenceCall, MessageActionTodoCompletions, MessageActionTodoAppendTasks, MessageActionSuggestedPostApproval, MessageActionSuggestedPostSuccess, MessageActionSuggestedPostRefund)
TypeMessageExtendedMedia <- list(MessageExtendedMediaPreview, MessageExtendedMedia)
TypeMessageFwdHeader <- MessageFwdHeader
TypeMessageMedia <- list(MessageMediaEmpty, MessageMediaPhoto, MessageMediaGeo, MessageMediaContact, MessageMediaUnsupported, MessageMediaDocument, MessageMediaWebPage, MessageMediaVenue, MessageMediaGame, MessageMediaInvoice, MessageMediaGeoLive, MessageMediaPoll, MessageMediaDice, MessageMediaStory, MessageMediaGiveaway, MessageMediaGiveawayResults, MessageMediaPaidMedia, MessageMediaToDo)
TypeMessagePeerReaction <- MessagePeerReaction
TypeMessagePeerVote <- list(MessagePeerVote, MessagePeerVoteInputOption, MessagePeerVoteMultiple)
TypeMessageRange <- MessageRange
TypeMessageReactions <- MessageReactions
TypeMessageReactor <- MessageReactor
TypeMessageReplies <- MessageReplies
TypeMessageReplyHeader <- list(MessageReplyHeader, MessageReplyStoryHeader)
TypeMessageReportOption <- MessageReportOption
TypeMessageViews <- MessageViews
TypeMissingInvitee <- MissingInvitee
TypeSavedDialog <- list(SavedDialog, MonoForumDialog)
TypeMsgDetailedInfo <- list(MsgDetailedInfo, MsgNewDetailedInfo)
TypeMsgResendReq <- MsgResendReq
TypeMsgsAck <- MsgsAck
TypeMsgsAllInfo <- MsgsAllInfo
TypeMsgsStateInfo <- MsgsStateInfo
TypeMsgsStateReq <- MsgsStateReq
TypeMyBoost <- MyBoost
TypeNearestDc <- NearestDc
TypeNewSession <- NewSessionCreated
TypeNotificationSound <- list(NotificationSoundDefault, NotificationSoundNone, NotificationSoundLocal, NotificationSoundRingtone)
TypeNotifyPeer <- list(NotifyPeer, NotifyUsers, NotifyChats, NotifyBroadcasts, NotifyForumTopic)
TypeOutboxReadDate <- OutboxReadDate
TypeP_Q_innerdata <- list(PQInnerData, PQInnerDataDc, PQInnerDataTemp, PQInnerDataTempDc)
TypePage <- Page
TypePageBlock <- list(PageBlockUnsupported, PageBlockTitle, PageBlockSubtitle, PageBlockAuthorDate, PageBlockHeader, PageBlockSubheader, PageBlockParagraph, PageBlockPreformatted, PageBlockFooter, PageBlockDivider, PageBlockAnchor, PageBlockList, PageBlockBlockquote, PageBlockPullquote, PageBlockPhoto, PageBlockVideo, PageBlockCover, PageBlockEmbed, PageBlockEmbedPost, PageBlockCollage, PageBlockSlideshow, PageBlockChannel, PageBlockAudio, PageBlockKicker, PageBlockTable, PageBlockOrderedList, PageBlockDetails, PageBlockRelatedArticles, PageBlockMap)
TypePageCaption <- PageCaption
TypePageListItem <- list(PageListItemText, PageListItemBlocks)
TypePageListOrderedItem <- list(PageListOrderedItemText, PageListOrderedItemBlocks)
TypePageRelatedArticle <- PageRelatedArticle
TypePageTableCell <- PageTableCell
TypePageTableRow <- PageTableRow
TypePaidReactionPrivacy <- list(PaidReactionPrivacyDefault, PaidReactionPrivacyAnonymous, PaidReactionPrivacyPeer)
TypePasswordKdfAlgo <- list(PasswordKdfAlgoUnknown, PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow)
TypePaymentCharge <- PaymentCharge
TypePaymentFormMethod <- PaymentFormMethod
TypePaymentRequestedInfo <- PaymentRequestedInfo
TypePaymentSavedCredentials <- PaymentSavedCredentialsCard
TypePeerBlocked <- PeerBlocked
TypePeer <- list(PeerUser, PeerChat, PeerChannel)
TypePeerColor <- PeerColor
TypePeerLocated <- list(PeerLocated, PeerSelfLocated)
TypePeerNotifySettings <- PeerNotifySettings
TypePeerSettings <- PeerSettings
TypePeerStories <- PeerStories
TypePendingSuggestion <- PendingSuggestion
TypePhoneCall <- list(PhoneCallEmpty, PhoneCallWaiting, PhoneCallRequested, PhoneCallAccepted, PhoneCall, PhoneCallDiscarded)
TypePhoneCallDiscardReason <- list(PhoneCallDiscardReasonMissed, PhoneCallDiscardReasonDisconnect, PhoneCallDiscardReasonHangup, PhoneCallDiscardReasonBusy, PhoneCallDiscardReasonMigrateConferenceCall)
TypePhoneCallProtocol <- PhoneCallProtocol
TypePhoneConnection <- list(PhoneConnection, PhoneConnectionWebrtc)
TypePhoto <- list(PhotoEmpty, Photo)
TypePhotoSize <- list(PhotoSizeEmpty, PhotoSize, PhotoCachedSize, PhotoStrippedSize, PhotoSizeProgressive, PhotoPathSize)
TypePoll <- Poll
TypePollAnswer <- PollAnswer
TypePollAnswerVoters <- PollAnswerVoters
TypePollResults <- PollResults
TypePong <- Pong
TypePopularContact <- PopularContact
TypePostAddress <- PostAddress
TypePostInteractionCounters <- list(PostInteractionCountersMessage, PostInteractionCountersStory)
TypePremiumGiftCodeOption <- PremiumGiftCodeOption
TypePremiumSubscriptionOption <- PremiumSubscriptionOption
TypePrepaidGiveaway <- list(PrepaidGiveaway, PrepaidStarsGiveaway)
TypePrivacyKey <- list(PrivacyKeyStatusTimestamp, PrivacyKeyChatInvite, PrivacyKeyPhoneCall, PrivacyKeyPhoneP2P, PrivacyKeyForwards, PrivacyKeyProfilePhoto, PrivacyKeyPhoneNumber, PrivacyKeyAddedByPhone, PrivacyKeyVoiceMessages, PrivacyKeyAbout, PrivacyKeyBirthday, PrivacyKeyStarGiftsAutoSave, PrivacyKeyNoPaidMessages)
TypePrivacyRule <- list(PrivacyValueAllowContacts, PrivacyValueAllowAll, PrivacyValueAllowUsers, PrivacyValueDisallowContacts, PrivacyValueDisallowAll, PrivacyValueDisallowUsers, PrivacyValueAllowChatParticipants, PrivacyValueDisallowChatParticipants, PrivacyValueAllowCloseFriends, PrivacyValueAllowPremium, PrivacyValueAllowBots, PrivacyValueDisallowBots)
TypeProfileTab <- list(ProfileTabPosts, ProfileTabGifts, ProfileTabMedia, ProfileTabFiles, ProfileTabMusic, ProfileTabVoice, ProfileTabLinks, ProfileTabGifs)
TypePublicForward <- list(PublicForwardMessage, PublicForwardStory)
TypeQuickReply <- QuickReply
TypeReactionCount <- ReactionCount
TypeReaction <- list(ReactionEmpty, ReactionEmoji, ReactionCustomEmoji, ReactionPaid)
TypeReactionNotificationsFrom <- list(ReactionNotificationsFromContacts, ReactionNotificationsFromAll)
TypeReactionsNotifySettings <- ReactionsNotifySettings
TypeReadParticipantDate <- ReadParticipantDate
TypeReceivedNotifyMessage <- ReceivedNotifyMessage
TypeRecentMeUrl <- list(RecentMeUrlUnknown, RecentMeUrlUser, RecentMeUrlChat, RecentMeUrlChatInvite, RecentMeUrlStickerSet)
TypeReplyMarkup <- list(ReplyKeyboardHide, ReplyKeyboardForceReply, ReplyKeyboardMarkup, ReplyInlineMarkup)
TypeReportResult <- list(ReportResultChooseOption, ReportResultAddComment, ReportResultReported)
TypeRequestPeerType <- list(RequestPeerTypeUser, RequestPeerTypeChat, RequestPeerTypeBroadcast)
TypeRequestedPeer <- list(RequestedPeerUser, RequestedPeerChat, RequestedPeerChannel)
TypeRequirementToContact <- list(RequirementToContactEmpty, RequirementToContactPremium, RequirementToContactPaidMessages)
TypeResPQ <- ResPQ
TypeRestrictionReason <- RestrictionReason
TypeRpcDropAnswer <- list(RpcAnswerUnknown, RpcAnswerDroppedRunning, RpcAnswerDropped)
TypeRpcError <- RpcError
TypeSavedContact <- SavedPhoneContact
TypeSavedReactionTag <- SavedReactionTag
TypeSavedStarGift <- SavedStarGift
TypeSearchPostsFlood <- SearchPostsFlood
TypeSearchResultsPosition <- SearchResultPosition
TypeSearchResultsCalendarPeriod <- SearchResultsCalendarPeriod
TypeSecureCredentialsEncrypted <- SecureCredentialsEncrypted
TypeSecureData <- SecureData
TypeSecureFile <- list(SecureFileEmpty, SecureFile)
TypeSecurePasswordKdfAlgo <- list(SecurePasswordKdfAlgoUnknown, SecurePasswordKdfAlgoPBKDF2HMACSHA512iter100000, SecurePasswordKdfAlgoSHA512)
TypeSecurePlainData <- list(SecurePlainPhone, SecurePlainEmail)
TypeSecureRequiredType <- list(SecureRequiredType, SecureRequiredTypeOneOf)
TypeSecureSecretSettings <- SecureSecretSettings
TypeSecureValue <- SecureValue
TypeSecureValueError <- list(SecureValueErrorData, SecureValueErrorFrontSide, SecureValueErrorReverseSide, SecureValueErrorSelfie, SecureValueErrorFile, SecureValueErrorFiles, SecureValueError, SecureValueErrorTranslationFile, SecureValueErrorTranslationFiles)
TypeSecureValueHash <- SecureValueHash
TypeSecureValueType <- list(SecureValueTypePersonalDetails, SecureValueTypePassport, SecureValueTypeDriverLicense, SecureValueTypeIdentityCard, SecureValueTypeInternalPassport, SecureValueTypeAddress, SecureValueTypeUtilityBill, SecureValueTypeBankStatement, SecureValueTypeRentalAgreement, SecureValueTypePassportRegistration, SecureValueTypeTemporaryRegistration, SecureValueTypePhone, SecureValueTypeEmail)
TypeSendAsPeer <- SendAsPeer
TypeSendMessageAction <- list(SendMessageTypingAction, SendMessageCancelAction, SendMessageRecordVideoAction, SendMessageUploadVideoAction, SendMessageRecordAudioAction, SendMessageUploadAudioAction, SendMessageUploadPhotoAction, SendMessageUploadDocumentAction, SendMessageGeoLocationAction, SendMessageChooseContactAction, SendMessageGamePlayAction, SendMessageRecordRoundAction, SendMessageUploadRoundAction, SpeakingInGroupCallAction, SendMessageHistoryImportAction, SendMessageChooseStickerAction, SendMessageEmojiInteraction, SendMessageEmojiInteractionSeen)
TypeServer_DH_innerdata <- ServerDHInnerData
TypeServer_DH_Params <- list(ServerDHParamsFail, ServerDHParamsOk)
TypeShippingOption <- ShippingOption
TypeSmsJob <- SmsJob
TypeSponsoredMessage <- SponsoredMessage
TypeSponsoredMessageReportOption <- SponsoredMessageReportOption
TypeSponsoredPeer <- SponsoredPeer
TypeStarGift <- list(StarGift, StarGiftUnique)
TypeStarGiftAttribute <- list(StarGiftAttributeModel, StarGiftAttributePattern, StarGiftAttributeBackdrop, StarGiftAttributeOriginalDetails)
TypeStarGiftAttributeCounter <- StarGiftAttributeCounter
TypeStarGiftAttributeId <- list(StarGiftAttributeIdModel, StarGiftAttributeIdPattern, StarGiftAttributeIdBackdrop)
TypeStarGiftCollection <- StarGiftCollection
TypeStarRefProgram <- StarRefProgram
TypeStarsAmount <- list(StarsAmount, StarsTonAmount)
TypeStarsGiftOption <- StarsGiftOption
TypeStarsGiveawayOption <- StarsGiveawayOption
TypeStarsGiveawayWinnersOption <- StarsGiveawayWinnersOption
TypeStarsRating <- StarsRating
TypeStarsRevenueStatus <- StarsRevenueStatus
TypeStarsSubscription <- StarsSubscription
TypeStarsSubscriptionPricing <- StarsSubscriptionPricing
TypeStarsTopupOption <- StarsTopupOption
TypeStarsTransaction <- StarsTransaction
TypeStarsTransactionPeer <- list(StarsTransactionPeerUnsupported, StarsTransactionPeerAppStore, StarsTransactionPeerPlayMarket, StarsTransactionPeerPremiumBot, StarsTransactionPeerFragment, StarsTransactionPeer, StarsTransactionPeerAds, StarsTransactionPeerAPI)
TypeStatsAbsValueAndPrev <- StatsAbsValueAndPrev
TypeStatsDateRangeDays <- StatsDateRangeDays
TypeStatsGraph <- list(StatsGraphAsync, StatsGraphError, StatsGraph)
TypeStatsGroupTopAdmin <- StatsGroupTopAdmin
TypeStatsGroupTopInviter <- StatsGroupTopInviter
TypeStatsGroupTopPoster <- StatsGroupTopPoster
TypeStatsPercentValue <- StatsPercentValue
TypeStatsURL <- StatsURL
TypeStickerKeyword <- StickerKeyword
TypeStickerPack <- StickerPack
TypeStickerSet <- StickerSet
TypeStickerSetCovered <- list(StickerSetCovered, StickerSetMultiCovered, StickerSetFullCovered, StickerSetNoCovered)
TypeStoriesStealthMode <- StoriesStealthMode
TypeStoryAlbum <- StoryAlbum
TypeStoryFwdHeader <- StoryFwdHeader
TypeStoryItem <- list(StoryItemDeleted, StoryItemSkipped, StoryItem)
TypeStoryReaction <- list(StoryReaction, StoryReactionPublicForward, StoryReactionPublicRepost)
TypeStoryView <- list(StoryView, StoryViewPublicForward, StoryViewPublicRepost)
TypeStoryViews <- StoryViews
TypeSuggestedPost <- SuggestedPost
TypeRichText <- list(TextEmpty, TextPlain, TextBold, TextItalic, TextUnderline, TextStrike, TextFixed, TextUrl, TextEmail, TextConcat, TextSubscript, TextSuperscript, TextMarked, TextPhone, TextImage, TextAnchor)
TypeTextWithEntities <- TextWithEntities
TypeTheme <- Theme
TypeThemeSettings <- ThemeSettings
TypeTimezone <- Timezone
TypeTlsBlock <- list(TlsBlockString, TlsBlockRandom, TlsBlockZero, TlsBlockDomain, TlsBlockGrease, TlsBlockPublicKey, TlsBlockScope)
TypeTlsClientHello <- TlsClientHello
TypeTodoCompletion <- TodoCompletion
TypeTodoItem <- TodoItem
TypeTodoList <- TodoList
TypeTopPeer <- TopPeer
TypeTopPeerCategory <- list(TopPeerCategoryBotsPM, TopPeerCategoryBotsInline, TopPeerCategoryCorrespondents, TopPeerCategoryGroups, TopPeerCategoryChannels, TopPeerCategoryPhoneCalls, TopPeerCategoryForwardUsers, TopPeerCategoryForwardChats, TopPeerCategoryBotsApp)
TypeTopPeerCategoryPeers <- TopPeerCategoryPeers
TypeUpdate <- list(UpdateNewMessage, UpdateMessageID, UpdateDeleteMessages, UpdateUserTyping, UpdateChatUserTyping, UpdateChatParticipants, UpdateUserStatus, UpdateUserName, UpdateNewAuthorization, UpdateNewEncryptedMessage, UpdateEncryptedChatTyping, UpdateEncryption, UpdateEncryptedMessagesRead, UpdateChatParticipantAdd, UpdateChatParticipantDelete, UpdateDcOptions, UpdateNotifySettings, UpdateServiceNotification, UpdatePrivacy, UpdateUserPhone, UpdateReadHistoryInbox, UpdateReadHistoryOutbox, UpdateWebPage, UpdateReadMessagesContents, UpdateChannelTooLong, UpdateChannel, UpdateNewChannelMessage, UpdateReadChannelInbox, UpdateDeleteChannelMessages, UpdateChannelMessageViews, UpdateChatParticipantAdmin, UpdateNewStickerSet, UpdateStickerSetsOrder, UpdateStickerSets, UpdateSavedGifs, UpdateBotInlineQuery, UpdateBotInlineSend, UpdateEditChannelMessage, UpdateBotCallbackQuery, UpdateEditMessage, UpdateInlineBotCallbackQuery, UpdateReadChannelOutbox, UpdateDraftMessage, UpdateReadFeaturedStickers, UpdateRecentStickers, UpdateConfig, UpdatePtsChanged, UpdateChannelWebPage, UpdateDialogPinned, UpdatePinnedDialogs, UpdateBotWebhookJSON, UpdateBotWebhookJSONQuery, UpdateBotShippingQuery, UpdateBotPrecheckoutQuery, UpdatePhoneCall, UpdateLangPackTooLong, UpdateLangPack, UpdateFavedStickers, UpdateChannelReadMessagesContents, UpdateContactsReset, UpdateChannelAvailableMessages, UpdateDialogUnreadMark, UpdateMessagePoll, UpdateChatDefaultBannedRights, UpdateFolderPeers, UpdatePeerSettings, UpdatePeerLocated, UpdateNewScheduledMessage, UpdateDeleteScheduledMessages, UpdateTheme, UpdateGeoLiveViewed, UpdateLoginToken, UpdateMessagePollVote, UpdateDialogFilter, UpdateDialogFilterOrder, UpdateDialogFilters, UpdatePhoneCallSignalingData, UpdateChannelMessageForwards, UpdateReadChannelDiscussionInbox, UpdateReadChannelDiscussionOutbox, UpdatePeerBlocked, UpdateChannelUserTyping, UpdatePinnedMessages, UpdatePinnedChannelMessages, UpdateChat, UpdateGroupCallParticipants, UpdateGroupCall, UpdatePeerHistoryTTL, UpdateChatParticipant, UpdateChannelParticipant, UpdateBotStopped, UpdateGroupCallConnection, UpdateBotCommands, UpdatePendingJoinRequests, UpdateBotChatInviteRequester, UpdateMessageReactions, UpdateAttachMenuBots, UpdateWebViewResultSent, UpdateBotMenuButton, UpdateSavedRingtones, UpdateTranscribedAudio, UpdateReadFeaturedEmojiStickers, UpdateUserEmojiStatus, UpdateRecentEmojiStatuses, UpdateRecentReactions, UpdateMoveStickerSetToTop, UpdateMessageExtendedMedia, UpdateChannelPinnedTopic, UpdateChannelPinnedTopics, UpdateUser, UpdateAutoSaveSettings, UpdateStory, UpdateReadStories, UpdateStoryID, UpdateStoriesStealthMode, UpdateSentStoryReaction, UpdateBotChatBoost, UpdateChannelViewForumAsMessages, UpdatePeerWallpaper, UpdateBotMessageReaction, UpdateBotMessageReactions, UpdateSavedDialogPinned, UpdatePinnedSavedDialogs, UpdateSavedReactionTags, UpdateSmsJob, UpdateQuickReplies, UpdateNewQuickReply, UpdateDeleteQuickReply, UpdateQuickReplyMessage, UpdateDeleteQuickReplyMessages, UpdateBotBusinessConnect, UpdateBotNewBusinessMessage, UpdateBotEditBusinessMessage, UpdateBotDeleteBusinessMessage, UpdateNewStoryReaction, UpdateStarsBalance, UpdateBusinessBotCallbackQuery, UpdateStarsRevenueStatus, UpdateBotPurchasedPaidMedia, UpdatePaidReactionPrivacy, UpdateSentPhoneCode, UpdateGroupCallChainBlocks, UpdateReadMonoForumInbox, UpdateReadMonoForumOutbox, UpdateMonoForumNoPaidException)
TypeUpdates <- list(UpdatesTooLong, UpdateShortMessage, UpdateShortChatMessage, UpdateShort, UpdatesCombined, Updates, UpdateShortSentMessage)
TypeUrlAuthResult <- list(UrlAuthResultRequest, UrlAuthResultAccepted, UrlAuthResultDefault)
TypeUser <- list(UserEmpty, User)
TypeUserFull <- UserFull
TypeUserProfilePhoto <- list(UserProfilePhotoEmpty, UserProfilePhoto)
TypeUserStatus <- list(UserStatusEmpty, UserStatusOnline, UserStatusOffline, UserStatusRecently, UserStatusLastWeek, UserStatusLastMonth)
TypeUsername <- Username
TypeVideoSize <- list(VideoSize, VideoSizeEmojiMarkup, VideoSizeStickerMarkup)
TypeWallPaper <- list(WallPaper, WallPaperNoFile)
TypeWallPaperSettings <- WallPaperSettings
TypeWebAuthorization <- WebAuthorization
TypeWebDocument <- list(WebDocument, WebDocumentNoProxy)
TypeWebPage <- list(WebPageEmpty, WebPagePending, WebPage, WebPageNotModified)
TypeWebPageAttribute <- list(WebPageAttributeTheme, WebPageAttributeStory, WebPageAttributeStickerSet, WebPageAttributeUniqueStarGift, WebPageAttributeStarGiftCollection)
TypeWebViewMessageSent <- WebViewMessageSent
TypeWebViewResult <- WebViewResultUrl
