diff --git a/API/TelegramAPIDefinition.yml b/API/TelegramAPIDefinition.yml index 72f2d80..8136cc5 100644 --- a/API/TelegramAPIDefinition.yml +++ b/API/TelegramAPIDefinition.yml @@ -18,6 +18,7 @@ fields: - shipping_query: ShippingQuery? - pre_checkout_query: PreCheckoutQuery? - poll: Poll + - poll_answer: PollAnswer --- type: WebhookInfo @@ -39,6 +40,9 @@ fields: - last_name: String? - username: String? - language_code: String? + - can_join_groups: Bool? + - can_read_all_group_messages: Bool? + - supports_inline_queries: Bool? --- type: Chat @@ -117,6 +121,7 @@ fields: - length: Int - url: String? - user: User? + - language: String? --- type: PhotoSize @@ -223,13 +228,25 @@ fields: - text: String - voter_count: Int +--- +type: PollAnswer +fields: + - poll_id: String + - user: User + - option_ids: Int[] + --- type: Poll fields: - id: String - question: String - options: PollOption[] + - total_voter_count: Int - is_closed: Bool + - is_anonymous: Bool + - type: String + - allows_multiple_answers: Bool + - correct_option_id: Int? --- type: UserProfilePhotos @@ -259,6 +276,12 @@ fields: - text: String - request_contact: Bool? - request_location: Bool? + - request_poll: KeyboardButtonPollType? + +--- +type: KeyboardButtonPollType +fields: + - type: String? --- type: ReplyKeyboardRemove @@ -1082,6 +1105,10 @@ parameters: - chat_id: ChatId - question: String - options: String[] + - is_anonymous: Bool? + - type: String? + - correct_option_id: Int? + - is_closed: Bool? - disable_notification: Bool? - reply_to_message_id: Int? - reply_markup: InlineKeyboardMarkup? diff --git a/Sources/TelegramBotSDK/Generated/Methods.swift b/Sources/TelegramBotSDK/Generated/Methods.swift index 1b84bba..9bf1c9e 100644 --- a/Sources/TelegramBotSDK/Generated/Methods.swift +++ b/Sources/TelegramBotSDK/Generated/Methods.swift @@ -817,6 +817,10 @@ public extension TelegramBot { chatId: ChatId, question: String, options: [String], + isAnonymous: Bool? = nil, + type: String? = nil, + correctOptionId: Int? = nil, + isClosed: Bool? = nil, disableNotification: Bool? = nil, replyToMessageId: Int? = nil, replyMarkup: InlineKeyboardMarkup? = nil, @@ -825,6 +829,10 @@ public extension TelegramBot { "chat_id": chatId, "question": question, "options": options, +"is_anonymous": isAnonymous, +"type": type, +"correct_option_id": correctOptionId, +"is_closed": isClosed, "disable_notification": disableNotification, "reply_to_message_id": replyToMessageId, "reply_markup": replyMarkup]) @@ -834,6 +842,10 @@ public extension TelegramBot { chatId: ChatId, question: String, options: [String], + isAnonymous: Bool? = nil, + type: String? = nil, + correctOptionId: Int? = nil, + isClosed: Bool? = nil, disableNotification: Bool? = nil, replyToMessageId: Int? = nil, replyMarkup: InlineKeyboardMarkup? = nil, @@ -844,6 +856,10 @@ public extension TelegramBot { "chat_id": chatId, "question": question, "options": options, +"is_anonymous": isAnonymous, +"type": type, +"correct_option_id": correctOptionId, +"is_closed": isClosed, "disable_notification": disableNotification, "reply_to_message_id": replyToMessageId, "reply_markup": replyMarkup], diff --git a/Sources/TelegramBotSDK/Generated/Types.swift b/Sources/TelegramBotSDK/Generated/Types.swift index cac7ef1..f5913ff 100644 --- a/Sources/TelegramBotSDK/Generated/Types.swift +++ b/Sources/TelegramBotSDK/Generated/Types.swift @@ -109,6 +109,11 @@ public struct Update: JsonConvertible, InternalJsonConvertible { set { internalJson["poll"] = JSON(newValue.json) } } + public var pollAnswer: PollAnswer { + get { return PollAnswer(internalJson: internalJson["poll_answer"]) } + set { internalJson["poll_answer"] = JSON(newValue.json) } + } + internal init(internalJson: JSON = [:]) { self.internalJson = internalJson } @@ -223,6 +228,21 @@ public struct User: JsonConvertible, InternalJsonConvertible { set { internalJson["language_code"].string = newValue } } + public var canJoinGroups: Bool? { + get { return internalJson["can_join_groups"].bool } + set { internalJson["can_join_groups"].bool = newValue } + } + + public var canReadAllGroupMessages: Bool? { + get { return internalJson["can_read_all_group_messages"].bool } + set { internalJson["can_read_all_group_messages"].bool = newValue } + } + + public var supportsInlineQueries: Bool? { + get { return internalJson["supports_inline_queries"].bool } + set { internalJson["supports_inline_queries"].bool = newValue } + } + internal init(internalJson: JSON = [:]) { self.internalJson = internalJson } @@ -749,6 +769,11 @@ public struct MessageEntity: JsonConvertible, InternalJsonConvertible { } } + public var language: String? { + get { return internalJson["language"].string } + set { internalJson["language"].string = newValue } + } + internal init(internalJson: JSON = [:]) { self.internalJson = internalJson } @@ -1336,6 +1361,43 @@ public struct PollOption: JsonConvertible, InternalJsonConvertible { } +public struct PollAnswer: JsonConvertible, InternalJsonConvertible { + /// Original JSON for fields not yet added to Swift structures. + public var json: Any { + get { return internalJson.object } + set { internalJson = JSON(newValue) } + } + internal var internalJson: JSON + public var pollId: String { + get { return internalJson["poll_id"].stringValue } + set { internalJson["poll_id"].stringValue = newValue } + } + + public var user: User { + get { return User(internalJson: internalJson["user"]) } + set { internalJson["user"] = JSON(newValue.json) } + } + + public var optionIds: Int { + get { return internalJson["option_ids"].intValue } + set { internalJson["option_ids"].intValue = newValue } + } + + internal init(internalJson: JSON = [:]) { + self.internalJson = internalJson + } + public init() { + self.internalJson = JSON() + } + public init(json: Any) { + self.internalJson = JSON(json) + } + public init(data: Data) { + self.internalJson = JSON(data: data) + } +} + + public struct Poll: JsonConvertible, InternalJsonConvertible { /// Original JSON for fields not yet added to Swift structures. public var json: Any { @@ -1358,11 +1420,36 @@ public struct Poll: JsonConvertible, InternalJsonConvertible { set { internalJson["options"] = JSON.initFrom(newValue) } } + public var totalVoterCount: Int { + get { return internalJson["total_voter_count"].intValue } + set { internalJson["total_voter_count"].intValue = newValue } + } + public var isClosed: Bool { get { return internalJson["is_closed"].boolValue } set { internalJson["is_closed"].boolValue = newValue } } + public var isAnonymous: Bool { + get { return internalJson["is_anonymous"].boolValue } + set { internalJson["is_anonymous"].boolValue = newValue } + } + + public var typeString: String { + get { return internalJson["type"].stringValue } + set { internalJson["type"].stringValue = newValue } + } + + public var allowsMultipleAnswers: Bool { + get { return internalJson["allows_multiple_answers"].boolValue } + set { internalJson["allows_multiple_answers"].boolValue = newValue } + } + + public var correctOptionId: Int? { + get { return internalJson["correct_option_id"].int } + set { internalJson["correct_option_id"].int = newValue } + } + internal init(internalJson: JSON = [:]) { self.internalJson = internalJson } @@ -1542,6 +1629,43 @@ public struct KeyboardButton: JsonConvertible, InternalJsonConvertible { set { internalJson["request_location"].bool = newValue } } + public var requestPoll: KeyboardButtonPollType? { + get { + let value = internalJson["request_poll"] + return value.isNullOrUnknown ? nil : KeyboardButtonPollType(internalJson: value) + } + set { + internalJson["request_poll"] = newValue?.internalJson ?? JSON.null + } + } + + internal init(internalJson: JSON = [:]) { + self.internalJson = internalJson + } + public init() { + self.internalJson = JSON() + } + public init(json: Any) { + self.internalJson = JSON(json) + } + public init(data: Data) { + self.internalJson = JSON(data: data) + } +} + + +public struct KeyboardButtonPollType: JsonConvertible, InternalJsonConvertible { + /// Original JSON for fields not yet added to Swift structures. + public var json: Any { + get { return internalJson.object } + set { internalJson = JSON(newValue) } + } + internal var internalJson: JSON + public var typeString: String? { + get { return internalJson["type"].string } + set { internalJson["type"].string = newValue } + } + internal init(internalJson: JSON = [:]) { self.internalJson = internalJson }