telegram_chatbot 0.1.1 → 0.1.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79b122d7f5355236543557588ee7a2e237e5426610c30e80a1419b0e2d16ed54
|
4
|
+
data.tar.gz: fd423ca255d15f31a23c71fdd5706dd1ac8836199ddeb9dab3c2a1cfde7be4df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4f1274062183c37ef1da36c90a6a09c14507e24478637a69d52b1399e9882beb43f4a918b9971bca61b2f8f2b9de5cb0be1d4fbb3ab5442cee59954fb04195f
|
7
|
+
data.tar.gz: 4a3c4fffab70750dcea399e4c9d8f1101bf03269ec64a37498b831f4107aa389a65b61779666717c52ca16b2d1da86d2894929af236479db88f84037c34bed6f
|
@@ -1,14 +1,27 @@
|
|
1
1
|
module TelegramChatbot
|
2
2
|
class Notification
|
3
|
-
def self.
|
3
|
+
def self.bulk_notify_async(message, groups = [])
|
4
4
|
return unless bot.present? && bot.actived?
|
5
5
|
|
6
|
-
|
6
|
+
groups.each do |group|
|
7
|
+
notify_async(message, group)
|
8
|
+
end
|
7
9
|
end
|
8
10
|
|
9
|
-
def self.
|
10
|
-
|
11
|
-
|
11
|
+
def self.notify_async(message, group = nil)
|
12
|
+
return if group.nil? && !group.actived?
|
13
|
+
|
14
|
+
NotificationWorker.perform_async(message, group.id)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.notify(message, group_id = nil)
|
18
|
+
return if group_id.nil?
|
19
|
+
|
20
|
+
begin
|
21
|
+
group = ::TelegramChatbot::ChatGroup.find(group_id)
|
22
|
+
client.send_message(chat_id: group.chat_id, text: message, parse_mode: :HTML) if group.actived?
|
23
|
+
rescue ActiveRecord::RecordNotFound => e
|
24
|
+
logger.info "Find not found chat_group ID: #{group_id}"
|
12
25
|
rescue ::Telegram::Bot::Forbidden => e
|
13
26
|
group.update(actived: false, reason: e)
|
14
27
|
end
|
@@ -4,10 +4,10 @@ module TelegramChatbot
|
|
4
4
|
class NotificationWorker
|
5
5
|
include Sidekiq::Worker
|
6
6
|
|
7
|
-
def perform(message,
|
8
|
-
return
|
7
|
+
def perform(message, group_id = nil)
|
8
|
+
return if !(group_id.present? && message.present?)
|
9
9
|
|
10
|
-
Notification.notify(message,
|
10
|
+
Notification.notify(message, group_id)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: telegram_chatbot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sokly
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-04-
|
11
|
+
date: 2021-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -170,6 +170,20 @@ dependencies:
|
|
170
170
|
- - ">="
|
171
171
|
- !ruby/object:Gem::Version
|
172
172
|
version: '0'
|
173
|
+
- !ruby/object:Gem::Dependency
|
174
|
+
name: database_cleaner-active_record
|
175
|
+
requirement: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - ">="
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '0'
|
180
|
+
type: :development
|
181
|
+
prerelease: false
|
182
|
+
version_requirements: !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - ">="
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '0'
|
173
187
|
- !ruby/object:Gem::Dependency
|
174
188
|
name: pg
|
175
189
|
requirement: !ruby/object:Gem::Requirement
|