internal static async void OnMessageReceived(object sender, MessageEventArgs e)
        {
            var message = e.Message;

            if (message.Text.Trim().Sanitize() == "/start")
            {
                IntroMessage(message);
                return;
            }

            if (!message.Chat.Username.IsFilled())
            {
                SendMessageToClientById(message.Chat.Id, "You need to specify UserName for your Telegram account.");
                return;
            }

            if (!Helper.IsUserAuthentic(message))
            {
                return;
            }


            if (!Helper.IsUserBehaviourNormal(message))
            {
                return;
            }
            if (message.Chat.Type == ChatType.Group)
            {
            }



            switch (message.Text)
            {
            case "update":
                Helper.UpdateNewsDb();
                break;

            case "news":
                //var news = DbHelper.SelectNews((DateTime.Today.ToString("dddd") == "Saturday") ? 3 : 1);
                var news = Helper.GetNewsOffline();
                SendListOfNewsById(message, news);
                break;

            case "cert":
                var usSert = Helper.GetNewsOnline("https://www.us-cert.gov/ncas/all.xml", Model.NewsSupplier.UsCert);
                SendListOfNewsById(message, usSert);
                break;

            case "Twitter":
                var twitterUrl = Helper.GetNewsOnline("https://twitrss.me/twitter_user_to_rss/?user=CVEnew", Model.NewsSupplier.Twitter);
                SendListOfNewsById(message, twitterUrl);
                break;
            }
        }
Exemplo n.º 2
0
        private static void StartUpdating()
        {
            Console.WriteLine($"Getting updates on {DateTime.Now}");
            var freshNewsCount = Helper.UpdateNewsDb();

            if (freshNewsCount > 0)
            {
                Helper.ShowNotify(freshNewsCount + " fresh news downloaded");
            }
            Console.WriteLine($"Update finished on {DateTime.Now}");
            Console.WriteLine(new string('*', 50));
        }