enerbot-slack 1.0.4 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a8e768b87ed5b6b43965e79861fe36f3788b15c821ea3702f321ef8d96f42f11
4
- data.tar.gz: c534f61919b7e639c5cea2fcc20712511be1831324e413315a54f49c6e62e18d
3
+ metadata.gz: 7060b6859b55907fa4ab9fc489418b4dd878e4d5c8fd3647f256e8f19cbb7187
4
+ data.tar.gz: b31f59335f87d506d4c41dd91f820c9e47854789b0a006ddb536578267671811
5
5
  SHA512:
6
- metadata.gz: 9f52f04346896bcc63318418c4969283af6cfe0ac9359969020889dc831aa27ebfd4403b3196f6e6930faf37c9bd4aa5f77949c34cdf5e12991875083c01f4c3
7
- data.tar.gz: 3c877c16c250f52d412eb97dcd175c89231f13bc297e9dea0daffbd27a8d2ff87c9f1054846cc381ed3fd4e7dd1dfc5c72bfb4b21cbe6ad66501df2a328f3161
6
+ metadata.gz: f6e5283a3068ec99b480e6382ac1c46d3caffe3cb9a2d5a5f1dd4abe20b0ff70ccc22f7087ef137b9a0cb0084dcc0c4bb5470ed2a116e5a64e74d75b855fb950
7
+ data.tar.gz: 93691d4af630bbdea879029486d8ae04cb9474d93733a44fb2172cbea4f2d201abcd3b3816f584eeeb621102c7b3a4541010c1059f0234f084978de0262505ca
data/lib/enerbot-slack.rb CHANGED
@@ -1,9 +1,10 @@
1
1
  require 'slack-ruby-client'
2
+ require_relative 'modules/slack_realtime'
2
3
  require_relative 'modules/slack_message'
3
4
  require_relative 'modules/slack_search'
4
5
  require_relative 'modules/slack_image'
5
6
  require_relative 'modules/slack_format'
6
- require_relative 'credentials'
7
+ require_relative 'modules/credentials'
7
8
 
8
9
  # Groups client initialization with instance parameters
9
10
  class EnerbotSlack < Credentials
@@ -14,7 +15,7 @@ class EnerbotSlack < Credentials
14
15
  include SlackSearch
15
16
 
16
17
  def initialize(name: '', image: '', token: nil, as_user: false)
17
- set_credentials
18
+ set_defaults
18
19
 
19
20
  Slack.configure do |config|
20
21
  config.token = token.nil? ? @bot_token : token
@@ -1,5 +1,5 @@
1
1
  class Credentials
2
- def set_credentials
2
+ def set_defaults
3
3
  @bot_token = ENV['SLACK_TOKEN']
4
4
  @bot_name = ENV['SLACK_NAME']
5
5
  @bot_icon = ENV['SLACK_ICON']
@@ -4,10 +4,10 @@ require 'slack-ruby-client'
4
4
 
5
5
  # Client initialization that powers the rest of interactions
6
6
  module SlackClient
7
- def configure_client(type = 'web', token = ENV['SLACK_API_TOKEN'])
7
+ def configure_client(type = 'web', token = ENV['SLACK_TOKEN'])
8
8
  Slack.configure do |config|
9
9
  config.token = token
10
- config.raise 'Missing Bot token' unless config.token
10
+ config.raise 'Missing Bot token 2' unless config.token
11
11
  end
12
12
 
13
13
  case type
@@ -2,7 +2,7 @@ require 'colorize'
2
2
  require_relative 'slack_search'
3
3
 
4
4
  # Module to read data from Slack and show it on console
5
- module ConsoleSlack
5
+ module SlackConsole
6
6
  include SlackSearch
7
7
 
8
8
  def format_new_message(data)
@@ -10,16 +10,15 @@ module ConsoleSlack
10
10
  data.username
11
11
  else
12
12
  user = get_user_info(data.user)
13
- user.real_name
13
+ user.name
14
14
  end
15
15
  text = data.text
16
16
  channel_p = conversation_info(data.channel)
17
17
  if @current_channel == channel_p.id
18
- print "\n#{user_p}: ".yellow + text.blue
19
18
  else
20
19
  print "\n--- #{channel_p.name} ---".green
21
- print "\n#{user_p}: ".yellow + text.blue
22
20
  end
21
+ print "\n#{user_p}: ".yellow + text.blue
23
22
  @current_channel = channel_p.id
24
23
  end
25
24
  end
@@ -26,8 +26,8 @@ module SlackMessage
26
26
  destination_points(data, ts)
27
27
  client.chat_postMessage channel: @channel,
28
28
  text: text,
29
- icon_url: ENV['SLACK_BOT_ICON'],
30
- username: ENV['SLACK_BOT_NAME'],
29
+ icon_url: ENV['SLACK_ICON'],
30
+ username: ENV['SLACK_NAME'],
31
31
  thread_ts: @thread,
32
32
  as_user: false
33
33
  rescue Slack::Web::Api::Errors::SlackError => e
@@ -45,8 +45,8 @@ module SlackMessage
45
45
  destination_points(data, ts)
46
46
  client.chat_postMessage channel: @channel,
47
47
  attachments: attachment,
48
- icon_url: ENV['SLACK_BOT_ICON'],
49
- username: ENV['SLACK_BOT_NAME'],
48
+ icon_url: ENV['SLACK_ICON'],
49
+ username: ENV['SLACK_NAME'],
50
50
  thread_ts: @thread,
51
51
  as_user: false
52
52
  rescue Slack::Web::Api::Errors::SlackError => e
@@ -60,8 +60,8 @@ module SlackMessage
60
60
  client.chat_postEphemeral channel: @channel,
61
61
  text: text,
62
62
  user: user,
63
- icon_url: ENV['SLACK_BOT_ICON'],
64
- username: ENV['SLACK_BOT_NAME'],
63
+ icon_url: ENV['SLACK_ICON'],
64
+ username: ENV['SLACK_NAME'],
65
65
  as_user: false
66
66
  rescue Slack::Web::Api::Errors::SlackError => e
67
67
  print e.message
@@ -81,8 +81,8 @@ module SlackMessage
81
81
  client.reactions_add channel: channel,
82
82
  name: icon,
83
83
  timestamp: thread,
84
- icon_url: ENV['SLACK_BOT_ICON'],
85
- username: ENV['SLACK_BOT_NAME'],
84
+ icon_url: ENV['SLACK_ICON'],
85
+ username: ENV['SLACK_NAME'],
86
86
  as_user: false
87
87
  rescue Slack::Web::Api::Errors::SlackError => e
88
88
  print e.message
@@ -94,8 +94,8 @@ module SlackMessage
94
94
  client = configure_client
95
95
  destination_points(data, ts)
96
96
  client.files_upload channels: @channel,
97
- icon_url: ENV['SLACK_BOT_ICON'],
98
- username: ENV['SLACK_BOT_NAME'],
97
+ icon_url: ENV['SLACK_ICON'],
98
+ username: ENV['SLACK_NAME'],
99
99
  thread_ts: @thread,
100
100
  file: Faraday::UploadIO.new(file, 'text'),
101
101
  title: File.basename(file),
@@ -20,6 +20,10 @@ module SlackRealTime
20
20
  end
21
21
 
22
22
  def single_client(output = ENV['SLACK_DEFAULT_OUTPUT'])
23
+ @time_client.on :hello do
24
+ puts("Connected to '#{@time_client.team.name}' team at https://#{@time_client.team.domain}.slack.com.")
25
+ end
26
+
23
27
  @time_client.on :message do |data|
24
28
  share_message(data, output)
25
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enerbot-slack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luciano Adonis
@@ -11,61 +11,61 @@ cert_chain: []
11
11
  date: 2024-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: colorize
14
+ name: async-websocket
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.8.1
19
+ version: 0.8.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.8.1
26
+ version: 0.8.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: slack-ruby-client
28
+ name: bson_ext
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 2.0.0
33
+ version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 2.0.0
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: async-websocket
42
+ name: colorize
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.8.0
47
+ version: 0.8.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.8.0
54
+ version: 0.8.1
55
55
  - !ruby/object:Gem::Dependency
56
- name: bson_ext
56
+ name: slack-ruby-client
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 2.0.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: 2.0.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -86,8 +86,8 @@ executables: []
86
86
  extensions: []
87
87
  extra_rdoc_files: []
88
88
  files:
89
- - lib/credentials.rb
90
89
  - lib/enerbot-slack.rb
90
+ - lib/modules/credentials.rb
91
91
  - lib/modules/slack_admin.rb
92
92
  - lib/modules/slack_client.rb
93
93
  - lib/modules/slack_console.rb