fastlane-plugin-discord_webhook 0.1.0 → 0.2.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: 1c623e59ee75e6ee3443dbf34fda73c834a831bc2a90ff0a0bb6cb0a86924146
4
- data.tar.gz: e726c49563e2df88536facd4cc9492d6bbc8a15d01b131dbf147cb6fbeff1d8d
3
+ metadata.gz: 58687b16f95e449ab2018b13640cb50265bdf952187d958dd34d53b3e8784740
4
+ data.tar.gz: 275fb0893156ba816893dc3941a97237fb8e657c488c6d7e1abb09f1853018b5
5
5
  SHA512:
6
- metadata.gz: b493ed928ef47e68b470d13da492a5b150dc4365511bf16f4aad30ffbd4fdabc193df426fe18ba67a93e406d033ed212dbd4c765c5a6622a15e3baec682f3875
7
- data.tar.gz: b2bf0e922d25b2660ab0a38d2c68c7b8c8242a9fc5fb651d5a84a70f031609a111540890685e955b5811dd1fcac40457fdae8d6ef7e8a99851ae4a0da843e6c6
6
+ metadata.gz: 380970309b01d0790783ffccb3a0d637b5ba2af68d8826c3c2fc54c6507124151540b96abd21cd85fb782e20f17d660ed34219082317ec5c845bf4b8f6240a40
7
+ data.tar.gz: 1b4062e167256fbea60934ff8912b19af080917359807d0a49c307b7a8221a2f7a710579b85994612978e910ae6ddb2c462a81a7715fec9291c263d85b3835ee
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,7 +27,7 @@ module Fastlane
27
27
  embed_payload: embed_payload
28
28
  )
29
29
  handle_response(response)
30
- rescue StandardError => e
30
+ rescue Socket::ResolutionError, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError => e
31
31
  UI.user_error!(e.message)
32
32
  end
33
33
  end
@@ -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 StandardError => e
118
+ body
113
119
  end
114
120
  UI.user_error!("Failed to send a message to Discord: #{error_body}")
115
121
  end
@@ -40,9 +40,22 @@ module Fastlane
40
40
  [embed_payload]
41
41
  end
42
42
  payload_json = if !username.nil? && !username.empty?
43
- { username: username, content: content, embeds: embed_payload_content }
43
+ {
44
+ username: username,
45
+ content: content,
46
+ embeds: embed_payload_content,
47
+ allowed_mentions: {
48
+ parse: ['users', 'roles'],
49
+ }
50
+ }
44
51
  else
45
- { content: content, embeds: embed_payload_content }
52
+ {
53
+ content: content,
54
+ embeds: embed_payload_content,
55
+ allowed_mentions: {
56
+ parse: ['users', 'roles'],
57
+ }
58
+ }
46
59
  end
47
60
  request.set_form(
48
61
  [
@@ -81,7 +94,10 @@ module Fastlane
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
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module DiscordWebhook
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +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.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takuma Homma
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-16 00:00:00.000000000 Z
11
+ date: 2024-11-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: nagomimatcha@gmail.com
@@ -46,5 +46,5 @@ requirements: []
46
46
  rubygems_version: 3.5.16
47
47
  signing_key:
48
48
  specification_version: 4
49
- summary: A fastlane plugin to send a message via Discord Webhook
49
+ summary: A lightweight fastlane plugin to send a message via Discord Webhook
50
50
  test_files: []