Example #1
0
        public async Task Handle_CorrectParams_ShouldOpenAppropriateDialog()
        {
            // Arrange
            var actionParams = new AddAnswerSlackActionParams
            {
                User = new ItemInfo {
                    Id = "userId", Name = "userName"
                },
                ButtonParams = new AddAnswerActionButtonParams {
                    QuestionId = "questionId"
                },
                TriggerId       = "triggerId",
                OriginalMessage = new OriginalMessageDto
                {
                    TimeStamp = "state"
                }
            };

            DialogRequest actualRequest = null;

            _slackHttpClientMock.Setup(m => m.OpenDialogAsync(It.IsAny <DialogRequest>()))
            .Returns(Task.CompletedTask)
            .Callback((DialogRequest request) => actualRequest = request);

            // Act
            await _handler.Handle(actionParams);

            // Assert
            Assert.Equal(actualRequest.TriggerId, actionParams.TriggerId);
            _slackHttpClientMock.Verify(m => m.OpenDialogAsync(It.IsAny <DialogRequest>()), Times.Once);
            _slackHttpClientMock.VerifyNoOtherCalls();
        }
        public void OnHandleButtonClicked()
        {
            ToggleActive(true, false);
            ActivityData payload = ActivityData.Empty;

            try
            {
                if (!string.IsNullOrWhiteSpace(m_ParentHandle.target.payloadViewController.payload))
                {
                    payload = JsonUtility.FromJson <ActivityData>(m_ParentHandle.target.payloadViewController.payload);
                }
            }
            catch (ArgumentException)
            {
                // Invalid json
                Debug.LogWarning("Found invalid json.");
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }

            DialogComponent dialog = m_DialogFactory.Create(payload, OnActivityPayloadChanged);

            m_DialogService.SendRequest(DialogRequest.Create(dialog));
        }
Example #3
0
    public override bool Eval(DialogRequest request)
    {
        LogEvalElemStart("refCondition = " + refCondition);
        Debug.Log("ConditionRefCondition.Eval.refCondition = " + refCondition);

        if (refCondition == null)
        {
            LogEvalElemRet(true);
            return(true);
        }

        Condition condition = actorBrain.GetDialogs().GetCondition(refCondition);

        Debug.Log("ConditionRefCondition.Eval.condition = " + condition);

        if (condition != null)
        {
            Debug.Log("ConditionRefCondition.Eval.conditionRef = " + condition.GetRef());
            bool ret = condition.Eval(request);
            LogEvalElemRet(ret);
            return(ret);
        }
        LogEvalElemRet(false);
        return(false);
    }
        public DefaultDialog(DialogRequest dialogRequest, string viewID)
        {
            InitializeComponent();

            m_Request = dialogRequest;
            m_ViewID  = viewID;
        }
Example #5
0
    /*
     * public DialogResponse DialogRequest2(ActorMemoryDialogs actorMemory, string text)
     * {
     *  DialogResponse dialogResponse = null;
     *  DialogRequest dialogRequest = new DialogRequest(text);
     *
     *  Debug.Log("DialogInit.0. text = '" + text + "' / isInit = "+ actorMemory.IsInit());
     *
     *  if (actorMemory.IsInit())
     *  {
     *      dialogResponse = DialogRequest(dictPriorityListInitDialogs, actorMemory, text);
     *      actorMemory.SetIsInit(false);
     *      return dialogResponse;
     *  }
     *
     *  dialogResponse = new DialogResponse();
     *
     *  foreach (int priority in dictListPriorityDialogs.Keys)
     *  {
     *      Debug.Log("DialogInit.4. priority = " + priority);
     *
     *      List<Dialog> listDialogs = GetDialogsPriority(priority, false);
     *      foreach (Dialog dialog in listDialogs)
     *      {
     *          dialog.Eval(dialogRequest, dialogResponse);
     *          if (dialogResponse.IsValid()) return dialogResponse;
     *      }
     *  }
     *  return null;
     * }
     */

    public DialogResponse DialogRequest(DictPriorityListItems <Dialog> dictPriorityListItems, ActorMemoryDialogs actorMemory, string text)
    {
        DialogResponse dialogResponse;
        DialogRequest  dialogRequest = new DialogRequest(text);

        Debug.Log("DialogInit.0. text = '" + text + "' / isInit = " + actorMemory.IsInit());

        dialogResponse = new DialogResponse();

        foreach (int priority in dictPriorityListItems.GetListPriorities())
        {
            Debug.Log("DialogInit.4. priority = " + priority);

            List <Dialog> listDialogs = dictPriorityListItems.GetPriorityList(priority);
            foreach (Dialog dialog in listDialogs)
            {
                dialog.Eval(dialogRequest, dialogResponse);
                if (dialogResponse.IsValid())
                {
                    return(dialogResponse);
                }
            }
        }
        return(null);
    }
        /// <summary>
        ///     Opens a file selector dialog.
        /// </summary>
        /// <param name="fileSelected">Callback when file is selected.</param>
        /// <param name="filePaths">File directories to be searched</param>
        /// <param name="filters">Optional filters to be passed, e.g. extensions (*.ext)</param>
        /// <param name="dialogPriority">Dialog Priority. Higher values get displayed first.</param>
        /// <returns></returns>
        public FileSelectorViewController Show(FileSelectedDelegate fileSelected, IEnumerable <string> filePaths, IEnumerable <string> filters, DialogPriority dialogPriority = DialogPriority.High)
        {
            FileSelectorViewController fileSelector = m_Factory.Create(fileSelected, filePaths, filters);
            DialogRequest request = DialogRequest.Create((DialogComponent)fileSelector, dialogPriority);

            m_DialogService.SendRequest(request);
            return(fileSelector);
        }
Example #7
0
        protected override bool PrepareCreateMainWindow()
        {
            DialogRequest dialogRequest = DialogManager.Build(IDCollection.LoginView, true);

            dialogRequest.Raise();

            return(dialogRequest.DialogInformation.Confirm == true);
        }
Example #8
0
        /// <inheritdoc/>
        public IDialog DisplayMilestoneAchieved(MilestoneData milestoneData)
        {
            DialogComponent dialogComponent = m_PopupFactory.Create(milestoneData);
            DialogRequest   request         = DialogRequest.Create(dialogComponent, DialogPriority.Low);

            m_DialogService.SendRequest(request);
            return(dialogComponent);
        }
        /// <summary>
        ///     Opens a new file dialog.
        /// </summary>
        /// <param name="fileSelected">Callback when file is selected.</param>
        /// <param name="targetPath">Target path at which to create the file.</param>
        /// <param name="fileType">Target filetype extension (*.ext).</param>
        /// <param name="dialogPriority">Dialog Priority. Higher values get displayed first.</param>
        /// <returns></returns>
        public NewFileDialogViewController Show(FileSelectedDelegate fileSelected, string targetPath, string fileType, DialogPriority dialogPriority = DialogPriority.High)
        {
            NewFileDialogViewController newFileDialog = m_Factory.Create(fileSelected, targetPath, fileType);
            DialogRequest request = DialogRequest.Create((DialogComponent)newFileDialog, dialogPriority);

            m_DialogService.SendRequest(request);
            return(newFileDialog);
        }
Example #10
0
    public override bool Eval(DialogRequest request)
    {
        LogEvalElemStart();
        bool ret = !invert?actorBrain.GetMemory().IsInit() : !actorBrain.GetMemory().IsInit();

        LogEvalElemRet(ret);
        return(ret);
    }
 public void AddToQueue(DialogRequest request)
 {
     if (!this.IsSuppressed())
     {
         this.m_dialogRequests.Enqueue(request);
         this.UpdateQueue();
     }
 }
Example #12
0
    /*
     * public override void SetMatchText(string text)
     * {
     *  if (conditionIn != null) conditionIn.SetMatchText(text);
     * }
     */

    public override bool Eval(DialogRequest request)
    {
        LogEvalElemStart();
        bool ret = !conditionIn.Eval(request);

        LogEvalElemRet(ret);
        return(ret);
    }
Example #13
0
        public Task Handle(AddAnswerSlackActionParams actionParams)
        {
            if (actionParams == null)
            {
                throw new ArgumentNullException(nameof(actionParams));
            }
            if (actionParams.User == null)
            {
                throw new ArgumentNullException(nameof(actionParams.User));
            }
            if (actionParams.ButtonParams == null)
            {
                throw new ArgumentNullException(nameof(actionParams.ButtonParams));
            }

            var questionId = actionParams.ButtonParams.QuestionId;
            var triggerId  = actionParams.TriggerId;

            if (string.IsNullOrEmpty(questionId))
            {
                throw new ArgumentException(nameof(questionId));
            }
            if (string.IsNullOrEmpty(triggerId))
            {
                throw new ArgumentException(nameof(triggerId));
            }

            _logger.LogInformation(
                "User {User} with id {UserId} opened a dialog box to add an answer to the question {QuestionId}",
                actionParams.User.Name, actionParams.User.Id, questionId);

            var packedParams =
                _callbackIdCustomParamsWrappingService.Wrap(CallbackId.AddAnswerDialogSubmissionId,
                                                            new[] { questionId });

            var dialog = new DialogRequest
            {
                TriggerId = actionParams.TriggerId,
                Dialog    = new DialogDto
                {
                    CallbackId = packedParams,
                    Title      = "Add new answer",
                    State      = actionParams.OriginalMessage.TimeStamp,
                    Elements   = new List <DialogElementDto>
                    {
                        new DialogElementDto
                        {
                            Label = "Your answer",
                            Name  = "experts_answer",
                            Type  = "textarea"
                        }
                    }
                }
            };

            return(_slackClient.OpenDialogAsync(dialog));
        }
Example #14
0
    /*
     * public void SetMatchText(string text)
     * {
     *  if (conditions == null) return;
     *
     *  conditions.SetMatchText(text);
     *
     *
     *  foreach (int priority in dictListChildPriorityDialogs.Keys)
     *  {
     *      List<Dialog> listDialogs = GetChildDialogsPriority(priority, false);
     *      foreach (Dialog dialog in listDialogs)
     *      {
     *          // Debug.Log("DIALOGTREE.Eval(). refDialog = " + dialog.refDialog);
     *          dialog.SetMatchText(text);
     *      }
     *  }
     *
     * }
     */

    /*
     * public bool Eval()
     * {
     *  if (conditions == null) return true;
     *
     *  return conditions.Eval();
     * }
     */

    public void Eval(DialogRequest request, DialogResponse response)
    {
        bool okConditions = true;

        // Si no se cumplen las condiciones, se devuelve false.
        if (conditions != null)
        {
            okConditions = conditions.Eval(request);
        }
        if (!okConditions)
        {
            return;
        }

        // Si se cumplen las condiciones
        ApplySets(); // Se setean las variables

        // Se establece la respuesta
        response.SetDialog(this);

        /*
         * if (listChildDialogs != null && listChildDialogs.Count > 0)
         * {
         *  // Se evaluan los dialogos hijos
         *  foreach (Dialog childDialog in listChildDialogs)
         *  {
         *      childDialog.Eval(dialogResponse);
         *      if (dialogResponse.IsValid()) return;
         *  }
         * }
         */

        Debug.Log("DIALOGTREE.Eval(). refDialog = " + refDialog);
        foreach (int priority in dictListChildPriorityDialogs.Keys)
        {
            List <Dialog> listDialogs = GetChildDialogsPriority(priority, false);
            foreach (Dialog dialog in listDialogs)
            {
                Debug.Log("DIALOGTREE.Eval(). refDialog = " + dialog.refDialog);

                dialog.Eval(request, response);
                if (response.IsValid())
                {
                    return;
                }
            }
        }

        Debug.Log("DIALOGTREE.Eval(). respinse.refDialog = " + refDialog);

        // Solo se establece el texto y las acciones si los hijos no han devuelto una respuesta válida. De lo contrario el texto y las acciones serán las de los hijas.
        response.SetText(GetResolvedTemplate());
        response.SetActions(GetListActions());
    }
Example #15
0
    public override bool Eval(DialogRequest request)
    {
        LogEvalElemStart();

        string varvalue = actorBrain.GetFuncValue(funcname);
        bool   val      = Dialog.IsTrue(varvalue);
        bool   ret      = (!invert ? val : !val);

        LogEvalElemRet(ret);
        return(ret);
    }
Example #16
0
    public override bool Eval(DialogRequest request)
    {
        LogEvalElemStart();

        int    num;
        string ret       = Dialog.GetMatchExpValue(actorBrain, value, value);
        bool   isInteger = int.TryParse(ret, out num);

        LogEvalElemRet(isInteger);
        return(isInteger);
    }
Example #17
0
 public override bool Eval(DialogRequest request)
 {
     LogEvalElemStart();
     foreach (Condition condition in listConditions)
     {
         if (condition.Eval(request))
         {
             LogEvalElemRet(true);
             return(true);
         }
     }
     LogEvalElemRet(false);
     return(false);
 }
Example #18
0
    public override bool Eval(DialogRequest request)
    {
        LogEvalElemStart("varname = " + varname);

        bool   ret;
        string varvalue = actorBrain.GetVarValue(varname);

        if (!invert)
        {
            ret = (varvalue != null ? true : false);
        }
        else
        {
            ret = (varvalue != null ? false : true);
        }

        LogEvalElemRet(ret);
        return(ret);
    }
Example #19
0
    public override bool Eval(DialogRequest request)
    {
        LogEvalElemStart("refDialogCheck = " + refDialogCheck);

        Dialog dialogCheck = dialog;

        if (refDialogCheck != null && refDialogCheck.Length > 0)
        {
            dialogCheck = actorBrain.GetDialogs().GetDialogInPath(dialog, refDialogCheck);
        }

        bool saturated = actorBrain.GetMemory().IsDialogSatured(dialogCheck);

        if (not)
        {
            saturated = !saturated;
        }

        LogEvalElemRet(saturated);
        return(saturated);
    }
Example #20
0
        public ActionResult Api(string utterance)
        {
            // Docomo雑談API用の鍵
            string apiKey = "6863673132504d57574b32583564796867516a4b624630386d61486e4163646c5442446438787731746c37";
            // apiKeyを含んだREST API用URL
            string url = "https://api.apigw.smt.docomo.ne.jp/dialogue/v1/dialogue?APIKEY=" + apiKey;
            // URLに送るPOSTパラメータクラスのインスタンス化
            DialogRequest requestParam = new DialogRequest();

            // 前回のデータをcontext変数に代入
            requestParam.context = previousContext;
            // 送る会話の内容をutt変数に代入
            requestParam.utt = utterance;

            // 作成したデータをstring型にシリアライズ(変換)
            string requestJson = JsonConvert.SerializeObject(requestParam);
            // 作成したデータをエンコード
            StringContent requestContent = new StringContent(requestJson, Encoding.UTF8, "application/json");

            // HttpClient(ネットコネクション)をインスタンス化
            HttpClient client = new HttpClient();
            // 非同期通信を行いデータを送信し,DocomoAPIの返り値を取得
            var response = client.PostAsync(url, requestContent).Result;

            // 返り値の内容を読み込む
            var responseJson = response.Content.ReadAsStringAsync().Result;
            // 読み込んだデータをクラス型に変換
            DialogResponse responseParam = JsonConvert.DeserializeObject <DialogResponse>(responseJson);
            // Viewで使えるようJsonを用意
            JsonResult result = new JsonResult();

            // JsonにDocomoから帰ってきたデータのうち uttを格納
            result.Data = new { utterance = responseParam.utt };
            // Viewでgetで取れるように(セキュリティ)変更
            result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            // グローバル変数に今回の通信内容を保存
            previousContext = responseParam.context;
            // Jsonを返す
            return(result);
        }
Example #21
0
    public override bool Eval(DialogRequest request)
    {
        LogEvalElemStart("pattern = " + pattern);

        string text = request.GetText();

        Debug.Log("GAIMLLoader. EVAL. text = '" + text + "' / listTmpVarsCount = " + listTmpVars.Count + " / listTmpVars = " + listTmpVars);
        if (text == null)
        {
            LogEvalElemRet(false);
            return(false);
        }

        Match match = regex.Match(text);

        if (match.Success)
        {
            GroupCollection groups = match.Groups;
            Debug.Log("GAIMLLoader. Group.count = " + groups.Count + " / listTmpVarsCount = " + listTmpVars.Count + " / listTmpVars = " + listTmpVars);

            for (int i = 0; i < groups.Count - 1; i++)
            {
                Debug.Log("GAIMLLoader. Group [" + i + "] = " + i);
                string varname = listTmpVars[i];
                Debug.Log("GAIMLLoader. Group.varname [" + i + "] = " + varname);

                if (varname != null && varname.Length > 0)
                {
                    string varvalue = groups[i + 1].Value;
                    Debug.Log("GAIMLLoader. Variable: " + varname + " = " + varvalue);

                    actorBrain.GetMemory().SetPermanetVar(varname, varvalue);
                }
            }
            LogEvalElemRet(true);
            return(true);
        }
        LogEvalElemRet(false);
        return(false);
    }
Example #22
0
        private void button_send_Click(object sender, RoutedEventArgs e)
        {
            string utterance = textBox_utterance.Text;

            listView_messages.Items.Insert(0, "あなた: " + utterance);


            // Docomo雑談API用の鍵
            string apiKey = "6863673132504d57574b32583564796867516a4b624630386d61486e4163646c5442446438787731746c37";
            // apiKeyを含んだREST API用URL
            string url = "https://api.apigw.smt.docomo.ne.jp/dialogue/v1/dialogue?APIKEY=" + apiKey;
            // URLに送るPOSTパラメータクラスのインスタンス化
            DialogRequest requestParam = new DialogRequest();

            // 前回のデータをcontext変数に代入
            requestParam.context = previousContext;
            // 送る会話の内容をutt変数に代入
            requestParam.utt = utterance;

            // 作成したデータをstring型にシリアライズ(変換)
            string requestJson = JsonConvert.SerializeObject(requestParam);
            // 作成したデータをエンコード
            StringContent requestContent = new StringContent(requestJson, Encoding.UTF8, "application/json");

            // HttpClient(ネットコネクション)をインスタンス化
            HttpClient client = new HttpClient();
            // 非同期通信を行いデータを送信し,DocomoAPIの返り値を取得
            var response = client.PostAsync(url, requestContent).Result;

            // 返り値の内容を読み込む
            var responseJson = response.Content.ReadAsStringAsync().Result;
            // 読み込んだデータをクラス型に変換
            DialogResponse responseParam = JsonConvert.DeserializeObject <DialogResponse>(responseJson);

            // グローバル変数に今回の通信内容を保存
            previousContext = responseParam.context;

            listView_messages.Items.Insert(0, "システム: " + responseParam.utt);
            textBox_utterance.Text = "";
        }
Example #23
0
    public override bool Eval(DialogRequest request)
    {
        LogEvalElemStart("refPrev = " + refPrev);
        Debug.Log("ConditionRefPrev.refPrev = " + refPrev + " / idxPrev = " + idxPrev);
        if (refPrev == null || refPrev.Length == 0)
        {
            LogEvalElemRet(false);
            return(false);
        }

        bool ret;

        if (idxPrev == 0)
        {
            ret = actorBrain.GetMemory().ExistsDialogResponse(Dialog.ResolveMatchExpresions(actorBrain, refPrev));
            LogEvalElemRet(ret);
            return(ret);
        }

        ret = actorBrain.GetMemory().ExistsPrevRefDialogResponse(Dialog.ResolveMatchExpresions(actorBrain, refPrev), idxPrev);
        LogEvalElemRet(ret);
        return(ret);
    }
Example #24
0
    public override bool Eval(DialogRequest request)
    {
        LogEvalElemStart();

        NormalizeTypeValues();

        Debug.Log("Compare.EvalEquals (op=" + oper + ", type=" + type + "). strA=" + strA + " / strB=" + strB + "). intA=" + intA + " / intB=" + intB + "). floatA=" + floatA + " / floatB=" + floatB);

        switch (oper)
        {
        case CmpOp.Equals: return(EvalEquals());

        case CmpOp.Different: return(EvalDifferent());

        case CmpOp.Greater: return(EvalGreater());

        case CmpOp.Less: return(EvalLess());

        case CmpOp.GreaterEquals: return(EvalGreaterEquals());

        case CmpOp.LessEquals: return(EvalLessEquals());
        }
        return(EvalEquals());
    }
Example #25
0
    public void Open(string name, System.Action confirmCallback = null, System.Action closeCallback = null, bool queue = false)
    {
        if (open)
        {
            if (queue)
            {
                var request = new DialogRequest(name, confirmCallback, closeCallback);
                requestQueue.Enqueue(request);
            }
            return;
        }

        open = true;
        this.confirmCallback = confirmCallback;
        this.closeCallback   = closeCallback;
        animElapsed          = 0;
        travelIn.SetDelta(0);
        // show relevant dialog
        foreach (Transform item in transform)
        {
            item.gameObject.SetActive(item.name == name);
        }
        state = State.OPENING;
    }
Example #26
0
 public void ProcessMedalRequest(DialogRequest request, SeasonEndDialog seasonEndDialog)
 {
     object[] objArray1 = new object[] { request, seasonEndDialog };
     base.method_8("ProcessMedalRequest", objArray1);
 }
Example #27
0
 public void ProcessFriendlyChallengeRequest(DialogRequest request, FriendlyChallengeDialog friendlyChallengeDialog)
 {
     object[] objArray1 = new object[] { request, friendlyChallengeDialog };
     base.method_8("ProcessFriendlyChallengeRequest", objArray1);
 }
Example #28
0
 public void ProcessExistingAccountRequest(DialogRequest request, ExistingAccountPopup exAcctPopup)
 {
     object[] objArray1 = new object[] { request, exAcctPopup };
     base.method_8("ProcessExistingAccountRequest", objArray1);
 }
Example #29
0
 public void ProcessAlertRequest(DialogRequest request, AlertPopup alertPopup)
 {
     object[] objArray1 = new object[] { request, alertPopup };
     base.method_8("ProcessAlertRequest", objArray1);
 }
Example #30
0
 public void LoadPopup(DialogRequest request)
 {
     object[] objArray1 = new object[] { request };
     base.method_8("LoadPopup", objArray1);
 }