예제 #1
0
        private void ProcessMessageAndSendAnswer(object sender, TelegramBotMessageReceivedEventArgs e)
        {
            var messageProcessor = new PersonalAgentMessageProcessor(_controller);

            messageProcessor.ProcessMessage(e.Message);

            e.EnqueueResponse(messageProcessor.Answer);
        }
        public static void EnqueueResponse(this TelegramBotMessageReceivedEventArgs messageReceivedEventArgs, string text)
        {
            if (messageReceivedEventArgs == null)
            {
                throw new ArgumentNullException(nameof(messageReceivedEventArgs));
            }
            if (text == null)
            {
                throw new ArgumentNullException(nameof(text));
            }

            messageReceivedEventArgs.TelegramBot.EnqueueMessage(
                messageReceivedEventArgs.Message.CreateResponse(text));
        }
예제 #3
0
        public static async Task <bool> SendResponse(this TelegramBotMessageReceivedEventArgs messageReceivedEventArgs, string text)
        {
            if (messageReceivedEventArgs == null)
            {
                throw new ArgumentNullException(nameof(messageReceivedEventArgs));
            }
            if (text == null)
            {
                throw new ArgumentNullException(nameof(text));
            }

            return(await
                   messageReceivedEventArgs.TelegramBot.TrySendMessageAsync(
                       messageReceivedEventArgs.Message.CreateResponse(text)));
        }