-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIrcServer.cs
774 lines (695 loc) · 21.8 KB
/
IrcServer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Discord;
using Discord.WebSocket;
namespace dIRCd
{
internal class IrcServer
{
internal Dictionary<string, SocketChannel> channels = new Dictionary<string, SocketChannel>();
private IPAddress address;
private int port;
private TcpListener listener;
private TcpClient client;
private StreamReader reader;
private StreamWriter writer;
internal IrcServerConfig config;
private CancellationTokenSource canceller = new CancellationTokenSource();
internal readonly BridgeServer bridge;
private Queue<string> lastMessageHashes = new Queue<string>();
private Timer pingIntervalTimer, pingResponseTimer;
private string lastPing = null;
private ImmutableDictionary<string, SocketTextChannel> GuildChannels => channels.Where(e => e.Value is SocketTextChannel).ToImmutableDictionary(e => e.Key, e=> e.Value as SocketTextChannel);
private ImmutableDictionary<string, SocketDMChannel> DMChannels => channels.Where(e => e.Value is SocketDMChannel).ToImmutableDictionary(e => e.Key, e => e.Value as SocketDMChannel);
private ImmutableDictionary<string, SocketGroupChannel> GroupChannels => channels.Where(e => e.Value is SocketGroupChannel).ToImmutableDictionary(e => e.Key, e => e.Value as SocketGroupChannel);
private string CurrentNick => bridge.GetOwnUser(config.guildId).IrcNick();
private string CurrentHostname => bridge.GetOwnUser(config.guildId).IrcHostname();
internal IrcServer(BridgeServer bridge, IPAddress address, int port, IrcServerConfig config)
{
this.bridge = bridge;
this.address = address;
this.port = port;
this.config = config;
}
internal async Task Run(IEnumerable<IChannel> serverChannels)
{
try
{
listener = new TcpListener(address, port);
listener.Start();
Log(LogSeverity.Info, $"IRC Server for guild {config.guildName} ({config.guildId}) started on port {port}");
while (!canceller.Token.IsCancellationRequested)
{
Log(LogSeverity.Info, $"Waiting for new Client connection for {config.guildName}");
client = await listener.AcceptTcpClientAsync();
Log(LogSeverity.Info, $"Client connection initiated for {config.guildName}");
reader = new StreamReader(client.GetStream(), Encoding.UTF8);
writer = new StreamWriter(client.GetStream(), Encoding.UTF8)
{
AutoFlush = true,
NewLine = "\r\n"
};
pingIntervalTimer = new Timer(e => Ping(), null, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(60));
pingResponseTimer = new Timer(e => PingTimeout());
foreach (SocketChannel channel in serverChannels)
{
if (channel is SocketTextChannel textChannel)
{
channels["#" + textChannel.Name.Sanitize()] = textChannel;
Log(LogSeverity.Info, $"Adding guild channel #{textChannel.Name} ({textChannel.Id})");
}
else if (channel is SocketDMChannel dmChannel)
{
channels[dmChannel.Recipient.Id.ToString()] = dmChannel;
Log(LogSeverity.Info, $"Adding DM chat with #{dmChannel.Recipient.IrcNick()} ({dmChannel.Id})");
}
else if (channel is SocketGroupChannel groupChannel)
{
channels["&" + groupChannel.Name] = groupChannel;
Log(LogSeverity.Info, $"Adding group channel &{groupChannel.Name} ({groupChannel.Id})");
}
else if (channel is SocketGuildChannel guildChannel)
{
Log(LogSeverity.Debug, $"Skipping channel {guildChannel.Name} ({guildChannel.Id}) as it is not a text channel");
}
else
{
Log(LogSeverity.Debug, $"Skipping channel ({channel.Id}) as it is not a guild channel");
}
}
try
{
while (!canceller.IsCancellationRequested && client.Connected && (await DataAvailable(reader)))
{
string readLine = await reader.ReadLineAsync();
if (readLine != null)
{
try
{
await ProcessIrcLine(readLine);
}
catch (ArgumentException e)
{
Log(LogSeverity.Critical, $"{e.Message}\n{e.StackTrace}");
}
}
}
}
catch (IOException)
{
// TCP connection was aborted, just restart listening
}
finally
{
Log(LogSeverity.Info, $"Client connection died for {config.guildName}");
CleanupConnection();
}
}
}
catch (ObjectDisposedException)
{
// We shut down while awaiting a connection, just keep closing things down
}
catch (Exception e)
{
Log(LogSeverity.Critical, $"Unrecoverable {e}: {e.Message}\n{e.StackTrace}");
}
finally
{
CleanupConnection();
listener.Stop();
bridge.ircServers.Remove(config.guildId);
Log(LogSeverity.Info, $"IRC server for {config.guildName} shut down.");
}
}
private Task<bool> DataAvailable(StreamReader reader)
{
try
{
return Task.FromResult(!reader.EndOfStream);
}
catch (IOException)
{
// The reader got killed while attempting to read, just return that there's no more data
return Task.FromResult(false);
}
}
internal Task Shutdown()
{
Log(LogSeverity.Info, $"IRC server for {config.guildName} shutting down...");
canceller.Cancel();
CleanupConnection();
listener.Stop();
return Task.CompletedTask;
}
private void CleanupConnection()
{
pingResponseTimer?.Dispose();
pingIntervalTimer?.Dispose();
writer?.Dispose();
reader?.Dispose();
client?.Close();
}
#region Basic message receiving/sending
private Task ProcessIrcLine(string readLine)
{
IrcMessage message = new IrcMessage
{
source = null,
command = null,
arguments = new List<string>(),
trailing = false
};
int searchIndex = 0;
int nextIndex = 0;
// Check for optional SOURCE parameter
if (readLine.StartsWith(":"))
{
nextIndex = readLine.IndexOf(" ", searchIndex);
message.source = readLine.Substring(1, nextIndex - 1);
searchIndex = nextIndex + 1;
}
// Get COMMAND parameter
nextIndex = readLine.IndexOf(" ", searchIndex);
if (nextIndex > searchIndex)
{
message.command = readLine.Substring(searchIndex, nextIndex - searchIndex);
searchIndex = nextIndex + 1;
}
else
{
return Task.FromException(new ArgumentException($"Malformed message read from IRC ({readLine}): Command name expected at index {nextIndex}"));
}
// Get space-separated ARGUMENTS parameters
while ((searchIndex < readLine.Length) && ((nextIndex = readLine.IndexOf(" ", searchIndex)) >= searchIndex))
{
if (nextIndex == searchIndex)
{
searchIndex++;
continue;
}
else
{
string arg = readLine.Substring(searchIndex, nextIndex - searchIndex);
if (arg.StartsWith(":"))
{
message.trailing = true;
break;
}
else
{
message.arguments.Add(arg);
searchIndex = nextIndex + 1;
}
}
}
// Skip trailing argument indicator if present
if (readLine[searchIndex] == ':')
{
searchIndex++;
}
// Get last ARGUMENT
if (searchIndex < readLine.Length)
{
string lastArg = readLine.Substring(searchIndex);
if (lastArg.Length > 0)
{
message.arguments.Add(lastArg);
}
}
return ProcessMessage(message);
}
private Task ProcessMessage(IrcMessage message)
{
Log(message.command == "PING" || message.command == "PONG" ? LogSeverity.Debug : LogSeverity.Info, $"< {config.serverName} {message}");
RefreshPingTimer();
switch (message.command)
{
case "NICK":
if (!ValidateArgCount(message, 1))
{
break;
}
config.clientHostmask = message.arguments[0];
break;
case "USER":
SendHandshake();
SendSelfNickchange(CurrentNick);
ForceJoinChannels();
break;
case "PING":
if (!ValidateArgCount(message, 1))
{
break;
}
SendPong(message.arguments[0]);
break;
case "PONG":
if (!ValidateArgCount(message, 1))
{
break;
}
if (message.arguments[0] == lastPing)
{
SetPingResponseTimer(Timeout.InfiniteTimeSpan);
lastPing = null;
}
else
{
Log(LogSeverity.Warning, $"Ping response did not match up: {message.arguments[0]}, {lastPing}");
}
break;
case "PRIVMSG":
case "NOTICE":
if (!ValidateArgCount(message, 2))
{
break;
}
string target = message.arguments[0];
string messageText = message.arguments[1];
if (target[0] == '#' || target[0] == '&')
{
if (channels.TryGetValue(target, out SocketChannel channel))
{
if (channel is SocketTextChannel guildChannel)
{
guildChannel.SendMessageAsync(messageText);
AddOwnMessage(messageText);
}
else if (channel is SocketGroupChannel groupChannel)
{
groupChannel.SendMessageAsync(messageText);
AddOwnMessage(messageText);
}
else
{
Log(LogSeverity.Critical, $"I have no idea how you sent to channel {channel.Id}, but you shouldn't be able to.");
}
}
else
{
bridge.UnknownChannelMessage(config.guildId, message);
}
}
else
{
string targetId = bridge.TryParseUserId(target, config.guildId);
if (targetId != null)
{
if (channels.TryGetValue(targetId, out SocketChannel channel))
{
if (channel is SocketDMChannel dmChannel)
{
dmChannel.SendMessageAsync(messageText);
AddOwnMessage(messageText);
}
}
else
{
bridge.UnknownChannelMessage(config.guildId, message);
}
}
}
break;
case "MODE":
break;
case "CAP":
case "USERHOST":
//we're ignoring these
break;
default:
Log(LogSeverity.Warning, $"Unknown command [{message.command}].");
break;
}
return Task.CompletedTask;
}
private bool ValidateArgCount(IrcMessage message, int count)
{
if (message.arguments.Count == count)
{
return true;
}
else
{
Log(LogSeverity.Error, $"Invalid argument count ({message.arguments.Count}) for command [{message.command}] (takes {count}).");
return false;
}
}
private bool ValidateArgMin(IrcMessage message, int count)
{
if (message.arguments.Count >= count)
{
return true;
}
else
{
Log(LogSeverity.Error, $"Insufficient argument count ({message.arguments.Count}) for command [{message.command}] (requires at least {count}).");
return false;
}
}
private void SendIrcMessage(IrcMessage ircMessage, bool replaceNullSender = true, LogSeverity severity = LogSeverity.Info)
{
Log(severity, $"> {config.serverName} {ircMessage}");
RefreshPingTimer();
if (replaceNullSender)
{
ircMessage.source = ircMessage.source ?? config.serverName;
}
writer?.WriteLine(ircMessage);
}
#endregion
#region IRC message types
internal void SendMessage(string channel, string message, string author = null)
{
SendIrcMessage(new IrcMessage("PRIVMSG", new List<String> { channel, message }, author ?? config.clientHostmask));
}
internal void SendNotice(string message, string source = null, string target = null)
{
SendIrcMessage(new IrcMessage("NOTICE", new List<String> { config.clientHostmask, message }, source ?? config.serverName));
}
private void SendHandshake()
{
string clientNick = config.clientHostmask ?? String.Empty;
string serverName = config.serverName;
DateTime startTime = config.startTime;
System.Version appVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
SendIrcMessage(new IrcMessage(IrcNumerics.Welcome, new List<string> { clientNick, $"Welcome to your Discord IRC Bridge, {clientNick}" }));
SendIrcMessage(new IrcMessage(IrcNumerics.Host, new List<string> { clientNick, $"Your host is dIRCd, version {appVersion}" }));
SendIrcMessage(new IrcMessage(IrcNumerics.Created, new List<string> { clientNick, $"Server has been running for {DateTime.Now - startTime}, since {startTime}" }));
SendIrcMessage(new IrcMessage(IrcNumerics.Info, new List<string> { clientNick, $"{serverName} dIRCd{appVersion} {String.Empty} {String.Empty}"}, trailing: false));
}
private void SendPing(string timestamp)
{
SendIrcMessage(new IrcMessage("PING", timestamp), false, LogSeverity.Debug);
}
private void SendPong(string reply)
{
SendIrcMessage(new IrcMessage("PONG", reply), false, LogSeverity.Debug);
}
private void SendJoin(string channel, string user)
{
SendIrcMessage(new IrcMessage("JOIN", channel, user));
}
private void SendQuit(string user)
{
SendIrcMessage(new IrcMessage("QUIT", "User left server", user));
}
private void SendTopic(string channel, string topic)
{
SendIrcMessage(new IrcMessage(IrcNumerics.Topic, new List<string> { config.clientHostmask, channel, topic }));
}
private void SendNames(string channel, string names)
{
SendIrcMessage(new IrcMessage(IrcNumerics.Names, new List<string> { config.clientHostmask, "=", channel, names }));
SendIrcMessage(new IrcMessage(IrcNumerics.EndNames, new List<string> { config.clientHostmask, channel, "End of NAMES list" }));
}
private void SendNickchange(string hostname, string newNick)
{
SendIrcMessage(new IrcMessage("NICK", newNick, hostname));
}
#endregion
private void ForceJoinChannels()
{
foreach (KeyValuePair<string, SocketTextChannel> entry in GuildChannels.ToList().OrderBy(e => e.Value.Position))
{
string channelName = entry.Key;
SocketTextChannel discordChannel = entry.Value;
SendJoin(channelName, config.clientHostmask);
SendTopic(channelName, discordChannel.Topic);
SendNames(channelName, discordChannel.Users.Select(e => (e.IrcHostname())).Aggregate((a, v) => a + " " + v));
}
foreach (KeyValuePair<string, SocketGroupChannel> entry in GroupChannels.ToList().OrderBy(e => e.Value.CreatedAt))
{
string channelName = entry.Key;
SocketGroupChannel discordChannel = entry.Value;
SendJoin(channelName, config.clientHostmask);
SendNames(channelName, discordChannel.Users.Select(e => (e.IrcHostname())).Aggregate((a, v) => a + " " + v));
}
}
internal void JoinGuildChannel(SocketTextChannel discordChannel)
{
string channelName = "#" + discordChannel.Name;
if (!channels.ContainsKey(channelName))
{
channels[channelName] = discordChannel;
SendJoin(channelName, config.clientHostmask);
SendTopic(channelName, discordChannel.Topic);
SendNames(channelName, discordChannel.Users.Select(e => (e.IrcHostname())).Aggregate((a, v) => a + " " + v));
}
}
internal void JoinGroupChannel(SocketGroupChannel discordChannel)
{
string channelName = "&" + discordChannel.Name;
if (!channels.ContainsKey(channelName))
{
channels[channelName] = discordChannel;
SendJoin(channelName, config.clientHostmask);
SendNames(channelName, discordChannel.Users.Select(e => (e.IrcHostname())).Aggregate((a, v) => a + " " + v));
}
}
internal void JoinDMChannel(SocketDMChannel newChannel)
{
string channelName = newChannel.Recipient.Id.ToString();
if (!channels.ContainsKey(channelName))
{
channels[channelName] = newChannel;
}
}
internal void SendUserJoin(SocketGuildUser user)
{
foreach (KeyValuePair<string, SocketTextChannel> channel in GuildChannels)
{
if (channel.Value.Users.Contains(user))
{
SendJoin(channel.Key, user.IrcHostname());
}
}
}
internal void SendUserQuit(SocketGuildUser user)
{
SendQuit(user.IrcHostname());
}
internal void SendUserNickchange(string hostname, SocketUser newUser)
{
SendNickchange(hostname, newUser.IrcNick());
if (channels.ContainsKey(hostname))
{
channels[newUser.IrcHostname()] = channels[hostname];
channels.Remove(hostname);
}
}
internal void SendSelfNickchange(string newNick)
{
SendNickchange(config.clientHostmask, newNick);
config.clientHostmask = CurrentHostname;
}
#region Utility & housekeeping
internal bool IsOwnMessage(string message)
{
if (lastMessageHashes.Count > 0 && message.Md5Hash() == lastMessageHashes.Peek())
{
lastMessageHashes.Dequeue();
return true;
}
else
{
return false;
}
}
internal void AddOwnMessage(string message)
{
lastMessageHashes.Enqueue(message.Md5Hash());
}
private void Ping()
{
if (lastPing != null)
{
PingTimeout();
}
else
{
lastPing = DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString();
SetPingResponseTimer(TimeSpan.FromSeconds(10));
SendPing(lastPing);
}
}
private void RefreshPingTimer()
{
pingIntervalTimer?.Change(TimeSpan.FromSeconds(60), TimeSpan.FromSeconds(60));
}
private void SetPingResponseTimer(TimeSpan time)
{
pingResponseTimer?.Change(time, Timeout.InfiniteTimeSpan);
}
private void PingTimeout()
{
throw new IOException("Ping timeout");
}
private void Log(LogSeverity severity, string message)
{
bridge.Log(new LogMessage(severity, LogSource.IRC, message));
}
#endregion
}
internal struct IrcServerConfig
{
internal string serverName;
internal string clientHostmask;
internal string guildId;
internal string guildName;
internal DateTime startTime;
}
internal struct IrcMessage
{
internal string source;
internal string command;
internal List<string> arguments;
internal bool trailing;
internal IrcMessage(string command, List<string> arguments, string source = null, bool trailing = true)
{
this.source = source;
this.command = command;
this.arguments = arguments.ConvertAll(e => e ?? string.Empty);
this.trailing = this.arguments.Last().Contains(" ") || trailing;
}
internal IrcMessage(string command, string argument, string source = null, bool trailing = true) : this(command, new List<string> { argument }, source, trailing)
{
}
public override string ToString()
{
/****************************
* ABANDON ALL HOPE etc etc *
* ------------------------ *
* This method does some *
* heavy lifting. It really *
* isn't pretty. *
****************************/
StringBuilder messageBuilder = new StringBuilder();
if (source != null)
{
messageBuilder.Append(":" + source + " ");
}
messageBuilder.Append(command);
if (arguments.Count > 0)
{
for (int i = 0; i < arguments.Count - 1; i++)
{
messageBuilder.Append(" ");
messageBuilder.Append(arguments[i]);
}
//Special handling for the last argument, since that's almost always going to be the longest one, or nonexistent
if (!trailing)
{
messageBuilder.Append(" ");
messageBuilder.Append(arguments[arguments.Count - 1]);
}
else
{
messageBuilder.Append(" :");
string fullMessage = arguments[arguments.Count - 1];
string messageBase = messageBuilder.ToString();
int baseLength = Encoding.UTF8.GetByteCount(messageBase);
int maxArgumentsLength = 510 - baseLength;
List<string> splitLines = fullMessage.Split( new string[] {"\r\n", "\n", "\r"}, StringSplitOptions.RemoveEmptyEntries).ToList();
if (splitLines.Count == 1 && Encoding.UTF8.GetByteCount(splitLines[0]) <= maxArgumentsLength)
{
messageBuilder.Append(splitLines[0]);
}
else
{
messageBuilder.Clear();
for (int i = 0; i < splitLines.Count; i++)
{
if (splitLines[i].Length <= maxArgumentsLength)
{
continue;
}
else
{
int index = i;
string fullLine = splitLines[index];
splitLines.RemoveAt(index);
int lineLength = 0;
StringBuilder lineBuilder = new StringBuilder();
foreach (string word in fullLine.Split((char[]) null, StringSplitOptions.RemoveEmptyEntries))
{
int wordLength = Encoding.UTF8.GetByteCount(word);
if (lineLength + wordLength < maxArgumentsLength)
{
if (lineBuilder.Length > 0)
{
lineBuilder.Append(" ");
wordLength += 1;
}
lineBuilder.Append(word);
lineLength += wordLength;
}
else
{
splitLines.Insert(index, lineBuilder.ToString());
lineBuilder.Clear();
index += 1;
if (wordLength < maxArgumentsLength)
{
lineBuilder.Append(word);
lineLength = wordLength;
}
else
{
StringInfo wordRest = new StringInfo(word);
do
{
int wordIndex = Math.Min(wordRest.LengthInTextElements, maxArgumentsLength);
string front = wordRest.SubstringByTextElements(0, wordIndex);
while (Encoding.UTF8.GetByteCount(front) > maxArgumentsLength)
{
wordIndex -= 10;
front = wordRest.SubstringByTextElements(0, wordIndex);
}
lineBuilder.Append(front);
if (wordRest.LengthInTextElements > wordIndex)
{
splitLines.Insert(index, lineBuilder.ToString());
lineBuilder.Clear();
index += 1;
wordRest.String = wordRest.SubstringByTextElements(wordIndex);
}
else
{
lineLength = Encoding.UTF8.GetByteCount(front);
wordRest.String = String.Empty;
}
}
while (wordRest.LengthInTextElements > 0);
}
}
}
splitLines.Insert(index, lineBuilder.ToString());
}
}
for (int i = 0; i < splitLines.Count; i++)
{
messageBuilder.Append(messageBase);
messageBuilder.Append(splitLines[i]);
if (i < splitLines.Count - 1)
{
messageBuilder.Append("\r\n");
}
}
}
}
}
return messageBuilder.ToString();
}
}
struct IrcNumerics { internal static string Welcome = "001", Host = "002", Created = "003", Info = "004", Topic = "332", Names = "353", EndNames = "366"; };
}