Skip to content
This repository has been archived by the owner on Oct 1, 2019. It is now read-only.

Commit

Permalink
Release 2.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikos410 committed Mar 20, 2019
2 parents 2bfdee8 + c22a748 commit 0be8c69
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}

version = '2.6.0'
version = '2.6.1'
sourceCompatibility = 1.8
mainClassName = 'de.nikos410.discordbot.DiscordBot'

Expand Down
18 changes: 14 additions & 4 deletions src/main/java/de/nikos410/discordbot/util/discord/DiscordIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private static synchronized IMessage sendSingleMessage(final IChannel channel, f

private static synchronized IMessage sendSingleMessage(final IChannel channel, final String message, final int tries){
try {
return channel.sendMessage(message);
return channel.sendMessage(sanitizeMessage(message));
}
catch (RateLimitException rle) {
if (tries > 0) {
Expand Down Expand Up @@ -175,9 +175,9 @@ public static synchronized IMessage sendFile(final IChannel channel, final Strin
return sendFile(channel, content, file, 20);
}

private static IMessage sendFile(final IChannel channel, final String content, final File file, final int tries) {
private static IMessage sendFile(final IChannel channel, final String message, final File file, final int tries) {
try {
return channel.sendFile(content, file);
return channel.sendFile(sanitizeMessage(message), file);
}
catch (RateLimitException rle) {
if (tries > 0) {
Expand All @@ -191,7 +191,7 @@ private static IMessage sendFile(final IChannel channel, final String content, f
Thread.currentThread().interrupt();
}

return sendFile(channel, content, file, tries - 1);
return sendFile(channel, message, file, tries - 1);
}
else {
LOG.warn("Bot was ratelimited while trying to send file.", rle);
Expand All @@ -207,6 +207,16 @@ private static IMessage sendFile(final IChannel channel, final String content, f
return null;
}

/**
* Sanitize a message by replacing "@everyone" with "(at)everyone"
*
* @param message The message to be sanitized
* @return The sanitized message
*/
public static String sanitizeMessage(final String message) {
return message.replaceAll("@everyone", "(at)everyone");
}

/**
* Send a notification about an error to a channel.
*
Expand Down

0 comments on commit 0be8c69

Please sign in to comment.