private async Task <bool> NotifyTemperatureIfNeeded(INotifyTemperatureProvider[] notifyTemperatureProviders) { double?temperature = await _thermometerService.GetTempratureAsync(); if (!temperature.HasValue) { _logger.LogError($"thermometerService failed"); return(false); } double?previouslyKnownTemperature = ThermalNotifierServiceTemperatureHistory.LastKnownTemperature; ThermalNotifierServiceTemperatureHistory.LastKnownTemperature = temperature; INotifyTemperatureProvider notifyTemperatureProvider = FindNotificationProvider(notifyTemperatureProviders, temperature.Value, previouslyKnownTemperature); if (notifyTemperatureProvider == null) { _logger.LogDebug($"requestTemperature succeeded, but temperature is OK: {temperature}℃"); return(true); } var notificationRequestUrlBuilder = new UriBuilder(SlackEndpoint); string encodedMessage = UrlEncoder.Default.Encode(notifyTemperatureProvider.GenerateMessage(temperature.Value)); notificationRequestUrlBuilder.Query = $"payload={encodedMessage}"; bool success = await _slackNotifierService.NotifyAsync(SlackEndpoint, encodedMessage); return(true); }
public async Task Get(string message) { await _slackNotifierService.NotifyAsync(SlackEndpoint, message); }