private static void Main() { TaskScheduler.UnobservedTaskException += (sender, args) => Console.WriteLine($"Unobserved ex {args.Exception}"); _settings = ReadConfiguration(); var yandexDictionaryClient = new YandexDictionaryApiClient(_settings.YadicapiKey, _settings.YadicapiTimeout); var yandexTranslateApiClient = new YandexTranslateApiClient(_settings.YatransapiKey, _settings.YatransapiTimeout); var client = new MongoClient(_settings.MongoConnectionString); var db = client.GetDatabase("SayWhatDb"); var userWordRepo = new UserWordsRepo(db); var dictionaryRepo = new DictionaryRepo(db); var userRepo = new UsersRepo(db); var examplesRepo = new ExamplesRepo(db); userWordRepo.UpdateDb(); dictionaryRepo.UpdateDb(); userRepo.UpdateDb(); examplesRepo.UpdateDb(); _userWordService = new UsersWordsService(userWordRepo, examplesRepo); _dictionaryService = new DictionaryService(dictionaryRepo, examplesRepo); _userService = new UserService(userRepo); _addWordService = new AddWordService( _userWordService, yandexDictionaryClient, yandexTranslateApiClient, _dictionaryService, _userService); QuestionSelector.Singletone = new QuestionSelector(_dictionaryService); Console.WriteLine("Dic started"); _botClient = new TelegramBotClient(_settings.TelegramToken); var me = _botClient.GetMeAsync().Result; Console.WriteLine( $"Hello, World! I am user {me.Id} and my name is {me.FirstName}." ); _botClient.OnUpdate += BotClientOnOnUpdate; _botClient.OnMessage += Bot_OnMessage; _botClient.StartReceiving(); // workaround for infinity awaiting new TaskCompletionSource <bool>().Task.Wait(); // it will never happens _botClient.StopReceiving(); }
public void Intitalize() { MongoTestHelper.DropAllCollections(); _repo = new DictionaryRepo(MongoTestHelper.Database); _repo.UpdateDb().Wait(); }