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

Commit

Permalink
Use nickname when sending code URL (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
SlidyBat authored and Headline committed Oct 27, 2018
1 parent 4867f00 commit f3e1104
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions IRC-Relay/Discord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ private async Task DoStikkedUpload(string input, SocketUserMessage msg)
var url = await response.Content.ReadAsStringAsync();

if (config.IRCLogMessages)
LogManager.WriteLog(MsgSendType.DiscordToIRC, msg.Author.Username, url, "log.txt");
session.SendMessage(Session.TargetBot.IRC, url, msg.Author.Username);
LogManager.WriteLog(MsgSendType.DiscordToIRC, username, url, "log.txt");
session.SendMessage(Session.TargetBot.IRC, url, username);

}
}
Expand Down Expand Up @@ -283,10 +283,11 @@ private void Hastebin_UploadCompleted(object sender, UploadDataCompletedEventArg
string result = "https://hastebin.com/" + key + ".cs";

var msg = (SocketUserMessage)e.UserState;
string username = (msg.Author as SocketGuildUser)?.Nickname ?? msg.Author.Username;
if (config.IRCLogMessages)
LogManager.WriteLog(MsgSendType.DiscordToIRC, msg.Author.Username, result, "log.txt");
LogManager.WriteLog(MsgSendType.DiscordToIRC, username, result, "log.txt");

session.SendMessage(Session.TargetBot.IRC, result, msg.Author.Username);
session.SendMessage(Session.TargetBot.IRC, result, username);
}
}

Expand Down Expand Up @@ -326,9 +327,9 @@ public static string Unescape(string input)
Regex reg = new Regex("\\`[^`]*\\`");

int count = 0;
List<string> peices = new List<string>();
List<string> pieces = new List<string>();
reg.Replace(input, (m) => {
peices.Add(m.Value);
pieces.Add(m.Value);
input = input.Replace(m.Value, string.Format("__NEVER_BE_SENT_PLEASE_{0}_!@#%", count));
count++;
return ""; // doesn't matter what we replace with
Expand All @@ -339,10 +340,10 @@ public static string Unescape(string input)
// From here we prep the return string by doing our regex on the input that's not in '`'
reg = new Regex("__NEVER_BE_SENT_PLEASE_([0-9]+)_!@#%");
input = reg.Replace(retstr, (m) => {
return peices[int.Parse(m.Result("$1"))].ToString();
return pieces[int.Parse(m.Result("$1"))].ToString();
});

return input; // thank fuck we're done
return input; // thank f***k we're done
}

public static string ChannelMentionToName(string input, SocketUserMessage message)
Expand Down

0 comments on commit f3e1104

Please sign in to comment.