telegram-bot 0.15.6 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +43 -0
- data/Appraisals +5 -10
- data/CHANGELOG.md +11 -0
- data/Gemfile +9 -9
- data/README.md +5 -1
- data/Rakefile +14 -14
- 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_42.gemfile → rails_71.gemfile} +5 -5
- data/lib/telegram/bot/client/api_methods.txt +36 -4
- data/lib/telegram/bot/client/request_body_formatter.rb +21 -8
- data/lib/telegram/bot/middleware.rb +1 -1
- data/lib/telegram/bot/updates_controller/message_context.rb +1 -1
- data/lib/telegram/bot/updates_controller/rspec_helpers.rb +4 -3
- data/lib/telegram/bot/updates_controller/testing.rb +2 -2
- data/lib/telegram/bot/updates_controller/typed_update.rb +1 -1
- data/lib/telegram/bot/updates_controller.rb +8 -4
- data/lib/telegram/bot/version.rb +1 -1
- data/telegram-bot.gemspec +2 -2
- metadata +9 -10
- data/.travis.yml +0 -30
- data/gemfiles/rails_50.gemfile +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 678fc8a052951d69320003265d082899860e18dbaea0cf2e26b03498fc3d355f
|
4
|
+
data.tar.gz: c29b6e9dee95f9dbb795d5461bfc134946fafde604a25b020aecdfdea2399ad4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 863cf376b6ee18ed9b62c387a3306b09e95a250e4d15db241dbf9deb5c5e04acb5f970eb0c459adc7dc41ecc8b7e815ab00a0d49572624849213a1152049b380
|
7
|
+
data.tar.gz: a43acea839782fdfa01bf4b52a963c95ac6db7a7ed1bb9de3e625e20bc934a2bd9951af4d6cfab4898ecbf096423da45cd74bcf68ec17deb7157acbe1281053e
|
@@ -0,0 +1,43 @@
|
|
1
|
+
name: Lint & Test
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
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.0'
|
13
|
+
# bundler-cache: true
|
14
|
+
# - run: bundle exec rubocop
|
15
|
+
|
16
|
+
test:
|
17
|
+
runs-on: ubuntu-latest
|
18
|
+
strategy:
|
19
|
+
matrix:
|
20
|
+
ruby:
|
21
|
+
- '2.7'
|
22
|
+
gemfile:
|
23
|
+
- gemfiles/rails_61.gemfile
|
24
|
+
- gemfiles/rails_60.gemfile
|
25
|
+
- gemfiles/rails_52.gemfile
|
26
|
+
- gemfiles/rails_51.gemfile
|
27
|
+
include:
|
28
|
+
# ruby 3.x
|
29
|
+
- ruby: '3.2'
|
30
|
+
gemfile: gemfiles/rails_71.gemfile
|
31
|
+
- ruby: '3.0'
|
32
|
+
gemfile: gemfiles/rails_61.gemfile
|
33
|
+
- ruby: '3.0'
|
34
|
+
gemfile: gemfiles/rails_60.gemfile
|
35
|
+
env:
|
36
|
+
BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gemfile }}
|
37
|
+
steps:
|
38
|
+
- uses: actions/checkout@v3
|
39
|
+
- uses: ruby/setup-ruby@v1
|
40
|
+
with:
|
41
|
+
ruby-version: ${{ matrix.ruby }}
|
42
|
+
bundler-cache: true
|
43
|
+
- run: bundle exec rake spec
|
data/Appraisals
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
appraise 'rails-71' do
|
2
|
+
gem 'actionpack', '~> 7.1.0'
|
3
|
+
gem 'railties', '~> 7.1.0'
|
4
|
+
end
|
5
|
+
|
1
6
|
appraise 'rails-70' do
|
2
7
|
gem 'actionpack', '~> 7.0.0'
|
3
8
|
gem 'railties', '~> 7.0.0'
|
@@ -22,13 +27,3 @@ appraise 'rails-51' do
|
|
22
27
|
gem 'actionpack', '~> 5.1.0'
|
23
28
|
gem 'railties', '~> 5.1.0'
|
24
29
|
end
|
25
|
-
|
26
|
-
appraise 'rails-50' do
|
27
|
-
gem 'actionpack', '~> 5.0.0'
|
28
|
-
gem 'railties', '~> 5.0.0'
|
29
|
-
end
|
30
|
-
|
31
|
-
appraise 'rails-42' do
|
32
|
-
gem 'actionpack', '~> 4.2.0'
|
33
|
-
gem 'railties', '~> 4.2.0'
|
34
|
-
end
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# Unreleased
|
2
2
|
|
3
|
+
# 0.16.0
|
4
|
+
|
5
|
+
- Add `UpdatesController#webhook_request` that is set to `ActionDispatch::Request`
|
6
|
+
in webhook mode.
|
7
|
+
- Update to Bot API 6.8
|
8
|
+
- Added `chat_join_request` to PAYLOAD_TYPES
|
9
|
+
|
10
|
+
# 0.15.7
|
11
|
+
|
12
|
+
- Add support for editMessageMedia similar to sendMediaGroup.
|
13
|
+
|
3
14
|
# 0.15.6
|
4
15
|
|
5
16
|
- Rails 7.0 support.
|
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', '~> 2.0.3'
|
7
|
+
gem 'pry', '~> 0.14.1'
|
8
|
+
gem 'pry-byebug', '~> 3.10.1'
|
9
|
+
# gem 'sdoc', '~> 2.0.3'
|
10
10
|
|
11
|
-
gem 'telegram-bot-types', '~> 0.6.3'
|
11
|
+
# gem 'telegram-bot-types', '~> 0.6.3'
|
12
12
|
|
13
|
-
gem 'rspec', '~> 3.
|
14
|
-
gem 'rspec-its', '~> 1.3.0'
|
15
|
-
gem 'rspec-rails', '~> 4.0.2'
|
13
|
+
# gem 'rspec', '~> 3.12.0'
|
14
|
+
# gem 'rspec-its', '~> 1.3.0'
|
15
|
+
# gem 'rspec-rails', '~> 4.0.2'
|
16
16
|
|
17
|
-
gem 'rubocop', '~> 0.52.1'
|
17
|
+
# gem 'rubocop', '~> 0.52.1'
|
18
18
|
|
19
|
-
gem 'coveralls', '~> 0.8.23', require: false
|
19
|
+
# gem 'coveralls', '~> 0.8.23', require: false
|
20
20
|
end
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/telegram-bot.svg)](http://badge.fury.io/rb/telegram-bot)
|
4
4
|
[![Code Climate](https://codeclimate.com/github/telegram-bot-rb/telegram-bot/badges/gpa.svg)](https://codeclimate.com/github/telegram-bot-rb/telegram-bot)
|
5
|
-
[![
|
5
|
+
[![Lint & Test](https://github.com/telegram-bot-rb/telegram-bot/actions/workflows/ci.yml/badge.svg)](https://github.com/telegram-bot-rb/telegram-bot/actions/workflows/ci.yml)
|
6
6
|
|
7
7
|
Tools for developing Telegram bots. Best used with Rails, but can be used in
|
8
8
|
[standalone app](https://github.com/telegram-bot-rb/telegram-bot/wiki/Not-rails-application).
|
@@ -430,6 +430,10 @@ There are several options to run it automatically:
|
|
430
430
|
- Use `Telegram::Bot::Middleware` with rack ([example in wiki](https://github.com/telegram-bot-rb/telegram-bot/wiki/Not-rails-application)).
|
431
431
|
- Use poller (described in the next section).
|
432
432
|
|
433
|
+
When controller runs in webhook mode `Telegram::Bot::Middleware` passes
|
434
|
+
`ActionDispatch::Request` object to the `.dispatch` method.
|
435
|
+
It's available via `#webhook_request` controller method.
|
436
|
+
|
433
437
|
To run action without update (ex., send notifications from jobs),
|
434
438
|
you can call `#process` directly. In this case controller can be initialized
|
435
439
|
with `:from` and/or `:chat` options instead of `update` object:
|
data/Rakefile
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
|
-
require 'rspec/core/rake_task'
|
2
|
+
# require 'rspec/core/rake_task'
|
3
3
|
|
4
|
-
RSpec::Core::RakeTask.new(:spec)
|
4
|
+
# RSpec::Core::RakeTask.new(:spec)
|
5
5
|
|
6
6
|
task default: :spec
|
7
7
|
|
8
|
-
require 'sdoc'
|
9
|
-
RDoc::Task.new(:doc) do |rdoc|
|
10
|
-
|
8
|
+
# require 'sdoc'
|
9
|
+
# RDoc::Task.new(:doc) do |rdoc|
|
10
|
+
# rdoc.rdoc_dir = 'doc'
|
11
11
|
|
12
|
-
|
12
|
+
# rdoc.title = 'RailsStuff'
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
# rdoc.options << '--markup' << 'markdown'
|
15
|
+
# rdoc.options << '-e' << 'UTF-8'
|
16
|
+
# rdoc.options << '--format' << 'sdoc'
|
17
|
+
# rdoc.options << '--template' << 'rails'
|
18
|
+
# rdoc.options << '--all'
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
end
|
20
|
+
# rdoc.rdoc_files.include('README.md')
|
21
|
+
# rdoc.rdoc_files.include('lib/**/*.rb')
|
22
|
+
# end
|
data/gemfiles/rails_51.gemfile
CHANGED
@@ -7,11 +7,11 @@ 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.
|
10
|
+
gem "pry", "~> 0.14.1"
|
11
|
+
gem "pry-byebug", "~> 3.10.1"
|
12
12
|
gem "sdoc", "~> 2.0.3"
|
13
13
|
gem "telegram-bot-types", "~> 0.6.3"
|
14
|
-
gem "rspec", "~> 3.
|
14
|
+
gem "rspec", "~> 3.12.0"
|
15
15
|
gem "rspec-its", "~> 1.3.0"
|
16
16
|
gem "rspec-rails", "~> 4.0.2"
|
17
17
|
gem "rubocop", "~> 0.52.1"
|
data/gemfiles/rails_52.gemfile
CHANGED
@@ -7,11 +7,11 @@ 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.
|
10
|
+
gem "pry", "~> 0.14.1"
|
11
|
+
gem "pry-byebug", "~> 3.10.1"
|
12
12
|
gem "sdoc", "~> 2.0.3"
|
13
13
|
gem "telegram-bot-types", "~> 0.6.3"
|
14
|
-
gem "rspec", "~> 3.
|
14
|
+
gem "rspec", "~> 3.12.0"
|
15
15
|
gem "rspec-its", "~> 1.3.0"
|
16
16
|
gem "rspec-rails", "~> 4.0.2"
|
17
17
|
gem "rubocop", "~> 0.52.1"
|
data/gemfiles/rails_60.gemfile
CHANGED
@@ -7,11 +7,11 @@ gem "railties", "~> 6.0.0"
|
|
7
7
|
|
8
8
|
group :development do
|
9
9
|
gem "appraisal", "~> 2.2"
|
10
|
-
gem "pry", "~> 0.
|
11
|
-
gem "pry-byebug", "~> 3.
|
10
|
+
gem "pry", "~> 0.14.1"
|
11
|
+
gem "pry-byebug", "~> 3.10.1"
|
12
12
|
gem "sdoc", "~> 2.0.3"
|
13
13
|
gem "telegram-bot-types", "~> 0.6.3"
|
14
|
-
gem "rspec", "~> 3.
|
14
|
+
gem "rspec", "~> 3.12.0"
|
15
15
|
gem "rspec-its", "~> 1.3.0"
|
16
16
|
gem "rspec-rails", "~> 4.0.2"
|
17
17
|
gem "rubocop", "~> 0.52.1"
|
data/gemfiles/rails_61.gemfile
CHANGED
@@ -7,11 +7,11 @@ gem "railties", "~> 6.1.0"
|
|
7
7
|
|
8
8
|
group :development do
|
9
9
|
gem "appraisal", "~> 2.2"
|
10
|
-
gem "pry", "~> 0.
|
11
|
-
gem "pry-byebug", "~> 3.
|
10
|
+
gem "pry", "~> 0.14.1"
|
11
|
+
gem "pry-byebug", "~> 3.10.1"
|
12
12
|
gem "sdoc", "~> 2.0.3"
|
13
13
|
gem "telegram-bot-types", "~> 0.6.3"
|
14
|
-
gem "rspec", "~> 3.
|
14
|
+
gem "rspec", "~> 3.12.0"
|
15
15
|
gem "rspec-its", "~> 1.3.0"
|
16
16
|
gem "rspec-rails", "~> 4.0.2"
|
17
17
|
gem "rubocop", "~> 0.52.1"
|
data/gemfiles/rails_70.gemfile
CHANGED
@@ -7,11 +7,11 @@ gem "railties", "~> 7.0.0"
|
|
7
7
|
|
8
8
|
group :development do
|
9
9
|
gem "appraisal", "~> 2.2"
|
10
|
-
gem "pry", "~> 0.
|
11
|
-
gem "pry-byebug", "~> 3.
|
10
|
+
gem "pry", "~> 0.14.1"
|
11
|
+
gem "pry-byebug", "~> 3.10.1"
|
12
12
|
gem "sdoc", "~> 2.0.3"
|
13
13
|
gem "telegram-bot-types", "~> 0.6.3"
|
14
|
-
gem "rspec", "~> 3.
|
14
|
+
gem "rspec", "~> 3.12.0"
|
15
15
|
gem "rspec-its", "~> 1.3.0"
|
16
16
|
gem "rspec-rails", "~> 4.0.2"
|
17
17
|
gem "rubocop", "~> 0.52.1"
|
@@ -2,16 +2,16 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "actionpack", "~>
|
6
|
-
gem "railties", "~>
|
5
|
+
gem "actionpack", "~> 7.1.0"
|
6
|
+
gem "railties", "~> 7.1.0"
|
7
7
|
|
8
8
|
group :development do
|
9
9
|
gem "appraisal", "~> 2.2"
|
10
|
-
gem "pry", "~> 0.
|
11
|
-
gem "pry-byebug", "~> 3.
|
10
|
+
gem "pry", "~> 0.14.1"
|
11
|
+
gem "pry-byebug", "~> 3.10.1"
|
12
12
|
gem "sdoc", "~> 2.0.3"
|
13
13
|
gem "telegram-bot-types", "~> 0.6.3"
|
14
|
-
gem "rspec", "~> 3.
|
14
|
+
gem "rspec", "~> 3.12.0"
|
15
15
|
gem "rspec-its", "~> 1.3.0"
|
16
16
|
gem "rspec-rails", "~> 4.0.2"
|
17
17
|
gem "rubocop", "~> 0.52.1"
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Generated with bin/fetch-telegram-methods
|
2
|
-
# Bot API
|
2
|
+
# Bot API 6.8
|
3
3
|
|
4
4
|
getUpdates
|
5
5
|
setWebhook
|
@@ -21,8 +21,6 @@ sendVoice
|
|
21
21
|
sendVideoNote
|
22
22
|
sendMediaGroup
|
23
23
|
sendLocation
|
24
|
-
editMessageLiveLocation
|
25
|
-
stopMessageLiveLocation
|
26
24
|
sendVenue
|
27
25
|
sendContact
|
28
26
|
sendPoll
|
@@ -58,30 +56,64 @@ getChatMemberCount
|
|
58
56
|
getChatMember
|
59
57
|
setChatStickerSet
|
60
58
|
deleteChatStickerSet
|
59
|
+
getForumTopicIconStickers
|
60
|
+
createForumTopic
|
61
|
+
editForumTopic
|
62
|
+
closeForumTopic
|
63
|
+
reopenForumTopic
|
64
|
+
deleteForumTopic
|
65
|
+
unpinAllForumTopicMessages
|
66
|
+
editGeneralForumTopic
|
67
|
+
closeGeneralForumTopic
|
68
|
+
reopenGeneralForumTopic
|
69
|
+
hideGeneralForumTopic
|
70
|
+
unhideGeneralForumTopic
|
71
|
+
unpinAllGeneralForumTopicMessages
|
61
72
|
answerCallbackQuery
|
62
73
|
setMyCommands
|
63
74
|
deleteMyCommands
|
64
75
|
getMyCommands
|
76
|
+
setMyName
|
77
|
+
getMyName
|
78
|
+
setMyDescription
|
79
|
+
getMyDescription
|
80
|
+
setMyShortDescription
|
81
|
+
getMyShortDescription
|
82
|
+
setChatMenuButton
|
83
|
+
getChatMenuButton
|
84
|
+
setMyDefaultAdministratorRights
|
85
|
+
getMyDefaultAdministratorRights
|
65
86
|
|
66
87
|
editMessageText
|
67
88
|
editMessageCaption
|
68
89
|
editMessageMedia
|
90
|
+
editMessageLiveLocation
|
91
|
+
stopMessageLiveLocation
|
69
92
|
editMessageReplyMarkup
|
70
93
|
stopPoll
|
71
94
|
deleteMessage
|
72
95
|
|
73
96
|
sendSticker
|
74
97
|
getStickerSet
|
98
|
+
getCustomEmojiStickers
|
75
99
|
uploadStickerFile
|
76
100
|
createNewStickerSet
|
77
101
|
addStickerToSet
|
78
102
|
setStickerPositionInSet
|
79
103
|
deleteStickerFromSet
|
80
|
-
|
104
|
+
setStickerEmojiList
|
105
|
+
setStickerKeywords
|
106
|
+
setStickerMaskPosition
|
107
|
+
setStickerSetTitle
|
108
|
+
setStickerSetThumbnail
|
109
|
+
setCustomEmojiStickerSetThumbnail
|
110
|
+
deleteStickerSet
|
81
111
|
|
82
112
|
answerInlineQuery
|
113
|
+
answerWebAppQuery
|
83
114
|
|
84
115
|
sendInvoice
|
116
|
+
createInvoiceLink
|
85
117
|
answerShippingQuery
|
86
118
|
answerPreCheckoutQuery
|
87
119
|
|
@@ -11,8 +11,14 @@ module Telegram
|
|
11
11
|
|
12
12
|
def format(body, action)
|
13
13
|
body = body.dup
|
14
|
-
|
15
|
-
|
14
|
+
case action.to_s
|
15
|
+
when 'sendMediaGroup'
|
16
|
+
extract_files_from_array!(body, :media)
|
17
|
+
when 'editMessageMedia'
|
18
|
+
replace_field(body, :media) do |value|
|
19
|
+
files = {}
|
20
|
+
extract_files_from_hash(value, files).tap { body.merge!(files) }
|
21
|
+
end
|
16
22
|
end
|
17
23
|
body.each do |key, val|
|
18
24
|
body[key] = val.to_json if val.is_a?(Hash) || val.is_a?(Array)
|
@@ -21,12 +27,19 @@ module Telegram
|
|
21
27
|
|
22
28
|
private
|
23
29
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
+
# Detects field by symbol or string name and replaces it with mapped value.
|
31
|
+
def replace_field(hash, field_name)
|
32
|
+
field_name = [field_name.to_sym, field_name.to_s].find { |x| hash.key?(x) }
|
33
|
+
hash[field_name] = yield hash[field_name] if field_name
|
34
|
+
end
|
35
|
+
|
36
|
+
def extract_files_from_array!(hash, field_name)
|
37
|
+
replace_field(hash, field_name) do |value|
|
38
|
+
break value unless value.is_a?(Array)
|
39
|
+
files = {}
|
40
|
+
value.map { |x| extract_files_from_hash(x, files) }.
|
41
|
+
tap { hash.merge!(files) }
|
42
|
+
end
|
30
43
|
end
|
31
44
|
|
32
45
|
# Replace File objects with `attach` URIs. File objects are added into `files` hash.
|
@@ -13,8 +13,9 @@ RSpec.shared_context 'telegram/bot/updates_controller' do
|
|
13
13
|
x.extend Telegram::Bot::UpdatesController::Testing
|
14
14
|
end
|
15
15
|
end
|
16
|
-
let(:controller_args) { [bot, deep_stringify(update)] }
|
16
|
+
let(:controller_args) { [bot, deep_stringify(update), webhook_request] }
|
17
17
|
let(:update) { {payload_type => payload} }
|
18
|
+
let(:webhook_request) { nil }
|
18
19
|
let(:payload_type) { :some_type }
|
19
20
|
let(:payload) { double(:payload) }
|
20
21
|
let(:bot) { Telegram::Bot::ClientStub.new(bot_name) }
|
@@ -22,8 +23,8 @@ RSpec.shared_context 'telegram/bot/updates_controller' do
|
|
22
23
|
let(:session) { controller.send(:session) }
|
23
24
|
|
24
25
|
# Process update.
|
25
|
-
def dispatch(update = self.update, bot = self.bot)
|
26
|
-
controller.dispatch_again(bot, deep_stringify(update))
|
26
|
+
def dispatch(update = self.update, bot = self.bot, webhook_request = self.webhook_request)
|
27
|
+
controller.dispatch_again(bot, deep_stringify(update), webhook_request)
|
27
28
|
end
|
28
29
|
|
29
30
|
# Same as `.as_json` but mocks-friendly.
|
@@ -5,9 +5,9 @@ module Telegram
|
|
5
5
|
IVARS_TO_KEEP = %i[@_session].freeze
|
6
6
|
|
7
7
|
# Perform multiple dispatches on same instance.
|
8
|
-
def dispatch_again(bot = nil, update = nil)
|
8
|
+
def dispatch_again(bot = nil, update = nil, webhook_request = nil)
|
9
9
|
recycle!
|
10
|
-
initialize(bot, update)
|
10
|
+
initialize(bot, update, webhook_request)
|
11
11
|
dispatch
|
12
12
|
end
|
13
13
|
|
@@ -4,7 +4,7 @@ module Telegram
|
|
4
4
|
# Include this module to type cast update to Virtus model
|
5
5
|
# using `telegram-bot-types` gem (install this gem first).
|
6
6
|
module TypedUpdate
|
7
|
-
def initialize(bot = nil, update = nil)
|
7
|
+
def initialize(bot = nil, update = nil, webhook_request = nil)
|
8
8
|
update = Types::Update.new(update) if update && !update.is_a?(Types::Update)
|
9
9
|
super
|
10
10
|
end
|
@@ -101,6 +101,7 @@ module Telegram
|
|
101
101
|
poll_answer
|
102
102
|
my_chat_member
|
103
103
|
chat_member
|
104
|
+
chat_join_request
|
104
105
|
].freeze
|
105
106
|
|
106
107
|
class << self
|
@@ -117,21 +118,24 @@ module Telegram
|
|
117
118
|
end
|
118
119
|
end
|
119
120
|
|
120
|
-
attr_internal_reader :
|
121
|
+
attr_internal_reader :bot, :payload, :payload_type, :update, :webhook_request
|
121
122
|
delegate :username, to: :bot, prefix: true, allow_nil: true
|
122
123
|
|
123
|
-
#
|
124
|
+
# `update` can be either update object with hash access & string
|
124
125
|
# keys or Hash with `:from` or `:chat` to override this values and assume
|
125
126
|
# that update is nil.
|
126
|
-
|
127
|
+
# ActionDispatch::Request object is passed in `webhook_request` when bot running
|
128
|
+
# in webhook mode.
|
129
|
+
def initialize(bot = nil, update = nil, webhook_request = nil)
|
127
130
|
if update.is_a?(Hash) && (update.key?(:from) || update.key?(:chat))
|
128
131
|
options = update
|
129
132
|
update = nil
|
130
133
|
end
|
131
|
-
@_update = update
|
132
134
|
@_bot = bot
|
135
|
+
@_update = update
|
133
136
|
@_chat, @_from = options && options.values_at(:chat, :from)
|
134
137
|
@_payload, @_payload_type = self.class.payload_from_update(update)
|
138
|
+
@_webhook_request = webhook_request
|
135
139
|
end
|
136
140
|
|
137
141
|
# Accessor to `'chat'` field of payload. Also tries `'chat'` in `'message'`
|
data/lib/telegram/bot/version.rb
CHANGED
data/telegram-bot.gemspec
CHANGED
@@ -19,8 +19,8 @@ Gem::Specification.new do |spec|
|
|
19
19
|
|
20
20
|
spec.required_ruby_version = '>= 2.4'
|
21
21
|
|
22
|
-
spec.add_dependency 'actionpack', '>= 4.0', '< 7.
|
23
|
-
spec.add_dependency 'activesupport', '>= 4.0', '< 7.
|
22
|
+
spec.add_dependency 'actionpack', '>= 4.0', '< 7.2'
|
23
|
+
spec.add_dependency 'activesupport', '>= 4.0', '< 7.2'
|
24
24
|
spec.add_dependency 'httpclient', '~> 2.7'
|
25
25
|
|
26
26
|
spec.add_development_dependency 'bundler', '> 1.16'
|
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.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max Melentiev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-11-10 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: '7.
|
22
|
+
version: '7.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: '7.
|
32
|
+
version: '7.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: '7.
|
42
|
+
version: '7.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: '7.
|
52
|
+
version: '7.2'
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: httpclient
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,10 +100,10 @@ extensions: []
|
|
100
100
|
extra_rdoc_files: []
|
101
101
|
files:
|
102
102
|
- ".codeclimate.yml"
|
103
|
+
- ".github/workflows/ci.yml"
|
103
104
|
- ".gitignore"
|
104
105
|
- ".rspec"
|
105
106
|
- ".rubocop.yml"
|
106
|
-
- ".travis.yml"
|
107
107
|
- Appraisals
|
108
108
|
- CHANGELOG.md
|
109
109
|
- Gemfile
|
@@ -115,13 +115,12 @@ files:
|
|
115
115
|
- bin/git-hooks/pre-commit
|
116
116
|
- bin/install_git_hooks
|
117
117
|
- bin/setup
|
118
|
-
- gemfiles/rails_42.gemfile
|
119
|
-
- gemfiles/rails_50.gemfile
|
120
118
|
- gemfiles/rails_51.gemfile
|
121
119
|
- gemfiles/rails_52.gemfile
|
122
120
|
- gemfiles/rails_60.gemfile
|
123
121
|
- gemfiles/rails_61.gemfile
|
124
122
|
- gemfiles/rails_70.gemfile
|
123
|
+
- gemfiles/rails_71.gemfile
|
125
124
|
- lib/tasks/telegram-bot.rake
|
126
125
|
- lib/telegram/bot.rb
|
127
126
|
- lib/telegram/bot/async.rb
|
@@ -180,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
179
|
- !ruby/object:Gem::Version
|
181
180
|
version: '0'
|
182
181
|
requirements: []
|
183
|
-
rubygems_version: 3.
|
182
|
+
rubygems_version: 3.4.20
|
184
183
|
signing_key:
|
185
184
|
specification_version: 4
|
186
185
|
summary: Library for building Telegram Bots with Rails integration
|
data/.travis.yml
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
os: linux
|
2
|
-
dist: xenial
|
3
|
-
language: ruby
|
4
|
-
cache: bundler
|
5
|
-
rvm:
|
6
|
-
- 2.6
|
7
|
-
- 2.5
|
8
|
-
gemfile:
|
9
|
-
- gemfiles/rails_61.gemfile
|
10
|
-
- gemfiles/rails_60.gemfile
|
11
|
-
- gemfiles/rails_52.gemfile
|
12
|
-
jobs:
|
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
|
19
|
-
# old rails
|
20
|
-
- rvm: 2.5
|
21
|
-
gemfile: gemfiles/rails_51.gemfile
|
22
|
-
- rvm: 2.5
|
23
|
-
gemfile: gemfiles/rails_50.gemfile
|
24
|
-
- rvm: 2.5
|
25
|
-
gemfile: gemfiles/rails_42.gemfile
|
26
|
-
# old rubies
|
27
|
-
- rvm: 2.4
|
28
|
-
gemfile: gemfiles/rails_52.gemfile
|
29
|
-
notifications:
|
30
|
-
email: false
|
data/gemfiles/rails_50.gemfile
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
gem "actionpack", "~> 5.0.0"
|
6
|
-
gem "railties", "~> 5.0.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.3"
|
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: "../"
|