mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
29 lines
932 B
Swift
29 lines
932 B
Swift
import Foundation
|
|
import Postbox
|
|
import TelegramApi
|
|
|
|
extension BotMenuButton {
|
|
init(apiBotMenuButton: Api.BotMenuButton) {
|
|
switch apiBotMenuButton {
|
|
case .botMenuButtonCommands, .botMenuButtonDefault:
|
|
self = .commands
|
|
case let .botMenuButton(text, url):
|
|
self = .webView(text: text, url: url)
|
|
}
|
|
}
|
|
}
|
|
|
|
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)
|
|
}
|
|
}, menuButton: BotMenuButton(apiBotMenuButton: menuButton))
|
|
}
|
|
}
|
|
}
|