telegram-bot 0.16.1 → 0.16.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +0 -4
- data/.github/workflows/ci.yml +9 -9
- data/.rubocop.yml +31 -12
- data/Appraisals +2 -0
- data/CHANGELOG.md +10 -0
- data/Gemfile +5 -3
- data/Rakefile +2 -0
- data/bin/console +6 -2
- data/bin/fetch-telegram-methods +5 -3
- data/bin/install_git_hooks +2 -1
- data/gemfiles/rails_51.gemfile +3 -3
- data/gemfiles/rails_52.gemfile +3 -3
- data/gemfiles/rails_60.gemfile +3 -3
- data/gemfiles/rails_61.gemfile +3 -3
- data/gemfiles/rails_70.gemfile +3 -3
- data/gemfiles/rails_71.gemfile +3 -3
- data/lib/tasks/telegram-bot.rake +6 -4
- data/lib/telegram/bot/async.rb +4 -2
- data/lib/telegram/bot/client/api_helper.rb +3 -1
- data/lib/telegram/bot/client/api_methods.txt +11 -1
- data/lib/telegram/bot/client/request_body_formatter.rb +2 -0
- data/lib/telegram/bot/client/typed_response.rb +2 -0
- data/lib/telegram/bot/client.rb +5 -3
- data/lib/telegram/bot/client_stub.rb +4 -2
- data/lib/telegram/bot/config_methods.rb +3 -1
- data/lib/telegram/bot/debug_client.rb +3 -1
- data/lib/telegram/bot/middleware.rb +3 -1
- data/lib/telegram/bot/railtie.rb +3 -1
- data/lib/telegram/bot/routes_helper.rb +2 -0
- data/lib/telegram/bot/rspec/callback_query_helpers.rb +3 -1
- data/lib/telegram/bot/rspec/client_matchers.rb +12 -10
- data/lib/telegram/bot/rspec/integration/poller.rb +2 -0
- data/lib/telegram/bot/rspec/integration/rack.rb +2 -0
- data/lib/telegram/bot/rspec/integration/rails.rb +2 -0
- data/lib/telegram/bot/rspec/integration/shared.rb +3 -1
- data/lib/telegram/bot/rspec/message_helpers.rb +2 -0
- data/lib/telegram/bot/rspec.rb +2 -0
- data/lib/telegram/bot/tasks.rb +4 -4
- data/lib/telegram/bot/updates_controller/callback_query_context.rb +2 -0
- data/lib/telegram/bot/updates_controller/commands.rb +4 -2
- data/lib/telegram/bot/updates_controller/instrumentation.rb +7 -5
- data/lib/telegram/bot/updates_controller/log_subscriber.rb +4 -2
- data/lib/telegram/bot/updates_controller/message_context.rb +7 -5
- data/lib/telegram/bot/updates_controller/reply_helpers.rb +4 -2
- data/lib/telegram/bot/updates_controller/rescue.rb +3 -1
- data/lib/telegram/bot/updates_controller/rspec_helpers.rb +2 -0
- data/lib/telegram/bot/updates_controller/session.rb +7 -4
- data/lib/telegram/bot/updates_controller/testing.rb +5 -2
- data/lib/telegram/bot/updates_controller/translation.rb +2 -0
- data/lib/telegram/bot/updates_controller/typed_update.rb +2 -0
- data/lib/telegram/bot/updates_controller.rb +50 -19
- data/lib/telegram/bot/updates_poller.rb +9 -9
- data/lib/telegram/bot/version.rb +3 -1
- data/lib/telegram/bot.rb +3 -9
- data/telegram-bot.gemspec +7 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eea526dbd8061ac8b091d732f3637b5e28b110eb5496074449505c96a28d8877
|
4
|
+
data.tar.gz: 4736cf91267d22a50b8be5ae409e5f2f23467ee3241ded4d8b715d14a7badec5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6e2c4373149f030a499425bd1ecdde710ba12aca9c29e4b34bfde1892a9fc0c3a89bad8f19d507c2bcc0d18acd98735565bd2984b640de142891ad3341077ba
|
7
|
+
data.tar.gz: d2afee42d6e6b59189a5eee3559b0ea7ca9405c02b971b5082a362a270ec67b1b3ec0d60a5a46704fb3a6a71fb1e496c1a38a54d44e7efc9914913f669398a77
|
data/.codeclimate.yml
CHANGED
data/.github/workflows/ci.yml
CHANGED
@@ -3,15 +3,15 @@ name: Lint & Test
|
|
3
3
|
on: [push, pull_request]
|
4
4
|
|
5
5
|
jobs:
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
6
|
+
lint:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
steps:
|
9
|
+
- uses: actions/checkout@v3
|
10
|
+
- uses: ruby/setup-ruby@v1
|
11
|
+
with:
|
12
|
+
ruby-version: '3.2'
|
13
|
+
bundler-cache: true
|
14
|
+
- run: bundle exec rubocop
|
15
15
|
|
16
16
|
test:
|
17
17
|
runs-on: ubuntu-latest
|
data/.rubocop.yml
CHANGED
@@ -1,15 +1,18 @@
|
|
1
|
-
|
2
|
-
Gemspec/RequiredRubyVersion: {Enabled: false}
|
1
|
+
require: rubocop-rails
|
3
2
|
|
4
|
-
|
3
|
+
AllCops:
|
4
|
+
TargetRubyVersion: 2.4
|
5
|
+
NewCops: enable
|
6
|
+
SuggestExtensions: false
|
7
|
+
Exclude:
|
8
|
+
- gemfiles/*
|
9
|
+
- tmp/*
|
10
|
+
- vendor/**/* # for github actions
|
5
11
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
# EnforcedStyle:
|
11
|
-
# - with_first_parameter
|
12
|
-
# - with_fixed_indentation
|
12
|
+
Gemspec/DevelopmentDependencies: {Enabled: false}
|
13
|
+
|
14
|
+
Layout/ArgumentAlignment: {EnforcedStyle: with_fixed_indentation}
|
15
|
+
Layout/ParameterAlignment: {EnforcedStyle: with_fixed_indentation}
|
13
16
|
|
14
17
|
# Breaks
|
15
18
|
#
|
@@ -19,7 +22,11 @@ Layout/AlignParameters:
|
|
19
22
|
# )
|
20
23
|
Layout/ClosingParenthesisIndentation: {Enabled: false}
|
21
24
|
Layout/DotPosition: {EnforcedStyle: trailing}
|
25
|
+
Layout/EmptyLineAfterGuardClause: {Enabled: false}
|
22
26
|
Layout/FirstParameterIndentation: {EnforcedStyle: consistent}
|
27
|
+
Layout/LineContinuationLeadingSpace: {Enabled: false}
|
28
|
+
Layout/LineEndStringConcatenationIndentation: {EnforcedStyle: indented}
|
29
|
+
Layout/LineLength: {Max: 100}
|
23
30
|
# Same as Layout/ClosingParenthesisIndentation
|
24
31
|
Layout/MultilineMethodCallBraceLayout: {Enabled: false}
|
25
32
|
Layout/MultilineMethodCallIndentation: {EnforcedStyle: indented}
|
@@ -28,8 +35,16 @@ Layout/SpaceInsideHashLiteralBraces: {EnforcedStyle: no_space}
|
|
28
35
|
|
29
36
|
# Offences named scopes and `expect {}.to change {}`.
|
30
37
|
Lint/AmbiguousBlockAssociation: {Enabled: false}
|
38
|
+
Lint/EmptyBlock:
|
39
|
+
Exclude:
|
40
|
+
- spec/**/*
|
31
41
|
|
42
|
+
Naming/FileName:
|
43
|
+
Exclude:
|
44
|
+
- lib/tasks/telegram-bot.rake
|
45
|
+
Naming/MethodParameterName: {MinNameLength: 2}
|
32
46
|
Naming/PredicateName: {Enabled: false}
|
47
|
+
Naming/RescuedExceptionsVariableName: {PreferredName: exception}
|
33
48
|
Naming/VariableNumber: {EnforcedStyle: snake_case}
|
34
49
|
|
35
50
|
Style/Alias: {Enabled: false}
|
@@ -45,12 +60,16 @@ Style/ModuleFunction: {Enabled: false}
|
|
45
60
|
Style/NestedParenthesizedCalls: {Enabled: false}
|
46
61
|
Style/SignalException: {EnforcedStyle: only_raise}
|
47
62
|
Style/TrailingCommaInArguments: {Enabled: false}
|
48
|
-
Style/
|
63
|
+
Style/TrailingCommaInArrayLiteral: {EnforcedStyleForMultiline: comma}
|
64
|
+
Style/TrailingCommaInHashLiteral: {EnforcedStyleForMultiline: comma}
|
49
65
|
|
50
66
|
Metrics/AbcSize: {Max: 21}
|
51
67
|
# Other metrics are just enough.
|
52
68
|
# This one offences all specs, routes and some initializers.
|
53
69
|
Metrics/BlockLength: {Enabled: false}
|
54
|
-
Metrics/LineLength: {Max: 100}
|
55
70
|
Metrics/MethodLength: {Max: 30}
|
56
71
|
Metrics/CyclomaticComplexity: {Max: 8}
|
72
|
+
|
73
|
+
Rails/IndexWith: {Enabled: false}
|
74
|
+
Rails/RakeEnvironment: {Enabled: false}
|
75
|
+
Rails/ShortI18n: {Enabled: false}
|
data/Appraisals
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Unreleased
|
2
2
|
|
3
|
+
# 0.16.3
|
4
|
+
|
5
|
+
- Update to Bot API 7.7
|
6
|
+
- Added `pre_checkout_query` to PAYLOAD_TYPES
|
7
|
+
|
8
|
+
# 0.16.2
|
9
|
+
|
10
|
+
- Update to Bot API 7.3
|
11
|
+
- Add `# frozen_string_literal: true` to all source files.
|
12
|
+
|
3
13
|
# 0.16.1
|
4
14
|
|
5
15
|
- Fix logger in poller mode in rails 7.1
|
data/Gemfile
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
gemspec
|
3
5
|
|
4
6
|
group :development do
|
5
7
|
gem 'appraisal', '~> 2.2'
|
6
8
|
|
7
|
-
gem '
|
8
|
-
gem 'pry-byebug', '~> 3.10.1'
|
9
|
+
gem 'debug', '~> 1.9.2'
|
9
10
|
gem 'sdoc', '~> 2.0.3'
|
10
11
|
|
11
12
|
gem 'telegram-bot-types', '~> 0.6.3'
|
@@ -14,7 +15,8 @@ group :development do
|
|
14
15
|
gem 'rspec-its', '~> 1.3.0'
|
15
16
|
gem 'rspec-rails', '~> 4.0.2'
|
16
17
|
|
17
|
-
gem 'rubocop', '~>
|
18
|
+
gem 'rubocop', '~> 1.59.0'
|
19
|
+
gem 'rubocop-rails', '~> 2.23.1'
|
18
20
|
|
19
21
|
gem 'coveralls', '~> 0.8.23', require: false
|
20
22
|
end
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
data/bin/fetch-telegram-methods
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
#
|
3
5
|
# Fetch list of methods from Telegram docs.
|
4
6
|
# Use it to update client.rb.
|
@@ -6,7 +8,7 @@
|
|
6
8
|
require 'net/http'
|
7
9
|
require 'nokogiri'
|
8
10
|
|
9
|
-
DOCS_URL = 'https://core.telegram.org/bots/api'
|
11
|
+
DOCS_URL = 'https://core.telegram.org/bots/api'
|
10
12
|
|
11
13
|
page_html = Net::HTTP.get(URI(DOCS_URL))
|
12
14
|
doc = Nokogiri::HTML(page_html)
|
@@ -18,11 +20,11 @@ headers = doc.css('h3, h4').
|
|
18
20
|
map { |g| g.map(&:text) }
|
19
21
|
|
20
22
|
# Method starts with lowercase and does not have spaces.
|
21
|
-
NOT_METHOD_REGEXP = /(\A[^a-z])|\s
|
23
|
+
NOT_METHOD_REGEXP = /(\A[^a-z])|\s/.freeze
|
22
24
|
|
23
25
|
# Filter method names.
|
24
26
|
method_list = headers.
|
25
|
-
map { |g| g.
|
27
|
+
map { |g| g.grep_v(NOT_METHOD_REGEXP) }.
|
26
28
|
reject(&:empty?)
|
27
29
|
|
28
30
|
api_version = doc.text.match(/^(?:Introducing )?(Bot API ([\d\.]+))\.?$/)
|
data/bin/install_git_hooks
CHANGED
data/gemfiles/rails_51.gemfile
CHANGED
@@ -7,14 +7,14 @@ gem "railties", "~> 5.1.0"
|
|
7
7
|
|
8
8
|
group :development do
|
9
9
|
gem "appraisal", "~> 2.2"
|
10
|
-
gem "
|
11
|
-
gem "pry-byebug", "~> 3.10.1"
|
10
|
+
gem "debug", "~> 1.9.2"
|
12
11
|
gem "sdoc", "~> 2.0.3"
|
13
12
|
gem "telegram-bot-types", "~> 0.6.3"
|
14
13
|
gem "rspec", "~> 3.12.0"
|
15
14
|
gem "rspec-its", "~> 1.3.0"
|
16
15
|
gem "rspec-rails", "~> 4.0.2"
|
17
|
-
gem "rubocop", "~>
|
16
|
+
gem "rubocop", "~> 1.59.0"
|
17
|
+
gem "rubocop-rails", "~> 2.23.1"
|
18
18
|
gem "coveralls", "~> 0.8.23", require: false
|
19
19
|
end
|
20
20
|
|
data/gemfiles/rails_52.gemfile
CHANGED
@@ -7,14 +7,14 @@ gem "railties", "~> 5.2.0"
|
|
7
7
|
|
8
8
|
group :development do
|
9
9
|
gem "appraisal", "~> 2.2"
|
10
|
-
gem "
|
11
|
-
gem "pry-byebug", "~> 3.10.1"
|
10
|
+
gem "debug", "~> 1.9.2"
|
12
11
|
gem "sdoc", "~> 2.0.3"
|
13
12
|
gem "telegram-bot-types", "~> 0.6.3"
|
14
13
|
gem "rspec", "~> 3.12.0"
|
15
14
|
gem "rspec-its", "~> 1.3.0"
|
16
15
|
gem "rspec-rails", "~> 4.0.2"
|
17
|
-
gem "rubocop", "~>
|
16
|
+
gem "rubocop", "~> 1.59.0"
|
17
|
+
gem "rubocop-rails", "~> 2.23.1"
|
18
18
|
gem "coveralls", "~> 0.8.23", require: false
|
19
19
|
end
|
20
20
|
|
data/gemfiles/rails_60.gemfile
CHANGED
@@ -7,14 +7,14 @@ gem "railties", "~> 6.0.0"
|
|
7
7
|
|
8
8
|
group :development do
|
9
9
|
gem "appraisal", "~> 2.2"
|
10
|
-
gem "
|
11
|
-
gem "pry-byebug", "~> 3.10.1"
|
10
|
+
gem "debug", "~> 1.9.2"
|
12
11
|
gem "sdoc", "~> 2.0.3"
|
13
12
|
gem "telegram-bot-types", "~> 0.6.3"
|
14
13
|
gem "rspec", "~> 3.12.0"
|
15
14
|
gem "rspec-its", "~> 1.3.0"
|
16
15
|
gem "rspec-rails", "~> 4.0.2"
|
17
|
-
gem "rubocop", "~>
|
16
|
+
gem "rubocop", "~> 1.59.0"
|
17
|
+
gem "rubocop-rails", "~> 2.23.1"
|
18
18
|
gem "coveralls", "~> 0.8.23", require: false
|
19
19
|
end
|
20
20
|
|
data/gemfiles/rails_61.gemfile
CHANGED
@@ -7,14 +7,14 @@ gem "railties", "~> 6.1.0"
|
|
7
7
|
|
8
8
|
group :development do
|
9
9
|
gem "appraisal", "~> 2.2"
|
10
|
-
gem "
|
11
|
-
gem "pry-byebug", "~> 3.10.1"
|
10
|
+
gem "debug", "~> 1.9.2"
|
12
11
|
gem "sdoc", "~> 2.0.3"
|
13
12
|
gem "telegram-bot-types", "~> 0.6.3"
|
14
13
|
gem "rspec", "~> 3.12.0"
|
15
14
|
gem "rspec-its", "~> 1.3.0"
|
16
15
|
gem "rspec-rails", "~> 4.0.2"
|
17
|
-
gem "rubocop", "~>
|
16
|
+
gem "rubocop", "~> 1.59.0"
|
17
|
+
gem "rubocop-rails", "~> 2.23.1"
|
18
18
|
gem "coveralls", "~> 0.8.23", require: false
|
19
19
|
end
|
20
20
|
|
data/gemfiles/rails_70.gemfile
CHANGED
@@ -7,14 +7,14 @@ gem "railties", "~> 7.0.0"
|
|
7
7
|
|
8
8
|
group :development do
|
9
9
|
gem "appraisal", "~> 2.2"
|
10
|
-
gem "
|
11
|
-
gem "pry-byebug", "~> 3.10.1"
|
10
|
+
gem "debug", "~> 1.9.2"
|
12
11
|
gem "sdoc", "~> 2.0.3"
|
13
12
|
gem "telegram-bot-types", "~> 0.6.3"
|
14
13
|
gem "rspec", "~> 3.12.0"
|
15
14
|
gem "rspec-its", "~> 1.3.0"
|
16
15
|
gem "rspec-rails", "~> 4.0.2"
|
17
|
-
gem "rubocop", "~>
|
16
|
+
gem "rubocop", "~> 1.59.0"
|
17
|
+
gem "rubocop-rails", "~> 2.23.1"
|
18
18
|
gem "coveralls", "~> 0.8.23", require: false
|
19
19
|
end
|
20
20
|
|
data/gemfiles/rails_71.gemfile
CHANGED
@@ -7,14 +7,14 @@ gem "railties", "~> 7.1.0"
|
|
7
7
|
|
8
8
|
group :development do
|
9
9
|
gem "appraisal", "~> 2.2"
|
10
|
-
gem "
|
11
|
-
gem "pry-byebug", "~> 3.10.1"
|
10
|
+
gem "debug", "~> 1.9.2"
|
12
11
|
gem "sdoc", "~> 2.0.3"
|
13
12
|
gem "telegram-bot-types", "~> 0.6.3"
|
14
13
|
gem "rspec", "~> 3.12.0"
|
15
14
|
gem "rspec-its", "~> 1.3.0"
|
16
15
|
gem "rspec-rails", "~> 4.0.2"
|
17
|
-
gem "rubocop", "~>
|
16
|
+
gem "rubocop", "~> 1.59.0"
|
17
|
+
gem "rubocop-rails", "~> 2.23.1"
|
18
18
|
gem "coveralls", "~> 0.8.23", require: false
|
19
19
|
end
|
20
20
|
|
data/lib/tasks/telegram-bot.rake
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
namespace :telegram do
|
2
4
|
namespace :bot do
|
3
5
|
desc 'Run poller. It broadcasts Rails.logger to STDOUT in dev like `rails s` do. ' \
|
@@ -6,14 +8,14 @@ namespace :telegram do
|
|
6
8
|
ENV['BOT_POLLER_MODE'] = 'true'
|
7
9
|
Rake::Task['environment'].invoke
|
8
10
|
if ENV.fetch('LOG_TO_STDOUT') { Rails.env.development? }.present?
|
9
|
-
console = ActiveSupport::Logger.new(
|
10
|
-
if
|
11
|
-
|
11
|
+
console = ActiveSupport::Logger.new($stderr)
|
12
|
+
if Rails.logger.respond_to?(:broadcast_to)
|
13
|
+
Rails.logger.broadcast_to(console)
|
12
14
|
else
|
13
15
|
Rails.logger.extend ActiveSupport::Logger.broadcast console
|
14
16
|
end
|
15
17
|
end
|
16
|
-
Telegram::Bot::UpdatesPoller.start(ENV['BOT']
|
18
|
+
Telegram::Bot::UpdatesPoller.start(ENV['BOT']&.to_sym || :default)
|
17
19
|
end
|
18
20
|
|
19
21
|
desc 'Set webhook urls for all bots'
|
data/lib/telegram/bot/async.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Telegram
|
2
4
|
module Bot
|
3
5
|
# Telegram clients can perform requests in async way with
|
@@ -128,7 +130,7 @@ module Telegram
|
|
128
130
|
#
|
129
131
|
# If no block is given returns previously set value or the global one,
|
130
132
|
# set by #async=.
|
131
|
-
def async(val = true)
|
133
|
+
def async(val = true) # rubocop:disable Style/OptionalBooleanParameter
|
132
134
|
thread_key = object_id
|
133
135
|
thread_store = Async.thread_store
|
134
136
|
return thread_store.fetch(thread_key) { @async } unless block_given?
|
@@ -137,7 +139,7 @@ module Telegram
|
|
137
139
|
thread_store[thread_key] = self.class.prepare_async_val(val)
|
138
140
|
yield
|
139
141
|
ensure
|
140
|
-
if
|
142
|
+
if old_val == MISSING_VALUE
|
141
143
|
thread_store.delete(thread_key)
|
142
144
|
else
|
143
145
|
thread_store[thread_key] = old_val
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'active_support/core_ext/string/inflections'
|
2
4
|
|
3
5
|
module Telegram
|
4
6
|
module Bot
|
5
7
|
class Client
|
6
8
|
module ApiHelper
|
7
|
-
METHODS_LIST_FILE = File.expand_path('
|
9
|
+
METHODS_LIST_FILE = File.expand_path('api_methods.txt', __dir__)
|
8
10
|
|
9
11
|
class << self
|
10
12
|
def methods_list(file = METHODS_LIST_FILE)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Generated with bin/fetch-telegram-methods
|
2
|
-
# Bot API
|
2
|
+
# Bot API 7.7
|
3
3
|
|
4
4
|
getUpdates
|
5
5
|
setWebhook
|
@@ -11,7 +11,9 @@ logOut
|
|
11
11
|
close
|
12
12
|
sendMessage
|
13
13
|
forwardMessage
|
14
|
+
forwardMessages
|
14
15
|
copyMessage
|
16
|
+
copyMessages
|
15
17
|
sendPhoto
|
16
18
|
sendAudio
|
17
19
|
sendDocument
|
@@ -19,6 +21,7 @@ sendVideo
|
|
19
21
|
sendAnimation
|
20
22
|
sendVoice
|
21
23
|
sendVideoNote
|
24
|
+
sendPaidMedia
|
22
25
|
sendMediaGroup
|
23
26
|
sendLocation
|
24
27
|
sendVenue
|
@@ -26,6 +29,7 @@ sendContact
|
|
26
29
|
sendPoll
|
27
30
|
sendDice
|
28
31
|
sendChatAction
|
32
|
+
setMessageReaction
|
29
33
|
getUserProfilePhotos
|
30
34
|
getFile
|
31
35
|
banChatMember
|
@@ -70,6 +74,8 @@ hideGeneralForumTopic
|
|
70
74
|
unhideGeneralForumTopic
|
71
75
|
unpinAllGeneralForumTopicMessages
|
72
76
|
answerCallbackQuery
|
77
|
+
getUserChatBoosts
|
78
|
+
getBusinessConnection
|
73
79
|
setMyCommands
|
74
80
|
deleteMyCommands
|
75
81
|
getMyCommands
|
@@ -92,6 +98,7 @@ stopMessageLiveLocation
|
|
92
98
|
editMessageReplyMarkup
|
93
99
|
stopPoll
|
94
100
|
deleteMessage
|
101
|
+
deleteMessages
|
95
102
|
|
96
103
|
sendSticker
|
97
104
|
getStickerSet
|
@@ -101,6 +108,7 @@ createNewStickerSet
|
|
101
108
|
addStickerToSet
|
102
109
|
setStickerPositionInSet
|
103
110
|
deleteStickerFromSet
|
111
|
+
replaceStickerInSet
|
104
112
|
setStickerEmojiList
|
105
113
|
setStickerKeywords
|
106
114
|
setStickerMaskPosition
|
@@ -116,6 +124,8 @@ sendInvoice
|
|
116
124
|
createInvoiceLink
|
117
125
|
answerShippingQuery
|
118
126
|
answerPreCheckoutQuery
|
127
|
+
getStarTransactions
|
128
|
+
refundStarPayment
|
119
129
|
|
120
130
|
setPassportDataErrors
|
121
131
|
|
data/lib/telegram/bot/client.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'active_support/core_ext/hash/keys'
|
2
4
|
require 'httpclient'
|
3
5
|
|
4
6
|
module Telegram
|
5
7
|
module Bot
|
6
8
|
class Client
|
7
|
-
SERVER = 'https://api.telegram.org'
|
8
|
-
URL_TEMPLATE = '%<server>s/bot%<token>s/'
|
9
|
+
SERVER = 'https://api.telegram.org'
|
10
|
+
URL_TEMPLATE = '%<server>s/bot%<token>s/'
|
9
11
|
|
10
12
|
autoload :RequestBodyFormatter, 'telegram/bot/client/request_body_formatter'
|
11
13
|
autoload :TypedResponse, 'telegram/bot/client/typed_response'
|
@@ -41,7 +43,7 @@ module Telegram
|
|
41
43
|
end
|
42
44
|
|
43
45
|
def error_for_response(response)
|
44
|
-
result = JSON.parse(response.body) rescue nil # rubocop:disable RescueModifier
|
46
|
+
result = JSON.parse(response.body) rescue nil # rubocop:disable Style/RescueModifier
|
45
47
|
return Error.new(response.reason) unless result
|
46
48
|
message = result['description'] || '-'
|
47
49
|
# This errors are raised only for valid responses from Telegram
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Telegram
|
2
4
|
module Bot
|
3
5
|
# Stubbed client for tests. Saves all requests into #requests hash.
|
@@ -17,7 +19,7 @@ module Telegram
|
|
17
19
|
class << self
|
18
20
|
# Any call to Client.new will return ClientStub instance when `enabled` is true.
|
19
21
|
# Can be used with a block.
|
20
|
-
def stub_all!(enabled = true)
|
22
|
+
def stub_all!(enabled = true) # rubocop:disable Style/OptionalBooleanParameter
|
21
23
|
Client.extend(StubbedConstructor) unless Client < StubbedConstructor
|
22
24
|
return @_stub_all = enabled unless block_given?
|
23
25
|
begin
|
@@ -34,7 +36,7 @@ module Telegram
|
|
34
36
|
end
|
35
37
|
end
|
36
38
|
|
37
|
-
def initialize(token = nil, username = nil, **options)
|
39
|
+
def initialize(token = nil, username = nil, **options) # rubocop:disable Lint/MissingSuper
|
38
40
|
@token = token || options[:token]
|
39
41
|
@username = username || options[:username] || token
|
40
42
|
reset
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'active_support/core_ext/hash/keys'
|
2
4
|
require 'active_support/core_ext/hash/indifferent_access'
|
3
5
|
|
@@ -44,7 +46,7 @@ module Telegram
|
|
44
46
|
# from `secrets.yml` merging `telegram['bot']` at `:default` key.
|
45
47
|
#
|
46
48
|
# Can be overwritten with .bots_config=
|
47
|
-
def bots_config
|
49
|
+
def bots_config # rubocop:disable Metrics/PerceivedComplexity
|
48
50
|
@bots_config ||=
|
49
51
|
if defined?(Rails.application)
|
50
52
|
app = Rails.application
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'active_support/concern'
|
2
4
|
require 'active_support/core_ext/hash/indifferent_access'
|
3
5
|
require 'active_support/json'
|
@@ -21,7 +23,7 @@ module Telegram
|
|
21
23
|
end
|
22
24
|
|
23
25
|
def inspect
|
24
|
-
"#<#{self.class.name}(#{controller
|
26
|
+
"#<#{self.class.name}(#{controller&.name})>"
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
data/lib/telegram/bot/railtie.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'telegram/bot/routes_helper'
|
2
4
|
|
3
5
|
module Telegram
|
@@ -10,7 +12,7 @@ module Telegram
|
|
10
12
|
end
|
11
13
|
|
12
14
|
config.before_initialize do
|
13
|
-
::ActionDispatch::Routing::Mapper.
|
15
|
+
::ActionDispatch::Routing::Mapper.include RoutesHelper
|
14
16
|
end
|
15
17
|
|
16
18
|
initializer 'telegram.bot.updates_controller.set_config' do |app|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'telegram/bot/rspec'
|
2
4
|
require 'telegram/bot/rspec/message_helpers'
|
3
5
|
|
@@ -7,7 +9,7 @@ RSpec.shared_context 'telegram/bot/callback_query' do
|
|
7
9
|
|
8
10
|
subject { -> { dispatch callback_query: payload } }
|
9
11
|
let(:payload) { {id: callback_query_id, from: from, message: message, data: data} }
|
10
|
-
let(:callback_query_id) { 11 }
|
12
|
+
let(:callback_query_id) { '11' }
|
11
13
|
let(:message_id) { 22 }
|
12
14
|
let(:message) { {message_id: message_id, chat: chat, text: 'message text'} }
|
13
15
|
let(:data) { raise '`let(:data) { "callback query data here" }` is required' }
|