Example #1
0
 public WeatherAnswer(TelegramChatMessagePublisher publish)
 {
     this.publish = publish;
 }
Example #2
0
 public Utkin(TelegramChatMessagePublisher publish)
 {
     this.publish = publish;
 }
Example #3
0
 public Nike(TelegramChatMessagePublisher publish)
 {
     this.publish = publish;
 }
Example #4
0
 public TimeAnswer(TelegramChatMessagePublisher publish, Message msg)
 {
     this.publish = publish;
     this.message = msg;
 }
Example #5
0
 public Sport(TelegramChatMessagePublisher publish)
 {
     this.publish = publish;
 }
Example #6
0
 public Newbalance(TelegramChatMessagePublisher publish)
 {
     this.publish = publish;
 }
Example #7
0
        static void Main(string[] args)
        {
            var builder = new ConfigurationBuilder()
                          .AddJsonFile($"appsettings.json", true, true);


            var configuration = builder.Build();

            var webClient = new WebClient();

            var fileProvider        = new FileSystemProvider();
            var telegramBotSettings = configuration.GetSection("TelegramBotSettings").Get <TelegramBotSettings>();

            var webRequestor       = new WebRequestor(webClient);
            var chatUpdateReader   = new TelegramUpdatesReader(telegramBotSettings, webRequestor);
            var publishBotReaction = new TelegramChatMessagePublisher(telegramBotSettings, webRequestor);
            var chatBotState       = new ChatBotState(fileProvider);

            chatBotState.LoadState();

            var pollingWatcher = new TelegramChatUpdatesPollingWatcher(chatUpdateReader, chatBotState);

            var cancellationTokenSource = new CancellationTokenSource();


            var hellow     = new HellowAnswer(publishBotReaction);
            var Say        = new SayUserInformation(publishBotReaction);
            var weather    = new WeatherAnswer(publishBotReaction);
            var vedomosti  = new Vedomosti(publishBotReaction);
            var dw         = new EconomicsDw(publishBotReaction);
            var cbr        = new Cbr(publishBotReaction);
            var news       = new NewsRu(publishBotReaction);
            var prime      = new PrimeRu(publishBotReaction);
            var sport      = new Sport(publishBotReaction);
            var utkin      = new Utkin(publishBotReaction);
            var nike       = new Nike(publishBotReaction);
            var legislat   = new Legislation(publishBotReaction);
            var reebok     = new Reebok(publishBotReaction);
            var newbalance = new Newbalance(publishBotReaction);
            var answers    = new List <IBotAnswer>()
            {
                hellow, Say, weather, vedomosti, dw, cbr, news, prime, sport, utkin, nike, legislat, reebok, newbalance
            };
            var asker = new Asker(answers);



            pollingWatcher.OnMessageArrived += (msg) =>
            {
                Console.WriteLine($"{msg.text} from {msg.from.username} with id { msg.chat.id} {msg.from.id} ");

                if (msg.text == "/start")
                {
                    publishBotReaction.SendMessage("Приветствую вас! Я  готов к работе. Команды бота:\n1) Скажи погоду: [место].\n2)Скажи информацию про состояние атмосферы в городе: [название города].\n3)Сколько времени в городе: [название города].\nСобытия в мире экономики по версии:\n4)Газета ведомости -\n/EconomicsVedomosti.\n5)Cайт dw.com\n/EconomicsDw\n6)Сайт ЦБ РФ-\n/EconomicsCbr.\n7)Сайт news.ru-\n/EconomicsNewsRu.\n8)Сайт 1prime.ru-\n/EconomicsPrimeRu.\nНОВОСТИ СПОРТА:\n9)Cайт sports.ru-\n/SportsNews\n10)Блог Уткина-\n/UtkinSportsNews\nНОВЫЕ ЗАКОНЫ:\n11)Сайт с обновлениями законодательства РФ-\n/LegislationChanges.\nНОВОСТИ БРЕНДОВ ОДЕЖДЫ:\n12)Nike-\n/NikenewsFeed\n13)Reebok-\n/ReebokNewsGlobal\n14)NewBalance-\n/NewBalanceNewsMarket.", msg.chat.id);
                }



                TimeAnswer response = new TimeAnswer(publishBotReaction, msg);
                response.CanWork(msg.text);
                if (response.CanWork(msg.text) == true)
                {
                    response.Answer();
                }
                asker.Ask(msg.text, msg);
            };

            pollingWatcher.StartWatch(cancellationTokenSource.Token);

            var stop = Console.ReadLine();

            if (stop == "stop bot")
            {
                Console.WriteLine("Работа Бота остановлена. Сохранение.");
                cancellationTokenSource.Cancel();

                chatBotState.SaveState();
            }
        }
Example #8
0
 public Legislation(TelegramChatMessagePublisher publish)
 {
     this.publish = publish;
 }
Example #9
0
 public Reebok(TelegramChatMessagePublisher publish)
 {
     this.publish = publish;
 }
Example #10
0
 public Vedomosti(TelegramChatMessagePublisher publish)
 {
     this.publish = publish;
 }
Example #11
0
 public HellowAnswer(TelegramChatMessagePublisher publish)
 {
     this.publish = publish;
 }
Example #12
0
 public SayUserInformation(TelegramChatMessagePublisher publish)
 {
     this.publish = publish;
 }
Example #13
0
 public PrimeRu(TelegramChatMessagePublisher publish)
 {
     this.publish = publish;
 }
Example #14
0
 public EconomicsDw(TelegramChatMessagePublisher publish)
 {
     this.publish = publish;
 }
Example #15
0
 public NewsRu(TelegramChatMessagePublisher publish)
 {
     this.publish = publish;
 }