telegram-ruby 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +5 -0
  5. data/CHANGELOG.md +4 -0
  6. data/Gemfile +6 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +97 -0
  9. data/Rakefile +6 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +8 -0
  12. data/examples/api/inline_keyboard_markup.rb +17 -0
  13. data/examples/api/send_message.rb +5 -0
  14. data/examples/client/handler.rb +19 -0
  15. data/lib/telegram/bot.rb +29 -0
  16. data/lib/telegram/bot/api.rb +261 -0
  17. data/lib/telegram/bot/client.rb +54 -0
  18. data/lib/telegram/bot/client_accessors.rb +5 -0
  19. data/lib/telegram/bot/configuration.rb +11 -0
  20. data/lib/telegram/bot/exceptions.rb +13 -0
  21. data/lib/telegram/bot/types.rb +47 -0
  22. data/lib/telegram/bot/types/animation.rb +17 -0
  23. data/lib/telegram/bot/types/audio.rb +14 -0
  24. data/lib/telegram/bot/types/callback_game.rb +4 -0
  25. data/lib/telegram/bot/types/callback_query.rb +23 -0
  26. data/lib/telegram/bot/types/chat.rb +25 -0
  27. data/lib/telegram/bot/types/chat_member.rb +28 -0
  28. data/lib/telegram/bot/types/chat_photo.rb +10 -0
  29. data/lib/telegram/bot/types/chosen_inline_result.rb +21 -0
  30. data/lib/telegram/bot/types/contact.rb +12 -0
  31. data/lib/telegram/bot/types/document.rb +17 -0
  32. data/lib/telegram/bot/types/file.rb +15 -0
  33. data/lib/telegram/bot/types/force_reply.rb +9 -0
  34. data/lib/telegram/bot/types/game.rb +26 -0
  35. data/lib/telegram/bot/types/inline_keyboard_button.rb +19 -0
  36. data/lib/telegram/bot/types/inline_keyboard_markup.rb +20 -0
  37. data/lib/telegram/bot/types/inline_query.rb +21 -0
  38. data/lib/telegram/bot/types/invoice.rb +13 -0
  39. data/lib/telegram/bot/types/keyboard_button.rb +11 -0
  40. data/lib/telegram/bot/types/location.rb +10 -0
  41. data/lib/telegram/bot/types/mask_position.rb +12 -0
  42. data/lib/telegram/bot/types/message.rb +145 -0
  43. data/lib/telegram/bot/types/message_entity.rb +17 -0
  44. data/lib/telegram/bot/types/order_info.rb +16 -0
  45. data/lib/telegram/bot/types/photo_size.rb +12 -0
  46. data/lib/telegram/bot/types/pre_checkout_query.rb +23 -0
  47. data/lib/telegram/bot/types/reply_keyboard_markup.rb +22 -0
  48. data/lib/telegram/bot/types/reply_keyboard_remove.rb +9 -0
  49. data/lib/telegram/bot/types/shipping_address.rb +14 -0
  50. data/lib/telegram/bot/types/shipping_query.rb +20 -0
  51. data/lib/telegram/bot/types/sticker.rb +24 -0
  52. data/lib/telegram/bot/types/sticker_set.rb +16 -0
  53. data/lib/telegram/bot/types/successful_payment.rb +19 -0
  54. data/lib/telegram/bot/types/update.rb +54 -0
  55. data/lib/telegram/bot/types/user.rb +14 -0
  56. data/lib/telegram/bot/types/user_profile_photos.rb +14 -0
  57. data/lib/telegram/bot/types/venue.rb +16 -0
  58. data/lib/telegram/bot/types/video.rb +19 -0
  59. data/lib/telegram/bot/types/video_note.rb +17 -0
  60. data/lib/telegram/bot/types/voice.rb +12 -0
  61. data/lib/telegram/bot/types/webhook_info.rb +15 -0
  62. data/lib/telegram/version.rb +3 -0
  63. data/telegram-ruby.gemspec +29 -0
  64. metadata +176 -0
@@ -0,0 +1,14 @@
1
+ module Telegram::Bot::Types
2
+ class User
3
+ attr_accessor :id,
4
+ :is_bot,
5
+ :first_name,
6
+ :last_name,
7
+ :username,
8
+ :language_code
9
+
10
+ def initialize(attributes)
11
+ attributes.each { |k, v| self.send("#{k}=", v) if self.respond_to? k }
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module Telegram::Bot::Types
2
+ class UserProfilePhotos
3
+ attr_accessor :total_count,
4
+ :photos
5
+
6
+ def initialize(attributes)
7
+ attributes.each { |k, v| self.send("#{k}=", v) if self.respond_to? k }
8
+ end
9
+
10
+ def photos=(attributes)
11
+ @photos = attributes.map {|attr| PhotoSize.new(attr) }
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,16 @@
1
+ module Telegram::Bot::Types
2
+ class Venue
3
+ attr_accessor :location,
4
+ :title,
5
+ :address,
6
+ :foursquare_id
7
+
8
+ def initialize(attributes)
9
+ attributes.each { |k, v| self.send("#{k}=", v) if self.respond_to? k }
10
+ end
11
+
12
+ def location=(attributes)
13
+ @location = Location.new(attributes)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,19 @@
1
+ module Telegram::Bot::Types
2
+ class Video
3
+ attr_accessor :file_id,
4
+ :width,
5
+ :height,
6
+ :duration,
7
+ :thumb,
8
+ :mime_type,
9
+ :file_size
10
+
11
+ def initialize(attributes)
12
+ attributes.each { |k, v| self.send("#{k}=", v) if self.respond_to? k }
13
+ end
14
+
15
+ def thumb=(attributes)
16
+ @thumb = PhotoSize.new(attributes)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ module Telegram::Bot::Types
2
+ class VideoNote
3
+ attr_accessor :file_id,
4
+ :length,
5
+ :duration,
6
+ :thumb,
7
+ :file_size
8
+
9
+ def initialize(attributes)
10
+ attributes.each { |k, v| self.send("#{k}=", v) if self.respond_to? k }
11
+ end
12
+
13
+ def thumb=(attributes)
14
+ @thumb = PhotoSize.new(attributes)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,12 @@
1
+ module Telegram::Bot::Types
2
+ class Voice
3
+ attr_accessor :file_id,
4
+ :duration,
5
+ :mime_type,
6
+ :file_size
7
+
8
+ def initialize(attributes)
9
+ attributes.each { |k, v| self.send("#{k}=", v) if self.respond_to? k }
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,15 @@
1
+ module Telegram::Bot::Types
2
+ class WebhookInfo
3
+ attr_accessor :url,
4
+ :has_custom_certificate,
5
+ :pending_update_count,
6
+ :last_error_date,
7
+ :last_error_message,
8
+ :max_connections,
9
+ :allowed_updates
10
+
11
+ def initialize(attributes)
12
+ attributes.each { |k, v| self.send("#{k}=", v) if self.respond_to? k }
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module Telegram
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,29 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "telegram/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "telegram-ruby"
8
+ spec.version = Telegram::VERSION
9
+ spec.authors = ["Alex Belenky"]
10
+ spec.email = ["bagirs@gmail.com"]
11
+
12
+ spec.summary = "Ruby wrapper for Telegram's Bot API"
13
+ spec.homepage = "https://github.com/Stajor/telegram-ruby"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.16"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec", "~> 3.0"
26
+
27
+ spec.add_dependency 'faraday'
28
+ spec.add_dependency 'faraday_middleware'
29
+ end
metadata ADDED
@@ -0,0 +1,176 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: telegram-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alex Belenky
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-01-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: faraday
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: faraday_middleware
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email:
85
+ - bagirs@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - CHANGELOG.md
94
+ - Gemfile
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - bin/console
99
+ - bin/setup
100
+ - examples/api/inline_keyboard_markup.rb
101
+ - examples/api/send_message.rb
102
+ - examples/client/handler.rb
103
+ - lib/telegram/bot.rb
104
+ - lib/telegram/bot/api.rb
105
+ - lib/telegram/bot/client.rb
106
+ - lib/telegram/bot/client_accessors.rb
107
+ - lib/telegram/bot/configuration.rb
108
+ - lib/telegram/bot/exceptions.rb
109
+ - lib/telegram/bot/types.rb
110
+ - lib/telegram/bot/types/animation.rb
111
+ - lib/telegram/bot/types/audio.rb
112
+ - lib/telegram/bot/types/callback_game.rb
113
+ - lib/telegram/bot/types/callback_query.rb
114
+ - lib/telegram/bot/types/chat.rb
115
+ - lib/telegram/bot/types/chat_member.rb
116
+ - lib/telegram/bot/types/chat_photo.rb
117
+ - lib/telegram/bot/types/chosen_inline_result.rb
118
+ - lib/telegram/bot/types/contact.rb
119
+ - lib/telegram/bot/types/document.rb
120
+ - lib/telegram/bot/types/file.rb
121
+ - lib/telegram/bot/types/force_reply.rb
122
+ - lib/telegram/bot/types/game.rb
123
+ - lib/telegram/bot/types/inline_keyboard_button.rb
124
+ - lib/telegram/bot/types/inline_keyboard_markup.rb
125
+ - lib/telegram/bot/types/inline_query.rb
126
+ - lib/telegram/bot/types/invoice.rb
127
+ - lib/telegram/bot/types/keyboard_button.rb
128
+ - lib/telegram/bot/types/location.rb
129
+ - lib/telegram/bot/types/mask_position.rb
130
+ - lib/telegram/bot/types/message.rb
131
+ - lib/telegram/bot/types/message_entity.rb
132
+ - lib/telegram/bot/types/order_info.rb
133
+ - lib/telegram/bot/types/photo_size.rb
134
+ - lib/telegram/bot/types/pre_checkout_query.rb
135
+ - lib/telegram/bot/types/reply_keyboard_markup.rb
136
+ - lib/telegram/bot/types/reply_keyboard_remove.rb
137
+ - lib/telegram/bot/types/shipping_address.rb
138
+ - lib/telegram/bot/types/shipping_query.rb
139
+ - lib/telegram/bot/types/sticker.rb
140
+ - lib/telegram/bot/types/sticker_set.rb
141
+ - lib/telegram/bot/types/successful_payment.rb
142
+ - lib/telegram/bot/types/update.rb
143
+ - lib/telegram/bot/types/user.rb
144
+ - lib/telegram/bot/types/user_profile_photos.rb
145
+ - lib/telegram/bot/types/venue.rb
146
+ - lib/telegram/bot/types/video.rb
147
+ - lib/telegram/bot/types/video_note.rb
148
+ - lib/telegram/bot/types/voice.rb
149
+ - lib/telegram/bot/types/webhook_info.rb
150
+ - lib/telegram/version.rb
151
+ - telegram-ruby.gemspec
152
+ homepage: https://github.com/Stajor/telegram-ruby
153
+ licenses:
154
+ - MIT
155
+ metadata: {}
156
+ post_install_message:
157
+ rdoc_options: []
158
+ require_paths:
159
+ - lib
160
+ required_ruby_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ required_rubygems_version: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ version: '0'
170
+ requirements: []
171
+ rubyforge_project:
172
+ rubygems_version: 2.7.3
173
+ signing_key:
174
+ specification_version: 4
175
+ summary: Ruby wrapper for Telegram's Bot API
176
+ test_files: []