Skip to content

Commit

Permalink
Merge pull request #109 from cipi1965/support-new-apis
Browse files Browse the repository at this point in the history
Update to API v4.8
  • Loading branch information
cipi1965 authored Jun 3, 2020
2 parents b990fdf + e1875d3 commit 8dcac1b
Show file tree
Hide file tree
Showing 3 changed files with 224 additions and 9 deletions.
57 changes: 55 additions & 2 deletions API/TelegramAPIDefinition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ fields:
- video_note: VideoNote?
- caption: String?
- contact: Contact?
- dice: Dice?
- location: Location?
- venue: Venue?
- poll: Poll?
Expand Down Expand Up @@ -207,6 +208,12 @@ fields:
- user_id: Int64?
- vcard: String?

---
type: Dice
fields:
- emoji: String
- value: Int

---
type: Location
fields:
Expand Down Expand Up @@ -247,6 +254,10 @@ fields:
- type: PollType
- allows_multiple_answers: Bool
- correct_option_id: Int?
- explanation: String
- explanation_entities: MessageEntity[]?
- open_period: Int?
- close_date: Date?

---
type: UserProfilePhotos
Expand Down Expand Up @@ -374,6 +385,12 @@ fields:
- can_invite_users: Bool?
- can_pin_messages: Bool?

---
type: BotCommand
fields:
- command: String
- description: String

---
type: ResponseParameters
fields:
Expand Down Expand Up @@ -456,6 +473,7 @@ fields:
- is_animated: Bool
- contains_masks: Bool
- stickers: Sticker[]
- thumb: PhotoSize?

---
type: MaskPosition
Expand Down Expand Up @@ -1107,13 +1125,28 @@ parameters:
- options: String[]
- is_anonymous: Bool?
- type: PollType?
- allow_multiple_answers: Bool?
- correct_option_id: Int?
- explanation: String?
- explanation_parse_mode: ParseMode?
- open_period: Int?
- close_date: Date?
- is_closed: Bool?
- disable_notification: Bool?
- reply_to_message_id: Int?
- reply_markup: ReplyMarkup?
result: Message?

---
method: sendDice
parameters:
- chat_id: ChatId
- emoji: String?
- disable_notification: Bool?
- reply_to_message_id: Int?
- reply_markup: ReplyMarkup?
result: Message?

---
method: sendChatAction
parameters:
Expand Down Expand Up @@ -1290,6 +1323,16 @@ parameters:
- cache_time: Int?
result: Bool?

---
method: setMyCommands
parameters:
- commands: BotCommand[]
result: Bool?

---
method: getMyCommands
result: BotCommand[]?

---
method: editMessageText
parameters:
Expand Down Expand Up @@ -1376,7 +1419,8 @@ parameters:
- user_id: Int64
- name: String
- title: String
- png_sticker: FileInfo
- png_sticker: FileInfo?
- tgs_sticker: InputFile?
- emojis: String
- contains_masks: Bool?
- mask_position: Bool?
Expand All @@ -1387,7 +1431,8 @@ method: addStickerToSet
parameters:
- user_id: Int
- name: String
- png_sticker: FileInfo
- png_sticker: FileInfo?
- tgs_sticker: InputFile?
- emojis: String
- mask_position: MaskPosition?
result: Bool?
Expand All @@ -1405,6 +1450,14 @@ parameters:
- sticker: String
result: Bool?

---
method: setStickerSetThumb
parameters:
- name: String
- user_id: Int
- thumb: FileInfo?
result: Bool?

---
method: answerInlineQuery
parameters:
Expand Down
136 changes: 132 additions & 4 deletions Sources/TelegramBotSDK/Generated/Methods.swift
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,12 @@ public extension TelegramBot {
options: [String],
isAnonymous: Bool? = nil,
type: PollType? = nil,
allowMultipleAnswers: Bool? = nil,
correctOptionId: Int? = nil,
explanation: String? = nil,
explanationParseMode: ParseMode? = nil,
openPeriod: Int? = nil,
closeDate: Date? = nil,
isClosed: Bool? = nil,
disableNotification: Bool? = nil,
replyToMessageId: Int? = nil,
Expand All @@ -831,7 +836,12 @@ public extension TelegramBot {
"options": options,
"is_anonymous": isAnonymous,
"type": type,
"allow_multiple_answers": allowMultipleAnswers,
"correct_option_id": correctOptionId,
"explanation": explanation,
"explanation_parse_mode": explanationParseMode,
"open_period": openPeriod,
"close_date": closeDate,
"is_closed": isClosed,
"disable_notification": disableNotification,
"reply_to_message_id": replyToMessageId,
Expand All @@ -844,7 +854,12 @@ public extension TelegramBot {
options: [String],
isAnonymous: Bool? = nil,
type: PollType? = nil,
allowMultipleAnswers: Bool? = nil,
correctOptionId: Int? = nil,
explanation: String? = nil,
explanationParseMode: ParseMode? = nil,
openPeriod: Int? = nil,
closeDate: Date? = nil,
isClosed: Bool? = nil,
disableNotification: Bool? = nil,
replyToMessageId: Int? = nil,
Expand All @@ -858,10 +873,50 @@ public extension TelegramBot {
"options": options,
"is_anonymous": isAnonymous,
"type": type,
"allow_multiple_answers": allowMultipleAnswers,
"correct_option_id": correctOptionId,
"explanation": explanation,
"explanation_parse_mode": explanationParseMode,
"open_period": openPeriod,
"close_date": closeDate,
"is_closed": isClosed,
"disable_notification": disableNotification,
"reply_to_message_id": replyToMessageId,
"reply_markup": replyMarkup],
queue: queue, completion: completion)
}
typealias SendDiceCompletion = (_ result: Message?, _ error: DataTaskError?) -> ()

@discardableResult
func sendDiceSync(
chatId: ChatId,
emoji: String? = nil,
disableNotification: Bool? = nil,
replyToMessageId: Int? = nil,
replyMarkup: ReplyMarkup? = nil,
_ parameters: [String: Encodable?] = [:]) -> Message? {
return requestSync("sendDice", defaultParameters["sendDice"], parameters, [
"chat_id": chatId,
"emoji": emoji,
"disable_notification": disableNotification,
"reply_to_message_id": replyToMessageId,
"reply_markup": replyMarkup])
}

func sendDiceAsync(
chatId: ChatId,
emoji: String? = nil,
disableNotification: Bool? = nil,
replyToMessageId: Int? = nil,
replyMarkup: ReplyMarkup? = nil,
_ parameters: [String: Encodable?] = [:],
queue: DispatchQueue = .main,
completion: SendDiceCompletion? = nil) {
return requestAsync("sendDice", defaultParameters["sendDice"], parameters, [
"chat_id": chatId,
"emoji": emoji,
"disable_notification": disableNotification,
"reply_to_message_id": replyToMessageId,
"reply_markup": replyMarkup],
queue: queue, completion: completion)
}
Expand Down Expand Up @@ -1441,6 +1496,44 @@ public extension TelegramBot {
"cache_time": cacheTime],
queue: queue, completion: completion)
}
typealias SetMyCommandsCompletion = (_ result: Bool?, _ error: DataTaskError?) -> ()

@discardableResult
func setMyCommandsSync(
commands: [BotCommand],
_ parameters: [String: Encodable?] = [:]) -> Bool? {
return requestSync("setMyCommands", defaultParameters["setMyCommands"], parameters, [
"commands": commands])
}

func setMyCommandsAsync(
commands: [BotCommand],
_ parameters: [String: Encodable?] = [:],
queue: DispatchQueue = .main,
completion: SetMyCommandsCompletion? = nil) {
return requestAsync("setMyCommands", defaultParameters["setMyCommands"], parameters, [
"commands": commands],
queue: queue, completion: completion)
}
typealias GetMyCommandsCompletion = (_ result: [BotCommand]?, _ error: DataTaskError?) -> ()

@discardableResult
func getMyCommandsSync(

_ parameters: [String: Encodable?] = [:]) -> [BotCommand]? {
return requestSync("getMyCommands", defaultParameters["getMyCommands"], parameters, [
:])
}

func getMyCommandsAsync(

_ parameters: [String: Encodable?] = [:],
queue: DispatchQueue = .main,
completion: GetMyCommandsCompletion? = nil) {
return requestAsync("getMyCommands", defaultParameters["getMyCommands"], parameters, [
:],
queue: queue, completion: completion)
}
typealias EditMessageTextCompletion = (_ result: MessageOrBool?, _ error: DataTaskError?) -> ()

@discardableResult
Expand Down Expand Up @@ -1723,7 +1816,8 @@ public extension TelegramBot {
userId: Int64,
name: String,
title: String,
pngSticker: FileInfo,
pngSticker: FileInfo? = nil,
tgsSticker: InputFile? = nil,
emojis: String,
containsMasks: Bool? = nil,
maskPosition: Bool? = nil,
Expand All @@ -1733,6 +1827,7 @@ public extension TelegramBot {
"name": name,
"title": title,
"png_sticker": pngSticker,
"tgs_sticker": tgsSticker,
"emojis": emojis,
"contains_masks": containsMasks,
"mask_position": maskPosition])
Expand All @@ -1742,7 +1837,8 @@ public extension TelegramBot {
userId: Int64,
name: String,
title: String,
pngSticker: FileInfo,
pngSticker: FileInfo? = nil,
tgsSticker: InputFile? = nil,
emojis: String,
containsMasks: Bool? = nil,
maskPosition: Bool? = nil,
Expand All @@ -1754,6 +1850,7 @@ public extension TelegramBot {
"name": name,
"title": title,
"png_sticker": pngSticker,
"tgs_sticker": tgsSticker,
"emojis": emojis,
"contains_masks": containsMasks,
"mask_position": maskPosition],
Expand All @@ -1765,22 +1862,25 @@ public extension TelegramBot {
func addStickerToSetSync(
userId: Int,
name: String,
pngSticker: FileInfo,
pngSticker: FileInfo? = nil,
tgsSticker: InputFile? = nil,
emojis: String,
maskPosition: MaskPosition? = nil,
_ parameters: [String: Encodable?] = [:]) -> Bool? {
return requestSync("addStickerToSet", defaultParameters["addStickerToSet"], parameters, [
"user_id": userId,
"name": name,
"png_sticker": pngSticker,
"tgs_sticker": tgsSticker,
"emojis": emojis,
"mask_position": maskPosition])
}

func addStickerToSetAsync(
userId: Int,
name: String,
pngSticker: FileInfo,
pngSticker: FileInfo? = nil,
tgsSticker: InputFile? = nil,
emojis: String,
maskPosition: MaskPosition? = nil,
_ parameters: [String: Encodable?] = [:],
Expand All @@ -1790,6 +1890,7 @@ public extension TelegramBot {
"user_id": userId,
"name": name,
"png_sticker": pngSticker,
"tgs_sticker": tgsSticker,
"emojis": emojis,
"mask_position": maskPosition],
queue: queue, completion: completion)
Expand Down Expand Up @@ -1836,6 +1937,33 @@ public extension TelegramBot {
"sticker": sticker],
queue: queue, completion: completion)
}
typealias SetStickerSetThumbCompletion = (_ result: Bool?, _ error: DataTaskError?) -> ()

@discardableResult
func setStickerSetThumbSync(
name: String,
userId: Int,
thumb: FileInfo? = nil,
_ parameters: [String: Encodable?] = [:]) -> Bool? {
return requestSync("setStickerSetThumb", defaultParameters["setStickerSetThumb"], parameters, [
"name": name,
"user_id": userId,
"thumb": thumb])
}

func setStickerSetThumbAsync(
name: String,
userId: Int,
thumb: FileInfo? = nil,
_ parameters: [String: Encodable?] = [:],
queue: DispatchQueue = .main,
completion: SetStickerSetThumbCompletion? = nil) {
return requestAsync("setStickerSetThumb", defaultParameters["setStickerSetThumb"], parameters, [
"name": name,
"user_id": userId,
"thumb": thumb],
queue: queue, completion: completion)
}
typealias AnswerInlineQueryCompletion = (_ result: Bool?, _ error: DataTaskError?) -> ()

@discardableResult
Expand Down
Loading

0 comments on commit 8dcac1b

Please sign in to comment.