immosquare-slack 0.1.0 → 0.1.2
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/immosquare-slack/channel.rb +22 -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: 64ce7966173035e0831abfb2254abecba89bc821a58fba28441390409dcfae78
|
4
|
+
data.tar.gz: 20d86d9420346ec337e7fd626f9fdd88d8035c3c9dd9d88f8a0378e7fe2e7900
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b39052b2c44e3a0cdb3ee5ad1b1d07f2971440886257f2e15f5d3c412c1c7884bd6d54f50a4d4f93f015681911248a01b68d62587a3304c679ada15367da1555
|
7
|
+
data.tar.gz: 6f2f4256398427a964302992b6222e2e542d414ccce9a5dde98ebc8b2e2dee7123f7340cf5e334075edeb29eb98b9aa6933440cb822268f3dab43d8aeccf256d
|
@@ -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,24 @@ 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
|
+
elsif notify.to_sym == :here
|
66
|
+
"<!here>"
|
67
|
+
elsif notify.to_sym == :everyone
|
68
|
+
"<!everyone>"
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
"#{text} #{final}\n" if final.present?
|
59
73
|
end
|
60
74
|
|
61
75
|
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.2
|
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
|