-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #387 from Rakambda/filter/discord-customization
Discord messages customization
- Loading branch information
Showing
40 changed files
with
887 additions
and
488 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"accounts" : [ | ||
{ | ||
"discord" : { | ||
"embeds" : false, | ||
"webhookUrl" : "https://my-webhook-url", | ||
"events" : { | ||
"DropClaimedEvent" : {}, | ||
"MinerStartedEvent" : {}, | ||
"PointsSpentEvent" : {} | ||
} | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"accounts" : [ | ||
{ | ||
"discord" : { | ||
"embeds" : false, | ||
"webhookUrl" : "https://my-webhook-url", | ||
"events" : { | ||
"DropClaimedEvent" : {}, | ||
"MinerStartedEvent" : { | ||
"format" : "Oh my, the miner started for my account {username} and it uses the brand new version {version}!" | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
= Discord settings | ||
|
||
Discord settings can be customized to filter events and/or customize the format of messages sent. | ||
|
||
== Filtering [[filtering]] | ||
|
||
To filter messages, you need to provide a list of events you want to be sent, and set no customization. | ||
|
||
The name of the events can be found in link:https://github.com/Rakambda/ChannelPointsMiner/tree/develop/miner/src/main/java/fr/rakambda/channelpointsminer/miner/event/impl[miner/src/main/java/fr/rakambda/channelpointsminer/miner/event/impl] as the name of the classes (name of the file without `.java`). | ||
|
||
.Example to sent only 3 type of events with default format | ||
[%collapsible] | ||
==== | ||
[source,json] | ||
---- | ||
include::example$discord-filtering.json[] | ||
---- | ||
==== | ||
|
||
== Format | ||
|
||
Format works the same way as <<filtering, filtering>> except that additional parameters are provided. | ||
|
||
Placeholders are expected to be between braces, example: `\{placeholder_name}`. | ||
Available values can be seen in link:https://github.com/Rakambda/ChannelPointsMiner/blob/filter/develop/miner/src/main/java/fr/rakambda/channelpointsminer/miner/event/EventVariableKey.java[EventVariableKey]. | ||
|
||
NOTE: If you want to override the format of one event, you'll have to do the all as it'll also act as a filter. | ||
|
||
.Example of filtering 2 events with 1 having a custom format | ||
[%collapsible] | ||
==== | ||
[source,json] | ||
---- | ||
include::example$discord-format.json[] | ||
---- | ||
==== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
.../src/main/java/fr/rakambda/channelpointsminer/miner/config/DiscordEventConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package fr.rakambda.channelpointsminer.miner.config; | ||
|
||
import com.fasterxml.jackson.annotation.JsonClassDescription; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonPropertyDescription; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
@ToString | ||
@JsonClassDescription("Customization of the event sent.") | ||
public class DiscordEventConfiguration{ | ||
@JsonProperty("format") | ||
@JsonPropertyDescription(value = "Format of the message sent. Will be either the text, or the description of the embed. Placeholders are between braces {example_key} . Keys can be seen in EventVariableKey class.") | ||
@Nullable | ||
private String format; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
miner/src/main/java/fr/rakambda/channelpointsminer/miner/event/EventVariableKey.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package fr.rakambda.channelpointsminer.miner.event; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class EventVariableKey{ | ||
public static final String BALANCE = "balance"; | ||
public static final String BRANCH = "branch"; | ||
public static final String COLOR = "color"; | ||
public static final String COMMIT = "commit"; | ||
public static final String DROP_NAME = "drop_name"; | ||
public static final String EMOJI = "emoji"; | ||
public static final String POINTS = "points"; | ||
public static final String PREDICTION_NAME = "prediction_name"; | ||
public static final String PREDICTION_OUTCOME = "prediction_outcome"; | ||
public static final String PREDICTION_POINTS = "prediction_points"; | ||
public static final String PREDICTION_TYPE = "prediction_type"; | ||
public static final String REASON = "reason"; | ||
public static final String USERNAME = "username"; | ||
public static final String STREAMER = "streamer"; | ||
public static final String STREAMER_URL = "streamer_url"; | ||
public static final String STREAMER_PROFILE_PICTURE_URL = "streamer_profile_picture_url"; | ||
public static final String VERSION = "version"; | ||
} |
11 changes: 6 additions & 5 deletions
11
miner/src/main/java/fr/rakambda/channelpointsminer/miner/event/ILoggableEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
package fr.rakambda.channelpointsminer.miner.event; | ||
|
||
import fr.rakambda.channelpointsminer.miner.api.discord.data.Webhook; | ||
import org.apache.commons.text.lookup.StringLookup; | ||
import org.jetbrains.annotations.NotNull; | ||
import java.util.Map; | ||
|
||
public interface ILoggableEvent extends IEvent{ | ||
public interface ILoggableEvent extends IEvent, StringLookup{ | ||
@NotNull | ||
String getAsLog(); | ||
String getConsoleLogFormat(); | ||
|
||
@NotNull | ||
Webhook getAsWebhookEmbed(); | ||
String getDefaultFormat(); | ||
|
||
@NotNull | ||
Webhook getAsWebhookMessage(); | ||
Map<String, String> getEmbedFields(); | ||
} |
Oops, something went wrong.