teleruby 1.5.1 → 1.5.4

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.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.md +9 -0
  3. data/README.md +398 -0
  4. data/lib/api/all.rb +12 -0
  5. data/lib/api/delete_apis.rb +55 -0
  6. data/lib/api/get_apis.rb +162 -0
  7. data/lib/api/nstandard.rb +26 -0
  8. data/lib/api/other_apis.rb +225 -0
  9. data/lib/api/send_apis.rb +191 -0
  10. data/lib/api/set_apis.rb +130 -0
  11. data/lib/core_api.rb +41 -0
  12. data/lib/objects/all.rb +42 -0
  13. data/lib/objects/animation.rb +38 -0
  14. data/lib/objects/audio.rb +37 -0
  15. data/lib/objects/bot_command.rb +24 -0
  16. data/lib/objects/callback_query.rb +64 -0
  17. data/lib/objects/chat.rb +158 -0
  18. data/lib/objects/chat_member.rb +142 -0
  19. data/lib/objects/chat_permissions.rb +59 -0
  20. data/lib/objects/chat_photo.rb +37 -0
  21. data/lib/objects/chosen_inline_result.rb +43 -0
  22. data/lib/objects/contact.rb +37 -0
  23. data/lib/objects/dice.rb +21 -0
  24. data/lib/objects/document.rb +27 -0
  25. data/lib/objects/file.rb +32 -0
  26. data/lib/objects/game.rb +65 -0
  27. data/lib/objects/inline_query.rb +42 -0
  28. data/lib/objects/inlinekeyboardbutton.rb +59 -0
  29. data/lib/objects/inlinekeyboardmarkup.rb +30 -0
  30. data/lib/objects/location.rb +21 -0
  31. data/lib/objects/mask_position.rb +35 -0
  32. data/lib/objects/message.rb +378 -0
  33. data/lib/objects/message_entity.rb +93 -0
  34. data/lib/objects/order_info.rb +34 -0
  35. data/lib/objects/photo_size.rb +14 -0
  36. data/lib/objects/poll.rb +97 -0
  37. data/lib/objects/poll_answer.rb +29 -0
  38. data/lib/objects/poll_option.rb +22 -0
  39. data/lib/objects/pre_checkout_query.rb +48 -0
  40. data/lib/objects/same/common.rb +37 -0
  41. data/lib/objects/same/common_2.rb +38 -0
  42. data/lib/objects/shipping_address.rb +39 -0
  43. data/lib/objects/shipping_query.rb +32 -0
  44. data/lib/objects/sticker.rb +55 -0
  45. data/lib/objects/update.rb +174 -0
  46. data/lib/objects/user.rb +66 -0
  47. data/lib/objects/user_profile_photos.rb +35 -0
  48. data/lib/objects/venue.rb +40 -0
  49. data/lib/objects/video.rb +37 -0
  50. data/lib/objects/video_note.rb +48 -0
  51. data/lib/objects/voice.rb +20 -0
  52. data/lib/teleruby.rb +4 -40
  53. data/lib/teleruby/all_apis.rb +22 -0
  54. data/lib/teleruby/api/delete_apis.rb +58 -0
  55. data/lib/teleruby/api/get_apis.rb +172 -0
  56. data/lib/teleruby/api/nstandard.rb +27 -0
  57. data/lib/teleruby/api/other_apis.rb +241 -0
  58. data/lib/teleruby/api/send_apis.rb +206 -0
  59. data/lib/teleruby/api/set_apis.rb +137 -0
  60. data/lib/teleruby/core_api.rb +52 -0
  61. data/lib/teleruby/objects/all.rb +42 -0
  62. data/lib/teleruby/objects/animation.rb +40 -0
  63. data/lib/teleruby/objects/audio.rb +39 -0
  64. data/lib/teleruby/objects/bot_command.rb +24 -0
  65. data/lib/teleruby/objects/callback_query.rb +66 -0
  66. data/lib/teleruby/objects/chat.rb +164 -0
  67. data/lib/teleruby/objects/chat_member.rb +142 -0
  68. data/lib/teleruby/objects/chat_permissions.rb +59 -0
  69. data/lib/teleruby/objects/chat_photo.rb +37 -0
  70. data/lib/teleruby/objects/chosen_inline_result.rb +45 -0
  71. data/lib/teleruby/objects/contact.rb +37 -0
  72. data/lib/teleruby/objects/dice.rb +21 -0
  73. data/lib/teleruby/objects/document.rb +29 -0
  74. data/lib/teleruby/objects/file.rb +32 -0
  75. data/lib/teleruby/objects/game.rb +65 -0
  76. data/lib/teleruby/objects/inline_query.rb +44 -0
  77. data/lib/teleruby/objects/inlinekeyboardbutton.rb +59 -0
  78. data/lib/teleruby/objects/inlinekeyboardmarkup.rb +31 -0
  79. data/lib/teleruby/objects/location.rb +21 -0
  80. data/lib/teleruby/objects/mask_position.rb +35 -0
  81. data/lib/teleruby/objects/message.rb +400 -0
  82. data/lib/teleruby/objects/message_entity.rb +95 -0
  83. data/lib/teleruby/objects/order_info.rb +36 -0
  84. data/lib/teleruby/objects/photo_size.rb +14 -0
  85. data/lib/teleruby/objects/poll.rb +97 -0
  86. data/lib/teleruby/objects/poll_answer.rb +29 -0
  87. data/lib/teleruby/objects/poll_option.rb +22 -0
  88. data/lib/teleruby/objects/pre_checkout_query.rb +50 -0
  89. data/lib/teleruby/objects/same/common.rb +31 -0
  90. data/lib/teleruby/objects/same/common_2.rb +32 -0
  91. data/lib/teleruby/objects/shipping_address.rb +39 -0
  92. data/lib/teleruby/objects/shipping_query.rb +32 -0
  93. data/lib/teleruby/objects/sticker.rb +59 -0
  94. data/lib/teleruby/objects/update.rb +207 -0
  95. data/lib/teleruby/objects/user.rb +66 -0
  96. data/lib/teleruby/objects/user_profile_photos.rb +36 -0
  97. data/lib/teleruby/objects/venue.rb +40 -0
  98. data/lib/teleruby/objects/video.rb +39 -0
  99. data/lib/teleruby/objects/video_note.rb +50 -0
  100. data/lib/teleruby/objects/voice.rb +20 -0
  101. data/lib/teleruby/version.rb +3 -0
  102. data/msg.png +0 -0
  103. data/rdoc.png +0 -0
  104. data/teleruby.gemspec +9 -7
  105. metadata +109 -6
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ ##
5
+ # +Monday+, +August+ +24+ +2020+ +EAT+
6
+ # ===This object represents a chat photo.
7
+ class ChatPhoto
8
+ def initialize(photo) # :nodoc:
9
+ @photo = photo
10
+ end
11
+
12
+ # File identifier of small (160x160) chat photo. This file_id can be used
13
+ # only for photo download and only for as long as the photo is not changed.
14
+ def small_file_id
15
+ @photo.small_file_id
16
+ end
17
+
18
+ # Unique file identifier of small (160x160) chat photo, which is supposed
19
+ # to be the same over time and for different bots.
20
+ # Can't be used to download or reuse the file.
21
+ def small_file_unique_id
22
+ @photo.small_file_unique_id
23
+ end
24
+
25
+ # File identifier of big (640x640) chat photo. This file_id can be used
26
+ # only for photo download and only for as long as the photo is not changed.
27
+ def big_file_id
28
+ @photo.big_file_id
29
+ end
30
+
31
+ # Unique file identifier of big (640x640) chat photo, which is supposed
32
+ # to be the same over time and for different bots.
33
+ # Can't be used to download or reuse the file.
34
+ def big_file_unique_id
35
+ @photo.big_file_unique_id
36
+ end
37
+ end
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'user'
5
+ require_relative 'location'
6
+
7
+ # ===Represents a result of an inline query that was chosen by the user
8
+ # ====and sent to their chat partner.
9
+ class ChoseInlineResult
10
+ def initialize(result) # :nodoc:
11
+ @result = result
12
+ end
13
+
14
+ # The unique identifier for the result that was chosen.
15
+ def result_id
16
+ @result.result_id
17
+ end
18
+
19
+ # The user that chose the result.
20
+ def from
21
+ User.new(@result.from)
22
+ end
23
+
24
+ # +Optional+. Sender location, only for bots that require user location.
25
+ def location
26
+ lcation = @result.location
27
+ unless lcation.nil?
28
+ return Location.new(lcation)
29
+ end
30
+
31
+ false
32
+ end
33
+
34
+ # +Optional.+ Identifier of the sent inline message. Available only if
35
+ # there is an inline keyboard attached to the message. Will be also
36
+ # received in callback queries and can be used to edit the message.
37
+ def inline_message_id
38
+ @result.inline_message_id
39
+ end
40
+
41
+ # The query that was used to obtain the result.
42
+ def query
43
+ @result.query
44
+ end
45
+ end
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ ##
5
+ # +Monday+, +August+ +24+ +2020+ +EAT+
6
+ # ===This object represents a phone contact.
7
+ class Contact
8
+ def initialize(conta) # :nodoc:
9
+ @conta = conta
10
+ freeze
11
+ end
12
+
13
+ # Contact's phone number.
14
+ def phone_number
15
+ @conta.phone_number
16
+ end
17
+
18
+ # Contact's first name
19
+ def first_name
20
+ @conta.first_name
21
+ end
22
+
23
+ # +Optional+. Contact's last name
24
+ def last_name
25
+ @conta.last_name
26
+ end
27
+
28
+ # +Optional+. Contact's user identifier in Telegram
29
+ def user_id
30
+ @conta.user_id
31
+ end
32
+
33
+ # +Optional.+ Additional data about the contact in the form of a vCard
34
+ def vcard
35
+ @conta.vcard
36
+ end
37
+ end
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ # +Sunday+, +August+ +23+ +2020+ +EAT+
5
+
6
+ # ===This object represents an animated emoji that displays a random value.
7
+ class Dice
8
+ def initialize(dice) # :nodoc:
9
+ @dice = dice
10
+ end
11
+
12
+ # Emoji on which the dice throw animation is based.
13
+ def emoji
14
+ @dice.emoji
15
+ end
16
+
17
+ # Value of the dice
18
+ def value
19
+ @dice.value
20
+ end
21
+ end
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'same/common_2'
5
+ require_relative 'photo_size'
6
+
7
+ # +Sunday+, +August+ +23+ +2020+
8
+
9
+ # ===This object represents a general file (as opposed to Photo, Voice messages and Audio files).
10
+ # Extend Common2 clas.
11
+ class Document < Common2
12
+ def initialize(obj) # :nodoc:
13
+ super(obj)
14
+ end
15
+
16
+ # +Optional+. Original filename as defined by sender.
17
+ def file_name
18
+ @obj.file_name
19
+ end
20
+
21
+ def thumb
22
+ data = @obj.file_name
23
+ unless data.nil?
24
+ return PhotoSize.new(data)
25
+ end
26
+
27
+ false
28
+ end
29
+ end
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ ##
5
+ # +Monday+, +August+ +24+ +2020+
6
+ # ===This object represents a file ready to be downloaded.
7
+ class TFile
8
+ def initialize(file) # :nodoc:
9
+ @file = file
10
+ end
11
+
12
+ # Identifier for this file, which can be used to download or reuse the file.
13
+ def file_id
14
+ @file.file_id
15
+ end
16
+
17
+ # Unique identifier for this file, which is supposed to be the same over
18
+ # time and for different bots. Can't be used to download or reuse the file.
19
+ def file_unique_id
20
+ @file.file_unique_id
21
+ end
22
+
23
+ # +Optional+. File size, if known.
24
+ def file_size
25
+ @file.file_size
26
+ end
27
+
28
+ # +Optional+. File path.
29
+ def file_path
30
+ @file.file_path
31
+ end
32
+ end
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'animation'
5
+ require_relative 'photo_size'
6
+ require_relative 'message_entity'
7
+
8
+ # This object represents a game. Use BotFather to create and edit games,
9
+ # their short names will act as unique identifiers.
10
+ class Game
11
+ def initialize(game) # :nodoc:
12
+ @game = game
13
+ end
14
+
15
+ # Title of the game.
16
+ def title
17
+ @game.title
18
+ end
19
+
20
+ # Description of the game.
21
+ def description
22
+ @game.description
23
+ end
24
+
25
+ # +Optional.+ Brief description of the game or high scores included in
26
+ # the game message.
27
+ def text
28
+ @game.text
29
+ end
30
+
31
+ # +Optional+. Animation that will be displayed in the game message in
32
+ # chats. Upload via BotFather
33
+ def animation
34
+ @game.animation
35
+ end
36
+
37
+ # +Optional+. Special entities that appear in text, such as usernames,
38
+ # URLs, bot commands, etc.
39
+ def text_entities
40
+ t_ent = @game.text_entities
41
+ ary_ent = []
42
+ unless t_ent.empty?
43
+ t_ent.each do |ent|
44
+ ary_ent << MessageEntity.new(ent)
45
+ end
46
+ return ary_ent
47
+ end
48
+
49
+ false
50
+ end
51
+
52
+ # Photo that will be displayed in the game message in chats.
53
+ def photo
54
+ poto = @game.photo
55
+ ary_poto = []
56
+ unless poto.empty?
57
+ poto.each do |p|
58
+ ary_poto << PhotoSize.new(p)
59
+ end
60
+ return ary_poto
61
+ end
62
+
63
+ false
64
+ end
65
+ end
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'user'
5
+ require_relative 'location'
6
+
7
+ # This object represents an incoming inline query. When the user sends
8
+ # an empty query, your bot could return some default or trending results.
9
+ class InlineQuery
10
+ def initialize(query) # :nodoc:
11
+ @query = query
12
+ end
13
+
14
+ # Unique identifier for this query
15
+ def id
16
+ @query.id
17
+ end
18
+
19
+ # Sender.
20
+ # User object
21
+ def from
22
+ User.new(@query.from)
23
+ end
24
+
25
+ # +Optional+. Sender location, only for bots that request user location,
26
+ def location
27
+ lcation = @query.location
28
+ unless lcation.nil?
29
+ return Location.new(lcation)
30
+ end
31
+
32
+ false
33
+ end
34
+
35
+ # Text of the query (up to 256 characters)
36
+ def query
37
+ @query.query
38
+ end
39
+
40
+ # Offset of the results to be returned, can be controlled by the bot.
41
+ def offset
42
+ @query.offset
43
+ end
44
+ end
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ # ===This object represents one button of an inline keyboard.
5
+ # You must use exactly one of the optional fields.
6
+ class InlineKeyboardButton
7
+ def initialize(button) # :nodoc:
8
+ @button = button
9
+ end
10
+
11
+ # Label text on the button.
12
+ def text
13
+ @button.text
14
+ end
15
+
16
+ # +Optional+. HTTP or tg:// url to be opened when button is pressed
17
+ def url
18
+ @button.url
19
+ end
20
+
21
+ # +Optional+. An HTTP URL used to automatically authorize the user.
22
+ # Can be used as a replacement for the Telegram
23
+ # {Login Widget.}[https://core.telegram.org/widgets/login]
24
+ def login_url
25
+ @button.login_url
26
+ end
27
+
28
+ # +Optional+. Data to be sent in a CallbackQuery to the bot when
29
+ # button is pressed, 1-64 bytes.
30
+ def callback_data
31
+ @button.callback_data
32
+ end
33
+
34
+ # +Optional+. If set, pressing the button will prompt the user to
35
+ # select one of their chats, open that chat and insert the bot's
36
+ # username and the specified inline query in the input field.
37
+ # Can be empty, in which case just the bot's username will be inserted.
38
+ def switch_inline_query
39
+ @button.switch_inline_query
40
+ end
41
+
42
+ # +Optional.+ If set, pressing the button will insert the bot's username
43
+ # and the specified inline query in the current chat's input field.
44
+ # Can be empty, in which case only the bot's username will be inserted.
45
+ def switch_inline_query_current_chat
46
+ @button.switch_inline_query_current_chat
47
+ end
48
+
49
+ # +Optional+. Description of the game that will be launched when the
50
+ # user presses the button.
51
+ def callback_game
52
+ @button.callback_game
53
+ end
54
+
55
+ # +Optional+. Specify True, to send a Pay button.
56
+ def pay?
57
+ @button.pay
58
+ end
59
+ end
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'inlinekeyboardbutton'
5
+
6
+ # This object represents an inline keyboard that appears
7
+ # right next to the message it belongs to.
8
+ class InlineKeyboardMarkup
9
+ def initialize(mup) # :nodoc:
10
+ @mup = mup
11
+ end
12
+
13
+ # Array of button rows, each represented by an Array of
14
+ # InlineKeyboardButton objects.
15
+ def inline_keyboard
16
+ data = @mup.inline_keyboard
17
+ unless data.empty?
18
+ ary = []
19
+ data.each do |e|
20
+ ary2 = []
21
+ e.each do |f|
22
+ ary2 << InlineKeyboardButton.new(f)
23
+ end
24
+ ary << ary2
25
+ end
26
+ return ary
27
+ end
28
+
29
+ false
30
+ end
31
+ end
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ ##
5
+ # +Monday+, +August+ +24+ +2020+ +EAT+
6
+ # ===This object represents a point on the map
7
+ class Location
8
+ def initialize(location) # :nodoc:
9
+ @loc = location
10
+ end
11
+
12
+ # Longitude as defined by sender.
13
+ def longitude
14
+ @loc.longitude
15
+ end
16
+
17
+ # Latitude as defined by sender.
18
+ def latitude
19
+ @loc.latitude
20
+ end
21
+ end
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ # This object describes the position on faces where a mask should be
5
+ # placed by default.
6
+ class MaskPosition
7
+ def initialize(pos) # :nodoc:
8
+ @pos = pos
9
+ end
10
+
11
+ # The part of the face relative to which the mask should be placed.
12
+ # One of “forehead”, “eyes”, “mouth”, or “chin”.
13
+ def point
14
+ @pos.point
15
+ end
16
+
17
+ # Shift by X-axis measured in widths of the mask scaled to the face size,
18
+ # from left to right. For example, choosing -1.0 will place mask just to
19
+ # the left of the default mask position.
20
+ def x_shift
21
+ @pos.x_shift
22
+ end
23
+
24
+ # Shift by Y-axis measured in heights of the mask scaled to the face size,
25
+ # from top to bottom. For example, 1.0 will place the mask just below the
26
+ # default mask position.
27
+ def y_shift
28
+ @pos.y_shift
29
+ end
30
+
31
+ # Mask scaling coefficient. For example, 2.0 means double size.
32
+ def scale
33
+ @pos.scale
34
+ end
35
+ end