Answer the question
In order to leave comments, you need to log in
How does a simple while loop work in the telegram api example?
I deal with an example on a telegram bot. Tell me if I understand the work of the following code correctly, or rather, even the cycle itself.
Initially, the update_id = 0 variable was declared. If my last message's update_id is 969654771, it turns out that the loop runs the following line 969654771 times:
string url = $"{startUrl}/getUpdates?offset={updateid + 1}"
until it reaches this number? Do I understand correctly?int update_id = 0;
string messageFromId = "";
string messageText = "";
string token = "540661148";
WebClient webclient = new WebClient();
string startUrl = $"https://api.telegram.org/bot{token}";
while(true)
{
string url = $"{startUrl}/getUpdates?offset={update_id + 1}";
string response = webclient.DownloadString(url);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question