public UserConfiguration(IAppSettings appSettings, ISlackConfiguration slackConfiguration, ITeamConfiguration teamConfiguration, IZoomConfiguration zoomConfiguration) { m_appSettings = appSettings; SlackConfiguration = slackConfiguration; TeamConfiguration = teamConfiguration; ZoomConfiguration = zoomConfiguration; }
public SlackChannelApi(ISlackConfiguration configuration) { _httpClient = new HttpClient { BaseAddress = new Uri("https://slack.com/") }; _configuration = configuration; }
/// <summary> /// Initializes a new instance of the <see cref="Slack"/> class. /// </summary> /// <param name="slackConfiguration">The Slack configuration.</param> /// <param name="poster">The Slack message poster.</param> public Slack(ISlackConfiguration slackConfiguration, ISlackMessagePoster poster) { this.poster = poster; // Set default values... messageLevel = SlackMessageLevel.Info; pendingSlackMessage = new SlackMessage(slackConfiguration.DefaultChannel); }
public SlackBot(ISlackBotCommand[] commands, ISlackConfiguration configuration, IShutdown shutdown) { if (!configuration.Enabled) { return; } CancellationToken token = shutdown.Token; Worker = Task.Run(() => { SlackConnector.SlackConnector connector = new SlackConnector.SlackConnector(); ISlackConnection client = connector.Connect(configuration.BotUserToken).Result; client.OnMessageReceived += message => { var context = new SlackBotCommandContext(client.Say, message); var tasks = new List <Task>(); Parallel.ForEach(commands, command => { Task task; if (command.TryHandle(context, token, out task)) { tasks.Add(task); } }); // TODO: Implement various messages - randomly selected // - also implement a "/help" command type if (tasks.Count == 0) { return(context.WriteText("Hey, you're cool, but I don't understand what you're trying to do.")); } return(Task.WhenAll(tasks)); }; token.WaitHandle.WaitOne(); client.Disconnect(); }, token); }
public SlackMessageQueue(ISlackMessageHandlerFactory factory, IShutdown shutdown, ILogger logger, ISlackConfiguration configuration) { _factory = factory; _logger = logger; if (!configuration.Enabled) { return; } _token = shutdown.Token; _queue = new BlockingCollection <Func <Task> >(); Consumer = Task.Run(() => { while (!_token.IsCancellationRequested) { Func <Task> messageInvoker = null; try { messageInvoker = _queue.Take(_token); } catch (OperationCanceledException) { } Task task = messageInvoker?.Invoke(); if (task != null) { try { task.Wait(_token); } catch (OperationCanceledException) { // ignore if operation is cancelled. } catch (AggregateException ex) { foreach (Exception exception in ex.Flatten().InnerExceptions) { _logger.LogError(exception); } } catch (Exception ex) { _logger.LogError(ex); } } } }, _token); }
public SlackChangeNotifier(ISlackConfiguration configuration) { _configuration = configuration; }
/// <summary> /// Initializes a new instance of the <see cref="SlackMessagePoster"/> class. /// </summary> /// <param name="configuration">The configuration.</param> public SlackMessagePoster(ISlackConfiguration configuration) { this.configuration = configuration; }
public SlackChangeNotifier(ISlackConfiguration configuration) { _configuration = configuration; }