Exemplo n.º 1
0
        private static bool GetAnswer(string input, out AkinatorAnswer answer)
        {
            answer = null;
            foreach (var command in _commands)
            {
                if (command.Validate(input))
                {
                    answer = command.Invoke(_akinator, input);
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 2
0
        private static void OnMessage(object sender, MessageEventArgs e)
        {
            if (!GetAnswer(e.Message.Text, out var answer))
            {
                answer = new AkinatorAnswer
                {
                    Message = "Pls, type 'start', 'yes', 'no' or 'idk'"
                }
            }
            ;

            if (answer == null)
            {
                return;
            }
            var message = AnswerToString(answer);

            _botClient.SendTextMessageAsync(e.Message.Chat.Id, message);
        }
Exemplo n.º 3
0
 private static string AnswerToString(AkinatorAnswer answer)
 {
     return(answer.Message);
 }