fastlane-plugin-slack_bot 1.2.0 → 1.4.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: d41be99af2fa9df13b2a8b613f0afc6ca95ec7e78abe90c07231b2564e9d6431
4
- data.tar.gz: f5b92143896f6a54b893b06daf6a2e4f6b464fba24473851b98f70c16995a15e
3
+ metadata.gz: 547c728585d89dc90c21cb4fa8d7f769b66f25c6ca075d09870a631422065357
4
+ data.tar.gz: 751cfc3322ced61cf3b745f1015ebe100232d779f86960bbd524e8dacf32a51b
5
5
  SHA512:
6
- metadata.gz: 40e353d5df69d1822acceb88aaced1b4eb79f5c56d615bf36abb82b56c593311e0e50bbe82362a662e63c9c5a343eae50a0a2fe666b3e48e044090da5d557c77
7
- data.tar.gz: 34fb53d69b3fa99084615db23e2ab03c862928af864b6c28239004af7b7ab4e747f91c756dabe6e855008ed58706802618a1c8becfbfc2cc26c80f8810524f35
6
+ metadata.gz: f19684e2772e518c7b257402a312644c1fab18ca9ef3314e8504e94e6e2ab936429a83c24125f431c13b3e6b21564b177825a90a1a993f4e5dfdb97686776ead
7
+ data.tar.gz: c880684936b29820f7bca82087aab76d11b7fe35cb2d60bf53babbcaf768a9e394d56f4a5e08b72c001070ca8cea379ce62f07e74276ba0417609f8e06977a5f
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2021 Manish Rathi
3
+ Copyright (c) 2022 Manish Rathi
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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
 
@@ -24,7 +26,7 @@ i.e Listing couple of slack **webhook url** limitations:
24
26
  - can’t post a message inside a slack thread.
25
27
  - can’t update a posted slack message.
26
28
  - can’t list and upload a file inside a slack channel.
27
- - much more, compare to a **Slack Bot** 🤖 using the [Slack APIs](https://api.slack.com/)
29
+ - many more, compare to a **Slack Bot** 🤖 using the [Slack APIs](https://api.slack.com/)
28
30
 
29
31
  ## Getting Started
30
32
 
@@ -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
@@ -39,6 +39,7 @@ module Fastlane
39
39
  attachments: [slack_attachment]
40
40
  }
41
41
  payload[:as_user] = options[:as_user] if options[:as_user] # default is false
42
+ payload[:reply_broadcast] = options[:reply_broadcast] if options[:reply_broadcast] # default is false
42
43
  payload[:thread_ts] = options[:thread_ts] unless options[:thread_ts].nil?
43
44
  payload = payload.to_json
44
45
 
@@ -144,7 +145,13 @@ module Fastlane
144
145
  FastlaneCore::ConfigItem.new(key: :thread_ts,
145
146
  env_name: "FL_POST_TO_SLACK_THREAD_TS",
146
147
  description: "Provide another message's ts value to make this message a reply",
147
- optional: true)
148
+ optional: true),
149
+ FastlaneCore::ConfigItem.new(key: :reply_broadcast,
150
+ env_name: "FL_POST_TO_SLACK_REPLY_BROADCAST",
151
+ description: "Used in conjunction with thread_ts and indicates whether reply should be made visible to everyone in the channel or conversation. Defaults to false",
152
+ optional: true,
153
+ default_value: false,
154
+ is_string: false)
148
155
  ]
149
156
  end
150
157
 
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module SlackBot
3
- VERSION = "1.2.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.2.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manish Rathi
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-12 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
@@ -136,7 +136,7 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: 2.148.1
139
- description:
139
+ description:
140
140
  email: manishrathi19902013@gmail.com
141
141
  executables: []
142
142
  extensions: []
@@ -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
@@ -157,7 +158,7 @@ homepage: https://github.com/crazymanish/fastlane-plugin-slack_bot
157
158
  licenses:
158
159
  - MIT
159
160
  metadata: {}
160
- post_install_message:
161
+ post_install_message:
161
162
  rdoc_options: []
162
163
  require_paths:
163
164
  - lib
@@ -172,8 +173,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
173
  - !ruby/object:Gem::Version
173
174
  version: '0'
174
175
  requirements: []
175
- rubygems_version: 3.1.4
176
- signing_key:
176
+ rubygems_version: 3.3.26
177
+ signing_key:
177
178
  specification_version: 4
178
179
  summary: "A fastlane plugin to post slack message using bot api token. \U0001F680"
179
180
  test_files: []