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

Commit 43380fa

Browse files
committed
Add Authentication :D & Shorten Name
1 parent b1eba92 commit 43380fa

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

IRC-Relay/IRC-Relay.csproj

+3
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,8 @@
9393
<None Include="App.config" />
9494
<None Include="packages.config" />
9595
</ItemGroup>
96+
<ItemGroup>
97+
<Content Include="Settings.xml" />
98+
</ItemGroup>
9699
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
97100
</Project>

IRC-Relay/Program.cs

+15-3
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,14 @@ private async Task MainAsync()
6767

6868
IRC.ActiveChannelSyncing = true;
6969

70+
IRC.AutoRetry = true;
71+
IRC.AutoRejoin = true;
72+
IRC.AutoRelogin = true;
73+
IRC.AutoRejoinOnKick = true;
74+
7075
IRC.OnError += new ErrorEventHandler(OnError);
7176
IRC.OnChannelMessage += new IrcEventHandler(OnChannelMessage);
72-
77+
IRC.OnConnected += new EventHandler(OnConnected);
7378

7479
int port;
7580
int.TryParse(Config.Config.Instance.IRCPort, out port);
@@ -88,7 +93,8 @@ private async Task MainAsync()
8893

8994
try
9095
{
91-
IRC.Login("discord-relay", "Discord - IRC Relay");
96+
IRC.Login("r", "Discord - IRC Relay"); // todo: make this configurable in settings.xml
97+
9298
IRC.RfcJoin(channel);
9399

94100
IRC.Listen();
@@ -104,6 +110,12 @@ private async Task MainAsync()
104110
await Task.Delay(-1);
105111
}
106112

113+
public static void OnConnected(object sender, EventArgs e)
114+
{
115+
IRC.SendMessage(SendType.Message, "AuthServ@Services.Gamesurge.net", Config.Config.Instance.AuthString);
116+
//Program.IRC.SendMessage(SendType.Message, Config.Config.Instance.IRCChannel, Config.Config.Instance.IRCCommand);
117+
}
118+
107119
public static void OnError(object sender, ErrorEventArgs e)
108120
{
109121
System.Console.WriteLine("Error: " + e.ErrorMessage);
@@ -117,7 +129,7 @@ public static void OnChannelMessage(object sender, IrcEventArgs e)
117129
return;
118130
}
119131

120-
if (e.Data.Nick.Contains("discord-relay"))
132+
if (e.Data.Nick.Equals("r"))
121133
{
122134
return;
123135
}

IRC-Relay/Settings.cs

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class Config
1111
public string IRCServer;
1212
public string IRCPort;
1313
public string IRCChannel;
14+
public string AuthString;
1415

1516
public string DiscordBotToken;
1617
public string DiscordGuildName;
@@ -38,6 +39,7 @@ public static void Default()
3839
Config.Instance.IRCServer = "server";
3940
Config.Instance.IRCPort = "port";
4041
Config.Instance.IRCChannel = "#channel";
42+
Config.Instance.AuthString = "some command here";
4143

4244
Config.Instance.DiscordBotToken = "token";
4345
Config.Instance.DiscordGuildName = "server name";

0 commit comments

Comments
 (0)