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

Commit 0be8c69

Browse files
committed
Release 2.6.1
2 parents 2bfdee8 + c22a748 commit 0be8c69

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ tasks.withType(JavaCompile) {
3131
options.encoding = "UTF-8"
3232
}
3333

34-
version = '2.6.0'
34+
version = '2.6.1'
3535
sourceCompatibility = 1.8
3636
mainClassName = 'de.nikos410.discordbot.DiscordBot'
3737

src/main/java/de/nikos410/discordbot/util/discord/DiscordIO.java

+14-4
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ private static synchronized IMessage sendSingleMessage(final IChannel channel, f
9292

9393
private static synchronized IMessage sendSingleMessage(final IChannel channel, final String message, final int tries){
9494
try {
95-
return channel.sendMessage(message);
95+
return channel.sendMessage(sanitizeMessage(message));
9696
}
9797
catch (RateLimitException rle) {
9898
if (tries > 0) {
@@ -175,9 +175,9 @@ public static synchronized IMessage sendFile(final IChannel channel, final Strin
175175
return sendFile(channel, content, file, 20);
176176
}
177177

178-
private static IMessage sendFile(final IChannel channel, final String content, final File file, final int tries) {
178+
private static IMessage sendFile(final IChannel channel, final String message, final File file, final int tries) {
179179
try {
180-
return channel.sendFile(content, file);
180+
return channel.sendFile(sanitizeMessage(message), file);
181181
}
182182
catch (RateLimitException rle) {
183183
if (tries > 0) {
@@ -191,7 +191,7 @@ private static IMessage sendFile(final IChannel channel, final String content, f
191191
Thread.currentThread().interrupt();
192192
}
193193

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

210+
/**
211+
* Sanitize a message by replacing "@everyone" with "(at)everyone"
212+
*
213+
* @param message The message to be sanitized
214+
* @return The sanitized message
215+
*/
216+
public static String sanitizeMessage(final String message) {
217+
return message.replaceAll("@everyone", "(at)everyone");
218+
}
219+
210220
/**
211221
* Send a notification about an error to a channel.
212222
*

0 commit comments

Comments
 (0)