immosquare-slack 0.1.0 → 0.1.2

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: 64ce7966173035e0831abfb2254abecba89bc821a58fba28441390409dcfae78
4
+ data.tar.gz: 20d86d9420346ec337e7fd626f9fdd88d8035c3c9dd9d88f8a0378e7fe2e7900
5
5
  SHA512:
6
- metadata.gz: f6d89e11d26a10f08515915260ef442a5ab6164c75761695e78d87258024f601c72ebe903ecc11870802bf0c60205fa5f88b0f5aae9fa174356afe6e6f9707be
7
- data.tar.gz: e21b4091ab55defe1fa6c2924a98e52c287b4befbb7eada3607c50b9c7d82474d1ff4fbb8e414b727baceadf1a0c07b68a170eb15b8c0d57ed1eb8fecc24f6f8
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: 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,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
- 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
+ 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
@@ -1,3 +1,3 @@
1
1
  module ImmosquareSlack
2
- VERSION = "0.1.0".freeze
2
+ VERSION = "0.1.2".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.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-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