konsierge-notifier 0.1.2 → 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 +4 -4
- data/konsierge-notifier.gemspec +1 -4
- data/lib/konsierge/notifier/configuration.rb +26 -0
- data/lib/konsierge/notifier/version.rb +7 -0
- data/lib/konsierge/notifier.rb +10 -14
- data/mise.toml +2 -0
- data/sig/konsierge/notifier.rbs +12 -0
- metadata +6 -18
- data/sig/konsierge/notifier/mailer.rbs +0 -31
- data/sig/konsierge/notifier/telegram.rbs +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 392db80e0f625751fe214faa879dc1a4e6218c77d5338a69a35c44cad0ca0eb0
|
4
|
+
data.tar.gz: cb3ab8bb6983b4cc97220a691d975f1796d47b05f1cd1ea3230b84723273ef4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fa88d757296eeb57e9d5e691c0e2a85e189fc4790e9fca1da88596f958c63231fc73e76bdd6bda848b9444331882b287455f73af8999faffa3ab81561316084
|
7
|
+
data.tar.gz: acb2407a783958a0d6e2e902aacd054b122783d911e1e983b517c7b309d548619eab52684f844af23c23cc1734f058b851f8362eae17f429bf649a5de183c1e5
|
data/konsierge-notifier.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'lib/konsierge/notifier'
|
3
|
+
require_relative 'lib/konsierge/notifier/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'konsierge-notifier'
|
@@ -26,9 +26,6 @@ Gem::Specification.new do |spec|
|
|
26
26
|
|
27
27
|
spec.add_dependency 'dotenv', '~> 2.7'
|
28
28
|
|
29
|
-
# All notifiers
|
30
|
-
spec.add_dependency 'dry-configurable', '~> 1.0'
|
31
|
-
|
32
29
|
# Telegram notifier
|
33
30
|
spec.add_dependency 'telegram-bot', '~> 0.16.1'
|
34
31
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Konsierge
|
4
|
+
module Notifier
|
5
|
+
class Configuration
|
6
|
+
attr_accessor :app_name, :chat_id, :bot_enabled, :message_template_path, :error_template_path, :logger,
|
7
|
+
:parse_mode
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@app_name = nil
|
11
|
+
@chat_id = ENV.fetch('TELEGRAM_CHANNEL_ID', nil)
|
12
|
+
@bot_enabled = ENV.fetch('TELEGRAM_BOT_ENABLED', false)
|
13
|
+
@message_template_path = File.expand_path('template.html.erb', __dir__)
|
14
|
+
@error_template_path = File.expand_path('error_template.html.erb', __dir__)
|
15
|
+
@logger = Logger.new($stdout)
|
16
|
+
@parse_mode = 'HTML'
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_h
|
20
|
+
instance_variables.each_with_object({}) do |var, hash|
|
21
|
+
hash[var.to_s.delete('@').to_sym] = instance_variable_get(var)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/konsierge/notifier.rb
CHANGED
@@ -1,29 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'dry-configurable'
|
4
3
|
require 'logger'
|
5
4
|
require 'telegram/bot'
|
5
|
+
require_relative 'notifier/configuration'
|
6
6
|
|
7
7
|
module Konsierge
|
8
|
-
|
9
|
-
extend ::Dry::Configurable
|
10
|
-
|
11
|
-
setting :app_name
|
12
|
-
setting :chat_id, default: ENV.fetch('TELEGRAM_CHANNEL_ID', nil)
|
13
|
-
setting :bot_enabled, default: ENV.fetch('TELEGRAM_BOT_ENABLED', false)
|
14
|
-
setting :message_template_path, default: File.expand_path('notifier/template.html.erb', __dir__)
|
15
|
-
setting :error_template_path, default: File.expand_path('notifier/error_template.html.erb', __dir__)
|
16
|
-
setting :logger, default: Logger.new($stdout)
|
17
|
-
setting :parse_mode, default: 'HTML'
|
18
|
-
|
19
|
-
VERSION = '0.1.2'
|
20
|
-
|
8
|
+
module Notifier
|
21
9
|
TELEGRAM_CHAT_ID_NOT_SET = 'Telegram Chat ID is not set'
|
22
10
|
TELEGRAM_BOT_ERROR = 'TelegramBot Error: %s'
|
23
11
|
TELEGRAM_BOT_DISABLED = 'TelegramBot is disabled! Message not sent.'
|
24
12
|
PATH_OR_CHAT_ID_NOT_PROVIDED = 'Please, provide path and chat_id'
|
25
13
|
|
26
14
|
class << self
|
15
|
+
def config
|
16
|
+
@config ||= Configuration.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def configure
|
20
|
+
yield(config)
|
21
|
+
end
|
22
|
+
|
27
23
|
def send_message(text, chat_id: nil)
|
28
24
|
send_with_message_template(
|
29
25
|
path: config.message_template_path,
|
data/mise.toml
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: konsierge-notifier
|
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
|
- David Rybolovlev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.7'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: dry-configurable
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '1.0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: telegram-bot
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -174,11 +160,13 @@ files:
|
|
174
160
|
- lib/generators/konsierge/notifier/mailer/templates/README
|
175
161
|
- lib/generators/konsierge/notifier/mailer/templates/initializer.rb
|
176
162
|
- lib/konsierge/notifier.rb
|
163
|
+
- lib/konsierge/notifier/configuration.rb
|
177
164
|
- lib/konsierge/notifier/error_template.html.erb
|
178
165
|
- lib/konsierge/notifier/template.html.erb
|
166
|
+
- lib/konsierge/notifier/version.rb
|
167
|
+
- mise.toml
|
179
168
|
- sig/konsierge.rbs
|
180
|
-
- sig/konsierge/notifier
|
181
|
-
- sig/konsierge/notifier/telegram.rbs
|
169
|
+
- sig/konsierge/notifier.rbs
|
182
170
|
homepage:
|
183
171
|
licenses: []
|
184
172
|
metadata:
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module Konsierge
|
2
|
-
module Notifier
|
3
|
-
class Mailer
|
4
|
-
@connection: ::Faraday::Connection
|
5
|
-
|
6
|
-
def initialize: (*untyped, **untyped) -> void
|
7
|
-
|
8
|
-
def configure: -> void
|
9
|
-
|
10
|
-
def config: -> ::Dry::Configurable::Config
|
11
|
-
|
12
|
-
def deliver!: (::Mail mail) -> void
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def build_payload: (::Mail mail) -> Hash[Symbol, Object]
|
17
|
-
|
18
|
-
def check_config!: -> void
|
19
|
-
|
20
|
-
def connection: -> ::Faraday::Connection
|
21
|
-
|
22
|
-
def determine_body: (::Mail mail) -> String
|
23
|
-
|
24
|
-
def process_attachments: (Array[untyped] attachments) -> Array[::Faraday::Multipart::FilePart]
|
25
|
-
|
26
|
-
def with_error_handle: -> void
|
27
|
-
|
28
|
-
def with_temp_file_deletion: -> void
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module Konsierge
|
2
|
-
module Notifier
|
3
|
-
class Telegram
|
4
|
-
TELEGRAM_CHAT_ID_NOT_SET: String
|
5
|
-
TELEGRAM_BOT_ERROR: String
|
6
|
-
TELEGRAM_BOT_DISABLED: String
|
7
|
-
PATH_OR_CHAT_ID_NOT_PROVIDED: String
|
8
|
-
|
9
|
-
def self.send_message: (String) -> bool
|
10
|
-
|
11
|
-
def self.report_error: (Exception, source?: String) -> bool
|
12
|
-
|
13
|
-
def self.send_error: (Exception, source?: String) -> bool
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
def self.send_with_message_template: (Hash[Symbol, String]) -> bool
|
18
|
-
|
19
|
-
def self.sanitize_template_options!: (Hash[Symbol, String]) -> Hash[Symbol, String]
|
20
|
-
|
21
|
-
def self.check_chat_id!: (String | NilClass) -> String
|
22
|
-
|
23
|
-
def self.send_to_telegram: (String, chat_id?: String) -> bool
|
24
|
-
|
25
|
-
def self.bot_enabled?: () -> bool
|
26
|
-
|
27
|
-
def self.log_disabled_bot_warning: () -> false
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|