A wrapper for the Telegram getUpdates function to retrieve messages sent to your bot.

This function invokes an asynchronous request to the Telegram API. To ensure successful sending of the message this function waits for the callback.


string apiKey

The Telegram bot API key

string authUser

A list of authorized users that shall be able to send commands to the bot. The list must be made of chat IDs or usernames separated by ';' like



Indicates if updates shall be confirmed or not. If set to true, once you retrieved one update, it will will be ignored in following TelegramGetUpdates calls. This is achieved via the offset option of the Telegram API.


A string containing three fields separated by '|':

  1. A number indicating if the request was successfully executed. 0 means success.
  2. Total number of retrieved updates
  3. List of commands from authorized users. List is seperated by ';'.

Definition of a Command

On the basis of original Telegram commands a message in Telegram4MQL is considered as a command if it is a text message starting with a "/" like "/command".

Code Example

Assuming that

  • you sent following messages to your Telegram Bot as user with chatID "abc"
    1. "Hello, this is a test!"
    2. "/some_command value,value,value"
    3. "/another_command more,more"
  • and another user with chatID "xyz" sent
    1. "/command_from_unauthorized_user value,value"

Then the execution of this code block will produce the following output:

void OnInit()
   string chatid = "abc";
   /* 1. Will return "0|4|/some_command value,value,value;/another_command more,more" */
   Print(TelegramGetUpdates(apikey, chatid, false));
   /* 2. Will return "0|4|/some_command value,value,value;/another_command more,more" */
   Print(TelegramGetUpdates(apikey, chatid, true));
   /* 3. Will return "0|0|" */
   Print(TelegramGetUpdates(apikey, chatid, true));

The first execution of TelegramGetUpdates returns "0" for successful execution, a total number of 4 received messages as well as the list of commands from authorized users.

The second execution received exactly the same output because the first was called with confirmUpdates = false.

The third received no messages because the second was called with confirmUpdates = true.