示例#1
0
        static void Main()
        {
            TelegramAPI api  = new TelegramAPI();
            string      path = @$ "{Environment.CurrentDirectory}\commandToAnswer.json";
            var         data = File.ReadAllText(path);

            commandToAnswer = JsonConvert.DeserializeObject <Dictionary <string, string> >(data);

            while (true)
            {
                var updates = api.GetUpdates();
                if (updates == null)
                {
                    continue;
                }

                foreach (var update in updates)
                {
                    if (string.IsNullOrEmpty(update.Message.Text) || update.UpdateId == null)
                    {
                        continue;
                    }

                    string answer = AnswerQuestion(update.Message.Text);

                    api.SendMessage(answer, update.Message.Chat.Id);

                    Thread.Sleep(4000);
                }
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            var api = new TelegramAPI();

            api.SendApiRequest("getMe");
            //while (true)
            //{
            //    if (AnswerQuetion() == false)
            //    {
            //        break;
            //    }
            //}
            Console.ReadLine();
        }
示例#3
0
        static void Main(string[] args)
        {
            var Api  = new TelegramAPI();
            var data = System.IO.File.ReadAllText(@"C:\Users\timelord\source\repos\TelegramBot\TelegramBot\Properties\questions.json");

            questions = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, string> >(data);

            while (true)
            {
                var updates = Api.getUpdates();

                foreach (var up in updates)
                {
                    var answer = AnswerQuestion(up.message.text);
                    Api.sendMessage(answer, up.message.chat.id);
                }
            }
        }
示例#4
0
        static void Main(string[] args)
        {
            var QuestionsAnswersFile = File.ReadAllText(QUETIONS_ANSWERS_DB, Encoding.Default);

            QuestionsAnswers = JsonConvert.DeserializeObject <Dictionary <string, string> >(QuestionsAnswersFile);

            Console.WriteLine(QuestionsAnswers);



            TelegramAPI Api = new TelegramAPI();

            while (true)
            {
                var updates = Api.GetUpdates();
                foreach (var update in updates)
                {
                    var answer = answerQuestion(update.message.text);
                    //var message = $"Dear, {update.message.chat.first_name}, {answer}";
                    Api.SenMessage(answer, update.message.chat.id);
                }
            }
        }