Exemplo n.º 1
0
        private async Task ReadConsole(Message request, bool allowEval, CancellationToken ct)
        {
            TaskUtilities.AssertIsOnBackgroundThread();

            request.ExpectArguments(5);

            var contexts     = GetContexts(request);
            var len          = request.GetInt32(1, "len");
            var addToHistory = request.GetBoolean(2, "addToHistory");
            var retryReason  = request.GetString(3, "retry_reason", allowNull: true);
            var prompt       = request.GetString(4, "prompt", allowNull: true);

            string input;

            try {
                _canEval = allowEval;
                input    = await _callbacks.ReadConsole(contexts, prompt, len, addToHistory, _canEval, ct);
            } finally {
                _canEval = false;
            }

            ct.ThrowIfCancellationRequested();

            input = input.Replace("\r\n", "\n");
            await RespondAsync(request, ct, input);
        }