private void CreateFollowerService(TwitchConfiguration twitchConfiguration, TwitchAPI api) { followerService = new FollowerService(api, 10); followerService.SetChannelsByName(new List <string> { twitchConfiguration.Username }); // TODO ändern! }
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(); }
public async Task <string> GetCurrentGame() { TwitchConfiguration twitchConfiguration = configurationManager.LoadConfiguration <TwitchConfiguration>(); var channel = await api.V5.Channels.GetChannelByIDAsync(twitchConfiguration.BroadcasterUserId); return(channel.Game); }
private TwitchAPI InitializeTwitchApi(TwitchConfiguration twitchConfiguration) { return(new TwitchAPI(null, null, new ApiSettings { ClientId = twitchConfiguration.ApiClientId, AccessToken = twitchConfiguration.ApiAccessToken })); }
/// <summary> /// Called when the sub module is loaded by the game. /// </summary> protected override void OnSubModuleLoad() { TwitchConfiguration = new TwitchConfiguration(); TwitchSurvey = new TwitchSurveyProvider(TwitchConfiguration); Module.CurrentModule.AddInitialStateOption( new InitialStateOption("twitch_integration", new TextObject("Twitch integration"), 9990, TwitchConfiguration.Configure, isDisabled: false) ); }
public void ConnectToTwitch(TwitchConfiguration twitchConfiguration) { SetUpEvents(); api = InitializeTwitchApi(twitchConfiguration); CreateFollowerService(twitchConfiguration, api); RegisterFollowerServiceCallback(); followerService.Start(); }
public TwitchChatBot( IOptions <TwitchConfiguration> twitchConfiguration, IEnumerable <IChatMessageRule> listChatMessageRules ) { _twitchConfiguration = twitchConfiguration.Value; _listChatMessageRules = listChatMessageRules; _connectionCredentials = new ConnectionCredentials(_twitchConfiguration.BotUsername, _twitchConfiguration.BotToken); }
public TwitchChatBotService( IOptions <TwitchConfiguration> twitchConfiguration, IEnumerable <IChatMessageRule> listChatMessageRules, ILogger <TwitchChatBotService> logger ) { _twitchConfiguration = twitchConfiguration.Value; _listChatMessageRules = listChatMessageRules.ToArray(); _logger = logger; _twitchLibConnectionCredentials = new ConnectionCredentials(_twitchConfiguration.BotUsername, _twitchConfiguration.BotToken); }
public async Task <bool> Execute(CancellationToken cancellationToken) { try { twitchConfiguration = configurationManager.LoadConfiguration <TwitchConfiguration>(); logger.Information("Twitch Konfiguration wurde geladen."); if (!twitchConfiguration.IsValid()) { logger.Information("Die Twitch Konfiguration ist nicht valide"); return(false); } clientWrapper.ConnectToTwitch(twitchConfiguration); apiWrapper.ConnectToTwitch(twitchConfiguration); } catch (Exception e) { logger.Error("Der Bot wurde aufgrund eines Fehlers beendet. Fehler: {e}", e); } bus.SubscribeToTopic <SendChannelMessageRequestedEvent>(identifier); bus.SubscribeToTopic <SendWhisperMessageRequestedEvent>(identifier); bus.SubscribeToTopic <UpdateChannelEvent>(identifier); while (!cancellationToken.IsCancellationRequested) { try { if (bus.TryConsume(identifier, out SendChannelMessageRequestedEvent message)) { SendChannelMessage(message); } if (bus.TryConsume(identifier, out SendWhisperMessageRequestedEvent whisper)) { SendWhisperMessage(whisper); } if (bus.TryConsume(identifier, out UpdateChannelEvent channelUpdate)) { apiWrapper.UpdateChannel(channelUpdate); } await Task.Delay(100, cancellationToken); } catch (Exception e) { logger.Error("Bei der Verarbeitung von Twitch Events ist ein Fehler aufgetreten: {e}", e); } } return(true); }
public void UpdateChannel(UpdateChannelEvent updateChannelEvent) { TwitchConfiguration twitchConfiguration = configurationManager.LoadConfiguration <TwitchConfiguration>(); api.V5.Channels.GetChannelByIDAsync(twitchConfiguration.BroadcasterUserId) .ContinueWith(task => { updateChannelEvent.Update(task.Result); return(api.V5.Channels.UpdateChannelAsync(twitchConfiguration.BroadcasterUserId, updateChannelEvent.Title, updateChannelEvent.Game)); }) .ContinueWith(task => task.Result.ContinueWith(x => PublishSuccessMessageOnCompletion(x))); }
public void ConnectToTwitch(TwitchConfiguration twitchConfiguration) { SetUpEvents(); ConnectionCredentials credentials = new ConnectionCredentials(twitchConfiguration.Username, twitchConfiguration.AccessToken); ClientOptions clientOptions = CreateClientOptions(); WebSocketClient customClient = new WebSocketClient(clientOptions); InitializeTwitchClient(twitchConfiguration, credentials, customClient); RegisterClientCallbacks(); client.Connect(); }
public TwitchChatService(IOptionsMonitor<TwitchConfiguration> options, IServiceProvider services, ChatBot bot) { _services = services; _bot = bot; _twitchConfig = options.CurrentValue; options.OnChange(config => { _twitchConfig = config; }); _client = new TwitchClient(); _client.Connect(); _client.OnChatCommandReceived += _client_OnChatCommandReceived; }
public TwitchChatBotService( IOptions <TwitchConfiguration> twitchConfiguration, IOptions <LuisConfiguration> luisConfiguration, IChatMessageService chatMessageService, ITwitchUserChatRepository twitchUserChatRepository, ITwitchNewSubscriberRepository twitchNewSubscriberRepository, ITwitchUserAttendanceEventRepository twitchUserAttendanceEventRepository, ILuisService luisService ) { _twitchConfiguration = twitchConfiguration.Value ?? throw new ArgumentNullException(nameof(twitchConfiguration)); _luisConfiguration = luisConfiguration.Value ?? throw new ArgumentNullException(nameof(luisConfiguration)); _chatMessageService = chatMessageService ?? throw new ArgumentNullException(nameof(chatMessageService)); _twitchUserChatRepository = twitchUserChatRepository ?? throw new ArgumentNullException(nameof(twitchUserChatRepository)); _twitchNewSubscriberRepository = twitchNewSubscriberRepository ?? throw new ArgumentNullException(nameof(twitchNewSubscriberRepository)); _twitchUserAttendanceEventRepository = twitchUserAttendanceEventRepository ?? throw new ArgumentNullException(nameof(twitchUserAttendanceEventRepository)); _twitchClientConnectionCredentials = new ConnectionCredentials(_twitchConfiguration.BotUserName, _twitchConfiguration.BotToken); _luisService = luisService ?? throw new ArgumentNullException(nameof(luisService)); _twitchClient = new TwitchClient(); }
private void InitializeTwitchClient(TwitchConfiguration twitchConfiguration, ConnectionCredentials credentials, WebSocketClient customClient) { client = new TwitchClient(customClient); client.Initialize(credentials, twitchConfiguration.Channel); }
public TwitchClient(ILogger <TwitchClient> logger, IOptions <TwitchConfiguration> options) { _log = logger; _config = options.Value; _sendQueue = new ConcurrentQueue <string>(); }
private void PublishFeedbackMessage(string message) { TwitchConfiguration twitchConfiguration = configurationManager.LoadConfiguration <TwitchConfiguration>(); bus.Publish(new SendChannelMessageRequestedEvent(message, twitchConfiguration.Channel)); }