S
S
Senseich2018-02-28 13:39:33
C++ / C#
Senseich, 2018-02-28 13:39:33

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

1 answer(s)
G
GavriKos, 2018-02-28
@GavriKos

If my update_id of the last post is 969654771,

Show with your finger, where is the check for this condition in the code?
And no, the code works completely differently.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question