//ez reagál a felhasználónak, amennyiben a score alapján ez a dialógus veszi át az irányítást protected override async Task PostAsync(IActivity item, string state, CancellationToken token) { InterruptionDialog cancelInterruptionDialog = new InterruptionDialog(TextProvider.Provide(TextCategory.INTERRUPTION_Cancel)); IDialog <IMessageActivity> cancelInterruption = cancelInterruptionDialog.Void <object, IMessageActivity>(); task.Call(cancelInterruption, null); task.Reset(); }
/// <summary> /// Helper to quickly go to root dialog and optionally reset the dialog stack. /// </summary> /// <param name="dialogTask">context/stack</param> /// <param name="clearStack">TRUE to clear stack, FALSE to leave it unchanged</param> internal async static Task ForwardToRootDialogAsync(IDialogTask dialogTask, bool clearStack) { if (clearStack) { dialogTask.Reset(); } var newActivity = Activity.CreateEventActivity(); newActivity.Value = "INIT_DIALOG"; await dialogTask.Forward(new RootDialog(), null, newActivity, CancellationToken.None); }
/// <summary> /// Post an item to the dialog task and poll the dialog task for any work to be done. /// </summary> /// <typeparam name="R">The type of the root dialog.</typeparam> /// <typeparam name="T">The type of the item.</typeparam> /// <param name="task">The dialog task.</param> /// <param name="toBot">The item to be sent to the bot.</param> /// <param name="MakeRoot">The factory method for the root dialog.</param> /// <param name="token">An optional cancellation token.</param> /// <returns>A task representing the post operation.</returns> public static async Task PostAsync <T, R>(this IDialogTask task, T toBot, Func <IDialog <R> > MakeRoot, CancellationToken token = default(CancellationToken)) { await LoadAsync(task, MakeRoot, token); IPostToBot postToBot = task; try { await postToBot.PostAsync(toBot, token); } catch { task.Reset(); throw; } task.Save(); }
async Task IPostToBot.PostAsync <T>(T item, CancellationToken token) { try { if (dialogTask.Frames.Count == 0) { var root = this.makeRoot(); var loop = root.Loop(); dialogTask.Call(loop, null); await dialogTask.PollAsync(token); } await dialogTask.PostAsync(item, token); } catch { dialogTask.Reset(); throw; } }
// 當攔截到進來的訊息時,進入到這個函式 protected override async Task PostAsync(IActivity item, string state, CancellationToken token) { await _context.ReplyMessageAsync("Reset Dialog", waitTime : 1000, isSendTyping : true); _task.Reset(); }
protected override async Task PostAsync(IActivity item, string state, CancellationToken token) { task.Reset(); }