Esempio n. 1
0
        public Task <SlackMessage> SendActionMessage(string channel, string message, SlackInteractiveMessage messageData)
        {
            var ts      = new TaskCompletionSource <SlackMessage>();
            var actions = new List <AttachmentAction>();

            foreach (var button in messageData.Buttons)
            {
                actions.Add(new AttachmentAction(button.Name, button.Text));
            }

            Slack.PostMessage(
                _ => { ProcessCompletion(ts, channel, _); },
                channel,
                message,
                as_user: true,
                attachments: new Attachment[]
            {
                new Attachment()
                {
                    title       = messageData.Text,
                    text        = messageData.Description,
                    callback_id = messageData.CallbackId,

                    actions = actions.ToArray()
                }
            });

            return(ts.Task);
        }
Esempio n. 2
0
 protected void SendActionMessage(SlackChannel channel, string message, SlackInteractiveMessage messageData)
 {
     SendActionMessageAsync(channel, message, messageData);
 }
Esempio n. 3
0
 protected Task <SlackMessage> SendActionMessageAsync(SlackChannel channel, string message, SlackInteractiveMessage messageData)
 {
     return(Slack.SendActionMessage(channel.Name, message, messageData));
 }
Esempio n. 4
0
 protected Task <string> SendActionMessageAndWait(SlackChannel channel, string message, SlackInteractiveMessage messageData)
 {
     return(Slack.SendActionMessageAndWait(channel.Name, message, messageData));
 }
Esempio n. 5
0
        public Task <string> SendActionMessageAndWait(string channel, string message, SlackInteractiveMessage messageData)
        {
            var requestId = (new Guid()).ToString();
            var tcs       = new TaskCompletionSource <string>();

            SQSSubscriber.WaitFor(requestId, (selected) =>
            {
                tcs.SetResult(selected);
            });
            messageData.CallbackId = requestId;
            SendActionMessage(channel, message, messageData);

            return(tcs.Task);
        }