fastlane-plugin-discord_webhook 0.1.0 → 0.3.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: 1c623e59ee75e6ee3443dbf34fda73c834a831bc2a90ff0a0bb6cb0a86924146
4
- data.tar.gz: e726c49563e2df88536facd4cc9492d6bbc8a15d01b131dbf147cb6fbeff1d8d
3
+ metadata.gz: b0321cbe2bda0fd6f25a2334c7f1fc8fad24b232efcfd350236e0018137edf00
4
+ data.tar.gz: 0d8b960e8c7aeb55b8056c66eec1df7d2057a10940a620fdaeb16e3aba74def7
5
5
  SHA512:
6
- metadata.gz: b493ed928ef47e68b470d13da492a5b150dc4365511bf16f4aad30ffbd4fdabc193df426fe18ba67a93e406d033ed212dbd4c765c5a6622a15e3baec682f3875
7
- data.tar.gz: b2bf0e922d25b2660ab0a38d2c68c7b8c8242a9fc5fb651d5a84a70f031609a111540890685e955b5811dd1fcac40457fdae8d6ef7e8a99851ae4a0da843e6c6
6
+ metadata.gz: 22a53efd41173d9d6a3e5fcdad36505d9f7a457c887cede09232d35d0e3c2b35263318e2d50b0e0a5337d438de87430229e6f16731e27a875adae40f43ac4bdd
7
+ data.tar.gz: c9962ad15f652ea557dec11aea66a23cf8382b2d70f0f2f73a84eaac5277d4f1bd7c33f394c211d58f16df8568537eef05c547e180b677d738f73421a687f361
data/README.md CHANGED
@@ -10,14 +10,16 @@ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To
10
10
  fastlane add_plugin discord_webhook
11
11
  ```
12
12
 
13
+ You must create a webhook before using library. See details: https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks.
14
+
13
15
  ## About discord_webhook
14
16
 
15
- Send a message using Discord Webhook
17
+ A lightweight fastlane plugin to send a message using Discord Webhook
16
18
 
17
- ## Usage
19
+ ## Parameters
18
20
 
19
21
  | Key | Description |
20
- | :--: | :--: |
22
+ | --- | --- |
21
23
  | `webhook_url` | Discord Webhook URL. |
22
24
  | `username` | [Optional] Username. It will override webhook's username if specified. |
23
25
  | `message` | The message you want to send. |
@@ -27,15 +29,19 @@ Send a message using Discord Webhook
27
29
  ## Example
28
30
 
29
31
  ```ruby
32
+ # Send a simple message
30
33
  lane :discord_message do
31
34
  discord_webhook(
32
35
  webhook_url: 'https://yourDiscordWebhookUrl',
33
- message: 'hello'
36
+ message: 'hello',
37
+ # You can override username by specifying it if needed.
38
+ # username: 'mataku'
34
39
  )
35
40
  end
36
41
  ```
37
42
 
38
43
  ```ruby
44
+ # Send a message with a file
39
45
  lane :discord_message_with_file do
40
46
  discord_webhook(
41
47
  webhook_url: 'https://yourDiscordWebhookUrl',
@@ -48,6 +54,7 @@ end
48
54
  ```
49
55
 
50
56
  ```ruby
57
+ # Send a message with embed content
51
58
  lane :discord_message_with_embed do
52
59
  discord_webhook(
53
60
  webhook_url: 'https://yourDiscordWebhookUrl',
@@ -64,6 +71,36 @@ lane :discord_message_with_embed do
64
71
  end
65
72
  ```
66
73
 
74
+ ### Mention
75
+
76
+ You can mention by using **User ID** or **Role ID**, not display name.
77
+
78
+ ```ruby
79
+ lane :user_mention do
80
+ discord_webhook(
81
+ # ...
82
+ # Specify User ID, like <@USER_ID>
83
+ message: 'Hi, <@12340987651234567>'
84
+ )
85
+ end
86
+
87
+ lane :role_mention do
88
+ discord_webhook(
89
+ # ...
90
+ # Specify Role ID with &, like <@&ROLE_ID>
91
+ message: 'Hi, <@&123456798765123456>'
92
+ )
93
+ end
94
+ ```
95
+
96
+ User ID reference | Role ID reference
97
+ :--: | :--:
98
+ ![](./misc/user_id.png) | ![](./misc/role_id.png)
99
+
100
+ - - -
101
+
102
+ See details: https://support.discord.com/hc/en-us/articles/206346498-Where-can-I-find-my-User-Server-Message-ID#h_01HRSTXPS5H5D7JBY2QKKPVKNA.
103
+
67
104
  ## Issues and Feedback
68
105
 
69
106
  For any other issues and feedback about this plugin, please submit it to this repository.
@@ -27,17 +27,17 @@ module Fastlane
27
27
  embed_payload: embed_payload
28
28
  )
29
29
  handle_response(response)
30
- rescue StandardError => e
30
+ rescue SocketError, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError => e
31
31
  UI.user_error!(e.message)
32
32
  end
33
33
  end
34
34
 
35
35
  def self.description
36
- "Send a message using Discord Webhook"
36
+ 'Send a message using Discord Webhook'
37
37
  end
38
38
 
39
39
  def self.authors
40
- ["Takuma Homma"]
40
+ ['Takuma Homma']
41
41
  end
42
42
 
43
43
  def self.return_value
@@ -45,15 +45,15 @@ module Fastlane
45
45
  end
46
46
 
47
47
  def self.details
48
- "Send a message using Discord Webhook"
48
+ 'Send a message using Discord Webhook'
49
49
  end
50
50
 
51
51
  def self.available_options
52
52
  [
53
53
  FastlaneCore::ConfigItem.new(
54
54
  key: :webhook_url,
55
- env_name: "FL_DISCORD_WEBHOOK_URL",
56
- description: "Discord Webhook URL",
55
+ env_name: 'FL_DISCORD_WEBHOOK_URL',
56
+ description: 'Discord Webhook URL',
57
57
  optional: false,
58
58
  type: String,
59
59
  verify_block: proc do |value|
@@ -62,22 +62,22 @@ module Fastlane
62
62
  ),
63
63
  FastlaneCore::ConfigItem.new(
64
64
  key: :message,
65
- env_name: "FL_DISCORD_WEBHOOK_MESSAGE",
66
- description: "The message you want to send",
65
+ env_name: 'FL_DISCORD_WEBHOOK_MESSAGE',
66
+ description: 'The message you want to send',
67
67
  optional: true,
68
68
  type: String
69
69
  ),
70
70
  FastlaneCore::ConfigItem.new(
71
71
  key: :username,
72
- env_name: "FL_DISCORD_WEBHOOK_USERNAME",
73
- description: "[Optional] Username",
72
+ env_name: 'FL_DISCORD_WEBHOOK_USERNAME',
73
+ description: '[Optional] Username',
74
74
  optional: true,
75
75
  type: String
76
76
  ),
77
77
  FastlaneCore::ConfigItem.new(
78
78
  key: :attachment_file_path,
79
- env_name: "FL_DISCORD_WEBHOOK_ATTACHMENT_FILE_PATH",
80
- description: "[Optional] File path to upload",
79
+ env_name: 'FL_DISCORD_WEBHOOK_ATTACHMENT_FILE_PATH',
80
+ description: '[Optional] File path to upload',
81
81
  optional: true,
82
82
  type: String,
83
83
  verify_block: proc do |value|
@@ -89,8 +89,8 @@ module Fastlane
89
89
  # See: https://discord.com/developers/docs/resources/message#embed-object
90
90
  FastlaneCore::ConfigItem.new(
91
91
  key: :embed_payload,
92
- env_name: "FL_DISCORD_WEBHOOK_EMBED_PAYLOAD",
93
- description: "[Optional] Embed Object. You can specify one object. See details: https://discord.com/developers/docs/resources/message#embed-object",
92
+ env_name: 'FL_DISCORD_WEBHOOK_EMBED_PAYLOAD',
93
+ description: '[Optional] Embed Object. You can specify one object. See details: https://discord.com/developers/docs/resources/message#embed-object',
94
94
  optional: true,
95
95
  type: Hash
96
96
  )
@@ -106,10 +106,16 @@ module Fastlane
106
106
  if response.kind_of?(Net::HTTPSuccess)
107
107
  UI.success('Successfully sent a message to Discord')
108
108
  else
109
+ body = response.body
109
110
  error_body = begin
110
- JSON.parse(response.body)['message']
111
- rescue StandardError
112
- ''
111
+ parsed = JSON.parse(body)['message']
112
+ if parsed.nil?
113
+ body
114
+ else
115
+ parsed
116
+ end
117
+ rescue JSON::ParserError
118
+ body
113
119
  end
114
120
  UI.user_error!("Failed to send a message to Discord: #{error_body}")
115
121
  end
@@ -35,15 +35,28 @@ module Fastlane
35
35
  uri = URI.parse(@webhook_url)
36
36
  request = Net::HTTP::Post.new(uri)
37
37
  embed_payload_content = if embed_payload.nil? || embed_payload.empty?
38
- []
39
- else
40
- [embed_payload]
41
- end
38
+ []
39
+ else
40
+ [embed_payload]
41
+ end
42
42
  payload_json = if !username.nil? && !username.empty?
43
- { username: username, content: content, embeds: embed_payload_content }
44
- else
45
- { content: content, embeds: embed_payload_content }
46
- end
43
+ {
44
+ username: username,
45
+ content: content,
46
+ embeds: embed_payload_content,
47
+ allowed_mentions: {
48
+ parse: ['users', 'roles'],
49
+ }
50
+ }
51
+ else
52
+ {
53
+ content: content,
54
+ embeds: embed_payload_content,
55
+ allowed_mentions: {
56
+ parse: ['users', 'roles'],
57
+ }
58
+ }
59
+ end
47
60
  request.set_form(
48
61
  [
49
62
  [
@@ -74,14 +87,17 @@ module Fastlane
74
87
  request = Net::HTTP::Post.new(uri)
75
88
  request.content_type = 'application/json'
76
89
  embed_payload_content = if embed_payload.nil? || embed_payload.empty?
77
- []
78
- else
79
- [embed_payload]
80
- end
90
+ []
91
+ else
92
+ [embed_payload]
93
+ end
81
94
 
82
95
  body = {
83
96
  content: content,
84
- embeds: embed_payload_content
97
+ embeds: embed_payload_content,
98
+ allowed_mentions: {
99
+ parse: ['users', 'roles'],
100
+ }
85
101
  }
86
102
  body[:username] = username if !username.nil? && !username.empty?
87
103
  request.body = body.to_json
@@ -14,10 +14,10 @@ module Fastlane
14
14
  uri = URI.parse(webhook_url)
15
15
  request = Net::HTTP::Post.new(uri)
16
16
  payload_json = if !username.nil? && !username.empty?
17
- { username: username, content: content }
18
- else
19
- { content: content }
20
- end
17
+ { username: username, content: content }
18
+ else
19
+ { content: content }
20
+ end
21
21
  request.set_form(
22
22
  [
23
23
  [
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module DiscordWebhook
3
- VERSION = "0.1.0"
3
+ VERSION = '0.3.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,16 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-discord_webhook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takuma Homma
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-11-16 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies: []
13
- description:
14
12
  email: nagomimatcha@gmail.com
15
13
  executables: []
16
14
  extensions: []
@@ -28,7 +26,8 @@ licenses:
28
26
  - MIT
29
27
  metadata:
30
28
  rubygems_mfa_required: 'true'
31
- post_install_message:
29
+ source_code_uri: https://github.com/mataku/fastlane-plugin-discord_webhook
30
+ changelog_uri: https://github.com/mataku/fastlane-plugin-discord_webhook/blob/v0.3.0/CHANGELOG.md
32
31
  rdoc_options: []
33
32
  require_paths:
34
33
  - lib
@@ -36,15 +35,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
36
35
  requirements:
37
36
  - - ">="
38
37
  - !ruby/object:Gem::Version
39
- version: '2.7'
38
+ version: '3.2'
40
39
  required_rubygems_version: !ruby/object:Gem::Requirement
41
40
  requirements:
42
41
  - - ">="
43
42
  - !ruby/object:Gem::Version
44
43
  version: '0'
45
44
  requirements: []
46
- rubygems_version: 3.5.16
47
- signing_key:
45
+ rubygems_version: 4.0.16
48
46
  specification_version: 4
49
- summary: A fastlane plugin to send a message via Discord Webhook
47
+ summary: A lightweight fastlane plugin to send a message via Discord Webhook
50
48
  test_files: []