namespace Nonemm.Spotting.Telnet; /// Reads what a cluster node is asking for at login. Every node asks in its own /// words; these are the ones DXSpider, AR-Cluster, CC Cluster and DXNet use. public static class ClusterPrompts { private static readonly string[] Callsign = [ "login", "log in", "logon", "enter call", "enter your call", "your call", "callsign", "call:", "user:", ]; private static readonly string[] Password = ["password"]; public static bool AsksForCallsign(string text) => Holds(text, Callsign); public static bool AsksForPassword(string text) => Holds(text, Password); /// Which cluster program said this, or `Unknown` when the text names none /// of them. The words are the ones N1MM looks for in the banner. public static ClusterKind KindOf(string text) { if (Holds(text, ["gocluster"])) { return ClusterKind.GoCluster; } if (Holds(text, ["ar-cluster"])) { return ClusterKind.ArCluster; } if (Holds(text, ["cc cluster", "cc-cluster"])) { return ClusterKind.CcCluster; } return Holds(text, ["dxspider", "dx spider"]) ? ClusterKind.DxSpider : ClusterKind.Unknown; } private static bool Holds(string text, IReadOnlyList phrases) { foreach (string phrase in phrases) { if (text.Contains(phrase, StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } }