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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 30900d7e5d44acbfd25f87836eea3f8e95458e06977ad7dc48db9f2d327f4dcf
4
- data.tar.gz: 0fd10ae542118b73b92fb943cb509feddc4fb42812e82b1d8707234dc446eb1c
3
+ metadata.gz: d9b52f86dbd4ff1cc0d3ef59fb7c92921e73c8491907204123408c7712361f6a
4
+ data.tar.gz: 7179ca47d7f1dbf1bfbbcbe0e16bf2f7f1d4993933c6e96bf79f20b5ac8a894c
5
5
  SHA512:
6
- metadata.gz: f6d89e11d26a10f08515915260ef442a5ab6164c75761695e78d87258024f601c72ebe903ecc11870802bf0c60205fa5f88b0f5aae9fa174356afe6e6f9707be
7
- data.tar.gz: e21b4091ab55defe1fa6c2924a98e52c287b4befbb7eada3607c50b9c7d82474d1ff4fbb8e414b727baceadf1a0c07b68a170eb15b8c0d57ed1eb8fecc24f6f8
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: false, bot_name: nil)
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 => "#{build_notification_text(channel_id) if notify}#{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
- members = get_channel_members(channel_id)
57
- members = member_mentions = members.map {|member_id| "<@#{member_id}>" }
58
- "#{text} #{member_mentions.join(", ")}\n"
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
@@ -1,3 +1,3 @@
1
1
  module ImmosquareSlack
2
- VERSION = "0.1.0".freeze
2
+ VERSION = "0.1.1".freeze
3
3
  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.0
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-10 00:00:00.000000000 Z
11
+ date: 2023-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty