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

Commit

Permalink
Allow username hiding for both platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
Headline committed Oct 20, 2018
1 parent e07f61c commit dfde895
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
28 changes: 26 additions & 2 deletions IRC-Relay/IRC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,19 @@ public IRC(dynamic config, Session session)

public void SendMessage(string username, string message)
{
ircClient.SendMessage(SendType.Message, config.IRCChannel, "<" + username + "> " + message);
if (!Program.HasMember(config, "HideDiscordNames")) // bcompat
{
ircClient.SendMessage(SendType.Message, config.IRCChannel, "<" + username + "> " + message);
return;
}
if (!config.HideDiscordNames) // normal behavior (don't hide)
{
ircClient.SendMessage(SendType.Message, config.IRCChannel, "<" + username + "> " + message);
return;
}

// now let's hide.
ircClient.SendMessage(SendType.Message, config.IRCChannel, message);
}

public async Task SpawnBot()
Expand Down Expand Up @@ -147,7 +159,19 @@ private void OnChannelMessage(object sender, IrcEventArgs e)
}
}

session.SendMessage(Session.TargetBot.Discord, "**<" + prefix + Regex.Escape(e.Data.Nick) + ">** " + msg);
if (!Program.HasMember(config, "HideIRCNames")) // bcompat
{
session.SendMessage(Session.TargetBot.Discord, "**<" + prefix + Regex.Escape(e.Data.Nick) + ">** " + msg);
return;
}
if (!config.HideIRCNames) // normal behavior (don't hide)
{
session.SendMessage(Session.TargetBot.Discord, "**<" + prefix + Regex.Escape(e.Data.Nick) + ">** " + msg);
return;
}

// now let's hide.
session.SendMessage(Session.TargetBot.Discord, msg);
}
}
}
10 changes: 9 additions & 1 deletion IRC-Relay/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,15 @@ private static async Task StartSessions(dynamic config)

public static bool HasMember(dynamic obj, string name)
{
return obj.GetType().GetMember(name) != null;
var it = obj.Keys.GetEnumerator();
while (it.MoveNext())
{
if (it.Current == name)
{
return true;
}
}
return false;
}
}
}
4 changes: 3 additions & 1 deletion IRC-Relay/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@
],
"DiscordUserIDBlacklist": [
],
"StikkedCreateUrlAndKey": ""
"StikkedCreateUrlAndKey": "",
"HideDiscordNames": false,
"HideIRCNames": false
}

0 comments on commit dfde895

Please sign in to comment.