telegram_workflow 1.6.0 → 1.8.0
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/.github/workflows/ruby.yml +1 -1
- data/Gemfile +1 -2
- data/lib/telegram_workflow/action.rb +1 -1
- data/lib/telegram_workflow/client.rb +30 -5
- data/lib/telegram_workflow/config.rb +4 -0
- data/lib/telegram_workflow/params.rb +13 -6
- data/lib/telegram_workflow/version.rb +1 -1
- data/lib/telegram_workflow/workflow.rb +8 -4
- data/lib/telegram_workflow.rb +0 -1
- metadata +3 -4
- data/lib/telegram_workflow/stores/file.rb +0 -18
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4e920305a6060ecc2d039a6527387f4f89f02b064278c43c9d3fedc41d1123ae
|
|
4
|
+
data.tar.gz: fdd2e724083ca50bcfe2c805142da92f5972d9abfff25e5140892aca0d5bdd68
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9895a4c27ab3740acdf3efd69c1bf40ee074a387375f0c9f858ff05aa88a0df69c2e8e1046c698cc38936e6fa2995f705377b5933098db9bc7e191c8cf3bfb26
|
|
7
|
+
data.tar.gz: 0dd8a6b2fe280fa0d1bd556fc39cbe027073da5210c76c3e5d93a91616a6967b41e594383f2edb86eb2bbd6e115e40e8eddf6845dfe2f79f11655277c4b414be
|
data/.github/workflows/ruby.yml
CHANGED
data/Gemfile
CHANGED
|
@@ -3,11 +3,10 @@ source "https://rubygems.org"
|
|
|
3
3
|
# Specify your gem's dependencies in telegram_workflow.gemspec
|
|
4
4
|
gemspec
|
|
5
5
|
|
|
6
|
-
gem "rake", "~>
|
|
6
|
+
gem "rake", "~> 13.0"
|
|
7
7
|
gem "rspec", "~> 3.0"
|
|
8
8
|
|
|
9
9
|
group :test do
|
|
10
10
|
gem "simplecov"
|
|
11
11
|
gem "simplecov-lcov", "~> 0.8.0"
|
|
12
|
-
gem "dbm"
|
|
13
12
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
class TelegramWorkflow::Client
|
|
2
|
-
API_VERSION = "
|
|
2
|
+
API_VERSION = "6.7"
|
|
3
3
|
WebhookConfigPath = Pathname.new("tmp/telegram_workflow/webhook_config.txt")
|
|
4
4
|
|
|
5
5
|
AVAILABLE_ACTIONS = %i(
|
|
@@ -34,6 +34,8 @@ class TelegramWorkflow::Client
|
|
|
34
34
|
restrictChatMember
|
|
35
35
|
promoteChatMember
|
|
36
36
|
setChatAdministratorCustomTitle
|
|
37
|
+
banChatSenderChat
|
|
38
|
+
unbanChatSenderChat
|
|
37
39
|
setChatPermissions
|
|
38
40
|
exportChatInviteLink
|
|
39
41
|
createChatInviteLink
|
|
@@ -43,6 +45,10 @@ class TelegramWorkflow::Client
|
|
|
43
45
|
deleteChatPhoto
|
|
44
46
|
setChatTitle
|
|
45
47
|
setChatDescription
|
|
48
|
+
setMyDescription
|
|
49
|
+
getMyDescription
|
|
50
|
+
setMyShortDescription
|
|
51
|
+
getMyShortDescription
|
|
46
52
|
pinChatMessage
|
|
47
53
|
unpinChatMessage
|
|
48
54
|
unpinAllChatMessages
|
|
@@ -55,9 +61,28 @@ class TelegramWorkflow::Client
|
|
|
55
61
|
setChatStickerSet
|
|
56
62
|
deleteChatStickerSet
|
|
57
63
|
answerCallbackQuery
|
|
64
|
+
answerWebAppQuery
|
|
58
65
|
setMyCommands
|
|
59
66
|
deleteMyCommands
|
|
60
67
|
getMyCommands
|
|
68
|
+
setChatMenuButton
|
|
69
|
+
getChatMenuButton
|
|
70
|
+
setMyDefaultAdministratorRights
|
|
71
|
+
getMyDefaultAdministratorRights
|
|
72
|
+
getCustomEmojiStickers
|
|
73
|
+
|
|
74
|
+
createForumTopic
|
|
75
|
+
editForumTopic
|
|
76
|
+
closeForumTopic
|
|
77
|
+
reopenForumTopic
|
|
78
|
+
deleteForumTopic
|
|
79
|
+
unpinAllForumTopicMessages
|
|
80
|
+
getForumTopicIconStickers
|
|
81
|
+
editGeneralForumTopic
|
|
82
|
+
closeGeneralForumTopic
|
|
83
|
+
reopenGeneralForumTopic
|
|
84
|
+
hideGeneralForumTopic
|
|
85
|
+
unhideGeneralForumTopic
|
|
61
86
|
|
|
62
87
|
editMessageText
|
|
63
88
|
editMessageCaption
|
|
@@ -73,7 +98,7 @@ class TelegramWorkflow::Client
|
|
|
73
98
|
addStickerToSet
|
|
74
99
|
setStickerPositionInSet
|
|
75
100
|
deleteStickerFromSet
|
|
76
|
-
|
|
101
|
+
setStickerSetThumbnail
|
|
77
102
|
|
|
78
103
|
answerInlineQuery
|
|
79
104
|
|
|
@@ -101,7 +126,7 @@ class TelegramWorkflow::Client
|
|
|
101
126
|
|
|
102
127
|
define_method(method_name) do |params = {}|
|
|
103
128
|
if deprecated_in_favor_of = DEPRECATED_ACTIONS[action]
|
|
104
|
-
TelegramWorkflow.config.logger.warn "
|
|
129
|
+
TelegramWorkflow.config.logger.warn "#{action} action is deprecated. Use #{deprecated_in_favor_of} action instead."
|
|
105
130
|
end
|
|
106
131
|
|
|
107
132
|
@inline ?
|
|
@@ -129,12 +154,12 @@ class TelegramWorkflow::Client
|
|
|
129
154
|
end
|
|
130
155
|
|
|
131
156
|
def __setup_webhook(webhook_url = TelegramWorkflow.config.webhook_url, params = {})
|
|
132
|
-
TelegramWorkflow.config.logger.info "
|
|
157
|
+
TelegramWorkflow.config.logger.info "Checking webhook setup..."
|
|
133
158
|
|
|
134
159
|
webhook_params = { url: webhook_url, allowed_updates: [], **params }
|
|
135
160
|
|
|
136
161
|
if cached_webhook_config != webhook_params
|
|
137
|
-
TelegramWorkflow.config.logger.info "
|
|
162
|
+
TelegramWorkflow.config.logger.info "Setting up a new webhook..."
|
|
138
163
|
set_webhook(webhook_params)
|
|
139
164
|
end
|
|
140
165
|
end
|
|
@@ -16,7 +16,10 @@ class TelegramWorkflow::Params
|
|
|
16
16
|
@params.dig("shipping_query", "from") ||
|
|
17
17
|
@params.dig("inline_query", "from") ||
|
|
18
18
|
@params.dig("chosen_inline_result", "from") ||
|
|
19
|
-
@params.dig("poll_answer", "user")
|
|
19
|
+
@params.dig("poll_answer", "user") ||
|
|
20
|
+
@params.dig("chat_join_request", "from") ||
|
|
21
|
+
@params.dig("chat_member", "from") ||
|
|
22
|
+
@params.dig("my_chat_member", "from")
|
|
20
23
|
end
|
|
21
24
|
|
|
22
25
|
def language_code
|
|
@@ -32,11 +35,15 @@ class TelegramWorkflow::Params
|
|
|
32
35
|
end
|
|
33
36
|
|
|
34
37
|
def chat_id
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
chat&.dig("id")
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def chat
|
|
42
|
+
@params.dig("message", "chat") ||
|
|
43
|
+
@params.dig("callback_query", "message", "chat") ||
|
|
44
|
+
@params.dig("edited_message", "chat") ||
|
|
45
|
+
@params.dig("channel_post", "chat") ||
|
|
46
|
+
@params.dig("edited_channel_post", "chat")
|
|
40
47
|
end
|
|
41
48
|
|
|
42
49
|
def message
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
require "securerandom"
|
|
2
|
+
|
|
1
3
|
class TelegramWorkflow::Workflow
|
|
2
|
-
attr_reader :params, :client
|
|
4
|
+
attr_reader :params, :client, :logger
|
|
3
5
|
|
|
4
6
|
def initialize(raw_params)
|
|
5
7
|
@params = TelegramWorkflow::Params.new(raw_params)
|
|
6
8
|
@session = TelegramWorkflow::Session.new(@params)
|
|
9
|
+
|
|
7
10
|
@logger = TelegramWorkflow.config.logger
|
|
11
|
+
@logger = @logger.tagged(SecureRandom.hex(8)) if TelegramWorkflow.config.tagged_logger?
|
|
8
12
|
|
|
9
13
|
if @params.start?
|
|
10
14
|
set_current_action(TelegramWorkflow.config.start_action)
|
|
@@ -23,7 +27,7 @@ class TelegramWorkflow::Workflow
|
|
|
23
27
|
current_action.public_send(current_step) # setup callbacks
|
|
24
28
|
current_action.__run_on_message # run a callback
|
|
25
29
|
else
|
|
26
|
-
@logger.info "
|
|
30
|
+
@logger.info "Processing by shared handler"
|
|
27
31
|
end
|
|
28
32
|
|
|
29
33
|
while @redirect_to
|
|
@@ -47,10 +51,10 @@ class TelegramWorkflow::Workflow
|
|
|
47
51
|
private
|
|
48
52
|
|
|
49
53
|
def log_request
|
|
50
|
-
@logger.info "
|
|
54
|
+
@logger.info "Processing by #{current_action.class.name}##{current_step}"
|
|
51
55
|
|
|
52
56
|
if TelegramWorkflow.config.webhook_url.nil?
|
|
53
|
-
@logger.info "
|
|
57
|
+
@logger.info "Parameters: #{@params.to_h}"
|
|
54
58
|
end
|
|
55
59
|
end
|
|
56
60
|
|
data/lib/telegram_workflow.rb
CHANGED
|
@@ -35,7 +35,6 @@ require "telegram_workflow/updates"
|
|
|
35
35
|
require "telegram_workflow/workflow"
|
|
36
36
|
require "telegram_workflow/input_file"
|
|
37
37
|
require "telegram_workflow/stores/in_memory"
|
|
38
|
-
require "telegram_workflow/stores/file"
|
|
39
38
|
|
|
40
39
|
TelegramWorkflow.__after_configuration do |config|
|
|
41
40
|
if config.webhook_url
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: telegram_workflow
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Roman Samoilov
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2023-07-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: http
|
|
@@ -91,7 +91,6 @@ files:
|
|
|
91
91
|
- lib/telegram_workflow/params.rb
|
|
92
92
|
- lib/telegram_workflow/rspec.rb
|
|
93
93
|
- lib/telegram_workflow/session.rb
|
|
94
|
-
- lib/telegram_workflow/stores/file.rb
|
|
95
94
|
- lib/telegram_workflow/stores/in_memory.rb
|
|
96
95
|
- lib/telegram_workflow/updates.rb
|
|
97
96
|
- lib/telegram_workflow/version.rb
|
|
@@ -118,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
118
117
|
- !ruby/object:Gem::Version
|
|
119
118
|
version: '0'
|
|
120
119
|
requirements: []
|
|
121
|
-
rubygems_version: 3.
|
|
120
|
+
rubygems_version: 3.4.10
|
|
122
121
|
signing_key:
|
|
123
122
|
specification_version: 4
|
|
124
123
|
summary: A simple library to create Telegram Bots in Ruby.
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
require "dbm"
|
|
2
|
-
|
|
3
|
-
class TelegramWorkflow::Stores::File
|
|
4
|
-
StorePath = Pathname.new("tmp/telegram_workflow/file_store")
|
|
5
|
-
|
|
6
|
-
def initialize
|
|
7
|
-
StorePath.dirname.mkpath unless StorePath.exist?
|
|
8
|
-
@store = DBM.open(StorePath.to_s)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def read(key)
|
|
12
|
-
@store[key.to_s]
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def write(key, value)
|
|
16
|
-
@store[key.to_s] = value
|
|
17
|
-
end
|
|
18
|
-
end
|