immosquare-slack 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/immosquare-slack/channel.rb +28 -16
- data/lib/immosquare-slack/shared_methods.rb +3 -0
- data/lib/immosquare-slack/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa3bbd3b3a57145bcf994af26d5aecc034321ad8c65f5d10ef70011b25dc1399
|
4
|
+
data.tar.gz: 2f90ddfa14097c4b9bb06de7c17456d36d8e66cd8121d65a7f1932bcfacf572f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 555770a445c82bee6d56e3ff877889a9ff24884f977e7c99495d5b9883c319557c9af0957fdf2b20d32884bc91bb40596c8f054243d99173bdc49d1eb3342ef5
|
7
|
+
data.tar.gz: 7f8b11fa4d086bb0b29f3d82c6830a2fd24730a0daad4badd4a83f078dc0939f18d5731d75ce917e3d0c7e98412293c2787bc7d85823357335fe3693b349f4c9
|
@@ -17,14 +17,17 @@ module ImmosquareSlack
|
|
17
17
|
channel_id = get_channel_id_by_name(channel_name)
|
18
18
|
raise("Channel not found") if channel_id.nil?
|
19
19
|
|
20
|
-
url
|
21
|
-
|
20
|
+
url = "https://slack.com/api/chat.postMessage"
|
21
|
+
notification_text = notify ? build_notification_text(channel_id, notify, notify_text) : nil
|
22
|
+
text = "#{notification_text}#{text}"
|
22
23
|
|
23
24
|
body = {
|
24
|
-
:channel
|
25
|
-
:text
|
26
|
-
:username => bot_name.presence
|
25
|
+
:channel => channel_id,
|
26
|
+
:text => text
|
27
27
|
}
|
28
|
+
|
29
|
+
body[:username] = bot_name if bot_name
|
30
|
+
|
28
31
|
make_slack_api_call(url, :method => :post, :body => body)
|
29
32
|
end
|
30
33
|
|
@@ -51,20 +54,29 @@ module ImmosquareSlack
|
|
51
54
|
##============================================================##
|
52
55
|
## Méthode récupérant les membres d'un channel et les notifier
|
53
56
|
## sur le message
|
57
|
+
## on ne peut pas utilser in? si on veut que la gem soit
|
58
|
+
## compatible avec ruby (sans rails)
|
59
|
+
## pareil pour present?
|
54
60
|
##============================================================##
|
55
61
|
def build_notification_text(channel_id, notify, text = "Hello")
|
56
|
-
final =
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
final =
|
63
|
+
if notify.is_a?(Array)
|
64
|
+
members = ImmosquareSlack::User.list_users
|
65
|
+
members = members.select {|m| notify.include?(m["profile"]["email"]) }
|
66
|
+
members.map {|m| "<@#{m["id"]}>" }.join(", ")
|
67
|
+
elsif notify.to_sym == :all
|
68
|
+
members = get_channel_members(channel_id)
|
69
|
+
members.map {|m| "<@#{m}>" }.join(", ")
|
70
|
+
elsif notify.to_sym == :channel
|
71
|
+
"<!channel>"
|
72
|
+
elsif notify.to_sym == :here
|
73
|
+
"<!here>"
|
74
|
+
elsif notify.to_sym == :everyone
|
75
|
+
"<!everyone>"
|
76
|
+
end
|
77
|
+
|
66
78
|
|
67
|
-
"#{text} #{final}\n" if final.
|
79
|
+
"#{text} #{final}\n" if !final.to_s.empty?
|
68
80
|
end
|
69
81
|
|
70
82
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: immosquare-slack
|
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
|
- IMMO SQUARE
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
11
|
+
date: 2023-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|