Skip to content

Commit

Permalink
Made the IRC Bridge system also send the url for any files uploaded t…
Browse files Browse the repository at this point in the history
…o Discord.

Removed old jDiscord related code.
  • Loading branch information
DV8FromTheWorld committed Mar 9, 2016
1 parent a0b23bd commit e5fa0b0
Showing 1 changed file with 2 additions and 18 deletions.
Expand Up @@ -111,25 +111,9 @@ public Message getDiscordMessage()
public void setDiscordMessage(Message discordMessage)
{
String parsedMessage = discordMessage.getContent();
Pattern userPattern = Pattern.compile("(?<=<@)[0-9]{18}(?=>)");
Pattern channelPattern = Pattern.compile("(?<=<#)[0-9]{18}(?=>)");

Matcher userMatcher = userPattern.matcher(parsedMessage);
while (userMatcher.find())
{
String userId = userMatcher.group();
User user = Yui.getAPI().getUserById(userId);
if (user != null)
parsedMessage = parsedMessage.replace("<@" + userId + ">", user.getUsername());
}

Matcher channelMatcher = channelPattern.matcher(parsedMessage);
while(channelMatcher.find())
for (Message.Attachment attach : discordMessage.getAttachments())
{
String channelId = channelMatcher.group();
TextChannel channel = Yui.getAPI().getTextChannelById(channelId);
if (channel != null)
parsedMessage = parsedMessage.replace("<#" + channelId + ">", channel.getName());
parsedMessage += "\n" + attach.getUrl();
}

this.message = parsedMessage;
Expand Down

0 comments on commit e5fa0b0

Please sign in to comment.