teleruby 1.5.4 → 1.5.5

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 (63) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.md +0 -2
  3. data/lib/api/delete_apis.rb +6 -6
  4. data/lib/api/get_apis.rb +22 -16
  5. data/lib/api/nstandard.rb +4 -1
  6. data/lib/api/other_apis.rb +19 -19
  7. data/lib/api/send_apis.rb +17 -17
  8. data/lib/api/set_apis.rb +14 -15
  9. data/lib/core_api.rb +3 -1
  10. data/lib/teleruby.rb +7 -2
  11. data/teleruby.gemspec +1 -1
  12. metadata +3 -53
  13. data/lib/api/all.rb +0 -12
  14. data/lib/objects/all.rb +0 -42
  15. data/lib/teleruby/all_apis.rb +0 -22
  16. data/lib/teleruby/api/delete_apis.rb +0 -58
  17. data/lib/teleruby/api/get_apis.rb +0 -172
  18. data/lib/teleruby/api/nstandard.rb +0 -27
  19. data/lib/teleruby/api/other_apis.rb +0 -241
  20. data/lib/teleruby/api/send_apis.rb +0 -206
  21. data/lib/teleruby/api/set_apis.rb +0 -137
  22. data/lib/teleruby/core_api.rb +0 -52
  23. data/lib/teleruby/objects/all.rb +0 -42
  24. data/lib/teleruby/objects/animation.rb +0 -40
  25. data/lib/teleruby/objects/audio.rb +0 -39
  26. data/lib/teleruby/objects/bot_command.rb +0 -24
  27. data/lib/teleruby/objects/callback_query.rb +0 -66
  28. data/lib/teleruby/objects/chat.rb +0 -164
  29. data/lib/teleruby/objects/chat_member.rb +0 -142
  30. data/lib/teleruby/objects/chat_permissions.rb +0 -59
  31. data/lib/teleruby/objects/chat_photo.rb +0 -37
  32. data/lib/teleruby/objects/chosen_inline_result.rb +0 -45
  33. data/lib/teleruby/objects/contact.rb +0 -37
  34. data/lib/teleruby/objects/dice.rb +0 -21
  35. data/lib/teleruby/objects/document.rb +0 -29
  36. data/lib/teleruby/objects/file.rb +0 -32
  37. data/lib/teleruby/objects/game.rb +0 -65
  38. data/lib/teleruby/objects/inline_query.rb +0 -44
  39. data/lib/teleruby/objects/inlinekeyboardbutton.rb +0 -59
  40. data/lib/teleruby/objects/inlinekeyboardmarkup.rb +0 -31
  41. data/lib/teleruby/objects/location.rb +0 -21
  42. data/lib/teleruby/objects/mask_position.rb +0 -35
  43. data/lib/teleruby/objects/message.rb +0 -400
  44. data/lib/teleruby/objects/message_entity.rb +0 -95
  45. data/lib/teleruby/objects/order_info.rb +0 -36
  46. data/lib/teleruby/objects/photo_size.rb +0 -14
  47. data/lib/teleruby/objects/poll.rb +0 -97
  48. data/lib/teleruby/objects/poll_answer.rb +0 -29
  49. data/lib/teleruby/objects/poll_option.rb +0 -22
  50. data/lib/teleruby/objects/pre_checkout_query.rb +0 -50
  51. data/lib/teleruby/objects/same/common.rb +0 -31
  52. data/lib/teleruby/objects/same/common_2.rb +0 -32
  53. data/lib/teleruby/objects/shipping_address.rb +0 -39
  54. data/lib/teleruby/objects/shipping_query.rb +0 -32
  55. data/lib/teleruby/objects/sticker.rb +0 -59
  56. data/lib/teleruby/objects/update.rb +0 -207
  57. data/lib/teleruby/objects/user.rb +0 -66
  58. data/lib/teleruby/objects/user_profile_photos.rb +0 -36
  59. data/lib/teleruby/objects/venue.rb +0 -40
  60. data/lib/teleruby/objects/video.rb +0 -39
  61. data/lib/teleruby/objects/video_note.rb +0 -50
  62. data/lib/teleruby/objects/voice.rb +0 -20
  63. data/lib/teleruby/version.rb +0 -3
@@ -1,137 +0,0 @@
1
- #!/usr/bin/ruby
2
- # frozen_string_literal: true
3
-
4
- require_relative '../core_api'
5
-
6
- ##
7
- # Solomon Boloshe(Lee Crey)
8
- # Friday, August 21 2020 06:35:33 PM +0300
9
-
10
- module Telegram
11
- module SetApis # rubocop:disable Metrics/ModuleLength
12
- ##
13
- # Use this method to set a custom title for an administrator
14
- # in a supergroup promoted by the bot.
15
- def set_cutom_title(chat_id, user_id, title)
16
- if chat_id.to_i.negative?
17
- fail BadRequestError, 'can\' set custom title for private chat'
18
- end
19
- hash = { chat_id: chat_id, user_id: user_id, custom_title: title }
20
- response = post('setChatAdministratorCustomTitle', hash)
21
- unless response.ok # rubocop:disable Style/IfUnlessModifier
22
- fail PermissionError, response.description
23
- end
24
- response.result
25
- end
26
-
27
- def set_chat_permissions(chat_id, permissions)
28
- unless chat_id.to_i.negative?
29
- fail BadRequestError, 'can\' set permissions for private chat'
30
- end
31
- hash = { chat_id: chat_id, permissions: permissions }
32
- response = post('setChatPermissions', hash)
33
- unless response.ok # rubocop:disable Style/IfUnlessModifier
34
- fail PermissionError, response.description
35
- end
36
- response.result
37
- end
38
-
39
- ##
40
- # Use this method to set a new profile photo for the chat.
41
- # Photos can't be changed for private chats.
42
- def set_chat_photo(chat_id, file)
43
- unless chat_id.to_i.negative?
44
- fail BadRequestError, 'can\'t set photo for private chat'
45
- end
46
- hash = { chat_id: chat_id, photo: file }
47
- data = post('setChatPhoto', hash)
48
- unless data.ok # rubocop:disable Style/IfUnlessModifier
49
- fail PermissionError, data.description
50
- end
51
- data.result
52
- end
53
-
54
- ##
55
- # Use this method to change the title of a chat.
56
- # Titles can't be changed for private chats.
57
- def set_chat_title(chat_id, title)
58
- unless chat_id.to_i.negative?
59
- fail BadRequestError, 'can\'t set chat title for private'
60
- end
61
-
62
- hash = { chat_id: chat_id, title: title.to_s }
63
- data = post('setChatTitle', hash)
64
- unless data.ok # rubocop:disable Style/IfUnlessModifier
65
- throw PermissionError, data.description
66
- end
67
-
68
- data.result
69
- end
70
-
71
- ##
72
- # Use this method to change the description of a group,
73
- # a supergroup or a channel.
74
- def set_chat_description(chat_id, description)
75
- unless chat_id.to_i.negative?
76
- fail BadRequestError, 'can\'t set description for private chat'
77
- end
78
-
79
- hash = { chat_id: chat_id, description: description }
80
- data = post('setChatDescription', hash)
81
- unless data.ok # rubocop:disable Style/IfUnlessModifier
82
- fail PermissionError, data.description
83
- end
84
-
85
- data.result
86
- end
87
-
88
- ##
89
- # Use this method to set a new group sticker set for a supergroup.
90
- def set_chat_sticker_set(chat_id, set_name)
91
- hash = { chat_id: chat_id, set_name: set_name }
92
- data = post('setChatStickerSet', hash)
93
- unless data.ok # rubocop:disable Style/IfUnlessModifier
94
- fail StandardError, data.description
95
- end
96
- data.result
97
- end
98
-
99
- ##
100
- # Use this method to change the list of the bot's commands.
101
- def set_my_command(command)
102
- hash = { command: command }
103
- data = post('setMyCommand', hash)
104
- unless data.ok # rubocop:disable Style/IfUnlessModifier
105
- fail TokenError, data.description
106
- end
107
- data.result
108
- end
109
-
110
- ##
111
- # Use this method to move a sticker in a set created by the bot
112
- # to a specific position. position must be int value
113
- def set_sticker_position_in_the_set(sticker, position)
114
- hash = { sticker: sticker, position: position }
115
- data = post('setStickerPositionInTheSet', hash)
116
- unless data.ok # rubocop:disable Style/IfUnlessModifier
117
- fail Error, data.description
118
- end
119
- data.result
120
- end
121
-
122
- ##
123
- # Use this method to set the thumbnail of a sticker set.
124
- def set_sticker_set_thumb(name, user_id, params = {})
125
- hash = { name: name, user_id: user_id }.merge!(params)
126
- data = post('setStickerSetThumb', hash)
127
- unless data.ok # rubocop:disable Style/IfUnlessModifier
128
- fail Error, data.description
129
- end
130
- data.result
131
- end
132
-
133
- def set_webhook(url, params = {})
134
- fail NotImplementedError, 'not implemented'
135
- end
136
- end
137
- end
@@ -1,52 +0,0 @@
1
- #!/usr/bin/ruby
2
- # frozen_string_literal: true
3
-
4
- begin
5
- require 'faraday'
6
- f = true
7
- require 'json'
8
- j = true
9
- rescue LoadError
10
- puts 'some gems are not installed'
11
- print 'should i install them?(y/n):'
12
- ans = gets.chomp!
13
- unless (ans.eql? 'y') or (ans.eql? 'Y')
14
- puts 'okay bye'
15
- exit 0
16
- end
17
- if !f
18
- Gem.install 'faday'
19
- elsif !j
20
- Gem.install 'json'
21
- end
22
- end
23
-
24
- require_relative 'objects/all'
25
-
26
- class Hash
27
- def method_missing(method_name)
28
- self[method_name.to_s]
29
- end
30
- end
31
-
32
- module Telegram
33
- class TGClient
34
- @@base_uri = %q{https://api.telegram.org/bot}
35
- @@file_uri = %q{https://api.telegram.org/file/bot}
36
- # == Post
37
- # method to submit data to telegram server
38
- def post(method, params = {})
39
- body = Faraday.post(@@base_uri + @token + '/' + method, params).body
40
- JSON.parse(body)
41
- end
42
-
43
- # == Get
44
- # method to get data from telegram server
45
- def get(method, params = {})
46
- body = Faraday.get(@@base_uri + @token + '/' + method, params).body
47
- JSON.parse(body)
48
- end
49
-
50
- protected :post, :get
51
- end
52
- end
@@ -1,42 +0,0 @@
1
- #!/usr/bin/ruby
2
- # frozen_string_literal: false
3
-
4
- # :nodoc:
5
-
6
- require_relative 'poll'
7
- require_relative 'location'
8
- require_relative 'venue'
9
- require_relative 'chat'
10
- require_relative 'bot_command'
11
- require_relative 'chat_permissions'
12
- require_relative 'chat_photo'
13
- require_relative 'callback_query'
14
- require_relative 'file'
15
- require_relative 'user_profile_photos'
16
- require_relative 'poll_answer'
17
- require_relative 'poll_option'
18
- require_relative 'dice'
19
- require_relative 'contact'
20
- require_relative 'voice'
21
- require_relative 'video'
22
- require_relative 'audio'
23
- require_relative 'photo_size'
24
- require_relative 'document'
25
- require_relative 'video_note'
26
- require_relative 'user'
27
- require_relative 'message_entity'
28
- require_relative 'chat_member'
29
- require_relative 'update'
30
- require_relative 'chosen_inline_result'
31
- require_relative 'sticker'
32
- require_relative 'game'
33
- require_relative 'inline_query'
34
- require_relative 'shipping_query'
35
- require_relative 'mask_position'
36
- require_relative 'shipping_address'
37
- require_relative 'pre_checkout_query'
38
- require_relative 'order_info'
39
- require_relative 'message'
40
- require_relative 'animation'
41
- require_relative 'inlinekeyboardbutton'
42
- require_relative 'inlinekeyboardmarkup'
@@ -1,40 +0,0 @@
1
- #!/usr/bin/ruby
2
- # frozen_string_literal: true
3
-
4
- require_relative 'photo_size'
5
- require_relative 'same/common'
6
-
7
- ##
8
- # +Sunday+, +August+ +23+ +2020+
9
- # ===This object represents an animation file.
10
- # (GIF or H.264/MPEG-4 AVC video without sound).
11
- class Animation < Common
12
- def initialize(obj) # :nodoc:
13
- super(obj)
14
- freeze
15
- end
16
-
17
- # Duration of the video in seconds as defined by sender.
18
- def duration
19
- @obj.duration
20
- end
21
-
22
- # +Optional+. Original animation filename as defined by sender.
23
- def file_name
24
- @obj.file_name
25
- end
26
-
27
- # +Optional.+ MIME type of the file as defined by sender.
28
- def mime_type
29
- @obj.mime_type
30
- end
31
-
32
- def thumb
33
- data = @obj.thumb
34
- unless data.nil?
35
- return PhotoSize.new(data)
36
- end
37
-
38
- false
39
- end
40
- end
@@ -1,39 +0,0 @@
1
- #!/usr/bin/ruby
2
- # frozen_string_literal: true
3
-
4
- require_relative 'same/common_2'
5
- require_relative 'photo_size'
6
-
7
- ##
8
- # +Monday,+ +August+ +24+ +2020+
9
- # ===This object represents an audio file to be treated as music by the Telegram clients.
10
- class Audio < Common2
11
- def initialize(audio) # :nodoc:
12
- super(audio)
13
- end
14
-
15
- # Duration of the audio in seconds as defined by sender.
16
- def duration
17
- @obj.duration
18
- end
19
-
20
- # +Optional.+ Performer of the audio as defined by sender or by audio tags.
21
- def performer
22
- @obj.performer
23
- end
24
-
25
- # +Optional+. Title of the audio as defined by sender or by audio tags
26
- def title
27
- @obj.title
28
- end
29
-
30
- # +Optional.+ Thumbnail of the album cover to which the music file belongs.
31
- def thumb
32
- data = @obj.thumb
33
- unless data.nil?
34
- return PhotoSize.new(data)
35
- end
36
-
37
- false
38
- end
39
- end
@@ -1,24 +0,0 @@
1
- #!/usr/bin/ruby
2
- # frozen_string_literal: true
3
-
4
- # +Saturday+, +August+ +22+ +2020+ +EAT+
5
-
6
- # ===This object represents a bot command
7
-
8
- class BotCommand
9
- def initialize(bot) # :nodoc:
10
- @bot = bot
11
- freeze
12
- end
13
-
14
- # Text of the command, 1-32 characters. Can contain only lowercase
15
- # English letters, digits and underscores.
16
- def command
17
- @bot.command
18
- end
19
-
20
- # Description of the command, 3-256 characters.
21
- def description
22
- @bot.description
23
- end
24
- end
@@ -1,66 +0,0 @@
1
- #!/usr/bin/ruby
2
- # frozen_string_literal: true
3
-
4
- require_relative 'user'
5
- require_relative 'message'
6
-
7
- ##
8
- # +Monday+, +August+ +24+ +2020+
9
- # ===This object represents an incoming callback query from a callback button in an inline keyboard.
10
- # If the button that originated the query was
11
- # attached to a message sent by the bot, the field message will be present.
12
- # If the button was attached to a message sent via the bot (in inline mode),
13
- # the field inline_message_id will be present. Exactly one of the fields data
14
- # or game_short_name will be present.
15
- class CallbackQuery
16
- def initialize(query) # :nodoc:
17
- @query = query
18
- end
19
-
20
- # Unique identifier for this query.
21
- def id
22
- @query.id
23
- end
24
-
25
- # Sender. Returns User object
26
- def from
27
- User.new(@query.from)
28
- end
29
-
30
- # +Optional+. Message with the callback button that originated the query.
31
- # Note that message content and message date will not be available if
32
- # the message is too old.
33
- def message
34
- data = @query.message
35
- unless data.nil?
36
- return Message.new(data)
37
- end
38
-
39
- false
40
- end
41
-
42
- # +Optional.+ Identifier of the message sent via the bot in inline mode,
43
- # that originated the query.
44
- def inline_message_id
45
- @query.inline_message_id
46
- end
47
-
48
- # Global identifier, uniquely corresponding to the chat to which the
49
- # message with the callback button was sent. Useful for high scores
50
- # in games.
51
- def chat_instance
52
- @query.chat_instance
53
- end
54
-
55
- # +Optional.+ Data associated with the callback button. Be aware that
56
- # a bad client can send arbitrary data in this field.
57
- def data
58
- @query.data
59
- end
60
-
61
- # +Optional.+ Short name of a Game to be returned, serves as the unique
62
- # identifier for the game
63
- def game_short_name
64
- @query.game_short_name
65
- end
66
- end
@@ -1,164 +0,0 @@
1
- #!/usr/bin/ruby
2
- # frozen_string_literal: true
3
-
4
- require_relative 'chat_permissions'
5
- require_relative 'message'
6
- require_relative 'chat_photo'
7
-
8
- # +Sunday+, +August+ +23+ +2020+ +EAT+
9
-
10
- # ===This object represents a chat.
11
- class Chat
12
- def initialize(chat) # :nodoc:
13
- @chat = chat
14
- end
15
-
16
- # Unique identifier for this chat.
17
- def id
18
- @chat.id
19
- end
20
-
21
- # Type of chat, can be either +private+, +group+,
22
- # +supergroup+ or +channel+.
23
- def type
24
- @chat.type
25
- end
26
-
27
- # +Optional+. *Title*, for +supergroups+, +channels+ and +group+ chats.
28
- def title
29
- @chat.title
30
- end
31
-
32
- # +Optional+. *Username*, for +private+ chats, +supergroups+ and
33
- # +channels+ if available else nil is returned.
34
- def username
35
- @chat.username
36
- end
37
-
38
- # Returns true if chat type is private else false is returned.
39
- def private?
40
- type.eql? 'private'
41
- end
42
-
43
- # Returns true if chat type is supergroup else false is returned.
44
- def supergroup?
45
- type.eql? 'supergroup'
46
- end
47
-
48
- # Returns true if chat type is channel else false is returned.
49
- def channel?
50
- type.eql? 'channel'
51
- end
52
-
53
- # Returns true if chat has title else false is returned.
54
- def has_title?
55
- title.nil?
56
- end
57
- end
58
-
59
- # ====Returned only for private chat
60
- # It extends from Chat class.
61
- class PrivateChat < Chat
62
- def initialize(chat) # :nodoc:
63
- super(chat)
64
- end
65
-
66
- # +Optional+. First name of the other party in a +private+ chat.
67
- def first_name
68
- @chat.first_name
69
- end
70
-
71
- # +Optional.+ Last name of the other party in a +private+ chat.
72
- def last_name
73
- @chat.last_name
74
- end
75
- end
76
-
77
- # ==== This object is returned only in get_chat methods
78
- # It extends from Chat class.
79
- class GetChat < Chat
80
- def initialize(chat) # :nodoc:
81
- super(chat)
82
- end
83
-
84
- # +Optional+. Returns ChatPhoto if available else false is returned.
85
- def photo
86
- data = @chat.photo
87
- unless data.nil?
88
- return ChatPhoto.new(data)
89
- end
90
-
91
- false
92
- end
93
-
94
- # +Optional.+ Description, for +groups+, +supergroups+ and +channel+
95
- # chats.
96
- def description
97
- @chat.description
98
- end
99
-
100
- # +Optional.+ Chat invite link, for +groups+, +supergroups+ and +channel+
101
- # chats. Each administrator in a chat generates their own invite links,
102
- # so the bot must first generate the link using +export_chat_link.+
103
- def invite_link
104
- @chat.invite_link
105
- end
106
-
107
- # +Optional+. Pinned message, for +groups+, +supergroups+ and +channels.+
108
- # Returns Message object.
109
- def pinned_message
110
- data = @chat.pinned_message
111
- unless data.nil?
112
- return Message.new(data)
113
- end
114
-
115
- false
116
- end
117
-
118
- # +Optional.+ Default chat member permissions, for +groups+ and
119
- # +supergroups+. Returns ChatPermissions object.
120
- def permissions
121
- data = @chat.permissions
122
- unless data.nil?
123
- return ChatPermissions.new(data)
124
- end
125
-
126
- false
127
- end
128
-
129
- # +Optional.+ For +supergroups,+ the minimum allowed delay between
130
- # consecutive messages sent by each unpriviledged user.
131
- def slow_mode_delay
132
- @chat.slow_mode_delay
133
- end
134
-
135
- # +Optional.+ For +supergroups,+ name of group sticker set.
136
- def sticker_set_name
137
- @chat.sticker_set_name
138
- end
139
-
140
- # +Optional.+ True, if the bot can change the group sticker set.
141
- def can_set_sticker_set?
142
- @chat.can_set_sticker_set
143
- end
144
-
145
- # Returns true if photo is set to chat else false is returned.
146
- def has_photo?
147
- photo ? true : false
148
- end
149
-
150
- # Returns true if description is set to chat else false is returned.
151
- def has_description?
152
- description.nil?
153
- end
154
-
155
- # Returns true if message is pinned in chat else false is returned.
156
- def pinned_message?
157
- pinned_message ? true : false
158
- end
159
-
160
- # Returns true if slow mode delay is set in chat.
161
- def slow_mode_delay_set?
162
- slow_mode_delay.nil?
163
- end
164
- end