2018-04-11 14:17:45 +02:00
---
title: Using methods
description: There are simplifications for many, if not all of, these methods.
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
---
2018-04-01 13:19:25 +02:00
# Using methods
There are simplifications for many, if not all of, these methods.
2019-06-23 13:07:51 +02:00
A list of all of the methods that can be called with MadelineProto can be found here: [here (layer 100) ](https://docs.madelineproto.xyz/API_docs/ ).
2018-04-11 14:17:45 +02:00
2019-06-01 18:08:28 +02:00
[Now fully async! ](https://docs.madelineproto.xyz/docs/ASYNC.html )
2018-06-29 13:59:08 +02:00
* [FULL API Documentation with descriptions ](https://docs.madelineproto.xyz/API_docs/methods/ )
2018-04-01 13:19:25 +02:00
* [Peers ](#peers )
2018-04-11 14:17:45 +02:00
* [Files ](https://docs.madelineproto.xyz/docs/FILES.html )
2018-04-01 13:19:25 +02:00
* [Secret chats ](#secret-chats )
* [Entities (Markdown & HTML) ](#entities )
* [reply_markup (keyboards & inline keyboards) ](#reply_markup )
* [bot API objects ](#bot-api-objects )
* [No result ](#no-result )
* [Queues ](#queues )
2019-06-05 18:39:04 +02:00
* [Multiple method calls ](#multiple-method-calls )
2018-04-01 13:19:25 +02:00
## Peers
[Full example ](https://github.com/danog/MadelineProto/blob/master/bot.php )
If an object of type User, InputUser, Chat, InputChannel, Peer or InputPeer must be provided as a parameter to a method, you can substitute it with the user/group/channel's username (`@username`), bot API id (`-1029449`, `1249421` , `-100412412901` ), or update.
```php
2019-06-01 18:08:28 +02:00
yield $MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => 'Testing MadelineProto...']);
2018-04-01 13:19:25 +02:00
```
If you want to check if a bot API id is a supergroup/channel ID:
```php
2019-10-29 22:23:35 +01:00
$Bool = yield $MadelineProto->isSupergroup($id);
2018-04-01 13:19:25 +02:00
```
Uses logarithmic conversion to avoid problems on 32 bit systems.
If you want to convert an MTProto API id to a supergroup/channel bot API ID:
```php
2019-10-29 22:23:35 +01:00
$bot_api_id = yield $MadelineProto->toSupergroup($id);
2018-04-01 13:19:25 +02:00
```
Uses logarithmic conversion to avoid problems on 32 bit systems.
## Secret chats
[Full example ](https://github.com/danog/MadelineProto/blob/master/secret_bot.php )
If an object of type InputSecretChat must be provided as a parameter to a method, you can substitute it with the secret chat's id, the updateNewEncrypted message or the decryptedMessage:
```php
2019-06-01 18:08:28 +02:00
yield $MadelineProto->messages->sendEncrypted(['peer' => $update, 'message' => ['_' => 'decryptedMessage', 'ttl' => 0, 'message' => 'Hi']]);
2018-04-01 13:19:25 +02:00
```
## Entities
[Full example ](https://github.com/danog/MadelineProto/blob/master/tests/testing.php )
Methods that allow sending message entities ([messages.sendMessage](http://docs.madelineproto.xyz/API_docs/methods/messages_sendMessage.html) for example) also have an additional `parse_mode` parameter that enables or disables html/markdown parsing of the message to be sent.
```php
2019-06-01 18:08:28 +02:00
yield $MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => '[Testing Markdown in MadelineProto](https://docs.madelineproto.xyz)', 'parse_mode' => 'Markdown']);
yield $MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => '< a href = "https://docs.madelineproto.xyz" > Testing HTML in MadelineProto< / a > ', 'parse_mode' => 'HTML']);
2018-04-01 13:19:25 +02:00
```
## reply_markup
reply_markup accepts bot API reply markup objects as well as MTProto ones.
```php
$bot_API_markup = ['inline_keyboard' =>
[
[
['text' => 'MadelineProto docs', 'url' => 'https://docs.madelineproto.xyz'],
['text' => 'MadelineProto channel', 'url' => 'https://t.me/MadelineProto']
]
]
];
2019-06-01 18:08:28 +02:00
yield $MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => 'lel', 'reply_markup' => $bot_API_markup]);
2018-04-01 13:19:25 +02:00
```
## Bot API objects
To convert the results of methods to bot API objects you must provide a second parameter to method wrappers, containing an array with the `botAPI` key set to true.
```php
2019-06-01 18:08:28 +02:00
$bot_API_object = yield $MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => 'lel'], ['botAPI' => true]);
2018-04-01 13:19:25 +02:00
```
MadelineProto also [supports bot API file IDs when working with files ](FILES.html )
## No result
2019-06-01 17:42:45 +02:00
Also see [ignored async ](https://docs.madelineproto.xyz/docs/ASYNC.html#ignored-async ).
2018-04-01 13:19:25 +02:00
To disable fetching the result of a method, the array that must be provided as second parameter to method wrapper must have the `noResponse` key set to true.
```php
2019-06-01 18:08:28 +02:00
yield $MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => 'lel'], ['noResponse' => true]);
2018-04-01 13:19:25 +02:00
```
2019-05-04 12:15:39 +02:00
## Queues
2019-06-01 17:42:45 +02:00
Method calls may be executed at diferent times server-side: to avoid this, method calls can be queued (this is especially useful when using [ignored async ](https://docs.madelineproto.xyz/docs/ASYNC.html#ignored-async )):
2018-04-01 13:19:25 +02:00
```php
2019-06-01 18:08:28 +02:00
yield $MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => 'lel'], ['queue' => 'queue_name']);
2018-04-01 13:19:25 +02:00
```
If the queue if the specified queue name does not exist, it will be created.
2019-06-05 18:39:04 +02:00
## Multiple method calls
See [multiple async ](https://docs.madelineproto.xyz/docs/ASYNC.html#multiple-async ).
2019-03-08 14:35:09 +01:00
< a href = "https://docs.madelineproto.xyz/docs/CONTRIB.html" > Next section< / a >