fastlane-plugin-discord_notifier 0.1.1 → 0.1.2
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 +4 -4
- data/LICENSE +2 -2
- data/README.md +33 -3
- data/lib/fastlane/plugin/discord_notifier/actions/discord_notifier_action.rb +42 -6
- data/lib/fastlane/plugin/discord_notifier/helper/discord_notifier_helper.rb +25 -0
- data/lib/fastlane/plugin/discord_notifier/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df02d5432c8eb9b837f56d41a5dcfacb0024acdc8f1a983df5dfd7767afc8333
|
4
|
+
data.tar.gz: 6e0b0dff9b4edbad76724402b4cbe47de7fb6dbdc8a2b334c84c07b18a2486aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05b8709efcc84b6047898fd05219ea97a4a0bffc1e77cef6a27e26197839ea092547b649c3c60176197749d219b96e18be9201bb64d1759192bf599f4ba51bc6
|
7
|
+
data.tar.gz: dc7304c5f2a4deb38a1b0b851b66415f23147ba2a78bb89a019ef37cdc510c7d22fb3ae4ff7fbd94ed849e68a2622ff3098014d55b6ed63aabdefbbb1a0086e1
|
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
MIT License
|
2
2
|
|
3
|
-
Copyright (c) 2020 Nikos Theodosis
|
3
|
+
Copyright (c) 2020 Nikos Theodosis
|
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
@@ -14,14 +14,44 @@ fastlane add_plugin discord_notifier
|
|
14
14
|
|
15
15
|
Discord Notifier
|
16
16
|
|
17
|
-
|
17
|
+
`discord_notifier` posts a message in a discord channel defined by a webhook created for your discord server.
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
To get started, first, create a webhook in your Discord server. You can find detailed instructions [here](https://support.discordapp.com/hc/en-us/articles/228383668-Intro-to-Webhooks). You will need the webhook url in each call to successfully post a message in your channel.
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
discord_notifier(
|
25
|
+
webhook_url:"<discord webhook url>",
|
26
|
+
title: "<a title>",
|
27
|
+
description: "<a description>",
|
28
|
+
success: "<true/false>", # Optional - Default is true
|
29
|
+
color: "FFFFF", # Optional
|
30
|
+
thumbnail_url:"<thumbnail url>", # Optional
|
31
|
+
image_url:"<image url>" # Optional
|
32
|
+
)
|
33
|
+
```
|
34
|
+
|
35
|
+
## Keys
|
36
|
+
|
37
|
+
| Key | Description | Optional
|
38
|
+
| --- | --- | ---|
|
39
|
+
| webhook_url | Discord webhook url | false
|
40
|
+
| title | Message title | false
|
41
|
+
| description | Message description | false
|
42
|
+
| thumbnail_url | Thumbnail url | true
|
43
|
+
| image_url | Message image url | true
|
44
|
+
| success | Show file differences that haven't been staged | true
|
45
|
+
| color | The color defined will be attributed to the message sidebar. The sidebar by default uses #4BB543 if `success` is set to true and #CC0000 if set to false. If color is set, it overrides the default color described before. | true
|
46
|
+
| gravatar_email | If set, then the author's image will be replaced by the resolved gravatar. If not and the next 3 keys are set, the author's image will be set as the user's discord avatar | true
|
47
|
+
| bot_token | Token of bot assigned to discord server | true
|
48
|
+
| client_id | Client id retrieved upon bot creation | true
|
49
|
+
| discord_user_id | User id of the discord user | true
|
18
50
|
|
19
51
|
## Example
|
20
52
|
|
21
53
|
Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.
|
22
54
|
|
23
|
-
**Note to author:** Please set up a sample project to make it easy for users to explore what your plugin does. Provide everything that is necessary to try out the plugin in this project (including a sample Xcode/Android project if necessary)
|
24
|
-
|
25
55
|
## Run tests for this plugin
|
26
56
|
|
27
57
|
To run both the tests, and code style validation, run
|
@@ -2,6 +2,7 @@ require 'fastlane/action'
|
|
2
2
|
require_relative '../helper/discord_notifier_helper'
|
3
3
|
require 'discordrb/webhooks'
|
4
4
|
|
5
|
+
|
5
6
|
module Fastlane
|
6
7
|
module Actions
|
7
8
|
class DiscordNotifierAction < Action
|
@@ -14,6 +15,22 @@ module Fastlane
|
|
14
15
|
unless params[:color].nil? || params[:color] == 0
|
15
16
|
color = params[:color]
|
16
17
|
end
|
18
|
+
|
19
|
+
begin
|
20
|
+
user = Helper::DiscordUserHelper.findUser(params[:bot_token], params[:client_id], params[:discord_user_id])
|
21
|
+
discord_avatar = user.avatar_url
|
22
|
+
rescue => ex
|
23
|
+
UI.important('Fetching user data failed. Continuing anyway...')
|
24
|
+
end
|
25
|
+
|
26
|
+
author_name = ENV['USER']
|
27
|
+
unless user.nil?
|
28
|
+
author_name = user.name
|
29
|
+
end
|
30
|
+
|
31
|
+
unless params[:gravatar_email].nil? || params[:gravatar_email].empty?
|
32
|
+
discord_avatar = Helper::DiscordUserHelper.gravatarImageUrl(params[:gravatar_email])
|
33
|
+
end
|
17
34
|
|
18
35
|
client = Discordrb::Webhooks::Client.new(url: params[:webhook_url])
|
19
36
|
client.execute do |builder|
|
@@ -27,7 +44,8 @@ module Fastlane
|
|
27
44
|
url: params[:image_url]
|
28
45
|
)
|
29
46
|
embed.author = Discordrb::Webhooks::EmbedAuthor.new(
|
30
|
-
name:
|
47
|
+
name: author_name,
|
48
|
+
icon_url: discord_avatar
|
31
49
|
)
|
32
50
|
embed.colour = color
|
33
51
|
embed.timestamp = Time.now
|
@@ -81,11 +99,6 @@ module Fastlane
|
|
81
99
|
optional: true,
|
82
100
|
type: String
|
83
101
|
),
|
84
|
-
FastlaneCore::ConfigItem.new(
|
85
|
-
key: :author,
|
86
|
-
optional: true,
|
87
|
-
type: String
|
88
|
-
),
|
89
102
|
FastlaneCore::ConfigItem.new(
|
90
103
|
key: :success,
|
91
104
|
optional: true,
|
@@ -96,6 +109,29 @@ module Fastlane
|
|
96
109
|
key: :color,
|
97
110
|
optional: true,
|
98
111
|
type: String
|
112
|
+
),
|
113
|
+
FastlaneCore::ConfigItem.new(
|
114
|
+
key: :gravatar_email,
|
115
|
+
optional: true,
|
116
|
+
type: String
|
117
|
+
),
|
118
|
+
FastlaneCore::ConfigItem.new(
|
119
|
+
key: :bot_token,
|
120
|
+
env_name: "DISCORD_BOT_TOKEN",
|
121
|
+
optional: true,
|
122
|
+
type: String
|
123
|
+
),
|
124
|
+
FastlaneCore::ConfigItem.new(
|
125
|
+
key: :client_id,
|
126
|
+
env_name: "DISCORD_CLIENT_ID",
|
127
|
+
optional: true,
|
128
|
+
type: String
|
129
|
+
),
|
130
|
+
FastlaneCore::ConfigItem.new(
|
131
|
+
key: :discord_user_id,
|
132
|
+
env_name: "DISCORD_USER_ID",
|
133
|
+
optional: true,
|
134
|
+
type: String
|
99
135
|
)
|
100
136
|
]
|
101
137
|
end
|
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'fastlane_core/ui/ui'
|
2
|
+
require 'digest/md5'
|
3
|
+
require 'discordrb'
|
2
4
|
|
3
5
|
module Fastlane
|
4
6
|
UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
|
@@ -12,5 +14,28 @@ module Fastlane
|
|
12
14
|
UI.message("Hello from the discord_notifier plugin helper!")
|
13
15
|
end
|
14
16
|
end
|
17
|
+
|
18
|
+
class DiscordUserHelper
|
19
|
+
|
20
|
+
def self.gravatarImageUrl(email)
|
21
|
+
email_address = ENV["FASTLANE_USER"].downcase
|
22
|
+
# create the md5 hash
|
23
|
+
hash = Digest::MD5.hexdigest(email)
|
24
|
+
# compile URL which can be used in <img src="RIGHT_HERE"...
|
25
|
+
image_src = "https://www.gravatar.com/avatar/#{hash}"
|
26
|
+
|
27
|
+
return image_src
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.findUser(bot_token, client_id, user_id)
|
31
|
+
bot = Discordrb::Bot.new(
|
32
|
+
token: bot_token,
|
33
|
+
client_id: client_id
|
34
|
+
)
|
35
|
+
user = bot.user(user)
|
36
|
+
|
37
|
+
return user
|
38
|
+
end
|
39
|
+
end
|
15
40
|
end
|
16
41
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-discord_notifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nikos Theodosis
|
@@ -137,7 +137,7 @@ dependencies:
|
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: 2.145.0
|
139
139
|
description:
|
140
|
-
email:
|
140
|
+
email: nikolas.theodosis@gmail.com
|
141
141
|
executables: []
|
142
142
|
extensions: []
|
143
143
|
extra_rdoc_files: []
|