Exemple #1
0
        private async Task HandleTextMessage(Message message)
        {
            var chat        = Chat.Create(message.Chat.Id);
            var chatContext = _chatsDictionary.GetOrAdd(chat.Id,
                                                        l => new ChatContext(chat, _telegramBotClient !,
                                                                             _serviceProvider.GetRequiredService <IServiceProvider>()));

            await chatContext.Handle(message);
        }
Exemple #2
0
        private async void TelegramBotClientOnOnCallbackQuery(object?sender, CallbackQueryEventArgs e)
        {
            try
            {
                var chat        = Chat.Create(e.CallbackQuery.From.Id);
                var chatContext = _chatsDictionary.GetOrAdd(chat.Id,
                                                            l => new ChatContext(chat, _telegramBotClient !,
                                                                                 _serviceProvider.GetRequiredService <IServiceProvider>()));

                await chatContext.Handle(e.CallbackQuery);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error on handle CallbackQuery in chat {ChatId}", e.CallbackQuery?.ChatInstance);
            }
        }
 public AddHealthChecksChatState(Chat chat, TelegramBotClient telegramBotClient, IServiceProvider serviceProvider)
     : base(telegramBotClient, serviceProvider, chat)
 {
 }
Exemple #4
0
 public StartChatState(Chat chat, TelegramBotClient telegramBotClient, IServiceProvider serviceProvider)
     : base(telegramBotClient, serviceProvider, chat)
 {
 }