public void PrerenderDefaultOutput( long chatId, TelegramBotClientFacade telegramBotClientFacade) { telegramBotClientFacade .SendTextMessageToChat(chatId, GetRooms()); }
public void PublishEvent(TelegramBotClientFacade telegramBotClientFacade) { foreach (var item in _subscribers) { item.Update(telegramBotClientFacade); } }
public void ProcessInput(long chatId, string input, TelegramBotClientFacade telegramBotClientFacade) { _currentState .ProcessInput(chatId, input, telegramBotClientFacade, this); }
public override void ProcessRequest( TelegramBotClientFacade client, MessageEventArgs args) { var chatId = args.Message.Chat.Id; var state = _stateRepository.Get(chatId); state.ProcessInput(chatId, args.Message.Text, client); }
public override void Update(TelegramBotClientFacade facade) { var message = "Уважаемый клиент! Рады сообщить, что в нашем медцентре" + " начинается неделя скидок - приведи друга и " + "забери его почку бесплатно!"; facade.SendTextMessageToChat(ChatId, message); }
public void PrerenderDefaultOutput(long chatId, TelegramBotClientFacade telegramBotClientFacade) { var instance = SpecialDiscountEventPublisher.Instance; instance.AddSubscriber(new SpecialDiscountEventSubscriber(chatId)); telegramBotClientFacade.SendTextMessageToChat(chatId, "Вы успешно подписались на новости нашего медцентра!"); }
public void ProcessInput( long chatId, string input, TelegramBotClientFacade telegramBotClientFacade, CurrentStateHolder stateHolder) { var nextState = new OnStartSelectState(); nextState.ProcessInput(chatId, input, telegramBotClientFacade, stateHolder); stateHolder.SetNextState(nextState); }
public void ProcessInput( long chatId, string input, TelegramBotClientFacade telegramBotClientFacade, CurrentStateHolder stateHolder) { telegramBotClientFacade.SendMapMessageToChat(chatId); var initialState = new OnStartSelectState(); initialState.PrerenderDefaultOutput(chatId, telegramBotClientFacade); stateHolder.SetNextState(initialState); }
public ProcessingMiddleware( TelegramBotClientFacade client, IEnumerable <MiddlewareComponentBase> middlewareComponents) { _client = client ?? throw new ArgumentNullException(nameof(client)); _middlewareComponents = middlewareComponents ?? throw new ArgumentNullException(nameof(middlewareComponents)); _logger = new LoggerConfiguration() .WriteTo.Console() .CreateLogger(); }
public void ProcessInput(long chatId, string input, TelegramBotClientFacade telegramBotClientFacade, CurrentStateHolder stateHolder) { var doctorName = input; var schedule = GetSchedule(doctorName); telegramBotClientFacade.SendTextMessageToChat(chatId, schedule); var nextState = new OnStartSelectState(); nextState.PrerenderDefaultOutput(chatId, telegramBotClientFacade); stateHolder.SetNextState(nextState); }
public override void ProcessRequest( TelegramBotClientFacade client, MessageEventArgs messageEventArgs) { var logger = new LoggerConfiguration() .WriteTo.Console() .CreateLogger(); var chatId = messageEventArgs.Message.Chat.Id; var userName = messageEventArgs.Message.Chat.Username; var lotItem = $"Поступило сообщение от пользователя {userName} в чате {chatId}"; logger.Information(lotItem); }
public override void ProcessRequest( TelegramBotClientFacade client, MessageEventArgs args) { var key = GetCurrentKey(args.Message.Chat.Id, DateTime.Now); _rateLimiterRepository.Increase(key); var currentCounter = _rateLimiterRepository.Get(key); if (currentCounter > _messageLimitPerMinute) { throw new InvalidOperationException("You have reached the limit of messages. Wait..."); } RefreshOldRecords(); }
public void RunWorker(TelegramBotClientFacade telegramBotClientFacade) { _workerThread = Task.Run(() => { while (true) { var eventsToRun = GetEventsToPublishNow(); foreach (var item in eventsToRun) { Console.WriteLine($"READY TO PUBLISH : {item.GetType().Name}"); item.PublishEvent(telegramBotClientFacade); } Thread.Sleep(TimeSpan.FromSeconds(1)); } }); }
public void ProcessInput( long chatId, string input, TelegramBotClientFacade telegramBotClientFacade, CurrentStateHolder stateHolder) { var selectedButton = GetButtons() .FirstOrDefault(p => input .Equals(p, StringComparison.InvariantCultureIgnoreCase)); if (selectedButton == null) { telegramBotClientFacade .SendButtonMessageToChat(chatId, GetButtons()); } else { var nextState = ButtonToNextStateMapper(selectedButton); nextState.PrerenderDefaultOutput(chatId, telegramBotClientFacade); stateHolder.SetNextState(nextState); } }
public void ProcessInput( long chatId, string input, TelegramBotClientFacade telegramBotClientFacade, CurrentStateHolder stateHolder) { var selectedCity = GetCities() .FirstOrDefault(p => p.Equals(input, StringComparison.InvariantCultureIgnoreCase)); if (selectedCity == null) { telegramBotClientFacade .SendTextMessageToChat(chatId, "Пожалуйста, повторите попытку"); telegramBotClientFacade .SendButtonMessageToChat(chatId, GetCities()); } else { var nextState = GetSelectAddressState(selectedCity); nextState.PrerenderDefaultOutput(chatId, telegramBotClientFacade); stateHolder.SetNextState(nextState); } }
public ProcessingMiddlewareBuilder AddTelegramClient( ITelegramBotClient telegramBotClient) { _client = new TelegramBotClientFacade(telegramBotClient); return(this); }
public abstract void Update(TelegramBotClientFacade facade);
public abstract void ProcessRequest( TelegramBotClientFacade client, MessageEventArgs message);
public void PrerenderDefaultOutput( long chatId, TelegramBotClientFacade telegramBotClientFacade) { telegramBotClientFacade.SendButtonMessageToChat(chatId, GetAddressesByCity(_selectedCity)); }
public ProcessingMiddlewareBuilder AddTelegramClient( TelegramBotClientFacade telegramBotClientFacade) { _client = telegramBotClientFacade; return(this); }
public void ProcessInput(long chatId, string input, TelegramBotClientFacade telegramBotClientFacade, CurrentStateHolder stateHolder) { stateHolder.SetNextState(new OnStartSelectState()); }
public void PrerenderDefaultOutput( long chatId, TelegramBotClientFacade telegramBotClientFacade) { telegramBotClientFacade.SendButtonMessageToChat(chatId, GetCities()); }