Пример #1
0
        public TelegramCollector()
        {
            bot = new TelegramBotClient("1614127935:AAGWfaa6RwOrrUGH2V0AR9phluns7ScvpFk");
            //bot.SendTextMessageAsync(new ChatId(-1001266511682), "Just setting khbrdnn.");
            var me = bot.GetMeAsync().Result;

            //bot.SendTextMessageAsync(new ChatId(-1001479837640), "Hello word.!");
            //keepconnected_timer.Elapsed += OnkeepAlive;
            _Bot           = new ContentSenderTelegramBot(bot);
            bot.OnMessage += OnTelegramMessage;
            int    app_id   = 2372991;
            string api_hash = "c7f27d96d2b3409d0b48d9682a3314a4";
            var    store    = new FileSessionStore();

            client = new TelegramClient(app_id, api_hash, store);

            TelegramClientManager._client = client;
            //await TelegramClientManager.CreateClientbyAuthorize(app_id, api_hash);
            //client = TelegramClientManager._client;


            while (true)
            {
                try
                {
                    //send message
                    client.ConnectAsync(false).Wait();
                    break;
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    Console.WriteLine("/n /n any key to retying...");
                    Console.ReadKey();
                    //countinue
                }
            }

            OnkeepAlive(null, null);
            keepconnected_timer.Enabled = true;

            //var client = new TelegramClient(app_id,api_hash);

            //Console.Write("Enter numberphone:");
            //var numberphone = Console.ReadLine();


            Console.WriteLine("Is connected: " + client.IsConnected);
            Console.WriteLine("Is user authorized: " + client.IsUserAuthorized());

            this._Context = new NewsConcentratorDbContext();
            Thread t = new Thread(GetNewses);

            t.Start();
        }
Пример #2
0
 public TelegramScraperSettingsController(NewsConcentratorDbContext context)
 {
     _context = context;
 }
Пример #3
0
 public MustnotContainController(NewsConcentratorDbContext context)
 {
     _context = context;
 }
Пример #4
0
 public MessageMustContainsController(NewsConcentratorDbContext context)
 {
     _context = context;
 }
 public TelegramChannelsController(NewsConcentratorDbContext context)
 {
     _context = context;
 }
 public PublishedNewsExpirer(int newshaourlifetime, NewsConcentratorDbContext context)
 {
     _newshourLifetime = newshaourlifetime;
     _context          = context;
 }
Пример #7
0
 public SettingsController(NewsConcentratorDbContext context)
 {
     _context = context;
 }
Пример #8
0
 public MessageReplaceWordsController(NewsConcentratorDbContext context)
 {
     _context = context;
 }