energon-notify 0.2.0 → 0.2.1
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/lib/energon-notify.rb +29 -0
- data/lib/modules/message_discord.rb +13 -0
- data/lib/modules/message_slack.rb +0 -2
- metadata +32 -3
- data/lib/energon_notify.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 795fd3c81002476287b8056851ee406e0bf2fa10befbca38135de500cb5b9ff0
|
4
|
+
data.tar.gz: 0a3cc1ba5948a6fe44695d37439af20225b59ebcd11299d182bad6fa1b58d711
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 310a6c37770acc356c59fd5e9eb6cd862886319ba5a162065fdf271a7e133c286a014c829886d8863af62eded0a96ce868785a128b87031a67ac54dbbf770178
|
7
|
+
data.tar.gz: 303fc873bacaa3dcd4098f5b4f493607335cebbc397e7e79ce15f3af3a854bda385d038d2f3b12b5e580e016b576afbb9e2c16523711b5445c7107c860a00eda
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'slack-ruby-client'
|
2
|
+
require_relative "modules/search_slack"
|
3
|
+
require_relative "modules/message_slack"
|
4
|
+
require_relative "modules/message_discord"
|
5
|
+
require_relative "credentials"
|
6
|
+
|
7
|
+
# Slack Set Up
|
8
|
+
class EnergonNotify < Credentials
|
9
|
+
include MessageSlack
|
10
|
+
include SearchOnSlack
|
11
|
+
include MessageDiscord
|
12
|
+
|
13
|
+
def initialize(name: '', image: '', slack_enabled: false, slack_token: nil, slack_as_user: false)
|
14
|
+
set_credentials
|
15
|
+
if slack_enabled
|
16
|
+
Slack.configure do |config|
|
17
|
+
config.token = slack_token.nil? ? @bot_token : slack_token
|
18
|
+
config.raise 'Missing token' unless config.token
|
19
|
+
end
|
20
|
+
|
21
|
+
@bot_name = name unless name.empty?
|
22
|
+
@bot_icon = image unless image.empty?
|
23
|
+
@bot_user = slack_as_user
|
24
|
+
|
25
|
+
@time_client ||= Slack::RealTime::Client.new
|
26
|
+
@web_client ||= Slack::Web::Client.new
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'discordrb/webhooks'
|
2
|
+
|
3
|
+
module MessageDiscord
|
4
|
+
def discord_event(text, web_hook = ENV['DISCORD_WEBHOOK'])
|
5
|
+
client = Discordrb::Webhooks::Client.new(url: web_hook)
|
6
|
+
client.execute do |builder|
|
7
|
+
builder.content = text
|
8
|
+
end
|
9
|
+
rescue StandardError => e
|
10
|
+
print "Discord: #{e.message}"
|
11
|
+
false
|
12
|
+
end
|
13
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: energon-notify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luciano Adonis
|
@@ -24,6 +24,34 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.14.5
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: discordrb
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.3.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.3.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: twitter
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 7.0.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 7.0.0
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: rspec
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,14 +66,15 @@ dependencies:
|
|
38
66
|
- - "~>"
|
39
67
|
- !ruby/object:Gem::Version
|
40
68
|
version: '3.2'
|
41
|
-
description:
|
69
|
+
description: Send notifications.
|
42
70
|
email: luciano.adonisv@gmail.com
|
43
71
|
executables: []
|
44
72
|
extensions: []
|
45
73
|
extra_rdoc_files: []
|
46
74
|
files:
|
47
75
|
- lib/credentials.rb
|
48
|
-
- lib/
|
76
|
+
- lib/energon-notify.rb
|
77
|
+
- lib/modules/message_discord.rb
|
49
78
|
- lib/modules/message_slack.rb
|
50
79
|
- lib/modules/search_slack.rb
|
51
80
|
homepage: https://rubygems.org/gems/core_slack
|
data/lib/energon_notify.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'slack-ruby-client'
|
2
|
-
require_relative "modules/search_slack"
|
3
|
-
require_relative "modules/message_slack"
|
4
|
-
require_relative "modules/message_discord"
|
5
|
-
require_relative "credentials"
|
6
|
-
|
7
|
-
# Slack Set Up
|
8
|
-
class EnergonNotify < Credentials
|
9
|
-
include MessageSlack
|
10
|
-
include SearchOnSlack
|
11
|
-
include MessageDiscord
|
12
|
-
|
13
|
-
def initialize(name: '', image: '', token: nil, as_user: false)
|
14
|
-
set_credentials
|
15
|
-
|
16
|
-
Slack.configure do |config|
|
17
|
-
config.token = token.nil? ? @bot_token : token
|
18
|
-
config.raise 'Missing token' unless config.token
|
19
|
-
end
|
20
|
-
|
21
|
-
@bot_name = name unless name.empty?
|
22
|
-
@bot_icon = image unless image.empty?
|
23
|
-
@bot_user = as_user
|
24
|
-
|
25
|
-
@time_client ||= Slack::RealTime::Client.new
|
26
|
-
@web_client ||= Slack::Web::Client.new
|
27
|
-
end
|
28
|
-
end
|