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.
- checksums.yaml +4 -4
- data/LICENSE.md +9 -0
- data/README.md +398 -0
- data/lib/api/all.rb +12 -0
- data/lib/api/delete_apis.rb +55 -0
- data/lib/api/get_apis.rb +162 -0
- data/lib/api/nstandard.rb +26 -0
- data/lib/api/other_apis.rb +225 -0
- data/lib/api/send_apis.rb +191 -0
- data/lib/api/set_apis.rb +130 -0
- data/lib/core_api.rb +41 -0
- data/lib/objects/all.rb +42 -0
- data/lib/objects/animation.rb +38 -0
- data/lib/objects/audio.rb +37 -0
- data/lib/objects/bot_command.rb +24 -0
- data/lib/objects/callback_query.rb +64 -0
- data/lib/objects/chat.rb +158 -0
- data/lib/objects/chat_member.rb +142 -0
- data/lib/objects/chat_permissions.rb +59 -0
- data/lib/objects/chat_photo.rb +37 -0
- data/lib/objects/chosen_inline_result.rb +43 -0
- data/lib/objects/contact.rb +37 -0
- data/lib/objects/dice.rb +21 -0
- data/lib/objects/document.rb +27 -0
- data/lib/objects/file.rb +32 -0
- data/lib/objects/game.rb +65 -0
- data/lib/objects/inline_query.rb +42 -0
- data/lib/objects/inlinekeyboardbutton.rb +59 -0
- data/lib/objects/inlinekeyboardmarkup.rb +30 -0
- data/lib/objects/location.rb +21 -0
- data/lib/objects/mask_position.rb +35 -0
- data/lib/objects/message.rb +378 -0
- data/lib/objects/message_entity.rb +93 -0
- data/lib/objects/order_info.rb +34 -0
- data/lib/objects/photo_size.rb +14 -0
- data/lib/objects/poll.rb +97 -0
- data/lib/objects/poll_answer.rb +29 -0
- data/lib/objects/poll_option.rb +22 -0
- data/lib/objects/pre_checkout_query.rb +48 -0
- data/lib/objects/same/common.rb +37 -0
- data/lib/objects/same/common_2.rb +38 -0
- data/lib/objects/shipping_address.rb +39 -0
- data/lib/objects/shipping_query.rb +32 -0
- data/lib/objects/sticker.rb +55 -0
- data/lib/objects/update.rb +174 -0
- data/lib/objects/user.rb +66 -0
- data/lib/objects/user_profile_photos.rb +35 -0
- data/lib/objects/venue.rb +40 -0
- data/lib/objects/video.rb +37 -0
- data/lib/objects/video_note.rb +48 -0
- data/lib/objects/voice.rb +20 -0
- data/lib/teleruby.rb +4 -40
- data/lib/teleruby/all_apis.rb +22 -0
- data/lib/teleruby/api/delete_apis.rb +58 -0
- data/lib/teleruby/api/get_apis.rb +172 -0
- data/lib/teleruby/api/nstandard.rb +27 -0
- data/lib/teleruby/api/other_apis.rb +241 -0
- data/lib/teleruby/api/send_apis.rb +206 -0
- data/lib/teleruby/api/set_apis.rb +137 -0
- data/lib/teleruby/core_api.rb +52 -0
- data/lib/teleruby/objects/all.rb +42 -0
- data/lib/teleruby/objects/animation.rb +40 -0
- data/lib/teleruby/objects/audio.rb +39 -0
- data/lib/teleruby/objects/bot_command.rb +24 -0
- data/lib/teleruby/objects/callback_query.rb +66 -0
- data/lib/teleruby/objects/chat.rb +164 -0
- data/lib/teleruby/objects/chat_member.rb +142 -0
- data/lib/teleruby/objects/chat_permissions.rb +59 -0
- data/lib/teleruby/objects/chat_photo.rb +37 -0
- data/lib/teleruby/objects/chosen_inline_result.rb +45 -0
- data/lib/teleruby/objects/contact.rb +37 -0
- data/lib/teleruby/objects/dice.rb +21 -0
- data/lib/teleruby/objects/document.rb +29 -0
- data/lib/teleruby/objects/file.rb +32 -0
- data/lib/teleruby/objects/game.rb +65 -0
- data/lib/teleruby/objects/inline_query.rb +44 -0
- data/lib/teleruby/objects/inlinekeyboardbutton.rb +59 -0
- data/lib/teleruby/objects/inlinekeyboardmarkup.rb +31 -0
- data/lib/teleruby/objects/location.rb +21 -0
- data/lib/teleruby/objects/mask_position.rb +35 -0
- data/lib/teleruby/objects/message.rb +400 -0
- data/lib/teleruby/objects/message_entity.rb +95 -0
- data/lib/teleruby/objects/order_info.rb +36 -0
- data/lib/teleruby/objects/photo_size.rb +14 -0
- data/lib/teleruby/objects/poll.rb +97 -0
- data/lib/teleruby/objects/poll_answer.rb +29 -0
- data/lib/teleruby/objects/poll_option.rb +22 -0
- data/lib/teleruby/objects/pre_checkout_query.rb +50 -0
- data/lib/teleruby/objects/same/common.rb +31 -0
- data/lib/teleruby/objects/same/common_2.rb +32 -0
- data/lib/teleruby/objects/shipping_address.rb +39 -0
- data/lib/teleruby/objects/shipping_query.rb +32 -0
- data/lib/teleruby/objects/sticker.rb +59 -0
- data/lib/teleruby/objects/update.rb +207 -0
- data/lib/teleruby/objects/user.rb +66 -0
- data/lib/teleruby/objects/user_profile_photos.rb +36 -0
- data/lib/teleruby/objects/venue.rb +40 -0
- data/lib/teleruby/objects/video.rb +39 -0
- data/lib/teleruby/objects/video_note.rb +50 -0
- data/lib/teleruby/objects/voice.rb +20 -0
- data/lib/teleruby/version.rb +3 -0
- data/msg.png +0 -0
- data/rdoc.png +0 -0
- data/teleruby.gemspec +9 -7
- metadata +109 -6
@@ -0,0 +1,93 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative 'user'
|
5
|
+
|
6
|
+
##
|
7
|
+
# +Monday+, +August+ +24+ +2020+ +EAT+
|
8
|
+
# ===This object represents one special entity in a text message.
|
9
|
+
# For example, +hashtags,+ +usernames+, +URLs,+ etc.
|
10
|
+
class MessageEntity
|
11
|
+
def initialize(msg) # :nodoc:
|
12
|
+
@msg = msg
|
13
|
+
freeze
|
14
|
+
end
|
15
|
+
|
16
|
+
# Type of the entity. Can be +mention+( @username ), +hashtag+( #hashtag ),
|
17
|
+
# +cashtag+( $USD ), +bot_command+( /start@jobs_bot ),
|
18
|
+
# +url+( https://telegram.org ), +email+( do-not-reply@telegram.org ),
|
19
|
+
# +phone_number+( +1-212-555-0123 ), +bold+(bold text),
|
20
|
+
# *italic*(italic text), +underline+(underlined text),
|
21
|
+
# +strikethrough+(strikethrough text), +code+
|
22
|
+
# (monowidth string), +pre+ (monowidth block),
|
23
|
+
# +text_link+(for clickable text URLs),
|
24
|
+
# +text_mention+ (for users without usernames)
|
25
|
+
def type
|
26
|
+
@msg.type
|
27
|
+
end
|
28
|
+
|
29
|
+
# Offset in UTF-16 code units to the start of the entity.
|
30
|
+
def offset
|
31
|
+
@msg.offset
|
32
|
+
end
|
33
|
+
|
34
|
+
# Length of the entity in UTF-16 code units.
|
35
|
+
def length
|
36
|
+
@msg.length
|
37
|
+
end
|
38
|
+
|
39
|
+
# +Optional.+ For +text_link+ only, url that will be opened after user
|
40
|
+
# taps on the text.
|
41
|
+
def url
|
42
|
+
@msg.url
|
43
|
+
end
|
44
|
+
|
45
|
+
# +Optional.+ For +pre+ only, the programming language of the entity text.
|
46
|
+
def language
|
47
|
+
@msg.language
|
48
|
+
end
|
49
|
+
|
50
|
+
# +Optional+. For text_mention? only, the mentioned user.
|
51
|
+
# Returns User object
|
52
|
+
def user
|
53
|
+
usr = @msg.user
|
54
|
+
return User.new(usr) if usr
|
55
|
+
|
56
|
+
false
|
57
|
+
end
|
58
|
+
|
59
|
+
# Returns true if entity #type is mention else false is returned.
|
60
|
+
def mention?
|
61
|
+
type.eql? 'mention'
|
62
|
+
end
|
63
|
+
|
64
|
+
# Returns true if entity #type is bot_command else false is returned.
|
65
|
+
def bot_command?
|
66
|
+
type.eql? 'bot_command'
|
67
|
+
end
|
68
|
+
|
69
|
+
# Return true if entity #type is url else false is returned.
|
70
|
+
def link?
|
71
|
+
type.elq? 'url'
|
72
|
+
end
|
73
|
+
|
74
|
+
# Returns true if entity #type is email else false is returned.
|
75
|
+
def email?
|
76
|
+
type.eql? 'email'
|
77
|
+
end
|
78
|
+
|
79
|
+
# Return true if entity #type is +phone_number+ else false is returned.
|
80
|
+
def phone_number?
|
81
|
+
type.eql? 'phone_number'
|
82
|
+
end
|
83
|
+
|
84
|
+
# Returns true if entity #type is +text_link+ else false is returned.
|
85
|
+
def text_link?
|
86
|
+
type.eql? 'text_link'
|
87
|
+
end
|
88
|
+
|
89
|
+
# Returns true if entity #type is +text_mention+ else false is returned.
|
90
|
+
def text_mention?
|
91
|
+
type.eql? 'text_mention'
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative 'shipping_address'
|
5
|
+
|
6
|
+
# This object represents information about an order.
|
7
|
+
class OrderInfo
|
8
|
+
def initialize(info) # :nodoc:
|
9
|
+
@info = info
|
10
|
+
end
|
11
|
+
|
12
|
+
# Optional. User name
|
13
|
+
def name
|
14
|
+
@info.name
|
15
|
+
end
|
16
|
+
|
17
|
+
# Optional. User's phone number.
|
18
|
+
def phone_number
|
19
|
+
@info.phone_number
|
20
|
+
end
|
21
|
+
|
22
|
+
# Optional. User email
|
23
|
+
def email
|
24
|
+
@info.email
|
25
|
+
end
|
26
|
+
|
27
|
+
# Optional. User shipping address
|
28
|
+
def shipping_address
|
29
|
+
address = @info.shipping_address
|
30
|
+
return ShippingAddress.new(address) if address
|
31
|
+
|
32
|
+
false
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative 'same/common'
|
5
|
+
|
6
|
+
##
|
7
|
+
# +Monday,+ +August+ +24+ +2020+
|
8
|
+
# ===This object represents one size of a photo or a file/sticker thumbnail.
|
9
|
+
# Extends Common class.
|
10
|
+
class PhotoSize < Common
|
11
|
+
def initialize(photo) # :nodoc:
|
12
|
+
super(photo)
|
13
|
+
end
|
14
|
+
end
|
data/lib/objects/poll.rb
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative 'poll_option'
|
5
|
+
require_relative 'message_entity'
|
6
|
+
|
7
|
+
# ===This object contains information about a poll.
|
8
|
+
class Poll
|
9
|
+
def initialize(poll) # :nodoc:
|
10
|
+
@poll = poll
|
11
|
+
freeze
|
12
|
+
end
|
13
|
+
|
14
|
+
# Unique poll identifier.
|
15
|
+
def id
|
16
|
+
@poll.id
|
17
|
+
end
|
18
|
+
|
19
|
+
# Poll question, 1-255 characters.
|
20
|
+
def question
|
21
|
+
@poll.question
|
22
|
+
end
|
23
|
+
|
24
|
+
# Returns array of PollOption s. else false is returned.
|
25
|
+
def options
|
26
|
+
opt = @poll.options
|
27
|
+
unless opt
|
28
|
+
return false
|
29
|
+
end
|
30
|
+
|
31
|
+
poll_options = []
|
32
|
+
opt.each do |o|
|
33
|
+
poll_options << PollOption.new(o)
|
34
|
+
end
|
35
|
+
poll_options
|
36
|
+
end
|
37
|
+
|
38
|
+
# Total number of users that voted in the poll.
|
39
|
+
def total_voter_count
|
40
|
+
@poll.total_voter_count
|
41
|
+
end
|
42
|
+
|
43
|
+
# True, if the poll is closed.
|
44
|
+
def closed?
|
45
|
+
@poll.is_closed
|
46
|
+
end
|
47
|
+
|
48
|
+
# True, if the poll is anonymous.
|
49
|
+
def anonymous?
|
50
|
+
@poll.is_anonymous
|
51
|
+
end
|
52
|
+
|
53
|
+
# Poll type, currently can be "regular" or "quiz"
|
54
|
+
def type
|
55
|
+
@poll.type
|
56
|
+
end
|
57
|
+
|
58
|
+
# +Optional+. 0-based identifier of the correct answer option.
|
59
|
+
# Available only for polls in the quiz mode, which are closed, or was
|
60
|
+
# sent (not forwarded) by the bot or to the private chat with the bot.
|
61
|
+
def correct_option_id
|
62
|
+
@poll.correct_option_id
|
63
|
+
end
|
64
|
+
|
65
|
+
# +Optional.+ Text that is shown when a user chooses an incorrect answer
|
66
|
+
# or taps on the lamp icon in a quiz-style poll, 0-200 characters.
|
67
|
+
def explanation
|
68
|
+
@poll.explanation
|
69
|
+
end
|
70
|
+
|
71
|
+
# +Optional.+ Special entities like *usernames*, *URLs*, bot commands,
|
72
|
+
# etc. that appear in the explanation.
|
73
|
+
def explanation_entities
|
74
|
+
data = @poll.explanation_entities
|
75
|
+
unless data
|
76
|
+
return false
|
77
|
+
end
|
78
|
+
|
79
|
+
explanations = []
|
80
|
+
data.each do |exp|
|
81
|
+
explanations << MessageEntity.new(exp)
|
82
|
+
end
|
83
|
+
explanations
|
84
|
+
end
|
85
|
+
|
86
|
+
# +Optional.+ Amount of time in seconds the poll will be active after
|
87
|
+
# creation.
|
88
|
+
def open_period
|
89
|
+
@poll.open_period
|
90
|
+
end
|
91
|
+
|
92
|
+
# +Optional.+ Point in time (Unix timestamp) when the poll will be
|
93
|
+
# automatically closed.
|
94
|
+
def close_date
|
95
|
+
@poll.close_date
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative 'user'
|
5
|
+
|
6
|
+
# +Sunday,+ +August+ +23+ +2020+
|
7
|
+
|
8
|
+
# ===This object represents an answer of a user in a non-anonymous poll.
|
9
|
+
class PollAnswer
|
10
|
+
def initialize(poll) # :nodoc:
|
11
|
+
@poll = poll
|
12
|
+
end
|
13
|
+
|
14
|
+
# Unique poll identifier.
|
15
|
+
def poll_id
|
16
|
+
@poll.poll_id
|
17
|
+
end
|
18
|
+
|
19
|
+
# The user, who changed the answer to the poll. Return User object
|
20
|
+
def user
|
21
|
+
User.new(@poll.user)
|
22
|
+
end
|
23
|
+
|
24
|
+
# 0-based identifiers of answer options, chosen by the user.
|
25
|
+
# May be empty if the user retracted their vote.
|
26
|
+
def option_ids
|
27
|
+
@poll.option_ids
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
##
|
5
|
+
# +Monday,+ +August+ +24+ 2020+ +EAT+
|
6
|
+
# ===This object contains information about one answer option in a poll.
|
7
|
+
class PollOption
|
8
|
+
def initialize(poll) # :nodoc:
|
9
|
+
@poll = poll
|
10
|
+
freeze
|
11
|
+
end
|
12
|
+
|
13
|
+
# +Option+ text, 1-100 characters.
|
14
|
+
def text
|
15
|
+
@poll.text
|
16
|
+
end
|
17
|
+
|
18
|
+
# Number of users that voted for this option.
|
19
|
+
def voter_count
|
20
|
+
@poll.voter_count
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative 'user'
|
5
|
+
require_relative 'order_info'
|
6
|
+
|
7
|
+
# This object contains information about an incoming pre-checkout query.
|
8
|
+
class PreCheckoutQuery
|
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
|
+
# Three-letter ISO 4217 currency code
|
24
|
+
def currency
|
25
|
+
@query.currency
|
26
|
+
end
|
27
|
+
|
28
|
+
# Total price in the smallest units of the currency
|
29
|
+
# (integer, not float/double). For example, for a price of US$ 1.45
|
30
|
+
# pass amount = 145 . See the exp parameter in currencies.json,
|
31
|
+
# it shows the number of digits past the decimal point for each
|
32
|
+
# currency (2 for the majority of currencies).
|
33
|
+
def total_count
|
34
|
+
@query.total_count
|
35
|
+
end
|
36
|
+
|
37
|
+
# Bot specified invoice payload.
|
38
|
+
def invoice_option_id
|
39
|
+
@query.invoice_option_id
|
40
|
+
end
|
41
|
+
|
42
|
+
def order_info
|
43
|
+
info = @query.order_info
|
44
|
+
return OrderInfo.new(info) if info
|
45
|
+
|
46
|
+
false
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
##
|
5
|
+
# +Monday+, +August+ +24+ +2020+ +EAT+
|
6
|
+
# ===Common class
|
7
|
+
class Hash
|
8
|
+
def method_missing(method_name)
|
9
|
+
self[method_name.to_s]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Common
|
14
|
+
def initialize(obj) # :nodoc:
|
15
|
+
@obj = obj
|
16
|
+
end
|
17
|
+
|
18
|
+
def file_id
|
19
|
+
@obj.file_id
|
20
|
+
end
|
21
|
+
|
22
|
+
def file_unique_id
|
23
|
+
@obj.file_unique_id
|
24
|
+
end
|
25
|
+
|
26
|
+
def width
|
27
|
+
@ob.width
|
28
|
+
end
|
29
|
+
|
30
|
+
def heigth
|
31
|
+
@obj.heigth
|
32
|
+
end
|
33
|
+
|
34
|
+
def file_size
|
35
|
+
@obj.file_size
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
##
|
5
|
+
# +Monday,+ +August+ +24+ +2020+
|
6
|
+
class Hash
|
7
|
+
def method_missing(method_name)
|
8
|
+
self[method_name.to_s]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# ===common class for Audio, Video, and Document and Voice
|
13
|
+
class Common2
|
14
|
+
def initialize(obj) # :nodoc:
|
15
|
+
@obj = obj
|
16
|
+
freeze
|
17
|
+
end
|
18
|
+
|
19
|
+
# File id for the object
|
20
|
+
def file_id
|
21
|
+
@obj.file_id
|
22
|
+
end
|
23
|
+
|
24
|
+
# File unique id for the object.
|
25
|
+
def file_unique_id
|
26
|
+
@obj.file_unique_id
|
27
|
+
end
|
28
|
+
|
29
|
+
# +Optional+. MIME type of the file as defined by sender.
|
30
|
+
def mime_type
|
31
|
+
@obj.mime_type
|
32
|
+
end
|
33
|
+
|
34
|
+
# +Optional.+ File size
|
35
|
+
def file_size
|
36
|
+
@obj.file_size
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# ===This object represents a shipping address
|
5
|
+
class ShippingAddress
|
6
|
+
def initialize(shipping) # :nodoc:
|
7
|
+
@shipping = shipping
|
8
|
+
end
|
9
|
+
|
10
|
+
# ISO 3166-1 alpha-2 country code.
|
11
|
+
def country_code
|
12
|
+
@shipping.country_code
|
13
|
+
end
|
14
|
+
|
15
|
+
# State, if applicable.
|
16
|
+
def state
|
17
|
+
@shipping.state
|
18
|
+
end
|
19
|
+
|
20
|
+
# City
|
21
|
+
def city
|
22
|
+
@shipping.city
|
23
|
+
end
|
24
|
+
|
25
|
+
# First line for the address.
|
26
|
+
def street_line1
|
27
|
+
@shipping.street_lin2
|
28
|
+
end
|
29
|
+
|
30
|
+
# Second line for the address
|
31
|
+
def street_line2
|
32
|
+
@shipping.street_line2
|
33
|
+
end
|
34
|
+
|
35
|
+
# Address post code
|
36
|
+
def post_code
|
37
|
+
@shipping.post_code
|
38
|
+
end
|
39
|
+
end
|