Skip to content

Commit

Permalink
Merge pull request #92 from cipi1965/api-v4.6
Browse files Browse the repository at this point in the history
Support Telegram API v4.6
  • Loading branch information
cipi1965 authored Jan 23, 2020
2 parents 66cee40 + 2f42248 commit e9390c4
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 0 deletions.
27 changes: 27 additions & 0 deletions API/TelegramAPIDefinition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ fields:
- shipping_query: ShippingQuery?
- pre_checkout_query: PreCheckoutQuery?
- poll: Poll
- poll_answer: PollAnswer

---
type: WebhookInfo
Expand All @@ -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
Expand Down Expand Up @@ -117,6 +121,7 @@ fields:
- length: Int
- url: String?
- user: User?
- language: String?

---
type: PhotoSize
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -259,6 +276,12 @@ fields:
- text: String
- request_contact: Bool?
- request_location: Bool?
- request_poll: KeyboardButtonPollType?

---
type: KeyboardButtonPollType
fields:
- type: String?

---
type: ReplyKeyboardRemove
Expand Down Expand Up @@ -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?
Expand Down
16 changes: 16 additions & 0 deletions Sources/TelegramBotSDK/Generated/Methods.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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])
Expand All @@ -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,
Expand All @@ -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],
Expand Down
124 changes: 124 additions & 0 deletions Sources/TelegramBotSDK/Generated/Types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit e9390c4

Please sign in to comment.