fastlane-plugin-slack_bot 1.3.0 → 1.5.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a46dbadbfa598f1c758348e0154ebdaf8dcdffcf4fba9d3f0e9605f517ef55a2
4
- data.tar.gz: 8a0fac48642f5583f420742bed53ec23061c5771c274c7ceff9376b9e0640f5d
3
+ metadata.gz: 6b17a65fd5a04b1dbf291d3c6f84fad8000fa9ac2d0743de9fd0c9b0ed12e5d4
4
+ data.tar.gz: 261a9d9474163883fa2863bf2ec41eac28992272128501b51eaa04314fbc360d
5
5
  SHA512:
6
- metadata.gz: fd12b23c8e91eab7dc0b826c55de32e7f54bd7cfe364a1bace438cf46e88db1fc4569ac5f4e234fbfd0e43b81593f6a606e73032ccc50ca8b876a39aae01f801
7
- data.tar.gz: 6c7a885efba03ef05109c60e771acab3d5c05c08bf5d9285abe09e12498139c2c414ffb1f38fd338fee4c402ac1fa563af64e3436797e940c383056bd9903d54
6
+ metadata.gz: 763624a358655449ffb4f3ce863405db0d11ba2ed2b3be04030b7772c392ad21d20a6ad84bb0736e7a507bfb8474d18d174dc6da0c9a160328ee869485ac78c5
7
+ data.tar.gz: 5bbe624ca8b643948e25636779461f9e587c4863891af30b7d7e59689123b2320137564e5a033a593f49bd8984352e5b3b7206b20610c7b006a1576d6ba0aca1
data/README.md CHANGED
@@ -3,8 +3,8 @@
3
3
  [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-slack_bot)
4
4
  ![![License]](https://img.shields.io/badge/license-MIT-green.svg?style=flat)
5
5
  [![Gem Version](https://badge.fury.io/rb/fastlane-plugin-slack_bot.svg)](https://badge.fury.io/rb/fastlane-plugin-slack_bot)
6
- ![![RubyGem Download Badge]](https://ruby-gem-downloads-badge.herokuapp.com/fastlane-plugin-slack_bot?type=total)
7
6
  [![Twitter: @manish](https://img.shields.io/badge/contact-@manish-blue.svg?style=flat)](https://twitter.com/iammanishrathi)
7
+ <!--![![RubyGem Download Badge]](https://ruby-gem-downloads-badge.herokuapp.com/fastlane-plugin-slack_bot?type=total)-->
8
8
 
9
9
  A fastlane plugin to customize your automation workflow(s) with a **Slack Bot** 🤖 using the [Slack APIs](https://api.slack.com/)
10
10
 
@@ -12,6 +12,8 @@ A fastlane plugin to customize your automation workflow(s) with a **Slack Bot**
12
12
  - [Getting Started](#getting-started)
13
13
  - [Features](#features)
14
14
  - [Post a message](#examples-post-a-message) examples
15
+ - [Update a message](https://github.com/crazymanish/fastlane-plugin-slack_bot/blob/master/lib/fastlane/plugin/slack_bot/actions/update_slack_message.rb#L115) examples
16
+ - [Delete a message](https://github.com/crazymanish/fastlane-plugin-slack_bot/blob/master/lib/fastlane/plugin/slack_bot/actions/delete_slack_message.rb#L78) examples
15
17
  - [Upload a file](#examples-upload-a-message) examples
16
18
  - [About Fastlane](#about-fastlane)
17
19
 
@@ -58,6 +60,9 @@ Using this `slack_bot` plugin, you can:
58
60
  - Update a message using [chat.update](https://api.slack.com/methods/chat.update) Slack API
59
61
  - [x] update a message in a channel
60
62
 
63
+ - Delete a message using [chat.delete](https://api.slack.com/methods/chat.delete) Slack API
64
+ - [x] delete a message in a channel
65
+
61
66
  - List of files in a channel using [files.list](https://api.slack.com/methods/files.list) Slack API
62
67
  - [x] A list of files in a channel, It can be filtered and sliced in various ways.
63
68
 
@@ -0,0 +1,90 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/slack_bot_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ module SharedValues
7
+ DELETE_SLACK_MESSAGE_RESULT = :DELETE_SLACK_MESSAGE_RESULT
8
+ end
9
+ class DeleteSlackMessageAction < Action
10
+ def self.run(options)
11
+ begin
12
+ require 'excon'
13
+
14
+ api_url = "https://slack.com/api/chat.delete"
15
+ headers = { "Content-Type": "application/json", "Authorization": "Bearer #{options[:api_token]}" }
16
+ payload = { channel: options[:channel], ts: options[:ts] }.to_json
17
+
18
+ response = Excon.post(api_url, headers: headers, body: payload)
19
+ result = self.formatted_result(response)
20
+ rescue => exception
21
+ UI.error("Exception: #{exception}")
22
+ return nil
23
+ else
24
+ UI.success("Successfully deleted the Slack message!")
25
+ Actions.lane_context[SharedValues::DELETE_SLACK_MESSAGE_RESULT] = result
26
+ return result
27
+ end
28
+ end
29
+
30
+ def self.formatted_result(response)
31
+ result = {
32
+ status: response[:status],
33
+ body: response.body || "",
34
+ json: self.parse_json(response.body) || {}
35
+ }
36
+ end
37
+
38
+ def self.parse_json(value)
39
+ require 'json'
40
+
41
+ JSON.parse(value)
42
+ rescue JSON::ParserError
43
+ nil
44
+ end
45
+
46
+ def self.description
47
+ "Deleate a slack message using time-stamp(ts) value"
48
+ end
49
+
50
+ def self.available_options
51
+ [
52
+ FastlaneCore::ConfigItem.new(key: :api_token,
53
+ env_name: "FL_DELETE_SLACK_MESSAGE_BOT_TOKEN",
54
+ description: "Slack bot Token",
55
+ sensitive: true,
56
+ code_gen_sensitive: true,
57
+ is_string: true,
58
+ default_value: ENV["SLACK_API_TOKEN"],
59
+ default_value_dynamic: true,
60
+ optional: false),
61
+ FastlaneCore::ConfigItem.new(key: :ts,
62
+ env_name: "FL_DELETE_SLACK_MESSAGE_TS",
63
+ description: "Timestamp of the message to be deleted",
64
+ optional: false),
65
+ FastlaneCore::ConfigItem.new(key: :channel,
66
+ env_name: "FL_DELETE_SLACK_MESSAGE_CHANNEL",
67
+ description: "Slack channel_id containing the message to be deleted. i.e C1234567890",
68
+ optional: false)
69
+ ]
70
+ end
71
+
72
+ def self.authors
73
+ ["crazymanish"]
74
+ end
75
+
76
+ def self.example_code
77
+ [
78
+ 'delete_slack_message(
79
+ ts: "1609711037.000100",
80
+ channel: "C1234567890"
81
+ )'
82
+ ]
83
+ end
84
+
85
+ def self.is_supported?(platform)
86
+ true
87
+ end
88
+ end
89
+ end
90
+ end
@@ -142,6 +142,12 @@ module Fastlane
142
142
  optional: true,
143
143
  default_value: true,
144
144
  is_string: false),
145
+ FastlaneCore::ConfigItem.new(key: :no_color,
146
+ env_name: "FL_POST_TO_SLACK_NO_COLOR",
147
+ description: "Removes the border on the left side. If true, :success option will be ignored.",
148
+ optional: true,
149
+ default_value: false,
150
+ is_string: false),
145
151
  FastlaneCore::ConfigItem.new(key: :thread_ts,
146
152
  env_name: "FL_POST_TO_SLACK_THREAD_TS",
147
153
  description: "Provide another message's ts value to make this message a reply",
@@ -15,18 +15,18 @@ module Fastlane
15
15
  end
16
16
 
17
17
  def self.generate_slack_attachments(options)
18
- color = (options[:success] ? 'good' : 'danger')
19
18
  should_add_payload = ->(payload_name) { options[:default_payloads].map(&:to_sym).include?(payload_name.to_sym) }
20
19
 
21
20
  slack_attachment = {
22
21
  fallback: options[:message],
23
22
  text: options[:message],
24
23
  pretext: options[:pretext],
25
- color: color,
26
24
  mrkdwn_in: ["pretext", "text", "fields", "message"],
27
25
  fields: []
28
26
  }
29
27
 
28
+ slack_attachment[:color] = (options[:success] ? 'good' : 'danger') unless options[:no_color]
29
+
30
30
  # custom user payloads
31
31
  slack_attachment[:fields] += options[:payload].map do |k, v|
32
32
  {
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module SlackBot
3
- VERSION = "1.3.0"
3
+ VERSION = "1.5.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-slack_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manish Rathi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-16 00:00:00.000000000 Z
11
+ date: 2025-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -145,6 +145,7 @@ files:
145
145
  - LICENSE
146
146
  - README.md
147
147
  - lib/fastlane/plugin/slack_bot.rb
148
+ - lib/fastlane/plugin/slack_bot/actions/delete_slack_message.rb
148
149
  - lib/fastlane/plugin/slack_bot/actions/fetch_files_slack.rb
149
150
  - lib/fastlane/plugin/slack_bot/actions/file_upload_to_slack.rb
150
151
  - lib/fastlane/plugin/slack_bot/actions/post_to_slack.rb
@@ -172,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
173
  - !ruby/object:Gem::Version
173
174
  version: '0'
174
175
  requirements: []
175
- rubygems_version: 3.3.7
176
+ rubygems_version: 3.4.19
176
177
  signing_key:
177
178
  specification_version: 4
178
179
  summary: "A fastlane plugin to post slack message using bot api token. \U0001F680"