baez_slack 0.0.3 → 0.0.8
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/baez_slack.rb +1 -0
- data/lib/modules/message_slack.rb +15 -0
- data/lib/modules/read_slack.rb +3 -5
- data/lib/modules/regex_slack.rb +25 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb3bc49c86eba7e97f89077c3f16d001fdd28e977f3d0ef15fb80c71dd07e1be
|
4
|
+
data.tar.gz: 9e920d19322e211127c4cf8462c2027d733a845e471c687102be38fa5de8d514
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b47ddffbbb7eab57b5d448d5a705ac684061768d6ba357fcc81bd23e7fb7b5728bb7a198c1509d4596d21ceb35347a70d54d084d170a7f772810905111f87ae0
|
7
|
+
data.tar.gz: b0b663ad4cd442983b94016b3e27d1b535321e44c7dbff32814e4cbc02c381bae4c6531dd1e5f13b557560395effeea8ab1c01e1fc9942335adeb27bbc1804a9
|
data/lib/baez_slack.rb
CHANGED
@@ -53,6 +53,21 @@ module MessageSlack
|
|
53
53
|
thread_ts: @thread
|
54
54
|
end
|
55
55
|
|
56
|
+
def send_file(path, data, ts = nil)
|
57
|
+
file = path
|
58
|
+
discern_end(data, ts)
|
59
|
+
@web_client.files_upload channels: @channel,
|
60
|
+
icon_url: @bot_icon,
|
61
|
+
username: @bot_name,
|
62
|
+
thread_ts: @thread,
|
63
|
+
file: Faraday::UploadIO.new(file, 'text'),
|
64
|
+
title: File.basename(file),
|
65
|
+
filename: File.basename(file)
|
66
|
+
rescue Slack::Web::Api::Errors::SlackError => e
|
67
|
+
print e.message
|
68
|
+
false
|
69
|
+
end
|
70
|
+
|
56
71
|
def add_reaction(icon, channel, thread)
|
57
72
|
@web_client.reactions_add channel: channel,
|
58
73
|
name: icon,
|
data/lib/modules/read_slack.rb
CHANGED
@@ -7,8 +7,7 @@ module ReadSlack
|
|
7
7
|
include ConsoleSlack
|
8
8
|
include DirectiveLookup
|
9
9
|
|
10
|
-
def share_message(data)
|
11
|
-
output = ENV['SLACK_C_OUTPUT'] || @output
|
10
|
+
def share_message(data, output)
|
12
11
|
case output
|
13
12
|
when 'slack'
|
14
13
|
check_type(data)
|
@@ -20,10 +19,9 @@ module ReadSlack
|
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
23
|
-
def single_client(output = '
|
24
|
-
@output = output
|
22
|
+
def single_client(output = ENV['SLACK_DEFAULT_OUTPUT'])
|
25
23
|
@time_client.on :message do |data|
|
26
|
-
share_message(data)
|
24
|
+
share_message(data, output)
|
27
25
|
end
|
28
26
|
@time_client.start!
|
29
27
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Module for regular expressions that are common
|
2
|
+
module RegexpSlack
|
3
|
+
def get_values_from(text, type = 'user')
|
4
|
+
pattern = case type
|
5
|
+
when 'user'
|
6
|
+
/<@(.*)>/
|
7
|
+
when 'channel'
|
8
|
+
/<#(.*)\|(.*)>/
|
9
|
+
end
|
10
|
+
text.match(pattern)
|
11
|
+
end
|
12
|
+
|
13
|
+
def echo(data, _pattern = '\echo')
|
14
|
+
match = data.match(/^\\echo\s(\<[#@])?((.*)\|)?(.*?)(\>)? (.*?)$/i)
|
15
|
+
unless match.nil?
|
16
|
+
channel = match.captures[2] || match.captures[3]
|
17
|
+
text = match.captures[5]
|
18
|
+
check_ts = channel.match(/(.*)-(\d*\.\d*)/)
|
19
|
+
# Useless... until someone find something
|
20
|
+
channel = check_ts.captures[0] unless check_ts.nil?
|
21
|
+
thread = check_ts.captures[1] unless check_ts.nil?
|
22
|
+
end
|
23
|
+
[text, channel, thread]
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: baez_slack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luciano Adonis
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- lib/modules/console_slack.rb
|
65
65
|
- lib/modules/message_slack.rb
|
66
66
|
- lib/modules/read_slack.rb
|
67
|
+
- lib/modules/regex_slack.rb
|
67
68
|
- lib/modules/search_slack.rb
|
68
69
|
homepage: https://rubygems.org/gems/core_slack
|
69
70
|
licenses:
|
@@ -84,8 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
85
|
- !ruby/object:Gem::Version
|
85
86
|
version: '0'
|
86
87
|
requirements: []
|
87
|
-
|
88
|
-
rubygems_version: 2.7.6
|
88
|
+
rubygems_version: 3.0.3
|
89
89
|
signing_key:
|
90
90
|
specification_version: 4
|
91
91
|
summary: Core functions for any kind of interaction with Slack
|