tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
ChatChannelExtensions.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Linq;
4
6
8{
13 {
19 public static string GetIrcChannelName(this ChatChannel chatChannel) => GetIrcChannelSplits(chatChannel).First();
20
26 public static string? GetIrcChannelKey(this ChatChannel chatChannel)
27 {
28 var splits = GetIrcChannelSplits(chatChannel);
29 if (splits.Count < 2)
30 return null;
31 return splits.Last();
32 }
33
39 static IReadOnlyCollection<string> GetIrcChannelSplits(ChatChannel chatChannel)
40 {
41 ArgumentNullException.ThrowIfNull(chatChannel);
42
43 if (chatChannel.IrcChannel == null)
44 throw new ArgumentException("IrcChannel must be set!", nameof(chatChannel));
45
46 return chatChannel.IrcChannel.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
47 }
48 }
49}
static string GetIrcChannelName(this ChatChannel chatChannel)
Gets the IRC channel name from a given chatChannel .
static ? string GetIrcChannelKey(this ChatChannel chatChannel)
Gets the IRC channel key from a given chatChannel .
static IReadOnlyCollection< string > GetIrcChannelSplits(ChatChannel chatChannel)
Split a given chatChannel 's ChatChannel.IrcChannel.
string? IrcChannel
The IRC channel name.