telegram-bot 0.3.0 → 0.14.3
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 +5 -5
- data/.codeclimate.yml +8 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +35 -7
- data/.travis.yml +26 -1
- data/Appraisals +31 -0
- data/CHANGELOG.md +161 -0
- data/Gemfile +8 -3
- data/README.md +463 -73
- data/bin/fetch-telegram-methods +41 -0
- data/bin/setup +1 -0
- data/gemfiles/rails_42.gemfile +21 -0
- data/gemfiles/rails_50.gemfile +21 -0
- data/gemfiles/rails_51.gemfile +21 -0
- data/gemfiles/rails_52.gemfile +21 -0
- data/gemfiles/rails_60.gemfile +21 -0
- data/gemfiles/rails_61.gemfile +23 -0
- data/lib/tasks/telegram-bot.rake +13 -7
- data/lib/telegram/bot/async.rb +157 -0
- data/lib/telegram/bot/client/api_helper.rb +31 -0
- data/lib/telegram/bot/client/api_methods.txt +75 -0
- data/lib/telegram/bot/client/typed_response.rb +26 -0
- data/lib/telegram/bot/client.rb +79 -0
- data/lib/telegram/bot/client_stub.rb +52 -0
- data/lib/telegram/bot/config_methods.rb +72 -0
- data/lib/telegram/bot/debug_client.rb +23 -0
- data/lib/telegram/bot/initializers.rb +21 -0
- data/lib/telegram/bot/middleware.rb +7 -5
- data/lib/telegram/bot/railtie.rb +4 -2
- data/lib/telegram/bot/routes_helper.rb +24 -33
- data/lib/telegram/bot/rspec/callback_query_helpers.rb +39 -0
- data/lib/telegram/bot/rspec/client_matchers.rb +151 -0
- data/lib/telegram/bot/rspec/integration/poller.rb +14 -0
- data/lib/telegram/bot/rspec/integration/rack.rb +24 -0
- data/lib/telegram/bot/rspec/integration/rails.rb +28 -0
- data/lib/telegram/bot/rspec/integration/shared.rb +14 -0
- data/lib/telegram/bot/rspec/integration.rb +10 -0
- data/lib/telegram/bot/rspec/message_helpers.rb +26 -0
- data/lib/telegram/bot/rspec.rb +16 -0
- data/lib/telegram/bot/updates_controller/callback_query_context.rb +37 -0
- data/lib/telegram/bot/updates_controller/commands.rb +44 -0
- data/lib/telegram/bot/updates_controller/instrumentation.rb +15 -8
- data/lib/telegram/bot/updates_controller/log_subscriber.rb +4 -4
- data/lib/telegram/bot/updates_controller/message_context.rb +78 -0
- data/lib/telegram/bot/updates_controller/reply_helpers.rb +74 -0
- data/lib/telegram/bot/updates_controller/rescue.rb +20 -0
- data/lib/telegram/bot/updates_controller/rspec_helpers.rb +41 -0
- data/lib/telegram/bot/updates_controller/session.rb +99 -0
- data/lib/telegram/bot/updates_controller/testing.rb +35 -0
- data/lib/telegram/bot/updates_controller/translation.rb +47 -0
- data/lib/telegram/bot/updates_controller/typed_update.rb +14 -0
- data/lib/telegram/bot/updates_controller.rb +179 -60
- data/lib/telegram/bot/updates_poller.rb +57 -27
- data/lib/telegram/bot/version.rb +2 -2
- data/lib/telegram/bot.rb +22 -84
- data/telegram-bot.gemspec +8 -5
- metadata +65 -17
- data/lib/telegram/bottable.rb +0 -41
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 86966ea026e7fee0f7fdf41ed9ed276ffe40573f2ca80b381d37fa3841e4106b
|
|
4
|
+
data.tar.gz: 31a39fd06a2d8ea5dc1f724ffba44df1ec20c56622825a3c871101b27d8ef0cf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c78d6cba52499218f9946d218b0b0224eea69abae54f4cc51e551120aa827955acdd20ba2dce76e4ca76906424a86292683c06e4ef034a4c6c3839b895beb35b
|
|
7
|
+
data.tar.gz: d3d9a48d327f364f1419fbf5a665564a3c63e53955515f7eb1d52d91af30e7e69690d958450bb02c4f66cae6e543df71cb35a79111716fcc1107211b7f30256f
|
data/.codeclimate.yml
ADDED
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -1,27 +1,55 @@
|
|
|
1
|
+
# Rubocop does not support 2.0
|
|
2
|
+
Gemspec/RequiredRubyVersion: {Enabled: false}
|
|
3
|
+
|
|
1
4
|
Rails: {Enabled: true}
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
Style/AlignParameters:
|
|
6
|
+
Layout/AlignParameters:
|
|
5
7
|
# Disable, till rubocop supports combination of styles.
|
|
6
8
|
# Use one of this styles where appropriate, keep it clean, compact and readable.
|
|
7
9
|
Enabled: false
|
|
8
10
|
# EnforcedStyle:
|
|
9
11
|
# - with_first_parameter
|
|
10
12
|
# - with_fixed_indentation
|
|
11
|
-
|
|
13
|
+
|
|
14
|
+
# Breaks
|
|
15
|
+
#
|
|
16
|
+
# I18n.t(key,
|
|
17
|
+
# param: val,
|
|
18
|
+
# # ...
|
|
19
|
+
# )
|
|
20
|
+
Layout/ClosingParenthesisIndentation: {Enabled: false}
|
|
21
|
+
Layout/DotPosition: {EnforcedStyle: trailing}
|
|
22
|
+
Layout/FirstParameterIndentation: {EnforcedStyle: consistent}
|
|
23
|
+
# Same as Layout/ClosingParenthesisIndentation
|
|
24
|
+
Layout/MultilineMethodCallBraceLayout: {Enabled: false}
|
|
25
|
+
Layout/MultilineMethodCallIndentation: {EnforcedStyle: indented}
|
|
26
|
+
Layout/MultilineOperationIndentation: {EnforcedStyle: indented}
|
|
27
|
+
Layout/SpaceInsideHashLiteralBraces: {EnforcedStyle: no_space}
|
|
28
|
+
|
|
29
|
+
# Offences named scopes and `expect {}.to change {}`.
|
|
30
|
+
Lint/AmbiguousBlockAssociation: {Enabled: false}
|
|
31
|
+
|
|
32
|
+
Naming/PredicateName: {Enabled: false}
|
|
33
|
+
Naming/VariableNumber: {EnforcedStyle: snake_case}
|
|
34
|
+
|
|
35
|
+
Style/Alias: {Enabled: false}
|
|
36
|
+
Style/AndOr: {EnforcedStyle: conditionals}
|
|
12
37
|
Style/Documentation: {Enabled: false}
|
|
13
|
-
Style/DotPosition: {EnforcedStyle: trailing}
|
|
14
38
|
Style/IfUnlessModifier: {Enabled: false}
|
|
39
|
+
|
|
40
|
+
# Consistent to other definitions.
|
|
41
|
+
Style/EmptyMethod: {EnforcedStyle: expanded}
|
|
42
|
+
|
|
15
43
|
Style/ModuleFunction: {Enabled: false}
|
|
16
|
-
Style/MultilineOperationIndentation: {EnforcedStyle: indented}
|
|
17
44
|
Style/NestedParenthesizedCalls: {Enabled: false}
|
|
18
|
-
Style/PredicateName: {Enabled: false}
|
|
19
45
|
Style/SignalException: {EnforcedStyle: only_raise}
|
|
20
|
-
Style/SpaceInsideHashLiteralBraces: {EnforcedStyle: no_space}
|
|
21
46
|
Style/TrailingCommaInArguments: {Enabled: false}
|
|
22
47
|
Style/TrailingCommaInLiteral: {EnforcedStyleForMultiline: comma}
|
|
23
48
|
|
|
24
49
|
Metrics/AbcSize: {Max: 21}
|
|
50
|
+
# Other metrics are just enough.
|
|
51
|
+
# This one offences all specs, routes and some initializers.
|
|
52
|
+
Metrics/BlockLength: {Enabled: false}
|
|
25
53
|
Metrics/LineLength: {Max: 100}
|
|
26
54
|
Metrics/MethodLength: {Max: 30}
|
|
27
55
|
Metrics/CyclomaticComplexity: {Max: 8}
|
data/.travis.yml
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
language: ruby
|
|
2
2
|
cache: bundler
|
|
3
3
|
rvm:
|
|
4
|
-
|
|
4
|
+
- 2.6
|
|
5
|
+
- 2.5
|
|
6
|
+
gemfile:
|
|
7
|
+
- gemfiles/rails_60.gemfile
|
|
8
|
+
- gemfiles/rails_52.gemfile
|
|
9
|
+
matrix:
|
|
10
|
+
include:
|
|
11
|
+
# old rails
|
|
12
|
+
- rvm: 2.5
|
|
13
|
+
gemfile: gemfiles/rails_51.gemfile
|
|
14
|
+
- rvm: 2.5
|
|
15
|
+
gemfile: gemfiles/rails_50.gemfile
|
|
16
|
+
- rvm: 2.5
|
|
17
|
+
gemfile: gemfiles/rails_42.gemfile
|
|
18
|
+
# old rubies
|
|
19
|
+
- rvm: 2.4
|
|
20
|
+
gemfile: gemfiles/rails_52.gemfile
|
|
21
|
+
- rvm: 2.3
|
|
22
|
+
gemfile: gemfiles/rails_52.gemfile
|
|
23
|
+
# future rails
|
|
24
|
+
- rvm: 2.5
|
|
25
|
+
gemfile: gemfiles/rails_61.gemfile
|
|
26
|
+
# Allow rails 6.1 to fail while master branch is used
|
|
27
|
+
allow_failures:
|
|
28
|
+
- rvm: 2.5
|
|
29
|
+
gemfile: gemfiles/rails_61.gemfile
|
|
5
30
|
notifications:
|
|
6
31
|
email: false
|
data/Appraisals
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
appraise 'rails-61' do
|
|
2
|
+
git 'https://github.com/rails/rails.git' do
|
|
3
|
+
gem 'actionpack', '~> 6.1.0.alpha'
|
|
4
|
+
gem 'railties', '~> 6.1.0.alpha'
|
|
5
|
+
end
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
appraise 'rails-60' do
|
|
9
|
+
gem 'actionpack', '~> 6.0.0'
|
|
10
|
+
gem 'railties', '~> 6.0.0'
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
appraise 'rails-52' do
|
|
14
|
+
gem 'actionpack', '~> 5.2.0'
|
|
15
|
+
gem 'railties', '~> 5.2.0'
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
appraise 'rails-51' do
|
|
19
|
+
gem 'actionpack', '~> 5.1.0'
|
|
20
|
+
gem 'railties', '~> 5.1.0'
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
appraise 'rails-50' do
|
|
24
|
+
gem 'actionpack', '~> 5.0.0'
|
|
25
|
+
gem 'railties', '~> 5.0.0'
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
appraise 'rails-42' do
|
|
29
|
+
gem 'actionpack', '~> 4.2.0'
|
|
30
|
+
gem 'railties', '~> 4.2.0'
|
|
31
|
+
end
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# Unreleased
|
|
2
|
+
|
|
3
|
+
- Rails 6.0 support.
|
|
4
|
+
- Update to Bot API 4.4.
|
|
5
|
+
|
|
6
|
+
# 0.14.2
|
|
7
|
+
|
|
8
|
+
- Add reply helpers: `answer_pre_checkout_query`, `answer_shipping_query`.
|
|
9
|
+
- Update to Bot API 4.3.
|
|
10
|
+
|
|
11
|
+
# 0.14.1
|
|
12
|
+
|
|
13
|
+
- Read config from secrets when credentials don't provide it in rails >= 5.2.
|
|
14
|
+
- Remove botan.io support. It's already shut down, so it should not be a braking change.
|
|
15
|
+
https://github.com/botanio/sdk#this-service-will-be-shut-down-on-25th-may-2018
|
|
16
|
+
- Update to Bot API 4.1.
|
|
17
|
+
|
|
18
|
+
# 0.14.0
|
|
19
|
+
|
|
20
|
+
- Make integration & controller specs consistent.
|
|
21
|
+
__Breaking changes__ for controller specs:
|
|
22
|
+
- Changed signature `dispatch(bot, update) => dispatch(update, bot)`.
|
|
23
|
+
- `update` helper is symbolized by default.
|
|
24
|
+
- `build_update(type, data)` is dropped in favor of `deep_stringify(type => data)`.
|
|
25
|
+
- Provide support for integration testing of bots in poller mode and non-Rails apps.
|
|
26
|
+
__Breaking changes__:
|
|
27
|
+
- Requiring `telegram/bot/rspec/integration` is deprecated in favor of
|
|
28
|
+
`telegram/bot/rspec/integration/rails`.
|
|
29
|
+
- `:telegram_bot` rspec tag is replaced with `telegram_bot: :rails`.
|
|
30
|
+
- __Breaking change__. Use bang-methods as actions for commands.
|
|
31
|
+
This prevents calling context contextual actions and payload specific actions with commands.
|
|
32
|
+
Translation helper strips `!` from action name for lazy translations.
|
|
33
|
+
- __Breaking change__. Drop `.context_handler`, `.context_to_action!` methods.
|
|
34
|
+
Use pass action name directly to `#save_context`.
|
|
35
|
+
It's the same as `.context_to_action!` is enabled by default.
|
|
36
|
+
- Class-level helper for lazy translations.
|
|
37
|
+
|
|
38
|
+
# 0.13.1
|
|
39
|
+
|
|
40
|
+
- Extracted typed response mappings to telegram-bot-types gem.
|
|
41
|
+
It now provides definitions for all API v3.5 methods.
|
|
42
|
+
- Fix #chat for non-message updates with TypedUpdates enabled
|
|
43
|
+
|
|
44
|
+
# 0.13.0
|
|
45
|
+
|
|
46
|
+
- `rescue_from`.
|
|
47
|
+
- Support for `credentials` store in Rails 5.2.
|
|
48
|
+
- Deprecate `telegram_webhooks` in favor of `telegram_webhook`.
|
|
49
|
+
It was too complicated and such routes looked ugly.
|
|
50
|
+
|
|
51
|
+
# 0.12.4
|
|
52
|
+
|
|
53
|
+
- Fix spec helpers for callback queries.
|
|
54
|
+
|
|
55
|
+
# 0.12.3
|
|
56
|
+
|
|
57
|
+
- New methods from Bot API v3.5
|
|
58
|
+
- Collect all api helper-methods in Client::ApiHelper module.
|
|
59
|
+
- Add `bin/fetch-telegram-methods` to update API methods list from website.
|
|
60
|
+
|
|
61
|
+
# 0.12.1
|
|
62
|
+
|
|
63
|
+
- Fix `set_webhook` rake task for async bots with self-issued certificates.
|
|
64
|
+
- Make `#session` raise error when store is not configured,
|
|
65
|
+
don't use Rails.cache as fallback for session_store.
|
|
66
|
+
- Allow use different sessions for MessageContext.
|
|
67
|
+
|
|
68
|
+
# 0.12.0
|
|
69
|
+
|
|
70
|
+
- New API methods and payload types (up to Bot API 3.2).
|
|
71
|
+
- Fix rails 5.1.x support.
|
|
72
|
+
- RSpec context for callback_query updates.
|
|
73
|
+
- `edit_message` helper.
|
|
74
|
+
- ClientStub saves and returns token. Fixes testing multiple bots.
|
|
75
|
+
- Raise descriptive error when accessing not-configured bot.
|
|
76
|
+
|
|
77
|
+
# 0.11.3
|
|
78
|
+
|
|
79
|
+
- Release dependencies for Rails 5.1.
|
|
80
|
+
|
|
81
|
+
# 0.11.2
|
|
82
|
+
|
|
83
|
+
- Rails 5.1 deep symbolized secrets support.
|
|
84
|
+
|
|
85
|
+
# 0.11.1
|
|
86
|
+
|
|
87
|
+
- Fixed poller for typed response.
|
|
88
|
+
|
|
89
|
+
# 0.11.0
|
|
90
|
+
|
|
91
|
+
- Remove Bot::StaleChat in favor of Bot::Forbidden, as Telegram adds more
|
|
92
|
+
and more new descriptions.
|
|
93
|
+
Please open an issue if you face a problem.
|
|
94
|
+
|
|
95
|
+
# 0.10.2
|
|
96
|
+
|
|
97
|
+
- Support `(edited_)channel_post` updates.
|
|
98
|
+
- New methods from 2.3, 2.3.1 API updates.
|
|
99
|
+
|
|
100
|
+
# 0.10.0
|
|
101
|
+
|
|
102
|
+
- Integration helpers for RSpec.
|
|
103
|
+
- Fix for ruby 2.2.0 bug by @bob-frost.
|
|
104
|
+
|
|
105
|
+
# 0.9.0
|
|
106
|
+
|
|
107
|
+
- Async API requests.
|
|
108
|
+
- One more description for StaleChat error.
|
|
109
|
+
- edit_message_* methods.
|
|
110
|
+
- API methods from 2016-10-03 update
|
|
111
|
+
- Fix typo in module name: CallbackQueyContext -> CallbackQueryContext.
|
|
112
|
+
- Take `chat` from `message` for callback queries
|
|
113
|
+
- RSpec matchers.
|
|
114
|
+
|
|
115
|
+
# 0.8.0
|
|
116
|
+
|
|
117
|
+
- Fixed `#reply_with`, now it sets `reply_to_message_id` as it's supposed to.
|
|
118
|
+
Added `#respond_with` which works the same way, but doesn't set `reply_to_message_id`.
|
|
119
|
+
Please, replace all occurrences of `reply_with` to `respond_with` to
|
|
120
|
+
keep it working the old way.
|
|
121
|
+
- Fixes for Rails 5:
|
|
122
|
+
- Controller callbacks
|
|
123
|
+
- Middleware
|
|
124
|
+
- Setup travis builds
|
|
125
|
+
|
|
126
|
+
# 0.7.4
|
|
127
|
+
|
|
128
|
+
- Rails 5 support by @dreyks (#4).
|
|
129
|
+
|
|
130
|
+
# 0.7.3
|
|
131
|
+
|
|
132
|
+
- Fixed issues with poller in production (#3)
|
|
133
|
+
|
|
134
|
+
# 0.7.2
|
|
135
|
+
|
|
136
|
+
- Bot API 2.1
|
|
137
|
+
- Fixed possible crashes when payload type is not supported.
|
|
138
|
+
Provides empty session when neither `from` nor `chat` is defined.
|
|
139
|
+
|
|
140
|
+
# 0.7.0
|
|
141
|
+
|
|
142
|
+
- New Bot API methods.
|
|
143
|
+
- Helpers for inline keyboards, support for callback_query (with contextual actions).
|
|
144
|
+
- Changed action methods signature
|
|
145
|
+
- `#inline_query(payload) -> #inline_query(query, offset)`
|
|
146
|
+
- `#chosen_inline_result(payload)` -> `#chosen_inline_result(result_id, query)`
|
|
147
|
+
- MessageContext doesn't use second #process call to run contextual action.
|
|
148
|
+
- Botan.io metrics.
|
|
149
|
+
|
|
150
|
+
# 0.6.0
|
|
151
|
+
|
|
152
|
+
- StaleChat error.
|
|
153
|
+
- Encode arrays as json in request body.
|
|
154
|
+
|
|
155
|
+
# 0.5.0
|
|
156
|
+
|
|
157
|
+
- MessageContext.
|
|
158
|
+
- Running controller action without update.
|
|
159
|
+
- Client.wrap supports symbols.
|
|
160
|
+
- Improved testing utils: ability to process multiple updates on same controller instance,
|
|
161
|
+
stubbing all clients in application.
|
data/Gemfile
CHANGED
|
@@ -2,14 +2,19 @@ source 'https://rubygems.org'
|
|
|
2
2
|
gemspec
|
|
3
3
|
|
|
4
4
|
group :development do
|
|
5
|
-
gem '
|
|
5
|
+
gem 'appraisal', '~> 2.2'
|
|
6
|
+
|
|
6
7
|
gem 'pry', '~> 0.10.1'
|
|
7
8
|
gem 'pry-byebug', '~> 3.2.0'
|
|
9
|
+
gem 'sdoc', '~> 0.4.1'
|
|
10
|
+
|
|
11
|
+
gem 'telegram-bot-types', '~> 0.6.0'
|
|
8
12
|
|
|
9
|
-
gem 'rspec', '~> 3.
|
|
13
|
+
gem 'rspec', '~> 3.5.0'
|
|
10
14
|
gem 'rspec-its', '~> 1.1.0'
|
|
15
|
+
gem 'rspec-rails', '~> 3.5.0'
|
|
11
16
|
|
|
12
|
-
gem 'rubocop', '~> 0.
|
|
17
|
+
gem 'rubocop', '~> 0.52.1'
|
|
13
18
|
|
|
14
19
|
gem 'coveralls', '~> 0.8.2', require: false
|
|
15
20
|
end
|