Skip to content
This repository has been archived by the owner on Sep 29, 2020. It is now read-only.

Commit

Permalink
Upload to hastebin before discord mutations
Browse files Browse the repository at this point in the history
  • Loading branch information
Headline committed Aug 17, 2018
1 parent 10fe663 commit 470d2d8
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions IRC-Relay/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,22 @@ public async Task OnDiscordMessage(SocketMessage messageParam)
}
}

string formatted = messageParam.Content;
string text = "```";
if (formatted.Contains(text))
{
int start = formatted.IndexOf(text, StringComparison.CurrentCulture);
int end = formatted.IndexOf(text, start + text.Length, StringComparison.CurrentCulture);

string code = formatted.Substring(start + text.Length, (end - start) - text.Length);

url = Helpers.UploadMarkDown(code);

formatted = formatted.Remove(start, (end - start) + text.Length);
}

/* Santize discord-specific notation to human readable things */
string formatted = Helpers.MentionToUsername(messageParam.Content, message);
formatted = Helpers.MentionToUsername(formatted, message);
formatted = Helpers.EmojiToName(formatted, message);
formatted = Helpers.ChannelMentionToName(formatted, message);
formatted = Helpers.Unescape(formatted);
Expand All @@ -116,20 +130,6 @@ public async Task OnDiscordMessage(SocketMessage messageParam)
}
}


string text = "```";
if (formatted.Contains(text))
{
int start = formatted.IndexOf(text, StringComparison.CurrentCulture);
int end = formatted.IndexOf(text, start + text.Length, StringComparison.CurrentCulture);

string code = formatted.Substring(start + text.Length, (end - start) - text.Length);

url = Helpers.UploadMarkDown(code);

formatted = formatted.Remove(start, (end - start) + text.Length);
}

// Send IRC Message
if (formatted.Length > 1000)
{
Expand Down

0 comments on commit 470d2d8

Please sign in to comment.