Various improvements

This commit is contained in:
Ilya Laktyushin
2022-04-15 03:31:37 +04:00
parent df2354e9bb
commit 701fe95891
56 changed files with 1035 additions and 788 deletions

View File

@@ -16,13 +16,21 @@ extension BotMenuButton {
extension BotInfo {
convenience init(apiBotInfo: Api.BotInfo) {
switch apiBotInfo {
case let .botInfo(_, description, commands, menuButton):
self.init(description: description, commands: commands.map { command in
switch command {
case let .botCommand(command, description):
return BotCommand(text: command, description: description)
case let .botInfo(_, _, description, _, apiCommands, apiMenuButton):
var commands: [BotCommand] = []
if let apiCommands = apiCommands {
commands = apiCommands.map { command in
switch command {
case let .botCommand(command, description):
return BotCommand(text: command, description: description)
}
}
}, menuButton: BotMenuButton(apiBotMenuButton: menuButton))
}
var menuButton: BotMenuButton = .commands
if let apiMenuButton = apiMenuButton {
menuButton = BotMenuButton(apiBotMenuButton: apiMenuButton)
}
self.init(description: description ?? "", commands: commands, menuButton: menuButton)
}
}
}