public ShowSubscribeTokenCommand(
     IRepository <Logger> loggerRepository,
     ITelegramBot telegramBot)
     : base(telegramBot)
 {
     _loggerRepository = loggerRepository;
 }
 public RemoveLoggerCommand(
     IRepository <Logger> loggerRepository,
     ITelegramBot telegramBot)
     : base(telegramBot)
 {
     _loggerRepository = loggerRepository;
 }
Example #3
0
        public MainWindow()
        {
            InitializeComponent();

            ConfigurationBuilder builder = new ConfigurationBuilder();

            builder.SetBasePath(Directory.GetCurrentDirectory());
            builder.AddJsonFile("appsettings.json");
            IConfigurationRoot config           = builder.Build();
            string             connectionString = config.GetConnectionString("DefaultConnection");
            string             telegramToken    = config.GetSection("TelegramToken").Value;
            string             weatherToken     = config.GetSection("WeatherToken").Value;

            DbContextOptionsBuilder <ApplicationContext> optionsBuilder = new DbContextOptionsBuilder <ApplicationContext>();
            DbContextOptions <ApplicationContext>        options        = optionsBuilder
                                                                          .UseSqlServer(connectionString)
                                                                          .Options;

            uiContext = SynchronizationContext.Current;

            this.db          = new ApplicationContext(options);
            this.telegramBot = new TelegramBot(db, telegramToken, uiContext);
            currentWeather   = new CurrentWeather(weatherToken);

            applicationViewModel = new ApplicationViewModel(db, telegramBot, currentWeather);
            this.DataContext     = applicationViewModel;
        }
 public ChangeLoggerNameCommand(
     IRepository <Logger> loggerRepository,
     ITelegramBot telegramBot)
     : base(telegramBot)
 {
     _loggerRepository = loggerRepository;
 }
Example #5
0
 public CancelCommand(
     IRepository <ApplicationUser> userRepository,
     ITelegramBot telegramBot)
     : base(telegramBot)
 {
     _userRepository = userRepository;
 }
Example #6
0
 public SubscribesCommand(
     IRepository <ApplicationUser> userRepository,
     ITelegramBot telegramBot)
     : base(telegramBot)
 {
     _userRepository = userRepository;
 }
 public RemoveLoggerRequestCommand(
     IRepository <ApplicationUser> userRepository,
     ITelegramBot telegramBot)
     : base(telegramBot)
 {
     _userRepository = userRepository;
 }
 public CallbackQueryService(
     IEnumerable <ICommand> commands,
     ITelegramBot telegramBot)
 {
     _commands    = commands;
     _telegramBot = telegramBot;
 }
Example #9
0
 public ExceptionService(
     IRepository <Logger> loggerRepository,
     ITelegramBot telegramBot)
 {
     _loggerRepository = loggerRepository;
     _telegramBot      = telegramBot;
 }
Example #10
0
 public AddLoggerCommand(
     ITelegramBot telegramBot,
     IRepository <ApplicationUser> userRepository)
     : base(telegramBot)
 {
     _userRepository = userRepository;
 }
Example #11
0
 public LoggerInfoCommand(
     IRepository <Logger> loggerRepository,
     ITelegramBot telegramBot)
     : base(telegramBot)
 {
     _loggerRepository = loggerRepository;
 }
Example #12
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ITelegramBot telegramBot)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
                app.UseHttpsRedirection();
            }

            IoC.MapperBootstrapper.Bootstrap(_cfg);
            Mapper.Initialize(_cfg);
            InitializeContainer(app);

            telegramBot.SetWebhook(
                Configuration["TelegramBotSettings:WebhookUri"],
                Configuration.GetSection("TelegramBotSettings").GetSection("AllowedUpdates").Get <string[]>());

            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
            });

            app.UseMvc();
        }
Example #13
0
 public MessagesQueue(ILogger <MessagesQueue> logger, ITelegramBot bot, IOptions <GitlabConfig> gitlabConfig, TelegramBotDBContext db)
 {
     _logger = logger;
     _bot    = bot;
     _db     = db;
     _admin  = gitlabConfig.Value.Admin;
     _queue  = new Queue <JToken>();
     _gitlab = new GitLabClient(gitlabConfig.Value.Host, gitlabConfig.Value.Token);
 }
 public OnSubscribeTokenCommand(
     IRepository <ApplicationUser> userRepository,
     IRepository <Logger> loggerRepository,
     ITelegramBot telegramBot)
     : base(telegramBot)
 {
     _userRepository   = userRepository;
     _loggerRepository = loggerRepository;
 }
Example #15
0
 public MessageHandlers(ITelegramBot telegramBot,
                        IFilesRepo filesRepo,
                        IUserStateRepo userStateRepo,
                        IIncidentRepo incidentRepo)
 {
     _telegramBot = telegramBot;
     _filesRepo = filesRepo;
     _userStateRepo = userStateRepo;
     _incidentRepo = incidentRepo;
 }
Example #16
0
        public BotManager(ITelegramBot client, IGamesService service)
        {
            _botWaitsForQuery      = new Dictionary <long, QueryAction>();
            _multipleDataForUser   = new Dictionary <long, List <string> >();
            _singleDataForUser     = new Dictionary <long, string>();
            _searchingSimilarUsers = new List <long>();
            _service = service;
            _client  = client;

            client.OnMessageReceived += ProcessMessage;
        }
Example #17
0
        protected override void OnStart(string[] args)
        {
            _cancellationTokenSource = new CancellationTokenSource();
            _telegramBot             = new TelegramBot();

            _telegramBot.Run();

            while (!_cancellationTokenSource.IsCancellationRequested)
            {
            }
        }
Example #18
0
        public WebhookService(ICommandResolver commandResolver,
                              ITelegramBot telegramBot,
                              ICommandInvoker commandInvoker,
                              ILogger <WebhookService> logger)
        {
            _commandResolver = commandResolver;
            _telegramBot     = telegramBot;
            _commandInvoker  = commandInvoker;
            _logger          = logger;

            _mapper = new Mapper(new MapperConfiguration(x => x.AddProfile <RequestProfile>()));
        }
        public ApplicationViewModel(ApplicationContext db, ITelegramBot telegramBot, IWeather currentWeather)
        {
            this.db                          = db;
            this.currentWeather              = currentWeather;
            this.telegramBot                 = telegramBot;
            this.telegramBot.ReceiveMessage += TelegramBot_ReceiveMessage;

            this.db.Users.Load();
            Users = this.db.Users.Local.ToObservableCollection();
            this.db.Messages.Load();
            Messages = this.db.Messages.Local.ToObservableCollection();

            timerUpdateUserMessages          = new System.Timers.Timer(1000);
            timerUpdateUserMessages.Elapsed += Timer_Elapsed;
            //timerUpdateUserMessages.Start();
        }
Example #20
0
 public ExportController(ITelegramBot bot)
 {
     _bot = bot;
 }
Example #21
0
 public UndefinedCommand(ITelegramBot telegramBot)
     : base(telegramBot)
 {
 }
Example #22
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, ITelegramBot bot, IMessagesQueue messagesQueue)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();
            loggerFactory.AddNLog();
            app.UseMvc();

            app.AddNLogWeb();
            env.ConfigureNLog("nlog.config");

            var accessToken = Configuration.GetSection("TelegramAccessToken")?.Value;
            var botname     = Configuration.GetSection("TelegramBotName")?.Value;

            bot.Connect(accessToken, botname);
            bot.Start();

            messagesQueue.Start();
        }
 public ContactFormController(ITelegramBot bot)
 {
     Bot = bot;
 }
 public BotControlController(ITelegramBot bot)
 {
     _bot = bot;
 }
Example #25
0
 public UpdateParser(ITelegramBot telegramBot, IStockProvider stockProvider, CompanyInfoProvider companyInfoProvider)
 {
     this.telegramBot         = telegramBot ?? throw new ArgumentNullException(nameof(telegramBot));
     this.stockProvider       = stockProvider ?? throw new ArgumentNullException(nameof(stockProvider));
     this.companyInfoProvider = companyInfoProvider ?? throw new ArgumentNullException(nameof(companyInfoProvider));
 }
Example #26
0
 public Client(ITelegramBot bot, IServiceScopeFactory scopeFactory)
 {
     _scopeFactory = scopeFactory;
     _bot          = bot;
 }
Example #27
0
 public ErrorCommand(ITelegramBot telegramBot)
     : base(telegramBot)
 {
 }
Example #28
0
 public MenuCommand(ITelegramBot telegramBot)
     : base(telegramBot)
 {
 }
Example #29
0
 public BaseCommand(ITelegramBot telegramBot)
 {
     _telegramBot = telegramBot;
 }
Example #30
0
 private static Task SendScanStatus(ITelegramBot telebot, long sendTo, string[] statuses)
 {
     return(telebot.SendMessageAsync(sendTo, statuses != null && statuses.Length > 0 ? String.Join("\n\n", statuses) : "You do not have any scans!"));
 }