immosquare-slack 0.1.0 → 0.1.1
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 +17 -8
- 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: d9b52f86dbd4ff1cc0d3ef59fb7c92921e73c8491907204123408c7712361f6a
|
4
|
+
data.tar.gz: 7179ca47d7f1dbf1bfbbcbe0e16bf2f7f1d4993933c6e96bf79f20b5ac8a894c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc6f01081f7afc0a15d95225b2415d4b65e634d6238502b08fe213b3c89e4246418cd82cb8e50c7dc0dfdfa82a70ac14b11b52b13745b8d99d4aa096e3af0b52
|
7
|
+
data.tar.gz: 8a756f01c5487a449835110ba2a3b28cffdd5d21ebb9df36d787191e97f0acd1b8f2b1f601bf22736ff0d7b661cd35ca1c575fdbd102778034fdc08b86eaec98
|
@@ -3,7 +3,6 @@ module ImmosquareSlack
|
|
3
3
|
extend SharedMethods
|
4
4
|
class << self
|
5
5
|
|
6
|
-
|
7
6
|
##============================================================##
|
8
7
|
## Pour récupérer la liste des channels
|
9
8
|
##============================================================##
|
@@ -14,15 +13,16 @@ module ImmosquareSlack
|
|
14
13
|
##============================================================##
|
15
14
|
## Pour poster un message dans un channel
|
16
15
|
##============================================================##
|
17
|
-
def post_message(channel_name, text, notify:
|
16
|
+
def post_message(channel_name, text, notify: nil, notify_text: nil, bot_name: nil)
|
18
17
|
channel_id = get_channel_id_by_name(channel_name)
|
19
18
|
raise("Channel not found") if channel_id.nil?
|
20
19
|
|
21
|
-
|
22
20
|
url = "https://slack.com/api/chat.postMessage"
|
21
|
+
text = "#{build_notification_text(channel_id, notify, notify_text) if notify.present?}#{text}"
|
22
|
+
|
23
23
|
body = {
|
24
24
|
:channel => channel_id,
|
25
|
-
:text =>
|
25
|
+
:text => text,
|
26
26
|
:username => bot_name.presence
|
27
27
|
}
|
28
28
|
make_slack_api_call(url, :method => :post, :body => body)
|
@@ -52,10 +52,19 @@ module ImmosquareSlack
|
|
52
52
|
## Méthode récupérant les membres d'un channel et les notifier
|
53
53
|
## sur le message
|
54
54
|
##============================================================##
|
55
|
-
def build_notification_text(channel_id, text = "Hello")
|
56
|
-
|
57
|
-
|
58
|
-
|
55
|
+
def build_notification_text(channel_id, notify, text = "Hello")
|
56
|
+
final = if notify.is_a?(Array)
|
57
|
+
members = ImmosquareSlack::User.list_users
|
58
|
+
members = members.select {|m| m["profile"]["email"].in?(notify) }
|
59
|
+
members.map {|m| "<@#{m["id"]}>" }.join(", ")
|
60
|
+
elsif notify.to_sym == :all
|
61
|
+
members = get_channel_members(channel_id)
|
62
|
+
members.map {|m| "<@#{m}>" }.join(", ")
|
63
|
+
elsif notify.to_sym == :channel
|
64
|
+
"@channel"
|
65
|
+
end
|
66
|
+
|
67
|
+
"#{text} #{final}\n" if final.present?
|
59
68
|
end
|
60
69
|
|
61
70
|
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.1
|
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-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|