Skip to content

Commit e9390c4

Browse files
authored
Merge pull request #92 from cipi1965/api-v4.6
Support Telegram API v4.6
2 parents 66cee40 + 2f42248 commit e9390c4

File tree

3 files changed

+167
-0
lines changed

3 files changed

+167
-0
lines changed

API/TelegramAPIDefinition.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ fields:
1818
- shipping_query: ShippingQuery?
1919
- pre_checkout_query: PreCheckoutQuery?
2020
- poll: Poll
21+
- poll_answer: PollAnswer
2122

2223
---
2324
type: WebhookInfo
@@ -39,6 +40,9 @@ fields:
3940
- last_name: String?
4041
- username: String?
4142
- language_code: String?
43+
- can_join_groups: Bool?
44+
- can_read_all_group_messages: Bool?
45+
- supports_inline_queries: Bool?
4246

4347
---
4448
type: Chat
@@ -117,6 +121,7 @@ fields:
117121
- length: Int
118122
- url: String?
119123
- user: User?
124+
- language: String?
120125

121126
---
122127
type: PhotoSize
@@ -223,13 +228,25 @@ fields:
223228
- text: String
224229
- voter_count: Int
225230

231+
---
232+
type: PollAnswer
233+
fields:
234+
- poll_id: String
235+
- user: User
236+
- option_ids: Int[]
237+
226238
---
227239
type: Poll
228240
fields:
229241
- id: String
230242
- question: String
231243
- options: PollOption[]
244+
- total_voter_count: Int
232245
- is_closed: Bool
246+
- is_anonymous: Bool
247+
- type: String
248+
- allows_multiple_answers: Bool
249+
- correct_option_id: Int?
233250

234251
---
235252
type: UserProfilePhotos
@@ -259,6 +276,12 @@ fields:
259276
- text: String
260277
- request_contact: Bool?
261278
- request_location: Bool?
279+
- request_poll: KeyboardButtonPollType?
280+
281+
---
282+
type: KeyboardButtonPollType
283+
fields:
284+
- type: String?
262285

263286
---
264287
type: ReplyKeyboardRemove
@@ -1082,6 +1105,10 @@ parameters:
10821105
- chat_id: ChatId
10831106
- question: String
10841107
- options: String[]
1108+
- is_anonymous: Bool?
1109+
- type: String?
1110+
- correct_option_id: Int?
1111+
- is_closed: Bool?
10851112
- disable_notification: Bool?
10861113
- reply_to_message_id: Int?
10871114
- reply_markup: InlineKeyboardMarkup?

Sources/TelegramBotSDK/Generated/Methods.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,10 @@ public extension TelegramBot {
817817
chatId: ChatId,
818818
question: String,
819819
options: [String],
820+
isAnonymous: Bool? = nil,
821+
type: String? = nil,
822+
correctOptionId: Int? = nil,
823+
isClosed: Bool? = nil,
820824
disableNotification: Bool? = nil,
821825
replyToMessageId: Int? = nil,
822826
replyMarkup: InlineKeyboardMarkup? = nil,
@@ -825,6 +829,10 @@ public extension TelegramBot {
825829
"chat_id": chatId,
826830
"question": question,
827831
"options": options,
832+
"is_anonymous": isAnonymous,
833+
"type": type,
834+
"correct_option_id": correctOptionId,
835+
"is_closed": isClosed,
828836
"disable_notification": disableNotification,
829837
"reply_to_message_id": replyToMessageId,
830838
"reply_markup": replyMarkup])
@@ -834,6 +842,10 @@ public extension TelegramBot {
834842
chatId: ChatId,
835843
question: String,
836844
options: [String],
845+
isAnonymous: Bool? = nil,
846+
type: String? = nil,
847+
correctOptionId: Int? = nil,
848+
isClosed: Bool? = nil,
837849
disableNotification: Bool? = nil,
838850
replyToMessageId: Int? = nil,
839851
replyMarkup: InlineKeyboardMarkup? = nil,
@@ -844,6 +856,10 @@ public extension TelegramBot {
844856
"chat_id": chatId,
845857
"question": question,
846858
"options": options,
859+
"is_anonymous": isAnonymous,
860+
"type": type,
861+
"correct_option_id": correctOptionId,
862+
"is_closed": isClosed,
847863
"disable_notification": disableNotification,
848864
"reply_to_message_id": replyToMessageId,
849865
"reply_markup": replyMarkup],

Sources/TelegramBotSDK/Generated/Types.swift

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ public struct Update: JsonConvertible, InternalJsonConvertible {
109109
set { internalJson["poll"] = JSON(newValue.json) }
110110
}
111111

112+
public var pollAnswer: PollAnswer {
113+
get { return PollAnswer(internalJson: internalJson["poll_answer"]) }
114+
set { internalJson["poll_answer"] = JSON(newValue.json) }
115+
}
116+
112117
internal init(internalJson: JSON = [:]) {
113118
self.internalJson = internalJson
114119
}
@@ -223,6 +228,21 @@ public struct User: JsonConvertible, InternalJsonConvertible {
223228
set { internalJson["language_code"].string = newValue }
224229
}
225230

231+
public var canJoinGroups: Bool? {
232+
get { return internalJson["can_join_groups"].bool }
233+
set { internalJson["can_join_groups"].bool = newValue }
234+
}
235+
236+
public var canReadAllGroupMessages: Bool? {
237+
get { return internalJson["can_read_all_group_messages"].bool }
238+
set { internalJson["can_read_all_group_messages"].bool = newValue }
239+
}
240+
241+
public var supportsInlineQueries: Bool? {
242+
get { return internalJson["supports_inline_queries"].bool }
243+
set { internalJson["supports_inline_queries"].bool = newValue }
244+
}
245+
226246
internal init(internalJson: JSON = [:]) {
227247
self.internalJson = internalJson
228248
}
@@ -749,6 +769,11 @@ public struct MessageEntity: JsonConvertible, InternalJsonConvertible {
749769
}
750770
}
751771

772+
public var language: String? {
773+
get { return internalJson["language"].string }
774+
set { internalJson["language"].string = newValue }
775+
}
776+
752777
internal init(internalJson: JSON = [:]) {
753778
self.internalJson = internalJson
754779
}
@@ -1336,6 +1361,43 @@ public struct PollOption: JsonConvertible, InternalJsonConvertible {
13361361
}
13371362

13381363

1364+
public struct PollAnswer: JsonConvertible, InternalJsonConvertible {
1365+
/// Original JSON for fields not yet added to Swift structures.
1366+
public var json: Any {
1367+
get { return internalJson.object }
1368+
set { internalJson = JSON(newValue) }
1369+
}
1370+
internal var internalJson: JSON
1371+
public var pollId: String {
1372+
get { return internalJson["poll_id"].stringValue }
1373+
set { internalJson["poll_id"].stringValue = newValue }
1374+
}
1375+
1376+
public var user: User {
1377+
get { return User(internalJson: internalJson["user"]) }
1378+
set { internalJson["user"] = JSON(newValue.json) }
1379+
}
1380+
1381+
public var optionIds: Int {
1382+
get { return internalJson["option_ids"].intValue }
1383+
set { internalJson["option_ids"].intValue = newValue }
1384+
}
1385+
1386+
internal init(internalJson: JSON = [:]) {
1387+
self.internalJson = internalJson
1388+
}
1389+
public init() {
1390+
self.internalJson = JSON()
1391+
}
1392+
public init(json: Any) {
1393+
self.internalJson = JSON(json)
1394+
}
1395+
public init(data: Data) {
1396+
self.internalJson = JSON(data: data)
1397+
}
1398+
}
1399+
1400+
13391401
public struct Poll: JsonConvertible, InternalJsonConvertible {
13401402
/// Original JSON for fields not yet added to Swift structures.
13411403
public var json: Any {
@@ -1358,11 +1420,36 @@ public struct Poll: JsonConvertible, InternalJsonConvertible {
13581420
set { internalJson["options"] = JSON.initFrom(newValue) }
13591421
}
13601422

1423+
public var totalVoterCount: Int {
1424+
get { return internalJson["total_voter_count"].intValue }
1425+
set { internalJson["total_voter_count"].intValue = newValue }
1426+
}
1427+
13611428
public var isClosed: Bool {
13621429
get { return internalJson["is_closed"].boolValue }
13631430
set { internalJson["is_closed"].boolValue = newValue }
13641431
}
13651432

1433+
public var isAnonymous: Bool {
1434+
get { return internalJson["is_anonymous"].boolValue }
1435+
set { internalJson["is_anonymous"].boolValue = newValue }
1436+
}
1437+
1438+
public var typeString: String {
1439+
get { return internalJson["type"].stringValue }
1440+
set { internalJson["type"].stringValue = newValue }
1441+
}
1442+
1443+
public var allowsMultipleAnswers: Bool {
1444+
get { return internalJson["allows_multiple_answers"].boolValue }
1445+
set { internalJson["allows_multiple_answers"].boolValue = newValue }
1446+
}
1447+
1448+
public var correctOptionId: Int? {
1449+
get { return internalJson["correct_option_id"].int }
1450+
set { internalJson["correct_option_id"].int = newValue }
1451+
}
1452+
13661453
internal init(internalJson: JSON = [:]) {
13671454
self.internalJson = internalJson
13681455
}
@@ -1542,6 +1629,43 @@ public struct KeyboardButton: JsonConvertible, InternalJsonConvertible {
15421629
set { internalJson["request_location"].bool = newValue }
15431630
}
15441631

1632+
public var requestPoll: KeyboardButtonPollType? {
1633+
get {
1634+
let value = internalJson["request_poll"]
1635+
return value.isNullOrUnknown ? nil : KeyboardButtonPollType(internalJson: value)
1636+
}
1637+
set {
1638+
internalJson["request_poll"] = newValue?.internalJson ?? JSON.null
1639+
}
1640+
}
1641+
1642+
internal init(internalJson: JSON = [:]) {
1643+
self.internalJson = internalJson
1644+
}
1645+
public init() {
1646+
self.internalJson = JSON()
1647+
}
1648+
public init(json: Any) {
1649+
self.internalJson = JSON(json)
1650+
}
1651+
public init(data: Data) {
1652+
self.internalJson = JSON(data: data)
1653+
}
1654+
}
1655+
1656+
1657+
public struct KeyboardButtonPollType: JsonConvertible, InternalJsonConvertible {
1658+
/// Original JSON for fields not yet added to Swift structures.
1659+
public var json: Any {
1660+
get { return internalJson.object }
1661+
set { internalJson = JSON(newValue) }
1662+
}
1663+
internal var internalJson: JSON
1664+
public var typeString: String? {
1665+
get { return internalJson["type"].string }
1666+
set { internalJson["type"].string = newValue }
1667+
}
1668+
15451669
internal init(internalJson: JSON = [:]) {
15461670
self.internalJson = internalJson
15471671
}

0 commit comments

Comments
 (0)