public async void Channel(SlashCommand command, string text) { if(command.channel_name == "privategroup" || command.channel_name == "directmessage") { this.DirectMessage(command, text); } else { Dictionary<string, string> settings = settingsBLL.Get(); List<string> toAddress = new List<string>(); using (var client = factory.HttpClient()) { client.BaseAddress = new Uri(settings["Notification.SlackWebhook"]); Entities.Slack.OutboundPayload payload = new Entities.Slack.OutboundPayload { channel = command.channel_name, text = $"<@{command.user_name}>: " + text, username = userName }; await client.PostAsJsonAsync<Entities.Slack.OutboundPayload>("", payload).ConfigureAwait(false); } } }
public async void DirectMessage(SlashCommand command, string text) { Dictionary<string, string> settings = settingsBLL.Get(); List<string> toAddress = new List<string>(); using (var client = factory.HttpClient()) { client.BaseAddress = new Uri(settings["Notification.SlackWebhook"]); Entities.Slack.OutboundPayload payload = new Entities.Slack.OutboundPayload { channel = $"@{command.user_name}", text = text, username = userName }; await client.PostAsJsonAsync<Entities.Slack.OutboundPayload>("", payload).ConfigureAwait(false); } }
public async void Execute(Entities.Enums.NotificationType notificationType, Entities.AutoMerge autoMerge, string text) { Dictionary<string, string> settings = settingsBLL.Get(); List<string> toAddress = new List<string>(); using(var client = factory.HttpClient()) { client.BaseAddress = new Uri(settings["Notification.SlackWebhook"]); foreach (Entities.AutoMergeSubscription sub in autoMerge.Subscriptions.Where(sub => sub.Notifications.HasFlag(notificationType) && sub.Delivery == Entities.Enums.DeliveryMethod.Slack)) { Entities.Slack.OutboundPayload payload = new Entities.Slack.OutboundPayload { channel = sub.Value, icon_emoji = notificationType == Entities.Enums.NotificationType.Successes ? ":white_check_mark:" : ":x:", text = text, username = userName }; await client.PostAsJsonAsync<Entities.Slack.OutboundPayload>("", payload).ConfigureAwait(false); } } }