public void Init() { if (hasInitialized) { return; } hasInitialized = true; // Checks if (configurationPath == "") { configurationPath = Application.persistentDataPath + "/config.json"; } if (commandPrefix == "" || commandPrefix == null) { commandPrefix = "!"; } if (commandPrefix.Length > 1) { Debug.LogError($"TwitchChatClient.Init :: Command prefix length should contain only 1 character. Command prefix: {commandPrefix}"); return; } data = TwitchConfiguration.Load(configurationPath); if (data == null) { return; } Login(); }
void ShowCommand(TwitchChatCommand chatCommand) { TwitchConnectData a = ScriptableObject.CreateInstance <TwitchConnectData>(); string parameters = string.Join(" - ", chatCommand.Parameters); string message = $"Command: '{chatCommand.Command}' - Username: {chatCommand.User.DisplayName} - Bits: {chatCommand.Bits} - Sub: {chatCommand.User.IsSub} - Parameters: {parameters}"; TwitchChatClient.instance.SendChatMessage($"Hello {chatCommand.User.DisplayName}! I received your message."); TwitchChatClient.instance.SendChatMessage( $"Hello {chatCommand.User.DisplayName}! This message will be sent in 5 seconds.", 5); AddText(message); }
public static TwitchConnectData Load(string path) { if (File.Exists(path)) { string fileText = File.ReadAllText(path); TwitchConnectData twitchConnectData = JsonConvert.DeserializeObject <TwitchConnectData>(fileText); if (!twitchConnectData.IsValid()) { Debug.Log(twitchConnectData.username); Debug.LogError($"TwitchConfiguration.Load :: Some mandatory fields are empty: {path}"); return(null); } return(twitchConnectData); } Debug.LogError($"TwitchConfiguration.Load :: Error loading the data, path does not exist: {path}"); return(null); }
private void ShowCommand(TwitchChatCommand chatCommand) { TwitchConnectData a = ScriptableObject.CreateInstance <TwitchConnectData>(); string parameters = string.Join(" - ", chatCommand.Parameters); string message = $"Command: '{chatCommand.Command}' - " + $"Username: {chatCommand.User.DisplayName} - " + $"Bits: {chatCommand.Bits} - " + $"Sub: {chatCommand.User.IsSub} - " + $"Badges count: {chatCommand.User.Badges.Count} - " + $"Badges: {string.Join("/", chatCommand.User.Badges.Select(badge => badge.Name))} - " + $"Badge versions: {string.Join("/", chatCommand.User.Badges.Select(badge => badge.Version))} - " + $"Parameters: {parameters}"; TwitchChatClient.instance.SendChatMessage($"Hello {chatCommand.User.DisplayName}! I received your message."); TwitchChatClient.instance.SendChatMessage( $"Hello {chatCommand.User.DisplayName}! This message will be sent in 5 seconds.", 5); AddText(message); }