Esempio n. 1
0
        public static async Task <TelegramBotClient> GetBotClientAsync()
        {
            if (botClient != null)
            {
                return(botClient);
            }

            BotConfig       botConfig = Startup.StaticConfig.GetSection("BotConfig").Get <BotConfig>();
            ActivityContext context   = new ActivityContext((DbContextOptions <ActivityContext>)Startup.DbOptions);

            var repository         = new Repository(context);
            var keyboardService    = new KeyboardService();
            var translatingService = new TranslatingService(botConfig);
            var commandService     = new CommandService(keyboardService, translatingService, repository);

            commandsList = new List <Command>
            {
                new StartCommand(),
                new FilterCommand(keyboardService),
                new RandomCommand(commandService),
                new AccessibilityCommand(commandService),
                new ParticipantsCommand(commandService),
                new PriceCommand(commandService),
                new TypeCommand(commandService)
            };

            botClient = new TelegramBotClient(botConfig.TelegramConfig.Token);
            await botClient.SetWebhookAsync(botConfig.WebsiteUrl + "/bot");

            return(botClient);
        }
Esempio n. 2
0
 public CommandService(KeyboardService keyboardService,
                       TranslatingService translatingService, Repository repository)
 {
     _keyboardService    = keyboardService;
     _translatingService = translatingService;
     _repository         = repository;
 }