Beispiel #1
0
        public override async Task <MatchResult> InvokeAsync(SocketMessage message)
        {
            if (ResponseIds.Contains(message.Content))
            {
                var chat = new StringBuilder();

                Dialog response = Tree.Branches.First().GetDialog(message.Content);
                Dialog loop     = Tree.Branches.First().GetBestReply(Npc, Husk, Brain, Log, response);

                switch (loop.Type)
                {
                case DialogType.End:
                    // TODO: Implement content separations, which are continued when the user types 'next' (loop.GetBestEntry(Npc))
                    await UpdateMessageAsync(loop.Tone, GetReplyBox(loop.GetAnyEntry().ToString(), false));

                    return(MatchResult.Success);

                case DialogType.Answer:
                    ResponseIds = GetEntryIds();
                    break;

                default:
                    if (loop.ReplyIds.Count == 0)
                    {
                        chat.AppendLine($"> **No responses available. Closing...**");
                        await UpdateMessageAsync(loop.Tone, chat.ToString());

                        return(MatchResult.Fail);
                    }

                    ResponseIds = loop.ReplyIds;
                    break;
                }

                chat.AppendLine(GetReplyBox(loop.GetAnyEntry().ToString()));

                await UpdateMessageAsync(loop.Tone, chat.ToString());

                return(MatchResult.Continue);
            }
            else
            {
                string old = MessageReference.Content;

                await MessageReference.ModifyAsync($"> **Please input a correct response ID.**\n" + old);

                return(MatchResult.Continue);
            }
        }
Beispiel #2
0
 private IEnumerable <string> WriteAvailableReplies()
 => ResponseIds.Select(x => string.Format(_replyFrame, x, Tree.Branches.First().GetDialog(x).Entry.ToString()));