private async Task Init()
        {
            // Reference: https://dev.twitch.tv/docs/irc/tags/
            // Reference: https://dev.twitch.tv/docs/irc/commands/
            // Reference: https://dev.twitch.tv/docs/irc/membership/
            await _client.SendIrcMessageAsync("CAP REQ :twitch.tv/tags");

            await _client.SendIrcMessageAsync("CAP REQ :twitch.tv/commands");

            await _client.SendIrcMessageAsync("CAP REQ :twitch.tv/membership");

            foreach (var channel in _config.Channels)
            {
                await _client.JoinChannelAsync(channel);
            }
        }
Example #2
0
        private async Task HandleReceivedMessageAsync(string message)
        {
            _logger.LogInformation($"Received message: {message}");

            if (message.Contains("PRIVMSG"))
            {
                var parsedMessage = ParseMessage(message);
                var response      = await _azureFunctionClient.ProcessCommandAsync(parsedMessage);

                await _ircClient.SendChatMessageAsync(response);
            }
            else if (message.StartsWith("PING"))
            {
                await _ircClient.SendIrcMessageAsync("PONG :tmi.twitch.tv");

                _logger.LogInformation("Sent PONG");
            }
        }
Example #3
0
 private void Run(object ct)
 {
     try
     {
         CancellationToken t = (CancellationToken)ct;
         while (!t.IsCancellationRequested)
         {
             logger.LogInformation("Sending PING");
             client.SendIrcMessageAsync("PING :tmi.twitch.tv");
             logger.LogInformation("Sent PING");
             Task.Delay(TimeSpan.FromMinutes(5), t).Wait();
         }
     }
     catch (TaskCanceledException ex)
     {
         logger.LogWarning(ex, "Ending thread because task was cancelled.");
     }
 }