grammerb 0.1.0-x86_64-linux

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,530 @@
1
+ # lib/grammerb/types.rb
2
+ module Grammerb
3
+ module Types
4
+ class Button
5
+ attr_reader :text, :callback_data, :url, :switch_inline, :web_app_url
6
+
7
+ def initialize(hash)
8
+ @text = hash[:text]
9
+ @callback_data = hash[:callback_data]
10
+ @url = hash[:url]
11
+ @switch_inline = hash[:switch_inline]
12
+ @web_app_url = hash[:web_app_url]
13
+ end
14
+
15
+ def callback?
16
+ !@callback_data.nil?
17
+ end
18
+
19
+ def url?
20
+ !@url.nil?
21
+ end
22
+
23
+ def web_app?
24
+ !@web_app_url.nil?
25
+ end
26
+
27
+ def data_str
28
+ @data_str_cache ||= @callback_data&.pack("C*")&.force_encoding("UTF-8")
29
+ end
30
+
31
+ def ==(other)
32
+ other.is_a?(Button) && @text == other.text && @callback_data == other.callback_data &&
33
+ @url == other.url && @switch_inline == other.switch_inline && @web_app_url == other.web_app_url
34
+ end
35
+ alias_method :eql?, :==
36
+
37
+ def hash
38
+ [@text, @callback_data, @url, @switch_inline, @web_app_url].hash
39
+ end
40
+
41
+ def to_h
42
+ { text: @text, callback_data: @callback_data, url: @url, switch_inline: @switch_inline, web_app_url: @web_app_url }.compact
43
+ end
44
+
45
+ def to_s
46
+ @text.to_s
47
+ end
48
+ end
49
+
50
+ class Message
51
+ attr_reader :id, :text, :chat_id, :chat_name, :sender_id, :sender_name, :date,
52
+ :chat_type, :grouped_id, :reply_to_message_id, :buttons,
53
+ :media_type, :media_id, :media_file_name, :media_mime_type,
54
+ :media_size, :media_duration, :media_width, :media_height,
55
+ :media_sticker_emoji
56
+ attr_accessor :client, :raw
57
+
58
+ def initialize(hash)
59
+ @raw = hash
60
+ @id = hash[:id] || hash[:message_id]
61
+ @text = hash[:text] || hash[:message_text]
62
+ @chat_id = hash[:chat_id]
63
+ @chat_name = hash[:chat_name]
64
+ @sender_id = hash[:sender_id]
65
+ @sender_name = hash[:sender_name]
66
+ @date = hash[:date] ? Time.at(hash[:date]) : nil
67
+ @chat_type = hash[:chat_type]
68
+ @grouped_id = hash[:grouped_id]
69
+ @reply_to_message_id = hash[:reply_to_message_id]
70
+ # Media
71
+ @media_type = hash[:media_type]
72
+ @media_id = hash[:media_id]
73
+ @media_file_name = hash[:media_file_name]
74
+ @media_mime_type = hash[:media_mime_type]
75
+ @media_size = hash[:media_size]
76
+ @media_duration = hash[:media_duration]
77
+ @media_width = hash[:media_width]
78
+ @media_height = hash[:media_height]
79
+ @media_sticker_emoji = hash[:media_sticker_emoji]
80
+ # Buttons
81
+ @buttons = (hash[:buttons] || []).map do |row|
82
+ row.map { |b| Button.new(b) }
83
+ end
84
+ end
85
+
86
+ def has_buttons?
87
+ !@buttons.empty?
88
+ end
89
+
90
+ def has_media?
91
+ !@media_type.nil?
92
+ end
93
+
94
+ def photo?
95
+ @media_type == "photo"
96
+ end
97
+
98
+ def document?
99
+ @media_type == "document"
100
+ end
101
+
102
+ def sticker?
103
+ @media_type == "sticker"
104
+ end
105
+
106
+ def poll?
107
+ @media_type == "poll"
108
+ end
109
+
110
+ def album?
111
+ !@grouped_id.nil?
112
+ end
113
+
114
+ def peer_id
115
+ @chat_id.to_s
116
+ end
117
+
118
+ # Action methods (require client to be set)
119
+ def reply(text, **opts)
120
+ @client&.send_message(chat_id, text, reply_to: id, **opts)
121
+ end
122
+
123
+ def edit(new_text, parse_mode: nil, buttons: nil, reply_markup: nil)
124
+ @client&.edit_message(chat_id, id, new_text, parse_mode: parse_mode, buttons: buttons, reply_markup: reply_markup)
125
+ end
126
+
127
+ def delete
128
+ @client&.delete_messages(chat_id, id)
129
+ end
130
+
131
+ def forward(to_chat)
132
+ @client&.forward_messages(chat_id, [id], to_chat)
133
+ end
134
+
135
+ def pin
136
+ @client&.pin_message(chat_id, id)
137
+ end
138
+
139
+ def download(path, &progress)
140
+ @client&.download_media(chat_id, id, path, &progress)
141
+ end
142
+
143
+ def ==(other)
144
+ other.is_a?(Message) && @id == other.id && @chat_id == other.chat_id
145
+ end
146
+ alias_method :eql?, :==
147
+
148
+ def hash
149
+ [@id, @chat_id].hash
150
+ end
151
+
152
+ def to_h
153
+ { id: @id, text: @text, chat_id: @chat_id, chat_name: @chat_name,
154
+ sender_id: @sender_id, sender_name: @sender_name,
155
+ date: @date, chat_type: @chat_type, grouped_id: @grouped_id,
156
+ reply_to_message_id: @reply_to_message_id,
157
+ media_type: @media_type, media_id: @media_id,
158
+ media_file_name: @media_file_name, media_mime_type: @media_mime_type,
159
+ media_size: @media_size, media_duration: @media_duration,
160
+ media_width: @media_width, media_height: @media_height,
161
+ media_sticker_emoji: @media_sticker_emoji,
162
+ buttons: @buttons.map { |row| row.map(&:to_h) } }.compact
163
+ end
164
+
165
+ def to_s
166
+ text.to_s
167
+ end
168
+ end
169
+
170
+ class User
171
+ attr_reader :id, :first_name, :last_name, :username, :phone, :bot
172
+
173
+ def initialize(hash)
174
+ @id = hash[:id]
175
+ @first_name = hash[:first_name]
176
+ @last_name = hash[:last_name]
177
+ @username = hash[:username]
178
+ @phone = hash[:phone]
179
+ @bot = hash[:bot]
180
+ end
181
+
182
+ def bot?
183
+ @bot
184
+ end
185
+
186
+ def full_name
187
+ [@first_name, @last_name].compact.join(" ")
188
+ end
189
+
190
+ def peer_id
191
+ @id.to_s
192
+ end
193
+
194
+ def ==(other)
195
+ other.is_a?(User) && @id == other.id
196
+ end
197
+ alias_method :eql?, :==
198
+
199
+ def hash
200
+ @id.hash
201
+ end
202
+
203
+ def to_h
204
+ { id: @id, first_name: @first_name, last_name: @last_name, username: @username, phone: @phone, bot: @bot }.compact
205
+ end
206
+
207
+ def to_s
208
+ full_name
209
+ end
210
+ end
211
+
212
+ class Dialog
213
+ attr_reader :name, :id, :peer_type, :unread_count, :last_message_text
214
+
215
+ def initialize(hash)
216
+ @name = hash[:name]
217
+ @id = hash[:id]
218
+ @peer_type = hash[:peer_type]
219
+ @unread_count = hash[:unread_count]
220
+ @last_message_text = hash[:last_message_text]
221
+ end
222
+
223
+ def peer_id
224
+ @id.to_s
225
+ end
226
+
227
+ def ==(other)
228
+ other.is_a?(Dialog) && @id == other.id
229
+ end
230
+ alias_method :eql?, :==
231
+
232
+ def hash
233
+ @id.hash
234
+ end
235
+
236
+ def to_h
237
+ { name: @name, id: @id, peer_type: @peer_type, unread_count: @unread_count, last_message_text: @last_message_text }.compact
238
+ end
239
+
240
+ def to_s
241
+ name.to_s
242
+ end
243
+ end
244
+
245
+ class Participant
246
+ attr_reader :id, :first_name, :last_name, :username
247
+
248
+ def initialize(hash)
249
+ @id = hash[:id]
250
+ @first_name = hash[:first_name]
251
+ @last_name = hash[:last_name]
252
+ @username = hash[:username]
253
+ end
254
+
255
+ def full_name
256
+ [@first_name, @last_name].compact.join(" ")
257
+ end
258
+
259
+ def peer_id
260
+ @id.to_s
261
+ end
262
+
263
+ def ==(other)
264
+ other.is_a?(Participant) && @id == other.id
265
+ end
266
+ alias_method :eql?, :==
267
+
268
+ def hash
269
+ @id.hash
270
+ end
271
+
272
+ def to_h
273
+ { id: @id, first_name: @first_name, last_name: @last_name, username: @username }.compact
274
+ end
275
+
276
+ def to_s
277
+ full_name
278
+ end
279
+ end
280
+
281
+ class Peer
282
+ attr_reader :id, :name, :peer_type
283
+
284
+ def initialize(hash)
285
+ @id = hash[:id]
286
+ @name = hash[:name]
287
+ @peer_type = hash[:peer_type]
288
+ end
289
+
290
+ def peer_id
291
+ @id.to_s
292
+ end
293
+
294
+ def ==(other)
295
+ other.is_a?(Peer) && @id == other.id
296
+ end
297
+ alias_method :eql?, :==
298
+
299
+ def hash
300
+ @id.hash
301
+ end
302
+
303
+ def to_h
304
+ { id: @id, name: @name, peer_type: @peer_type }.compact
305
+ end
306
+
307
+ def to_s
308
+ name.to_s
309
+ end
310
+ end
311
+
312
+ class Permissions
313
+ attr_reader :is_admin, :is_creator, :is_banned, :has_default_permissions
314
+
315
+ def initialize(hash)
316
+ @is_admin = hash[:is_admin]
317
+ @is_creator = hash[:is_creator]
318
+ @is_banned = hash[:is_banned]
319
+ @has_default_permissions = hash[:has_default_permissions]
320
+ end
321
+
322
+ def admin?
323
+ @is_admin
324
+ end
325
+
326
+ def creator?
327
+ @is_creator
328
+ end
329
+
330
+ def banned?
331
+ @is_banned
332
+ end
333
+
334
+ def ==(other)
335
+ other.is_a?(Permissions) && @is_admin == other.is_admin && @is_creator == other.is_creator && @is_banned == other.is_banned
336
+ end
337
+ alias_method :eql?, :==
338
+
339
+ def hash
340
+ [@is_admin, @is_creator, @is_banned].hash
341
+ end
342
+
343
+ def to_h
344
+ { is_admin: @is_admin, is_creator: @is_creator, is_banned: @is_banned, has_default_permissions: @has_default_permissions }
345
+ end
346
+ end
347
+
348
+ class PollResults
349
+ attr_reader :total_voters, :results, :solution
350
+
351
+ def initialize(hash)
352
+ @total_voters = hash[:total_voters]
353
+ @results = (hash[:results] || []).map { |r| PollOption.new(r) }
354
+ @solution = hash[:solution]
355
+ end
356
+
357
+ def to_h
358
+ { total_voters: @total_voters, results: @results.map(&:to_h), solution: @solution }.compact
359
+ end
360
+
361
+ def to_s
362
+ "PollResults(voters=#{@total_voters})"
363
+ end
364
+ end
365
+
366
+ class PollOption
367
+ attr_reader :option, :voters, :chosen, :correct
368
+
369
+ def initialize(hash)
370
+ @option = hash[:option]
371
+ @voters = hash[:voters]
372
+ @chosen = hash[:chosen]
373
+ @correct = hash[:correct]
374
+ end
375
+
376
+ def chosen?
377
+ @chosen
378
+ end
379
+
380
+ def correct?
381
+ @correct
382
+ end
383
+
384
+ def to_h
385
+ { option: @option, voters: @voters, chosen: @chosen, correct: @correct }
386
+ end
387
+
388
+ def to_s
389
+ "PollOption(voters=#{@voters})"
390
+ end
391
+ end
392
+
393
+ class PollVotes
394
+ attr_reader :count, :votes, :next_offset
395
+
396
+ def initialize(hash)
397
+ @count = hash[:count]
398
+ @votes = (hash[:votes] || []).map { |v| PollVote.new(v) }
399
+ @next_offset = hash[:next_offset]
400
+ end
401
+
402
+ def to_h
403
+ { count: @count, votes: @votes.map(&:to_h), next_offset: @next_offset }.compact
404
+ end
405
+
406
+ def to_s
407
+ "PollVotes(count=#{@count})"
408
+ end
409
+ end
410
+
411
+ class PollVote
412
+ attr_reader :peer_id, :options, :date
413
+
414
+ def initialize(hash)
415
+ @peer_id = hash[:peer_id]
416
+ @options = hash[:options] || []
417
+ @date = hash[:date] ? Time.at(hash[:date]) : nil
418
+ end
419
+
420
+ def to_h
421
+ { peer_id: @peer_id, options: @options, date: @date }
422
+ end
423
+
424
+ def to_s
425
+ "PollVote(peer=#{@peer_id})"
426
+ end
427
+ end
428
+
429
+ class Draft
430
+ attr_reader :peer_id, :text, :date, :reply_to_msg_id
431
+
432
+ def initialize(hash)
433
+ @peer_id = hash[:peer_id]
434
+ @text = hash[:text]
435
+ @date = hash[:date] ? Time.at(hash[:date]) : nil
436
+ @reply_to_msg_id = hash[:reply_to_msg_id]
437
+ end
438
+
439
+ def to_h
440
+ { peer_id: @peer_id, text: @text, date: @date, reply_to_msg_id: @reply_to_msg_id }.compact
441
+ end
442
+
443
+ def to_s
444
+ "Draft(peer=#{@peer_id}, #{@text&.slice(0, 30)})"
445
+ end
446
+ end
447
+
448
+ class AdminLogEvent
449
+ attr_reader :id, :date, :user_id, :action
450
+
451
+ def initialize(hash)
452
+ @id = hash[:id]
453
+ @date = hash[:date] ? Time.at(hash[:date]) : nil
454
+ @user_id = hash[:user_id]
455
+ @action = hash[:action]
456
+ end
457
+
458
+ def to_h
459
+ { id: @id, date: @date, user_id: @user_id, action: @action }
460
+ end
461
+
462
+ def to_s
463
+ "AdminLogEvent(#{@action}, user=#{@user_id})"
464
+ end
465
+ end
466
+
467
+ class InlineResult
468
+ attr_reader :id, :title, :description
469
+
470
+ def initialize(hash)
471
+ @id = hash[:id]
472
+ @title = hash[:title]
473
+ @description = hash[:description]
474
+ end
475
+
476
+ def to_h
477
+ { id: @id, title: @title, description: @description }.compact
478
+ end
479
+
480
+ def to_s
481
+ @title.to_s
482
+ end
483
+ end
484
+
485
+ class ChatFull
486
+ attr_reader :id, :about, :participants_count, :admins_count,
487
+ :kicked_count, :banned_count, :online_count,
488
+ :pinned_msg_id, :linked_chat_id, :slowmode_seconds,
489
+ :can_view_participants, :can_set_username
490
+
491
+ def initialize(hash)
492
+ @id = hash[:id]
493
+ @about = hash[:about]
494
+ @participants_count = hash[:participants_count]
495
+ @admins_count = hash[:admins_count]
496
+ @kicked_count = hash[:kicked_count]
497
+ @banned_count = hash[:banned_count]
498
+ @online_count = hash[:online_count]
499
+ @pinned_msg_id = hash[:pinned_msg_id]
500
+ @linked_chat_id = hash[:linked_chat_id]
501
+ @slowmode_seconds = hash[:slowmode_seconds]
502
+ @can_view_participants = hash[:can_view_participants]
503
+ @can_set_username = hash[:can_set_username]
504
+ end
505
+
506
+ def ==(other)
507
+ other.is_a?(ChatFull) && @id == other.id
508
+ end
509
+ alias_method :eql?, :==
510
+
511
+ def hash
512
+ @id.hash
513
+ end
514
+
515
+ def to_h
516
+ { id: @id, about: @about, participants_count: @participants_count,
517
+ admins_count: @admins_count, kicked_count: @kicked_count,
518
+ banned_count: @banned_count, online_count: @online_count,
519
+ pinned_msg_id: @pinned_msg_id, linked_chat_id: @linked_chat_id,
520
+ slowmode_seconds: @slowmode_seconds,
521
+ can_view_participants: @can_view_participants,
522
+ can_set_username: @can_set_username }.compact
523
+ end
524
+
525
+ def to_s
526
+ "ChatFull(id=#{@id}, about=#{@about&.slice(0, 50)})"
527
+ end
528
+ end
529
+ end
530
+ end
@@ -0,0 +1,4 @@
1
+ # lib/grammerb/version.rb
2
+ module Grammerb
3
+ VERSION = "0.1.0"
4
+ end
data/lib/grammerb.rb ADDED
@@ -0,0 +1,19 @@
1
+ # lib/grammerb.rb
2
+ require_relative "grammerb/version"
3
+
4
+ begin
5
+ RUBY_VERSION =~ /(\d+\.\d+)/
6
+ require_relative "grammerb/#{$1}/grammerb"
7
+ rescue LoadError
8
+ begin
9
+ require_relative "grammerb/grammerb"
10
+ rescue LoadError
11
+ raise LoadError, "Failed to load Grammerb native extension. Run `rake compile` first."
12
+ end
13
+ end
14
+
15
+ require_relative "grammerb/errors"
16
+ require_relative "grammerb/types"
17
+ require_relative "grammerb/events"
18
+ require_relative "grammerb/conversation"
19
+ require_relative "grammerb/client"
@@ -0,0 +1,145 @@
1
+ module Grammerb
2
+ class HandlerPool
3
+ def initialize: (Integer size) -> void
4
+ def schedule: () { () -> void } -> void
5
+ def shutdown: () -> void
6
+ end
7
+
8
+ class Client
9
+ attr_reader native: untyped
10
+ attr_reader logger: Logger
11
+
12
+ def initialize: (api_id: Integer, api_hash: String, ?session: String, ?proxy: String?, ?logger: Logger?, ?pool_size: Integer) -> void
13
+
14
+ # --- Connection ---
15
+ def connect: () -> self
16
+ def disconnect: () -> void
17
+ def authorized?: () -> bool
18
+
19
+ # --- Auth ---
20
+ def start: (phone: String, ?code_callback: (^() -> String)?, ?password_callback: (^() -> String)?) -> self
21
+ def bot_start: (token: String) -> self
22
+ def sign_out: () -> void
23
+
24
+ # --- Messages ---
25
+ def send_message: (peer chat, String text, ?reply_to: Integer?, ?parse_mode: String?, ?silent: bool, ?link_preview: bool, ?schedule: Time?, ?comment_to: Integer?, ?send_as: peer?, ?buttons: button_rows?, ?reply_markup: reply_markup?) -> Types::Message
26
+ def edit_message: (peer chat, Integer message_id, String text, ?parse_mode: String?, ?link_preview: bool, ?buttons: button_rows?, ?reply_markup: reply_markup?) -> self
27
+ def delete_messages: (peer chat, *Integer message_ids, ?revoke: bool) -> void
28
+ def forward_messages: (peer from_chat, Array[Integer] message_ids, peer to_chat, ?silent: bool, ?schedule: Time?, ?drop_author: bool, ?noforwards: bool) -> Array[Types::Message?]
29
+ def get_messages: (peer chat, ?limit: Integer, ?offset_id: Integer?, ?offset_date: (Time | Integer)?) -> Array[Types::Message]
30
+ def get_messages_by_id: (peer chat, *Integer message_ids) -> Array[Types::Message?]
31
+ def pin_message: (peer chat, Integer message_id, ?notify: bool) -> void
32
+ def unpin_message: (peer chat, Integer message_id) -> void
33
+ def unpin_all_messages: (peer chat) -> void
34
+ def get_pinned_message: (peer chat) -> Types::Message?
35
+ def send_reactions: (peer chat, Integer message_id, *String reactions) -> void
36
+ def search_messages: (peer chat, ?query: String, ?limit: Integer, ?filter: String?, ?from_user: peer?) -> Array[Types::Message]
37
+ def search_all_messages: (?query: String, ?limit: Integer) -> Array[Types::Message]
38
+ def get_reply_to_message: (peer chat, Integer message_id) -> Types::Message?
39
+ def send_chat_action: (peer chat, String | Symbol action) -> void
40
+ def send_poll: (peer chat, String question, Array[String] answers, ?quiz: bool, ?correct_option: Integer?) -> Types::Message
41
+ def get_poll_results: (peer chat, Integer message_id) -> Types::PollResults
42
+ def get_poll_votes: (peer chat, Integer message_id, ?option: Integer?, ?limit: Integer) -> Types::PollVotes
43
+
44
+ # --- Dialogs ---
45
+ def iter_dialogs: (?limit: Integer) -> Array[Types::Dialog]
46
+ alias get_dialogs iter_dialogs
47
+ def delete_dialog: (peer chat) -> void
48
+ def mark_as_read: (peer chat) -> void
49
+ def send_read_acknowledge: (peer chat, ?untyped? message, ?max_id: Integer?) -> void
50
+ def iter_drafts: () -> Array[Types::Draft]
51
+ alias get_drafts iter_drafts
52
+ def clear_drafts: () -> void
53
+ def clear_mentions: (peer chat) -> void
54
+
55
+ # --- Users / Chats ---
56
+ def get_me: () -> Types::User
57
+ def get_entity: (peer entity) -> Types::Peer?
58
+ def edit_permissions: (peer chat, **bool rights) -> void
59
+ def resolve_username: (String username) -> Types::Peer?
60
+ def iter_participants: (peer chat, ?limit: Integer, ?filter: String?, ?search: String?, ?aggressive: bool) -> Array[Types::Participant]
61
+ alias get_participants iter_participants
62
+ def kick_participant: (peer chat, peer user) -> void
63
+ def set_admin_rights: (peer chat, peer user, **bool rights) -> void
64
+ def set_banned_rights: (peer chat, peer user, **bool rights) -> void
65
+ def get_permissions: (peer chat, peer user) -> Types::Permissions
66
+ def iter_profile_photos: (peer chat, ?limit: Integer) -> Array[untyped]
67
+ def join_chat: (peer chat) -> (Types::Peer | void)
68
+ def accept_invite_link: (String link) -> Types::Peer?
69
+ def download_profile_photo: (peer entity, String path) -> bool
70
+ def iter_admin_log: (peer chat, ?limit: Integer, ?query: String?, ?filter: Hash[Symbol, bool]?) -> Array[Types::AdminLogEvent]
71
+ alias get_admin_log iter_admin_log
72
+ def edit_title: (peer chat, String title) -> void
73
+ def edit_photo: (peer chat, String path) -> void
74
+ def get_stats: (peer chat) -> untyped
75
+ def export_invite_link: (peer chat) -> String
76
+ def block_user: (peer user) -> void
77
+ def unblock_user: (peer user) -> void
78
+ def create_group: (String title, Array[peer] users) -> Types::Peer
79
+ def create_channel: (String title, ?about: String) -> Types::Peer
80
+ def create_supergroup: (String title, ?about: String) -> Types::Peer
81
+ def edit_about: (peer chat, String about) -> void
82
+ def get_full_chat: (peer chat) -> Types::ChatFull
83
+
84
+ # --- Keyboards ---
85
+ def send_reply_keyboard: (peer chat, String text, Array[Array[String | Hash[Symbol, untyped]]] keys, ?parse_mode: String?, ?resize: bool, ?single_use: bool, ?placeholder: String?) -> Types::Message
86
+ def remove_keyboard: (peer chat, ?String text, ?parse_mode: String?) -> Types::Message
87
+ def force_reply: (peer chat, String text, ?parse_mode: String?) -> Types::Message
88
+
89
+ # --- Files ---
90
+ def send_file: (peer chat, String path, ?caption: String?, ?parse_mode: String?, ?reply_to: Integer?, ?silent: bool, ?schedule: Time?, ?buttons: button_rows?, ?reply_markup: reply_markup?) -> Types::Message
91
+ def send_photo: (peer chat, String path, ?caption: String?, ?parse_mode: String?, ?reply_to: Integer?, ?silent: bool, ?schedule: Time?, ?buttons: button_rows?, ?reply_markup: reply_markup?) -> Types::Message
92
+ def send_audio: (peer chat, String path, ?caption: String?, ?parse_mode: String?, ?duration: Integer, ?title: String?, ?performer: String?, ?reply_to: Integer?, ?silent: bool, ?schedule: Time?, ?buttons: button_rows?, ?reply_markup: reply_markup?) -> Types::Message
93
+ def send_video: (peer chat, String path, ?caption: String?, ?parse_mode: String?, ?duration: Integer, ?width: Integer, ?height: Integer, ?supports_streaming: bool, ?round_message: bool, ?reply_to: Integer?, ?silent: bool, ?schedule: Time?, ?buttons: button_rows?, ?reply_markup: reply_markup?) -> Types::Message
94
+ def send_voice: (peer chat, String path, ?caption: String?, ?parse_mode: String?, ?duration: Integer, ?waveform: String?, ?reply_to: Integer?, ?silent: bool, ?schedule: Time?, ?buttons: button_rows?, ?reply_markup: reply_markup?) -> Types::Message
95
+ def send_album: (peer chat, *(String | Hash[Symbol, String]) media_items, ?reply_to: Integer?, ?silent: bool, ?buttons: button_rows?, ?reply_markup: reply_markup?) -> Array[Types::Message?]
96
+ def send_location: (peer chat, Float lat, Float long, ?accuracy_radius: Integer?, ?reply_to: Integer?, ?silent: bool, ?schedule: Time?, ?reply_markup: reply_markup?) -> Types::Message
97
+ def send_venue: (peer chat, Float lat, Float long, title: String, address: String, ?provider: String, ?venue_id: String, ?venue_type: String, ?reply_to: Integer?, ?silent: bool, ?schedule: Time?, ?reply_markup: reply_markup?) -> Types::Message
98
+ def send_contact: (peer chat, phone_number: String, first_name: String, ?last_name: String, ?vcard: String, ?reply_to: Integer?, ?silent: bool, ?schedule: Time?, ?reply_markup: reply_markup?) -> Types::Message
99
+ def send_dice: (peer chat, ?emoticon: String, ?reply_to: Integer?, ?silent: bool, ?schedule: Time?, ?reply_markup: reply_markup?) -> Types::Message
100
+ def send_sticker: (peer chat, String path, ?reply_to: Integer?, ?silent: bool, ?schedule: Time?, ?reply_markup: reply_markup?) -> Types::Message
101
+ def send_animation: (peer chat, String path, ?caption: String?, ?parse_mode: String?, ?duration: Integer, ?width: Integer, ?height: Integer, ?reply_to: Integer?, ?silent: bool, ?schedule: Time?, ?reply_markup: reply_markup?) -> Types::Message
102
+ def download_media: (peer chat, Integer message_id, String path) ?{ (Integer downloaded, Integer? total) -> void } -> void
103
+
104
+ # --- Bots ---
105
+ def inline_query: (peer bot, String query, ?limit: Integer) -> Array[Types::InlineResult]
106
+ def answer_callback_query: (Integer query_id, ?text: String?, ?alert: bool, ?cache_time: Integer?) -> void
107
+ def answer_inline_query: (Integer query_id, Array[Hash[Symbol, untyped]] results, ?cache_time: Integer?, ?is_personal: bool, ?next_offset: String?) -> void
108
+
109
+ # --- Payments ---
110
+ def send_invoice: (peer chat, title: String, description: String, payload: String, ?currency: String, amount: Integer, ?photo_url: String?) -> Types::Message?
111
+ def create_invoice_link: (title: String, description: String, payload: String, ?currency: String, amount: Integer) -> String
112
+ def answer_pre_checkout_query: (Integer query_id, ok: bool, ?error_message: String?) -> void
113
+ def refund_star_payment: (peer user_id, charge_id: String) -> bool
114
+ def get_star_transactions: (?offset: String, ?limit: Integer, ?inbound: bool, ?outbound: bool) -> Hash[Symbol, untyped]
115
+
116
+ # --- Sessions ---
117
+ def export_session: () -> String
118
+ def self.import_session: (String session_string, ?path: String) -> void
119
+ def save_session: () -> void
120
+
121
+ # --- Events ---
122
+ def on: (Class event_class, ?pattern: (Regexp | String)?, ?chats: (Array[peer] | peer)?) { (Events::Event) -> void } -> Events::Handler
123
+ def off: (Events::Handler handler) -> void
124
+ def run: () -> void
125
+ def stop: () -> void
126
+ def each_update: () { (Events::Event) -> void } -> void
127
+
128
+ # --- Conversations ---
129
+ def conversation: (peer chat, ?timeout: Integer, ?exclusive: bool) { (Conversation) -> void } -> Thread
130
+
131
+ # --- Raw TL ---
132
+ def invoke_raw: (String request_bytes) -> String
133
+
134
+ private
135
+
136
+ def safe_native: [T] () { () -> T } -> T
137
+ def peer_id: (untyped entity) -> String
138
+ def dispatch_event: (Events::Event event) -> void
139
+ def flush_album: (Array[Events::NewMessage]? events, Hash[Integer, Float] timers) -> void
140
+ def wrap_message: (Hash[Symbol, untyped] hash) -> Types::Message
141
+ def default_logger: () -> Logger
142
+ def build_buttons: (button_rows buttons) -> button_rows
143
+ def build_keys: (Array[Array[String | Hash[Symbol, untyped]]] keys) -> Array[Array[Hash[Symbol, untyped]]]
144
+ end
145
+ end