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,32 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'user'
5
+ require_relative 'shipping_address'
6
+
7
+ # ===This object contains information about an incoming shipping query.
8
+ class ShippingQuery
9
+ def initialize(query) # :nodoc:
10
+ @query = query
11
+ end
12
+
13
+ # Unique query identifier.
14
+ def id
15
+ @query.id
16
+ end
17
+
18
+ # User who sent the query.
19
+ def from
20
+ User.new(@query.from)
21
+ end
22
+
23
+ # Bot specified invoice payload.
24
+ def invoice_payload
25
+ @query.invoice_payload
26
+ end
27
+
28
+ # User specified shipping address.
29
+ def shipping_address
30
+ ShippingAddress.new(@query.shipping_address)
31
+ end
32
+ end
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'file'
5
+ require_relative 'photo_size'
6
+ require_relative 'mask_position'
7
+
8
+ ##
9
+ # This object represents a sticker.
10
+ # Extends from TFile
11
+ class Sticker < TFile
12
+ def initialize(sticker) # :nodoc:
13
+ super(sticker)
14
+ end
15
+
16
+ # Sticker width
17
+ def width
18
+ @file.width
19
+ end
20
+
21
+ # Sticker height
22
+ def height
23
+ @sticker.height
24
+ end
25
+
26
+ # True, if the sticker is animated
27
+ def animated?
28
+ @sticker.is_animated
29
+ end
30
+
31
+ # Optional. Sticker thumbnail in the .WEBP or .JPG format
32
+ def thumb
33
+ tmb = @sticker.thumb
34
+ return PhotoSize.new(tmb) if tmb
35
+
36
+ false
37
+ end
38
+
39
+ # Optional. Emoji associated with the sticker
40
+ def emoji
41
+ @sticker.emoji
42
+ end
43
+
44
+ # Optional. Name of the sticker set to which the sticker belongs.
45
+ def set_name
46
+ @sticker.set_name
47
+ end
48
+
49
+ def mask_position
50
+ msk_pos = @sticker.mask_position
51
+ return MaskPosition.new(msk_pos) if msk_pos
52
+
53
+ false
54
+ end
55
+ end
@@ -0,0 +1,174 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'message'
5
+ require_relative 'poll'
6
+ require_relative 'poll_answer'
7
+ require_relative 'callback_query'
8
+ require_relative 'chosen_inline_result'
9
+ require_relative 'inline_query'
10
+ require_relative 'pre_checkout_query'
11
+ require_relative 'shipping_query'
12
+
13
+ # ===This object represents an incoming update.
14
+ class Update
15
+ def initialize(update) # :nodoc:
16
+ @update = update
17
+ end
18
+
19
+
20
+ # The update's unique identifier. Update identifiers start from a
21
+ # certain positive number and increase sequentially. This ID becomes
22
+ # especially handy if you're using Webhooks, since it allows you to
23
+ # ignore repeated updates or to restore the correct update sequence,
24
+ # should they get out of order. If there are no new updates for at
25
+ # least a week, then identifier of the next update will be chosen
26
+ # randomly instead of sequentially.
27
+ def update_id
28
+ @update.update_id
29
+ end
30
+
31
+ # New incoming message of any kind — text, photo, sticker, etc else
32
+ # false is returned.
33
+ # returns Message object
34
+ def message
35
+ msg = @update.message
36
+ return Message.new(msg) if msg
37
+
38
+ false
39
+ end
40
+
41
+ # New version of a message that is known to the bot and was edited else
42
+ # false is returned.
43
+ def edited_message
44
+ e_msg = @update.edited_message
45
+ return Message.new(e_msg) if e_msg
46
+
47
+ false
48
+ end
49
+
50
+ # New incoming channel post of any kind — text, photo, sticker, etc else
51
+ # false is returned.
52
+ def channel_post
53
+ c_post = @update.channel_post
54
+ return Message.new(c_post) if c_post
55
+
56
+ false
57
+ end
58
+
59
+ # New version of a channel post that is known to the bot and was edited.
60
+ # else false is returned.
61
+ def edited_channel_post
62
+ c_post = @update.edited_channel_post
63
+ return Message.new(e_c_post) if c_post
64
+
65
+ false
66
+ end
67
+
68
+ # +Optional.+ New incoming inline query.
69
+ def inline_query
70
+ i_query = @update.inline_query
71
+ return InlineQuery.new(i_query) if i_query
72
+
73
+ false
74
+ end
75
+
76
+ # +Optional.+ The result of an inline query that was chosen by a user
77
+ # and sent to their chat partner. Please see our documentation on the
78
+ # feedback collecting for details on how to enable these updates for
79
+ # your bot.
80
+ def chosen_inline_result
81
+ inline_result = @update.chosen_inline_result
82
+ return ChoseInlineResult.new(inline_result) if inline_result
83
+
84
+ false
85
+ end
86
+
87
+ # +Optional+. New incoming callback query. Returns CallBackQuery object
88
+ def callback_query
89
+ query = @update.callback_query
90
+ return CallBackQuery.new(qury) if query
91
+
92
+ false
93
+ end
94
+
95
+ # +Optional.+ New incoming shipping query. Only for invoices with
96
+ # flexible price
97
+ def shipping_query
98
+ s_query = @udpate.shipping_query
99
+ return ShippingQuery.new(s_query) if s_query
100
+
101
+ false
102
+ end
103
+
104
+ # +Optional+. New incoming pre-checkout query. Contains full
105
+ # information about checkout
106
+ def pre_checkout_query
107
+ c_query = @update.pre_checkout_query
108
+ return PreCheckoutQuery.new(p_c_query) if c_query
109
+
110
+ false
111
+ end
112
+
113
+ # +Optional+. New poll state. Bots receive only updates about stopped
114
+ # polls and polls, which are sent by the bot.
115
+ def poll
116
+ pol = @udpate.poll
117
+ return Poll.new(pol) if pol
118
+
119
+ false
120
+ end
121
+
122
+ # New poll state. Bots receive only updates about stopped polls and
123
+ # polls, which are sent by the bot.
124
+ def poll_answer
125
+ p_answer = @update.poll_answer
126
+ return PollAnswer.new(p_answer) if p_answer
127
+
128
+ false
129
+ end
130
+
131
+ def msg?
132
+ @update.message ? true : false
133
+ end
134
+
135
+ def channel_post?
136
+ @update.channel_post ? true : false
137
+ end
138
+
139
+ def edited_msg?
140
+ @update.edited_message ? true : false
141
+ end
142
+
143
+ def edited_channel_post?
144
+ @update.edited_channel_post ? true : false
145
+ end
146
+
147
+ def inline_query?
148
+ @update.inline_query ? true : false
149
+ end
150
+
151
+ def new_state_poll?
152
+ @update.poll ? true : false
153
+ end
154
+
155
+ def chosen_inline_result?
156
+ @update.chosen_inline_result ? true : false
157
+ end
158
+
159
+ def callback_query?
160
+ @update.callback_query ? true : false
161
+ end
162
+
163
+ def shipping_query?
164
+ @update.shipping_query ? true : false
165
+ end
166
+
167
+ def pre_checkout_query?
168
+ @update.pre_checkout_query ? true : false
169
+ end
170
+
171
+ def poll_answer?
172
+ @update.poll_answer ? true : false
173
+ end
174
+ end
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ ##
5
+ # +Monday+, +August+ +24+ +2020+ +EAT+
6
+ # ===This object represents a Telegram user.
7
+ class User
8
+ def initialize(user) # :nodoc:
9
+ @user = user
10
+ end
11
+
12
+ # Unique identifier for this user or bot.
13
+ def id
14
+ @user.id
15
+ end
16
+
17
+ # True, if this user is a bot.
18
+ def bot?
19
+ @user.is_bot
20
+ end
21
+
22
+ # User's or bot's first name.
23
+ def first_name
24
+ @user.first_name
25
+ end
26
+
27
+ # +Optional.+ User 's or BotUser 's last name.
28
+ def last_name
29
+ @user.last_name
30
+ end
31
+
32
+ # +Optional+. User's or bot's username
33
+ def username
34
+ @user.username
35
+ end
36
+
37
+ # +Optional+.
38
+ # {IETF language}[https://en.wikipedia.org/wiki/IETF_language_tag]
39
+ # tag of the user's language.
40
+ def language_code
41
+ @user.language_code
42
+ end
43
+ end
44
+
45
+ # ===Class returned only in get_me method.
46
+ # This class extends from User class.
47
+ class BotUser < User
48
+ def initialize(bot) # :nodoc:
49
+ super(bot)
50
+ end
51
+
52
+ # +Optional.+ True, if the bot can be invited to groups.
53
+ def can_join_groups
54
+ @user.can_join_groups
55
+ end
56
+
57
+ # +Optional.+ True, if privacy mode is disabled for the bot.
58
+ def can_read_all_group_messages?
59
+ @user.can_read_all_group_messages
60
+ end
61
+
62
+ # +Optional.+ True, if the bot supports inline queries.
63
+ def supports_inline_queries?
64
+ @user.supports_inline_queries
65
+ end
66
+ end
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'photo_size'
5
+
6
+ ##
7
+ # +Monday+, +August+ +24+ +2020+
8
+ # ==This object represent a user's profile pictures.
9
+ class UserProfilePhotos
10
+ def initialize(photo) # :nodoc:
11
+ @photo = photo
12
+ end
13
+
14
+ #
15
+ # Total number of profile pictures the target user has.
16
+ def total_count
17
+ @photo.total_count
18
+ end
19
+
20
+ ##
21
+ # Requested profile pictures (in up to 4 sizes each).
22
+ # Returns array of array of PhotoSize.
23
+ def photos
24
+ data = @photo.photos
25
+ photo_size = []
26
+ data.each do |e|
27
+ ary = []
28
+ e.each do |e_d|
29
+ ary << PhotoSize.new(e_d)
30
+ end
31
+ photo_size << ary
32
+ end
33
+ photo_size
34
+ end
35
+ end
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'location'
5
+
6
+ ##
7
+ # +Monday+, +August+ +24+ +2020+ +EAT+
8
+ # ====This object represents a venue.
9
+ class Venue
10
+ def initialize(vn) # :nodoc:
11
+ @vn = vn
12
+ end
13
+
14
+ # Venue location. Returns Location Object.
15
+ def location
16
+ @vn.location
17
+ end
18
+
19
+ # Name of the venue.
20
+ def title
21
+ @vn.title
22
+ end
23
+
24
+ # Address of the venue.
25
+ def address
26
+ @vn.address
27
+ end
28
+
29
+ # +Optional+. Foursquare identifier of the venue
30
+ def foursquare_id
31
+ @vn.foursquare_id
32
+ end
33
+
34
+ # Optional. Foursquare type of the venue.
35
+ # (For example, +“arts_entertainment/default”+,
36
+ # +“arts_entertainment/aquarium”+ or +“food/icecream”.+)
37
+ def foursquare_type
38
+ @vn.foursquare_type
39
+ end
40
+ end
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'same/common_2'
5
+ require_relative 'photo_size'
6
+
7
+ ##
8
+ # ===This object represents a video file.
9
+ # Extends Common2 class.
10
+ class Video < Common2
11
+ def initialize(obj) # :nodoc:
12
+ super(obj)
13
+ end
14
+
15
+ # Video width as defined by sender.
16
+ def width
17
+ @obj.width
18
+ end
19
+
20
+ # Video height as defined by sender.
21
+ def heigth
22
+ @obj.heigth
23
+ end
24
+
25
+ # Duration of the video in seconds as defined by sender.
26
+ def duration
27
+ @obj.duration
28
+ end
29
+
30
+ # +Optional+. Video thumbnail.
31
+ def thumb
32
+ data = @obj.thumb
33
+ return false unless data
34
+
35
+ PhotoSize.new(data)
36
+ end
37
+ end
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative 'photo_size'
5
+
6
+ ##
7
+ # +Monday+, +August+ +24+ +2020+ +EAT+
8
+ # ===This object represents a video message
9
+ # (available in Telegram apps as of v.4.0).
10
+ class VideoNote
11
+ def initialize(obj) # :nodoc:
12
+ @note = obj
13
+ end
14
+
15
+ # Identifier for this file, which can be used to download or reuse the file.
16
+ def file_id
17
+ @note.file_id
18
+ end
19
+
20
+ # Unique identifier for this file, which is supposed to be the same over
21
+ # time and for different bots. Can't be used to download or reuse the file.
22
+ def file_unique_id
23
+ @note.file_unique_id
24
+ end
25
+
26
+ # Video width and height (diameter of the video message) as defined by sender.
27
+ def length
28
+ @note.length
29
+ end
30
+
31
+ # Duration of the video in seconds as defined by sender.
32
+ def duration
33
+ @note.duration
34
+ end
35
+
36
+ # +Optional+. File size
37
+ def file_size
38
+ @note.file_size
39
+ end
40
+
41
+ # +Optional+. Video thumbnail. Returns PhotoSize object.
42
+ def thumb
43
+ data = @note.thumb
44
+ return false unless data
45
+
46
+ PhotoSize.new(data)
47
+ end
48
+ end