예제 #1
0
        public static Cue CreateCueOld(Dictionary <string, object> reply)
        {
            Cue cue = new Cue();

            string callbackId = (string)reply["callback_id"];
            string signalId   = callbackId.Split('|')[0];
            string cueId      = HttpUtility.HtmlDecode(callbackId.Split('|')[1]);

            cue.Id    = signalId;
            cue.CueId = cueId;

            foreach (string key in reply.Keys)
            {
                if (key != "callback_id")
                {
                    MultiValueVariable variable = new MultiValueVariable();
                    variable.Name = key;
                    // TOOD: Might have to split value by commans for multi-value field types.
                    variable.Values.Add((string)reply[key]);

                    cue.Variables.Add(variable);
                }
            }

            return(cue);
        }
예제 #2
0
        public static Cue CreateCue(SlackReply reply)
        {
            if (reply.BodyJson != null)
            {
                // Reply Came Directly From Slack.  Decode the payload
                string body = reply.BodyJson;
                if (body.StartsWith("payload=", StringComparison.OrdinalIgnoreCase))
                {
                    body          = body.Replace("payload=", "", StringComparison.OrdinalIgnoreCase);
                    body          = body.Replace('+', ' ');
                    body          = HttpUtility.UrlDecode(body);
                    reply.Payload = JsonTools.Deserialize <SlackPayload>(body);
                }
            }

            SlackPayload payload = reply?.Payload;

            if (payload == null)
            {
                throw new Exception("Slack Reply Payload Not Found.");
            }

            string callbackId = payload.CallbackId;
            string signalId   = callbackId.Split('|')[0];
            string cueId      = HttpUtility.HtmlDecode(callbackId.Split('|')[1]);

            Cue cue = new Cue
            {
                Id      = signalId,
                CueId   = cueId,
                Payload = payload
            };

            foreach (SlackReplyAction actionReply in payload.Actions)
            {
                MultiValueVariable actionVariable = new MultiValueVariable();
                actionVariable.Name = actionReply.Name;

                if (actionReply.Type == "select")
                {
                    foreach (Dictionary <string, string> option in actionReply.SelectedOptions)
                    {
                        actionVariable.Values.Add(option["value"]);
                    }
                }
                else if (actionReply.Type == "button")
                {
                    actionVariable.Values.Add(actionReply.Value);
                }

                cue.Variables.Add(actionVariable);
            }

            return(cue);
        }
예제 #3
0
        public static Cue CreateCue(Dictionary <string, object> reply)
        {
            Cue cue = new Cue();

            string signalId = (string)reply["signalId"];
            string cueId    = (string)reply["cueId"];

            cue.Id    = signalId;
            cue.CueId = cueId;

            foreach (string key in reply.Keys)
            {
                if (key != "signalId" && key != "cueId")
                {
                    MultiValueVariable variable = new MultiValueVariable();
                    variable.Name = key;
                    // TODO: Might have to split value by semicolons for multi-value field types.
                    variable.Values.Add((string)reply[key]);
                    cue.Variables.Add(variable);
                }
            }

            return(cue);
        }