Skip to content

Commit 0355dad

Browse files
author
郭高虎
committedSep 3, 2021
Telegram Bot API update to 5.3 && fix generate_wrappers.rb
1 parent 17f7e60 commit 0355dad

File tree

114 files changed

+3267
-174
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+3267
-174
lines changed
 

‎API/generate_wrappers.rb

+21-4
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ def make_swift_type_name(var_name, var_type)
7373
if var_type == 'InputMediaAudio, InputMediaDocument, InputMediaPhoto and InputMediaVideo' then
7474
return "[InputMedia]"
7575
end
76+
if var_type == 'Integer' then
77+
return "[Int]"
78+
end
7679
return "[#{var_type}]"
7780
end
7881

@@ -165,8 +168,10 @@ def deduce_result_type(description)
165168
return "#{type_name}OrBoolean" unless type_name.nil?
166169

167170
type_name = description[/(\w+) is returned/, 1]
168-
return type_name unless type_name.nil?
169-
171+
if type_name != 'list' then
172+
return type_name unless type_name.nil?
173+
end
174+
170175
type_name = description[/Returns a (.+) object/, 1]
171176
return type_name unless type_name.nil?
172177

@@ -218,14 +223,16 @@ def convert_type(var_name, var_desc, var_type, type_name, var_optional)
218223
return "FileInfo"
219224
when ['Integer', true]
220225
is64bit = var_name.include?("user_id") || var_name.include?("chat_id") || var_desc.include?("64 bit integer") ||
221-
(type_name == 'User' && var_name == 'id')
226+
(type_name == 'User' && var_name == 'id') ||
227+
(type_name == 'Chat' && var_name == 'id')
222228
suffix = is64bit ? '64' : ''
223229
return "Int#{suffix}?"
224230
when ['Integer', false]
225231
is64bit = var_name.include?("user_id") ||
226232
var_name.include?("chat_id") ||
227233
var_desc.include?("64 bit integer") ||
228-
(type_name == 'User' && var_name == 'id')
234+
(type_name == 'User' && var_name == 'id') ||
235+
(type_name == 'Chat' && var_name == 'id')
229236
suffix = is64bit ? '64' : ''
230237
return "Int#{suffix}"
231238
when ['Float number', true], ['Float', true]
@@ -240,6 +247,16 @@ def convert_type(var_name, var_desc, var_type, type_name, var_optional)
240247
else
241248
return "Bool"
242249
end
250+
when ['Integer or String', true]
251+
if var_name.include?('chat_id') then
252+
return 'ChatId'
253+
end
254+
return 'String'
255+
when ['Integer or String', false]
256+
if var_name.include?('chat_id') then
257+
return 'ChatId?'
258+
end
259+
return 'String?'
243260
else
244261
two_d_array_prefix = 'Array of Array of '
245262
array_prefix = 'Array of '

‎Sources/Telegrammer/Bot/Telegram/Methods/Bot+addStickerToSet.swift

+12-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,18 @@ public extension Bot {
7171
#if compiler(>=5.5)
7272
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
7373
public extension Bot {
74-
74+
75+
/**
76+
Use this method to add a new sticker to a set created by the bot. You must use exactly one of the fields png_sticker or tgs_sticker. Animated stickers can be added to animated sticker sets and only to them. Animated sticker sets can have up to 50 stickers. Static sticker sets can have up to 120 stickers. Returns True on success.
77+
78+
SeeAlso Telegram Bot API Reference:
79+
[AddStickerToSetParams](https://core.telegram.org/bots/api#addstickertoset)
80+
81+
- Parameters:
82+
- params: Parameters container, see `AddStickerToSetParams` struct
83+
- Throws: Throws on errors
84+
- Returns: Future of `Bool` type
85+
*/
7586
@discardableResult
7687
func addStickerToSet(params: AddStickerToSetParams) async throws -> Bool {
7788
let body = try httpBody(for: params)

0 commit comments

Comments
 (0)
Please sign in to comment.