static string GetFilePath(TwitchAlertsType type) { if (type.IsDeepBot()) { return(deepBotPath + type + extension); } else { return(twitchAlertsPath + type.ToString().Replace("thirty_", "30") + extension); } }
public static bool IsDeepBot(this TwitchAlertsType type) { switch (type) { case TwitchAlertsType.YoutubeCurrentSong: case TwitchAlertsType.YoutubeCurrentSongRequestedBy: return(true); default: return(false); } }
public static AlertData Parse(TwitchAlertsType type, string data) { switch (type) { case TwitchAlertsType.most_recent_donator: string[] entries = data.Split(new[] { TextFromFile.DELIMETER }, StringSplitOptions.None); string[] left = entries[0].Split('('); string amountStr = new string(left[1].Where(c => char.IsDigit(c) || c == '.').ToArray()); float amount; if (!float.TryParse(amountStr, out amount)) { amount = 0; Debug.LogError("Could not parse amount: " + amountStr); } return(new DonationAlertData() { type = TwitchAlertsType.most_recent_donator, username = left[0].Trim(), amount = amount, message = entries[1] }); case TwitchAlertsType.most_recent_follower: return(new AlertData() { type = TwitchAlertsType.most_recent_follower, username = data.Trim() }); default: Debug.LogError("Cannot parse AlertData: " + type + " | " + data); return(null); } }
public static void WriteOnce(TwitchAlertsType type, string value) { WriteFile(GetFilePath(type), value); }
public static string ReadOnce(TwitchAlertsType type) { return(ReadFile(GetFilePath(type))); }