fastlane-plugin-slack_bot 1.3.0 → 1.4.0

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: a46dbadbfa598f1c758348e0154ebdaf8dcdffcf4fba9d3f0e9605f517ef55a2
4
- data.tar.gz: 8a0fac48642f5583f420742bed53ec23061c5771c274c7ceff9376b9e0640f5d
3
+ metadata.gz: 547c728585d89dc90c21cb4fa8d7f769b66f25c6ca075d09870a631422065357
4
+ data.tar.gz: 751cfc3322ced61cf3b745f1015ebe100232d779f86960bbd524e8dacf32a51b
5
5
  SHA512:
6
- metadata.gz: fd12b23c8e91eab7dc0b826c55de32e7f54bd7cfe364a1bace438cf46e88db1fc4569ac5f4e234fbfd0e43b81593f6a606e73032ccc50ca8b876a39aae01f801
7
- data.tar.gz: 6c7a885efba03ef05109c60e771acab3d5c05c08bf5d9285abe09e12498139c2c414ffb1f38fd338fee4c402ac1fa563af64e3436797e940c383056bd9903d54
6
+ metadata.gz: f19684e2772e518c7b257402a312644c1fab18ca9ef3314e8504e94e6e2ab936429a83c24125f431c13b3e6b21564b177825a90a1a993f4e5dfdb97686776ead
7
+ data.tar.gz: c880684936b29820f7bca82087aab76d11b7fe35cb2d60bf53babbcaf768a9e394d56f4a5e08b72c001070ca8cea379ce62f07e74276ba0417609f8e06977a5f
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
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module SlackBot
3
- VERSION = "1.3.0"
3
+ VERSION = "1.4.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.4.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: 2023-05-29 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.3.26
176
177
  signing_key:
177
178
  specification_version: 4
178
179
  summary: "A fastlane plugin to post slack message using bot api token. \U0001F680"