/// <summary> /// Initializes the connection to the Twitch chat. /// TwitchConnectData parameter is the init configuration to be able to connect. /// Invokes onSuccess when the connection is done, otherwise onError will be invoked. /// </summary> public void Init(TwitchConnectConfig twitchConnectConfig, OnSuccess onSuccess, OnError onError) { _twitchConnectConfig = twitchConnectConfig; if (IsConnected()) { onSuccess(); return; } // Checks if (_twitchConnectConfig == null || !_twitchConnectConfig.IsValid()) { string errorMessage = "TwitchChatClient.Init :: Twitch connect data is invalid, all fields are mandatory."; onError(errorMessage); return; } if (String.IsNullOrEmpty(commandPrefix)) { commandPrefix = "!"; } if (commandPrefix.Length > 1) { string errorMessage = $"TwitchChatClient.Init :: Command prefix length should contain only 1 character. Command prefix: {commandPrefix}"; onError(errorMessage); return; } Login(); onSuccess(); }
public bool IsValidLogin(TwitchConnectConfig config) { if (Type != TwitchInputType.LOGIN) { throw new Exception("IsValidLogin can only be used in LOGIN type commands"); } return(Message.StartsWith($"{TwitchChatRegex.LOGIN_SUCCESS_MESSAGE} {config.Username}")); }