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

Commit b243e31

Browse files
authored
Merge pull request #5 from SlidyBat/unescape
Unescape discord messages before sending to discord
2 parents 7ed5cd5 + 7eb1d42 commit b243e31

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

IRC-Relay/Helpers.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ class Helpers
1313
{
1414
public static string UploadMarkDown(string input)
1515
{
16-
1716
using (var client = new WebClient())
1817
{
1918
client.Headers[HttpRequestHeader.ContentType] = "text/plain";
@@ -52,6 +51,11 @@ public static string MentionToUsername(string input, SocketUserMessage message)
5251
return returnString;
5352
}
5453

54+
public static string Unescape(string input)
55+
{
56+
return Regex.Replace(input, @"\\([^A-Za-z0-9])", "$1");
57+
}
58+
5559
public static string ChannelMentionToName(string input, SocketUserMessage message)
5660
{
5761
string returnString = input;
@@ -78,7 +82,7 @@ public static string EmojiToName(string input, SocketUserMessage message)
7882

7983
Regex regex = new Regex("<:[A-Za-z0-9-_]+:[0-9]+>");
8084
Match match = regex.Match(input);
81-
if (match.Success) // contains a mention
85+
if (match.Success) // contains a emoji
8286
{
8387
string substring = input.Substring(match.Index, match.Length);
8488
string[] sections = substring.Split(':');

IRC-Relay/Program.cs

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ public async Task OnDiscordMessage(SocketMessage messageParam)
8787
string formatted = Helpers.MentionToUsername(messageParam.Content, message);
8888
formatted = Helpers.EmojiToName(formatted, message);
8989
formatted = Helpers.ChannelMentionToName(formatted, message);
90+
formatted = Helpers.Unescape(formatted);
9091

9192
string text = "```";
9293
if (formatted.Contains(text))

0 commit comments

Comments
 (0)