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); } } }
static void Main(string[] args) { var api = new TelegramAPI(); api.SendApiRequest("getMe"); //while (true) //{ // if (AnswerQuetion() == false) // { // break; // } //} Console.ReadLine(); }
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); } } }
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); } } }