Exemplo n.º 1
0
        public static SlackAction CreateSlackAction(SignalVariable action)
        {
            SlackAction slackAction = new SlackAction();

            slackAction.Name  = action.Id;
            slackAction.Value = action.DefaultValue;

            switch (action.Type)
            {
            case VariableType.choice:
                slackAction.Type    = SlackActionType.select;
                slackAction.Options = new List <SlackSelectOption>();
                foreach (string key in action.Values.Keys)
                {
                    SlackSelectOption option = new SlackSelectOption();
                    option.Text  = action.Values[key];
                    option.Value = key;
                    slackAction.Options.Add(option);
                }
                break;

            case VariableType.button:
                slackAction.Type = SlackActionType.button;
                slackAction.Text = action.Text;
                break;
            }

            return(slackAction);
        }
Exemplo n.º 2
0
        public static SlackAttachment CreateSlackAttachment(string signalId, string cueId, CueOption cue)
        {
            SlackAttachment attachment = new SlackAttachment();

            string cueTitle = $"{cue.Name}\n{cue.Description}";

            if (String.IsNullOrEmpty(cue.Name))
            {
                cueTitle = cue.Description;
            }
            else if (String.IsNullOrEmpty(cue.Description))
            {
                cueTitle = cue.Name;
            }
            attachment.Text       = cueTitle;
            attachment.CallbackId = $"{signalId}|{cueId}";

            foreach (SignalVariable action in cue.Actions)
            {
                SlackAction slackAction = CreateSlackAction(action);
                attachment.Actions.Add(slackAction);
            }


            return(attachment);
        }