telegram-bot 0.14.2 → 0.15.2
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/.rubocop.yml +1 -0
- data/.travis.yml +14 -11
- data/Appraisals +15 -12
- data/CHANGELOG.md +25 -0
- data/Gemfile +8 -8
- data/README.md +15 -11
- data/bin/fetch-telegram-methods +1 -1
- data/gemfiles/rails_42.gemfile +10 -10
- data/gemfiles/rails_50.gemfile +10 -10
- data/gemfiles/rails_51.gemfile +10 -10
- data/gemfiles/rails_52.gemfile +10 -10
- data/gemfiles/rails_60.gemfile +10 -12
- data/gemfiles/rails_61.gemfile +21 -0
- data/lib/tasks/telegram-bot.rake +16 -9
- data/lib/telegram/bot.rb +3 -3
- data/lib/telegram/bot/async.rb +3 -3
- data/lib/telegram/bot/client.rb +15 -4
- data/lib/telegram/bot/client/api_methods.txt +11 -1
- data/lib/telegram/bot/client_stub.rb +2 -2
- data/lib/telegram/bot/routes_helper.rb +10 -6
- data/lib/telegram/bot/tasks.rb +63 -0
- data/lib/telegram/bot/updates_controller.rb +7 -1
- data/lib/telegram/bot/updates_controller/instrumentation.rb +1 -1
- data/lib/telegram/bot/updates_poller.rb +1 -1
- data/lib/telegram/bot/version.rb +1 -1
- data/telegram-bot.gemspec +4 -7
- metadata +17 -17
- data/lib/telegram/bot/initializers.rb +0 -21
- data/lib/telegram/bot/rspec/integration.rb +0 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 81fae472dfd6080e48c0b3329cc7b5e8748aa89040162a089480bf0082a72477
|
|
4
|
+
data.tar.gz: a3620f420bcd83f58a70aa093ca8becf748156a88000f663d5b0ba5a4fb59f77
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0ccbbc372a75c5861ec8751f912282227e06850ca84d23617ddda126b0ab2eaa592d4f005b976d451c87c80f9bb59d27a13d58e752d6290dc27500d9c4252b97
|
|
7
|
+
data.tar.gz: 69553e905b7b8c7d31e8006e592ccfc824459c14dcc15f696e94866bd7a20f604dcf52a40622152602f44ec997628646a98fa75f2b766221c7cef2815c5271a1
|
data/.rubocop.yml
CHANGED
|
@@ -40,6 +40,7 @@ Style/IfUnlessModifier: {Enabled: false}
|
|
|
40
40
|
# Consistent to other definitions.
|
|
41
41
|
Style/EmptyMethod: {EnforcedStyle: expanded}
|
|
42
42
|
|
|
43
|
+
Style/Lambda: {EnforcedStyle: literal}
|
|
43
44
|
Style/ModuleFunction: {Enabled: false}
|
|
44
45
|
Style/NestedParenthesizedCalls: {Enabled: false}
|
|
45
46
|
Style/SignalException: {EnforcedStyle: only_raise}
|
data/.travis.yml
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
|
+
os: linux
|
|
2
|
+
dist: xenial
|
|
1
3
|
language: ruby
|
|
2
4
|
cache: bundler
|
|
3
5
|
rvm:
|
|
6
|
+
- 2.6
|
|
4
7
|
- 2.5
|
|
5
|
-
- 2.4
|
|
6
8
|
gemfile:
|
|
9
|
+
- gemfiles/rails_61.gemfile
|
|
10
|
+
- gemfiles/rails_60.gemfile
|
|
7
11
|
- gemfiles/rails_52.gemfile
|
|
8
|
-
|
|
9
|
-
matrix:
|
|
12
|
+
jobs:
|
|
10
13
|
include:
|
|
14
|
+
# ruby 3.x
|
|
15
|
+
- rvm: 3.0
|
|
16
|
+
gemfile: gemfiles/rails_61.gemfile
|
|
17
|
+
- rvm: 3.0
|
|
18
|
+
gemfile: gemfiles/rails_60.gemfile
|
|
11
19
|
# old rails
|
|
20
|
+
- rvm: 2.5
|
|
21
|
+
gemfile: gemfiles/rails_51.gemfile
|
|
12
22
|
- rvm: 2.5
|
|
13
23
|
gemfile: gemfiles/rails_50.gemfile
|
|
14
24
|
- rvm: 2.5
|
|
15
25
|
gemfile: gemfiles/rails_42.gemfile
|
|
16
26
|
# old rubies
|
|
17
|
-
- rvm: 2.
|
|
27
|
+
- rvm: 2.4
|
|
18
28
|
gemfile: gemfiles/rails_52.gemfile
|
|
19
|
-
# future rails
|
|
20
|
-
- rvm: 2.5
|
|
21
|
-
gemfile: gemfiles/rails_60.gemfile
|
|
22
|
-
# Allow rails 6 to fail while master branch is used
|
|
23
|
-
allow_failures:
|
|
24
|
-
- rvm: 2.5
|
|
25
|
-
gemfile: gemfiles/rails_60.gemfile
|
|
26
29
|
notifications:
|
|
27
30
|
email: false
|
data/Appraisals
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
|
+
appraise 'rails-61' do
|
|
2
|
+
gem 'actionpack', '~> 6.1.0'
|
|
3
|
+
gem 'railties', '~> 6.1.0'
|
|
4
|
+
end
|
|
5
|
+
|
|
1
6
|
appraise 'rails-60' do
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
gem 'railties', '~> 6.0.0.alpha'
|
|
5
|
-
end
|
|
7
|
+
gem 'actionpack', '~> 6.0.0'
|
|
8
|
+
gem 'railties', '~> 6.0.0'
|
|
6
9
|
end
|
|
7
10
|
|
|
8
11
|
appraise 'rails-52' do
|
|
9
|
-
gem 'actionpack', '~> 5.2.0
|
|
10
|
-
gem 'railties', '~> 5.2.0
|
|
12
|
+
gem 'actionpack', '~> 5.2.0'
|
|
13
|
+
gem 'railties', '~> 5.2.0'
|
|
11
14
|
end
|
|
12
15
|
|
|
13
16
|
appraise 'rails-51' do
|
|
14
|
-
gem 'actionpack', '~> 5.1'
|
|
15
|
-
gem 'railties', '~> 5.1'
|
|
17
|
+
gem 'actionpack', '~> 5.1.0'
|
|
18
|
+
gem 'railties', '~> 5.1.0'
|
|
16
19
|
end
|
|
17
20
|
|
|
18
21
|
appraise 'rails-50' do
|
|
19
|
-
gem 'actionpack', '~> 5.0'
|
|
20
|
-
gem 'railties', '~> 5.0'
|
|
22
|
+
gem 'actionpack', '~> 5.0.0'
|
|
23
|
+
gem 'railties', '~> 5.0.0'
|
|
21
24
|
end
|
|
22
25
|
|
|
23
26
|
appraise 'rails-42' do
|
|
24
|
-
gem 'actionpack', '~> 4.2'
|
|
25
|
-
gem 'railties', '~> 4.2'
|
|
27
|
+
gem 'actionpack', '~> 4.2.0'
|
|
28
|
+
gem 'railties', '~> 4.2.0'
|
|
26
29
|
end
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# Unreleased
|
|
2
2
|
|
|
3
|
+
# 0.15.2
|
|
4
|
+
|
|
5
|
+
- Ruby 3.0 support. Drop support for Ruby < 2.4.
|
|
6
|
+
|
|
7
|
+
# 0.15.1
|
|
8
|
+
|
|
9
|
+
- Rails 6.1 support.
|
|
10
|
+
|
|
11
|
+
# 0.15.0
|
|
12
|
+
|
|
13
|
+
- Add `:path` option to `telegram_webhook` route helper.
|
|
14
|
+
- __Breaking change!__ Default route is generated using hashed bot token.
|
|
15
|
+
Please reconfigure webhook after update (`rake telegram:bot:set_webhook`).
|
|
16
|
+
- Update to Bot API 5.0, add rake tasks for `deleteWebhook`, `close` & `logOut`.
|
|
17
|
+
- Add `server` option for client to support local bot API servers.
|
|
18
|
+
|
|
19
|
+
# 0.14.4
|
|
20
|
+
|
|
21
|
+
- Update to Bot API 4.7
|
|
22
|
+
|
|
23
|
+
# 0.14.3
|
|
24
|
+
|
|
25
|
+
- Rails 6.0 support.
|
|
26
|
+
- Update to Bot API 4.4.
|
|
27
|
+
|
|
3
28
|
# 0.14.2
|
|
4
29
|
|
|
5
30
|
- Add reply helpers: `answer_pre_checkout_query`, `answer_shipping_query`.
|
data/Gemfile
CHANGED
|
@@ -4,17 +4,17 @@ gemspec
|
|
|
4
4
|
group :development do
|
|
5
5
|
gem 'appraisal', '~> 2.2'
|
|
6
6
|
|
|
7
|
-
gem 'pry', '~> 0.
|
|
8
|
-
gem 'pry-byebug', '~> 3.
|
|
9
|
-
gem 'sdoc', '~> 0.
|
|
7
|
+
gem 'pry', '~> 0.13.1'
|
|
8
|
+
gem 'pry-byebug', '~> 3.9.0'
|
|
9
|
+
gem 'sdoc', '~> 2.0.3'
|
|
10
10
|
|
|
11
|
-
gem 'telegram-bot-types', '~> 0.6.
|
|
11
|
+
gem 'telegram-bot-types', '~> 0.6.2'
|
|
12
12
|
|
|
13
|
-
gem 'rspec', '~> 3.
|
|
14
|
-
gem 'rspec-its', '~> 1.
|
|
15
|
-
gem 'rspec-rails', '~>
|
|
13
|
+
gem 'rspec', '~> 3.10.0'
|
|
14
|
+
gem 'rspec-its', '~> 1.3.0'
|
|
15
|
+
gem 'rspec-rails', '~> 4.0.2'
|
|
16
16
|
|
|
17
17
|
gem 'rubocop', '~> 0.52.1'
|
|
18
18
|
|
|
19
|
-
gem 'coveralls', '~> 0.8.
|
|
19
|
+
gem 'coveralls', '~> 0.8.23', require: false
|
|
20
20
|
end
|
data/README.md
CHANGED
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
[](https://codeclimate.com/github/telegram-bot-rb/telegram-bot)
|
|
5
5
|
[](https://travis-ci.org/telegram-bot-rb/telegram-bot)
|
|
6
6
|
|
|
7
|
-
__Breaking changes in v0.14!__ See [upgrade guide](https://github.com/telegram-bot-rb/telegram-bot/wiki/Upgrading-to-0.14).
|
|
8
|
-
|
|
9
7
|
Tools for developing Telegram bots. Best used with Rails, but can be used in
|
|
10
8
|
[standalone app](https://github.com/telegram-bot-rb/telegram-bot/wiki/Not-rails-application).
|
|
11
9
|
Supposed to be used in webhook-mode in production, and poller-mode
|
|
@@ -65,7 +63,11 @@ which is used for `Telegram.bot`.
|
|
|
65
63
|
```ruby
|
|
66
64
|
Telegram.bots_config = {
|
|
67
65
|
default: DEFAULT_BOT_TOKEN,
|
|
68
|
-
chat: {
|
|
66
|
+
chat: {
|
|
67
|
+
token: CHAT_BOT_TOKEN,
|
|
68
|
+
username: 'ChatBot', # to support commands with mentions (/help@ChatBot)
|
|
69
|
+
server: 'http://local.bot.api.server', # for Local Bot API Server
|
|
70
|
+
},
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
Telegram.bot.get_updates
|
|
@@ -87,6 +89,7 @@ development:
|
|
|
87
89
|
bot:
|
|
88
90
|
token: TOKEN
|
|
89
91
|
username: SomeBot
|
|
92
|
+
server: http://local.bot.api.server
|
|
90
93
|
|
|
91
94
|
# For multiple bots in single app use hash of `internal_bot_id => settings`
|
|
92
95
|
bots:
|
|
@@ -128,9 +131,9 @@ bot.send_message(chat_id: chat_id, text: 'Test')
|
|
|
128
131
|
```
|
|
129
132
|
|
|
130
133
|
There is no magic, they just pass params as is and set `path_suffix`.
|
|
131
|
-
See [
|
|
132
|
-
|
|
133
|
-
new API versions.
|
|
134
|
+
See [list of available methods](https://github.com/telegram-bot-rb/telegram-bot/blob/master/lib/telegram/bot/client/api_methods.txt)
|
|
135
|
+
fetched from [API docs](https://core.telegram.org/bots/api).
|
|
136
|
+
Please open PR or issue if it misses methods from new API versions.
|
|
134
137
|
|
|
135
138
|
Any API request error will raise `Telegram::Bot::Error` with description in its message.
|
|
136
139
|
Special `Telegram::Bot::Forbidden` is raised when bot can't post messages to the chat anymore.
|
|
@@ -366,7 +369,7 @@ end
|
|
|
366
369
|
### Routes in Rails app
|
|
367
370
|
|
|
368
371
|
There is `telegram_webhook` helper for rails app to define routes for webhooks.
|
|
369
|
-
It defines routes at `telegram/#{bot.token}` and connects bots with controller.
|
|
372
|
+
It defines routes at `telegram/#{hash_of(bot.token)}` and connects bots with controller.
|
|
370
373
|
|
|
371
374
|
```ruby
|
|
372
375
|
# Most off apps would require
|
|
@@ -475,10 +478,11 @@ RSpec.describe TelegramWebhooksController, telegram_bot: :rails do
|
|
|
475
478
|
# dispatch_command(cmd, *args)
|
|
476
479
|
|
|
477
480
|
# Available matchers can be found in Telegram::Bot::RSpec::ClientMatchers.
|
|
478
|
-
it 'shows usage of basic matchers'
|
|
479
|
-
# The most basic one is #make_telegram_request(bot,
|
|
480
|
-
|
|
481
|
-
|
|
481
|
+
it 'shows usage of basic matchers' do
|
|
482
|
+
# The most basic one is #make_telegram_request(bot, action).
|
|
483
|
+
# It works similar to `receive` matcher and supports chaining `.with(args).exactly(n).times`.
|
|
484
|
+
expect { dispatch_command(:start) }.to make_telegram_request(bot, :sendMessage).
|
|
485
|
+
with(hash_including(text: 'msg text'))
|
|
482
486
|
|
|
483
487
|
# There are some shortcuts for dispatching basic updates and testing responses.
|
|
484
488
|
expect { dispatch_message('Hi') }.to send_telegram_message(bot, /msg regexp/, some: :option)
|
data/bin/fetch-telegram-methods
CHANGED
|
@@ -25,7 +25,7 @@ method_list = headers.
|
|
|
25
25
|
map { |g| g.reject { |x| x.match?(NOT_METHOD_REGEXP) } }.
|
|
26
26
|
reject(&:empty?)
|
|
27
27
|
|
|
28
|
-
api_version = doc.text.match(/^(Bot API ([\d\.]+))\.?$/)
|
|
28
|
+
api_version = doc.text.match(/^(?:Introducing )?(Bot API ([\d\.]+))\.?$/)
|
|
29
29
|
|
|
30
30
|
result = ['# Generated with bin/fetch-telegram-methods']
|
|
31
31
|
result << "# #{api_version[1]}" if api_version
|
data/gemfiles/rails_42.gemfile
CHANGED
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
source "https://rubygems.org"
|
|
4
4
|
|
|
5
|
-
gem "actionpack", "~> 4.2"
|
|
6
|
-
gem "railties", "~> 4.2"
|
|
5
|
+
gem "actionpack", "~> 4.2.0"
|
|
6
|
+
gem "railties", "~> 4.2.0"
|
|
7
7
|
|
|
8
8
|
group :development do
|
|
9
9
|
gem "appraisal", "~> 2.2"
|
|
10
|
-
gem "pry", "~> 0.
|
|
11
|
-
gem "pry-byebug", "~> 3.
|
|
12
|
-
gem "sdoc", "~> 0.
|
|
13
|
-
gem "telegram-bot-types", "~> 0.6.
|
|
14
|
-
gem "rspec", "~> 3.
|
|
15
|
-
gem "rspec-its", "~> 1.
|
|
16
|
-
gem "rspec-rails", "~>
|
|
10
|
+
gem "pry", "~> 0.13.1"
|
|
11
|
+
gem "pry-byebug", "~> 3.9.0"
|
|
12
|
+
gem "sdoc", "~> 2.0.3"
|
|
13
|
+
gem "telegram-bot-types", "~> 0.6.2"
|
|
14
|
+
gem "rspec", "~> 3.10.0"
|
|
15
|
+
gem "rspec-its", "~> 1.3.0"
|
|
16
|
+
gem "rspec-rails", "~> 4.0.2"
|
|
17
17
|
gem "rubocop", "~> 0.52.1"
|
|
18
|
-
gem "coveralls", "~> 0.8.
|
|
18
|
+
gem "coveralls", "~> 0.8.23", require: false
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
gemspec path: "../"
|
data/gemfiles/rails_50.gemfile
CHANGED
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
source "https://rubygems.org"
|
|
4
4
|
|
|
5
|
-
gem "actionpack", "~> 5.0"
|
|
6
|
-
gem "railties", "~> 5.0"
|
|
5
|
+
gem "actionpack", "~> 5.0.0"
|
|
6
|
+
gem "railties", "~> 5.0.0"
|
|
7
7
|
|
|
8
8
|
group :development do
|
|
9
9
|
gem "appraisal", "~> 2.2"
|
|
10
|
-
gem "pry", "~> 0.
|
|
11
|
-
gem "pry-byebug", "~> 3.
|
|
12
|
-
gem "sdoc", "~> 0.
|
|
13
|
-
gem "telegram-bot-types", "~> 0.6.
|
|
14
|
-
gem "rspec", "~> 3.
|
|
15
|
-
gem "rspec-its", "~> 1.
|
|
16
|
-
gem "rspec-rails", "~>
|
|
10
|
+
gem "pry", "~> 0.13.1"
|
|
11
|
+
gem "pry-byebug", "~> 3.9.0"
|
|
12
|
+
gem "sdoc", "~> 2.0.3"
|
|
13
|
+
gem "telegram-bot-types", "~> 0.6.2"
|
|
14
|
+
gem "rspec", "~> 3.10.0"
|
|
15
|
+
gem "rspec-its", "~> 1.3.0"
|
|
16
|
+
gem "rspec-rails", "~> 4.0.2"
|
|
17
17
|
gem "rubocop", "~> 0.52.1"
|
|
18
|
-
gem "coveralls", "~> 0.8.
|
|
18
|
+
gem "coveralls", "~> 0.8.23", require: false
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
gemspec path: "../"
|
data/gemfiles/rails_51.gemfile
CHANGED
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
source "https://rubygems.org"
|
|
4
4
|
|
|
5
|
-
gem "actionpack", "~> 5.1"
|
|
6
|
-
gem "railties", "~> 5.1"
|
|
5
|
+
gem "actionpack", "~> 5.1.0"
|
|
6
|
+
gem "railties", "~> 5.1.0"
|
|
7
7
|
|
|
8
8
|
group :development do
|
|
9
9
|
gem "appraisal", "~> 2.2"
|
|
10
|
-
gem "pry", "~> 0.
|
|
11
|
-
gem "pry-byebug", "~> 3.
|
|
12
|
-
gem "sdoc", "~> 0.
|
|
13
|
-
gem "telegram-bot-types", "~> 0.6.
|
|
14
|
-
gem "rspec", "~> 3.
|
|
15
|
-
gem "rspec-its", "~> 1.
|
|
16
|
-
gem "rspec-rails", "~>
|
|
10
|
+
gem "pry", "~> 0.13.1"
|
|
11
|
+
gem "pry-byebug", "~> 3.9.0"
|
|
12
|
+
gem "sdoc", "~> 2.0.3"
|
|
13
|
+
gem "telegram-bot-types", "~> 0.6.2"
|
|
14
|
+
gem "rspec", "~> 3.10.0"
|
|
15
|
+
gem "rspec-its", "~> 1.3.0"
|
|
16
|
+
gem "rspec-rails", "~> 4.0.2"
|
|
17
17
|
gem "rubocop", "~> 0.52.1"
|
|
18
|
-
gem "coveralls", "~> 0.8.
|
|
18
|
+
gem "coveralls", "~> 0.8.23", require: false
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
gemspec path: "../"
|
data/gemfiles/rails_52.gemfile
CHANGED
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
source "https://rubygems.org"
|
|
4
4
|
|
|
5
|
-
gem "actionpack", "~> 5.2.0
|
|
6
|
-
gem "railties", "~> 5.2.0
|
|
5
|
+
gem "actionpack", "~> 5.2.0"
|
|
6
|
+
gem "railties", "~> 5.2.0"
|
|
7
7
|
|
|
8
8
|
group :development do
|
|
9
9
|
gem "appraisal", "~> 2.2"
|
|
10
|
-
gem "pry", "~> 0.
|
|
11
|
-
gem "pry-byebug", "~> 3.
|
|
12
|
-
gem "sdoc", "~> 0.
|
|
13
|
-
gem "telegram-bot-types", "~> 0.6.
|
|
14
|
-
gem "rspec", "~> 3.
|
|
15
|
-
gem "rspec-its", "~> 1.
|
|
16
|
-
gem "rspec-rails", "~>
|
|
10
|
+
gem "pry", "~> 0.13.1"
|
|
11
|
+
gem "pry-byebug", "~> 3.9.0"
|
|
12
|
+
gem "sdoc", "~> 2.0.3"
|
|
13
|
+
gem "telegram-bot-types", "~> 0.6.2"
|
|
14
|
+
gem "rspec", "~> 3.10.0"
|
|
15
|
+
gem "rspec-its", "~> 1.3.0"
|
|
16
|
+
gem "rspec-rails", "~> 4.0.2"
|
|
17
17
|
gem "rubocop", "~> 0.52.1"
|
|
18
|
-
gem "coveralls", "~> 0.8.
|
|
18
|
+
gem "coveralls", "~> 0.8.23", require: false
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
gemspec path: "../"
|
data/gemfiles/rails_60.gemfile
CHANGED
|
@@ -2,22 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
source "https://rubygems.org"
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
gem "railties", "~> 6.0.0.alpha"
|
|
8
|
-
end
|
|
5
|
+
gem "actionpack", "~> 6.0.0"
|
|
6
|
+
gem "railties", "~> 6.0.0"
|
|
9
7
|
|
|
10
8
|
group :development do
|
|
11
9
|
gem "appraisal", "~> 2.2"
|
|
12
|
-
gem "pry", "~> 0.
|
|
13
|
-
gem "pry-byebug", "~> 3.
|
|
14
|
-
gem "sdoc", "~> 0.
|
|
15
|
-
gem "telegram-bot-types", "~> 0.6.
|
|
16
|
-
gem "rspec", "~> 3.
|
|
17
|
-
gem "rspec-its", "~> 1.
|
|
18
|
-
gem "rspec-rails", "~>
|
|
10
|
+
gem "pry", "~> 0.13.1"
|
|
11
|
+
gem "pry-byebug", "~> 3.9.0"
|
|
12
|
+
gem "sdoc", "~> 2.0.3"
|
|
13
|
+
gem "telegram-bot-types", "~> 0.6.2"
|
|
14
|
+
gem "rspec", "~> 3.10.0"
|
|
15
|
+
gem "rspec-its", "~> 1.3.0"
|
|
16
|
+
gem "rspec-rails", "~> 4.0.2"
|
|
19
17
|
gem "rubocop", "~> 0.52.1"
|
|
20
|
-
gem "coveralls", "~> 0.8.
|
|
18
|
+
gem "coveralls", "~> 0.8.23", require: false
|
|
21
19
|
end
|
|
22
20
|
|
|
23
21
|
gemspec path: "../"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# This file was generated by Appraisal
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
gem "actionpack", "~> 6.1.0"
|
|
6
|
+
gem "railties", "~> 6.1.0"
|
|
7
|
+
|
|
8
|
+
group :development do
|
|
9
|
+
gem "appraisal", "~> 2.2"
|
|
10
|
+
gem "pry", "~> 0.13.1"
|
|
11
|
+
gem "pry-byebug", "~> 3.9.0"
|
|
12
|
+
gem "sdoc", "~> 2.0.3"
|
|
13
|
+
gem "telegram-bot-types", "~> 0.6.2"
|
|
14
|
+
gem "rspec", "~> 3.10.0"
|
|
15
|
+
gem "rspec-its", "~> 1.3.0"
|
|
16
|
+
gem "rspec-rails", "~> 4.0.2"
|
|
17
|
+
gem "rubocop", "~> 0.52.1"
|
|
18
|
+
gem "coveralls", "~> 0.8.23", require: false
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
gemspec path: "../"
|
data/lib/tasks/telegram-bot.rake
CHANGED
|
@@ -14,15 +14,22 @@ namespace :telegram do
|
|
|
14
14
|
|
|
15
15
|
desc 'Set webhook urls for all bots'
|
|
16
16
|
task set_webhook: :environment do
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
Telegram::Bot::Tasks.set_webhook
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
desc 'Delete webhooks for all or specific BOT'
|
|
21
|
+
task :delete_webhook do
|
|
22
|
+
Telegram::Bot::Tasks.delete_webhook
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
desc 'Perform logOut command for all or specific BOT'
|
|
26
|
+
task :log_out do
|
|
27
|
+
Telegram::Bot::Tasks.log_out
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
desc 'Perform `close` command for all or specific BOT'
|
|
31
|
+
task :close do
|
|
32
|
+
Telegram::Bot::Tasks.close
|
|
26
33
|
end
|
|
27
34
|
end
|
|
28
35
|
end
|
data/lib/telegram/bot.rb
CHANGED
|
@@ -14,10 +14,10 @@ module Telegram
|
|
|
14
14
|
|
|
15
15
|
module_function
|
|
16
16
|
|
|
17
|
-
def
|
|
17
|
+
def deprecation_0_16
|
|
18
18
|
@deprecation ||= begin
|
|
19
19
|
require 'active_support/deprecation'
|
|
20
|
-
ActiveSupport::Deprecation.new('0.
|
|
20
|
+
ActiveSupport::Deprecation.new('0.16', 'Telegram::Bot')
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
|
|
@@ -25,9 +25,9 @@ module Telegram
|
|
|
25
25
|
autoload :Client, 'telegram/bot/client'
|
|
26
26
|
autoload :ClientStub, 'telegram/bot/client_stub'
|
|
27
27
|
autoload :DebugClient, 'telegram/bot/debug_client'
|
|
28
|
-
autoload :Initializers, 'telegram/bot/initializers'
|
|
29
28
|
autoload :Middleware, 'telegram/bot/middleware'
|
|
30
29
|
autoload :RSpec, 'telegram/bot/rspec'
|
|
30
|
+
autoload :Tasks, 'telegram/bot/tasks'
|
|
31
31
|
autoload :UpdatesController, 'telegram/bot/updates_controller'
|
|
32
32
|
autoload :UpdatesPoller, 'telegram/bot/updates_poller'
|
|
33
33
|
end
|
data/lib/telegram/bot/async.rb
CHANGED
|
@@ -16,8 +16,8 @@ module Telegram
|
|
|
16
16
|
# accessible via `Teletgram.bots[id]` in job worker. Or just use
|
|
17
17
|
# `Telegram.bots_config=` for configuration.
|
|
18
18
|
#
|
|
19
|
-
# Being in async mode `#request` enqueues job
|
|
20
|
-
# http request instead of performing it
|
|
19
|
+
# Being in async mode `#request` enqueues job to perform
|
|
20
|
+
# http request instead of performing it immediately.
|
|
21
21
|
# Async behavior is controlled with `#async=` writer
|
|
22
22
|
# and can be enabled/disabled for the block with `#async`:
|
|
23
23
|
#
|
|
@@ -29,7 +29,7 @@ module Telegram
|
|
|
29
29
|
# while `#async(val, &block)` is thread-safe.
|
|
30
30
|
#
|
|
31
31
|
# It can be set with custom job class or classname. By default it defines
|
|
32
|
-
# job classes
|
|
32
|
+
# job classes inherited from ApplicationJob, which
|
|
33
33
|
# can be accessed via `.default_async_job`. You can integrate it with any
|
|
34
34
|
# other job provider by defining a class with `.perform_later(bot_id, *args)`
|
|
35
35
|
# method. See Async::Job for implemetation.
|
data/lib/telegram/bot/client.rb
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
require 'active_support/core_ext/hash/keys'
|
|
1
2
|
require 'json'
|
|
2
3
|
require 'httpclient'
|
|
3
4
|
|
|
4
5
|
module Telegram
|
|
5
6
|
module Bot
|
|
6
7
|
class Client
|
|
7
|
-
|
|
8
|
+
SERVER = 'https://api.telegram.org'.freeze
|
|
9
|
+
URL_TEMPLATE = '%<server>s/bot%<token>s/'.freeze
|
|
8
10
|
|
|
9
11
|
autoload :TypedResponse, 'telegram/bot/client/typed_response'
|
|
10
|
-
extend Initializers
|
|
11
12
|
prepend Async
|
|
12
13
|
include DebugClient
|
|
13
14
|
|
|
@@ -15,6 +16,16 @@ module Telegram
|
|
|
15
16
|
include ApiHelper
|
|
16
17
|
|
|
17
18
|
class << self
|
|
19
|
+
# Accepts different options to initialize bot.
|
|
20
|
+
def wrap(input, **options)
|
|
21
|
+
case input
|
|
22
|
+
when Symbol then by_id(input) or raise "#{name} #{input.inspect} not configured"
|
|
23
|
+
when self then input
|
|
24
|
+
when Hash then new(**input.symbolize_keys, **options)
|
|
25
|
+
else new(input, **options)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
18
29
|
def by_id(id)
|
|
19
30
|
Telegram.bots[id]
|
|
20
31
|
end
|
|
@@ -51,11 +62,11 @@ module Telegram
|
|
|
51
62
|
|
|
52
63
|
attr_reader :client, :token, :username, :base_uri
|
|
53
64
|
|
|
54
|
-
def initialize(token = nil, username = nil, **options)
|
|
65
|
+
def initialize(token = nil, username = nil, server: SERVER, **options)
|
|
55
66
|
@client = HTTPClient.new
|
|
56
67
|
@token = token || options[:token]
|
|
57
68
|
@username = username || options[:username]
|
|
58
|
-
@base_uri = format(URL_TEMPLATE, token: self.token)
|
|
69
|
+
@base_uri = format(URL_TEMPLATE, server: server, token: self.token)
|
|
59
70
|
end
|
|
60
71
|
|
|
61
72
|
def request(action, body = {})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Generated with bin/fetch-telegram-methods
|
|
2
|
-
# Bot API
|
|
2
|
+
# Bot API 5.0
|
|
3
3
|
|
|
4
4
|
getUpdates
|
|
5
5
|
setWebhook
|
|
@@ -7,8 +7,11 @@ deleteWebhook
|
|
|
7
7
|
getWebhookInfo
|
|
8
8
|
|
|
9
9
|
getMe
|
|
10
|
+
logOut
|
|
11
|
+
close
|
|
10
12
|
sendMessage
|
|
11
13
|
forwardMessage
|
|
14
|
+
copyMessage
|
|
12
15
|
sendPhoto
|
|
13
16
|
sendAudio
|
|
14
17
|
sendDocument
|
|
@@ -23,6 +26,7 @@ stopMessageLiveLocation
|
|
|
23
26
|
sendVenue
|
|
24
27
|
sendContact
|
|
25
28
|
sendPoll
|
|
29
|
+
sendDice
|
|
26
30
|
sendChatAction
|
|
27
31
|
getUserProfilePhotos
|
|
28
32
|
getFile
|
|
@@ -30,6 +34,8 @@ kickChatMember
|
|
|
30
34
|
unbanChatMember
|
|
31
35
|
restrictChatMember
|
|
32
36
|
promoteChatMember
|
|
37
|
+
setChatAdministratorCustomTitle
|
|
38
|
+
setChatPermissions
|
|
33
39
|
exportChatInviteLink
|
|
34
40
|
setChatPhoto
|
|
35
41
|
deleteChatPhoto
|
|
@@ -37,6 +43,7 @@ setChatTitle
|
|
|
37
43
|
setChatDescription
|
|
38
44
|
pinChatMessage
|
|
39
45
|
unpinChatMessage
|
|
46
|
+
unpinAllChatMessages
|
|
40
47
|
leaveChat
|
|
41
48
|
getChat
|
|
42
49
|
getChatAdministrators
|
|
@@ -45,6 +52,8 @@ getChatMember
|
|
|
45
52
|
setChatStickerSet
|
|
46
53
|
deleteChatStickerSet
|
|
47
54
|
answerCallbackQuery
|
|
55
|
+
setMyCommands
|
|
56
|
+
getMyCommands
|
|
48
57
|
|
|
49
58
|
editMessageText
|
|
50
59
|
editMessageCaption
|
|
@@ -60,6 +69,7 @@ createNewStickerSet
|
|
|
60
69
|
addStickerToSet
|
|
61
70
|
setStickerPositionInSet
|
|
62
71
|
deleteStickerFromSet
|
|
72
|
+
setStickerSetThumb
|
|
63
73
|
|
|
64
74
|
answerInlineQuery
|
|
65
75
|
|
|
@@ -5,11 +5,11 @@ module Telegram
|
|
|
5
5
|
attr_reader :requests
|
|
6
6
|
|
|
7
7
|
module StubbedConstructor
|
|
8
|
-
def new(*args)
|
|
8
|
+
def new(*args, **kwargs)
|
|
9
9
|
if self == ClientStub || !ClientStub.stub_all?
|
|
10
10
|
super
|
|
11
11
|
else
|
|
12
|
-
ClientStub.new(*args)
|
|
12
|
+
ClientStub.new(*args, **kwargs)
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
end
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
require 'base64'
|
|
2
|
+
require 'openssl'
|
|
3
|
+
|
|
1
4
|
require 'telegram/bot'
|
|
2
5
|
require 'active_support/core_ext/array/wrap'
|
|
3
6
|
|
|
@@ -17,10 +20,8 @@ module Telegram
|
|
|
17
20
|
end || 'telegram_webhook'
|
|
18
21
|
end
|
|
19
22
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
def escape_token(token)
|
|
23
|
-
token && token.tr(':', '_')
|
|
23
|
+
def token_hash(token)
|
|
24
|
+
Base64.urlsafe_encode64(OpenSSL::Digest::SHA1.digest(token), padding: false)
|
|
24
25
|
end
|
|
25
26
|
end
|
|
26
27
|
|
|
@@ -34,14 +35,17 @@ module Telegram
|
|
|
34
35
|
#
|
|
35
36
|
# # pass additional options
|
|
36
37
|
# telegram_webhook TelegramController, :default, as: :custom_route_name
|
|
37
|
-
|
|
38
|
+
#
|
|
39
|
+
# # Default path is generated using hashed bot token. Override it using:
|
|
40
|
+
# telegram_webhook TelegramController, :default, path: 'top/secret'
|
|
41
|
+
def telegram_webhook(controller, bot = :default, path: nil, **options)
|
|
38
42
|
bot = Client.wrap(bot)
|
|
39
43
|
params = {
|
|
40
44
|
to: Middleware.new(bot, controller),
|
|
41
45
|
as: RoutesHelper.route_name_for_bot(bot),
|
|
42
46
|
format: false,
|
|
43
47
|
}.merge!(options)
|
|
44
|
-
post("telegram/#{RoutesHelper.
|
|
48
|
+
post(path || "telegram/#{bot.token && RoutesHelper.token_hash(bot.token)}", params)
|
|
45
49
|
UpdatesPoller.add(bot, controller) if Telegram.bot_poller_mode?
|
|
46
50
|
end
|
|
47
51
|
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Telegram
|
|
4
|
+
module Bot
|
|
5
|
+
module Tasks
|
|
6
|
+
extend self
|
|
7
|
+
|
|
8
|
+
def set_webhook
|
|
9
|
+
routes = Rails.application.routes.url_helpers
|
|
10
|
+
cert_file = ENV['CERT']
|
|
11
|
+
cert = File.open(cert_file) if cert_file
|
|
12
|
+
each_bot do |key, bot|
|
|
13
|
+
route_name = RoutesHelper.route_name_for_bot(bot)
|
|
14
|
+
url = routes.send("#{route_name}_url")
|
|
15
|
+
say("Setting webhook for #{key}...")
|
|
16
|
+
bot.set_webhook(
|
|
17
|
+
url: url,
|
|
18
|
+
certificate: cert,
|
|
19
|
+
ip_address: ENV['IP_ADDRESS'],
|
|
20
|
+
drop_pending_updates: drop_pending_updates,
|
|
21
|
+
)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def delete_webhook
|
|
26
|
+
each_bot do |key, bot|
|
|
27
|
+
say("Deleting webhook for #{key}...")
|
|
28
|
+
bot.delete_webhook(drop_pending_updates: drop_pending_updates)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def log_out
|
|
33
|
+
each_bot do |key, bot|
|
|
34
|
+
say("Logging out #{key}...")
|
|
35
|
+
bot.log_out
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def close
|
|
40
|
+
each_bot do |key, bot|
|
|
41
|
+
say("Closing #{key}...")
|
|
42
|
+
bot.close
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
private
|
|
47
|
+
|
|
48
|
+
def say(text)
|
|
49
|
+
puts(text) unless Rails.env.test? # rubocop:disable Rails/Output
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def each_bot(&block)
|
|
53
|
+
id = ENV['BOT'].try!(:to_sym)
|
|
54
|
+
bots = id ? {id => Client.by_id(id)} : Telegram.bots
|
|
55
|
+
bots.each { |key, bot| bot.async(false) { block[key, bot] } }
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def drop_pending_updates
|
|
59
|
+
ENV['DROP_PENDING_UPDATES'].try!(:downcase) == 'true'
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -97,6 +97,8 @@ module Telegram
|
|
|
97
97
|
callback_query
|
|
98
98
|
shipping_query
|
|
99
99
|
pre_checkout_query
|
|
100
|
+
poll
|
|
101
|
+
poll_answer
|
|
100
102
|
].freeze
|
|
101
103
|
|
|
102
104
|
class << self
|
|
@@ -148,7 +150,7 @@ module Telegram
|
|
|
148
150
|
# Accessor to `'from'` field of payload. Can be overriden with `from` option
|
|
149
151
|
# for #initialize.
|
|
150
152
|
def from
|
|
151
|
-
@_from ||= payload
|
|
153
|
+
@_from ||= payload.is_a?(Hash) ? payload['from'] : payload.try(:from)
|
|
152
154
|
end
|
|
153
155
|
|
|
154
156
|
# Processes current update.
|
|
@@ -206,6 +208,10 @@ module Telegram
|
|
|
206
208
|
[payload_type, [payload['data']]]
|
|
207
209
|
end
|
|
208
210
|
|
|
211
|
+
def action_for_poll_answer
|
|
212
|
+
[payload_type, [payload['poll_id'], payload['option_ids']]]
|
|
213
|
+
end
|
|
214
|
+
|
|
209
215
|
# Silently ignore unsupported messages to not fail when user crafts
|
|
210
216
|
# an update with usupported command, callback query context, etc.
|
|
211
217
|
def action_missing(action, *_args)
|
data/lib/telegram/bot/version.rb
CHANGED
data/telegram-bot.gemspec
CHANGED
|
@@ -17,15 +17,12 @@ Gem::Specification.new do |spec|
|
|
|
17
17
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
18
18
|
spec.require_paths = ['lib']
|
|
19
19
|
|
|
20
|
-
spec.
|
|
21
|
-
'See upgrade guide at https://github.com/telegram-bot-rb/telegram-bot/wiki/Upgrading-to-0.14'
|
|
20
|
+
spec.required_ruby_version = '>= 2.4'
|
|
22
21
|
|
|
23
|
-
spec.
|
|
24
|
-
|
|
25
|
-
spec.add_dependency 'actionpack', '>= 4.0', '< 6.0'
|
|
26
|
-
spec.add_dependency 'activesupport', '>= 4.0', '< 6.0'
|
|
22
|
+
spec.add_dependency 'actionpack', '>= 4.0', '< 6.2'
|
|
23
|
+
spec.add_dependency 'activesupport', '>= 4.0', '< 6.2'
|
|
27
24
|
spec.add_dependency 'httpclient', '~> 2.7'
|
|
28
25
|
|
|
29
26
|
spec.add_development_dependency 'bundler', '> 1.16'
|
|
30
|
-
spec.add_development_dependency 'rake', '~>
|
|
27
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
|
31
28
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: telegram-bot
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.15.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Max Melentiev
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-01-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: actionpack
|
|
@@ -19,7 +19,7 @@ dependencies:
|
|
|
19
19
|
version: '4.0'
|
|
20
20
|
- - "<"
|
|
21
21
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: '6.
|
|
22
|
+
version: '6.2'
|
|
23
23
|
type: :runtime
|
|
24
24
|
prerelease: false
|
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -29,7 +29,7 @@ dependencies:
|
|
|
29
29
|
version: '4.0'
|
|
30
30
|
- - "<"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '6.
|
|
32
|
+
version: '6.2'
|
|
33
33
|
- !ruby/object:Gem::Dependency
|
|
34
34
|
name: activesupport
|
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -39,7 +39,7 @@ dependencies:
|
|
|
39
39
|
version: '4.0'
|
|
40
40
|
- - "<"
|
|
41
41
|
- !ruby/object:Gem::Version
|
|
42
|
-
version: '6.
|
|
42
|
+
version: '6.2'
|
|
43
43
|
type: :runtime
|
|
44
44
|
prerelease: false
|
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -49,7 +49,7 @@ dependencies:
|
|
|
49
49
|
version: '4.0'
|
|
50
50
|
- - "<"
|
|
51
51
|
- !ruby/object:Gem::Version
|
|
52
|
-
version: '6.
|
|
52
|
+
version: '6.2'
|
|
53
53
|
- !ruby/object:Gem::Dependency
|
|
54
54
|
name: httpclient
|
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -84,15 +84,15 @@ dependencies:
|
|
|
84
84
|
requirements:
|
|
85
85
|
- - "~>"
|
|
86
86
|
- !ruby/object:Gem::Version
|
|
87
|
-
version: '
|
|
87
|
+
version: '13.0'
|
|
88
88
|
type: :development
|
|
89
89
|
prerelease: false
|
|
90
90
|
version_requirements: !ruby/object:Gem::Requirement
|
|
91
91
|
requirements:
|
|
92
92
|
- - "~>"
|
|
93
93
|
- !ruby/object:Gem::Version
|
|
94
|
-
version: '
|
|
95
|
-
description:
|
|
94
|
+
version: '13.0'
|
|
95
|
+
description:
|
|
96
96
|
email:
|
|
97
97
|
- melentievm@gmail.com
|
|
98
98
|
executables: []
|
|
@@ -120,6 +120,7 @@ files:
|
|
|
120
120
|
- gemfiles/rails_51.gemfile
|
|
121
121
|
- gemfiles/rails_52.gemfile
|
|
122
122
|
- gemfiles/rails_60.gemfile
|
|
123
|
+
- gemfiles/rails_61.gemfile
|
|
123
124
|
- lib/tasks/telegram-bot.rake
|
|
124
125
|
- lib/telegram/bot.rb
|
|
125
126
|
- lib/telegram/bot/async.rb
|
|
@@ -130,19 +131,18 @@ files:
|
|
|
130
131
|
- lib/telegram/bot/client_stub.rb
|
|
131
132
|
- lib/telegram/bot/config_methods.rb
|
|
132
133
|
- lib/telegram/bot/debug_client.rb
|
|
133
|
-
- lib/telegram/bot/initializers.rb
|
|
134
134
|
- lib/telegram/bot/middleware.rb
|
|
135
135
|
- lib/telegram/bot/railtie.rb
|
|
136
136
|
- lib/telegram/bot/routes_helper.rb
|
|
137
137
|
- lib/telegram/bot/rspec.rb
|
|
138
138
|
- lib/telegram/bot/rspec/callback_query_helpers.rb
|
|
139
139
|
- lib/telegram/bot/rspec/client_matchers.rb
|
|
140
|
-
- lib/telegram/bot/rspec/integration.rb
|
|
141
140
|
- lib/telegram/bot/rspec/integration/poller.rb
|
|
142
141
|
- lib/telegram/bot/rspec/integration/rack.rb
|
|
143
142
|
- lib/telegram/bot/rspec/integration/rails.rb
|
|
144
143
|
- lib/telegram/bot/rspec/integration/shared.rb
|
|
145
144
|
- lib/telegram/bot/rspec/message_helpers.rb
|
|
145
|
+
- lib/telegram/bot/tasks.rb
|
|
146
146
|
- lib/telegram/bot/updates_controller.rb
|
|
147
147
|
- lib/telegram/bot/updates_controller/callback_query_context.rb
|
|
148
148
|
- lib/telegram/bot/updates_controller/commands.rb
|
|
@@ -163,23 +163,23 @@ homepage: https://github.com/telegram-bot-rb/telegram-bot
|
|
|
163
163
|
licenses:
|
|
164
164
|
- MIT
|
|
165
165
|
metadata: {}
|
|
166
|
-
post_install_message:
|
|
166
|
+
post_install_message:
|
|
167
167
|
rdoc_options: []
|
|
168
168
|
require_paths:
|
|
169
169
|
- lib
|
|
170
170
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
171
171
|
requirements:
|
|
172
|
-
- - "
|
|
172
|
+
- - ">="
|
|
173
173
|
- !ruby/object:Gem::Version
|
|
174
|
-
version: '2.
|
|
174
|
+
version: '2.4'
|
|
175
175
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
176
176
|
requirements:
|
|
177
177
|
- - ">="
|
|
178
178
|
- !ruby/object:Gem::Version
|
|
179
179
|
version: '0'
|
|
180
180
|
requirements: []
|
|
181
|
-
rubygems_version: 3.
|
|
182
|
-
signing_key:
|
|
181
|
+
rubygems_version: 3.1.4
|
|
182
|
+
signing_key:
|
|
183
183
|
specification_version: 4
|
|
184
184
|
summary: Library for building Telegram Bots with Rails integration
|
|
185
185
|
test_files: []
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
require 'active_support/core_ext/hash/keys'
|
|
2
|
-
|
|
3
|
-
module Telegram
|
|
4
|
-
module Bot
|
|
5
|
-
module Initializers
|
|
6
|
-
# Accepts different options to initialize bot.
|
|
7
|
-
def wrap(input, **options)
|
|
8
|
-
case input
|
|
9
|
-
when Symbol then by_id(input) or raise "#{name} #{input.inspect} not configured"
|
|
10
|
-
when self then input
|
|
11
|
-
when Hash then new(**input.symbolize_keys, **options)
|
|
12
|
-
else new(input, **options)
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def by_id(_id)
|
|
17
|
-
raise 'Not implemented'
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
require 'telegram/bot'
|
|
2
|
-
Telegram::Bot.deprecation_0_15.warn(
|
|
3
|
-
"`require 'telegram/bot/rspec/integration'` is deprecated in favor of " \
|
|
4
|
-
"`require 'telegram/bot/rspec/integration/rails'`"
|
|
5
|
-
)
|
|
6
|
-
require 'telegram/bot/rspec/integration/rails'
|
|
7
|
-
|
|
8
|
-
Telegram::Bot::RSpec.with_include_context do |config|
|
|
9
|
-
config.include_context 'telegram/bot/integration/rails', telegram_bot: true
|
|
10
|
-
end
|