•  


Using methods Link Search Menu Expand Document

Using methods

There are simplifications for many, if not all of, these methods.

A list of all of the methods that can be called with MadelineProto can be found here: here (layer 179) .

Now fully async!

Named arguments

You must use named arguments instead of arrays to provide method arguments, which allows for much cleaner syntax:

$MadelineProto
->
messages
->
sendMessage
(
peer
:
 '@danogentili'
,
 message
:
 'Testing MadelineProto...'
);

Peers

Full example

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.

$MadelineProto
->
messages
->
sendMessage
(
peer
:
 '@danogentili'
,
 message
:
 'Testing MadelineProto...'
);

Secret chats

Full example 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:

$MadelineProto
->
messages
->
sendEncrypted
(
peer
:
 $update
,
 message
:
 [
'_'
 =>
 'decryptedMessage'
,
 'ttl'
 =>
 0
,
 'message'
 =>
 'Hi'
]);

Entities

Full example Methods that allow sending message entities ( messages.sendMessage for example) also have an additional parse_mode parameter that enables or disables html/markdown parsing of the message to be sent.

$MadelineProto
->
messages
->
sendMessage
(
peer
:
 '@danogentili'
,
 message
:
 '[Testing Markdown in MadelineProto](https://docs.madelineproto.xyz)'
,
 parse_mode
:
  'Markdown'
);

$MadelineProto
->
messages
->
sendMessage
(
peer
:
 '@danogentili'
,
 message
:
 '<a href="https://docs.madelineproto.xyz">Testing HTML in MadelineProto</a>'
,
 parse_mode
:
  'HTML'
);

reply_markup

reply_markup accepts bot API reply markup objects as well as MTProto ones.

$bot_API_markup
 =
 [
'inline_keyboard'
 =>
 
    [

        [

            [
'text'
 =>
 'MadelineProto docs'
,
 'url'
 =>
 'https://docs.madelineproto.xyz'
],

            [
'text'
 =>
 'MadelineProto channel'
,
 'url'
 =>
 'https://t.me/MadelineProto'
]

        ]

    ]

];

$MadelineProto
->
messages
->
sendMessage
(
peer
:
 '@danogentili'
,
 message
:
 'lel'
,
 reply_markup
:
 $bot_API_markup
);

Bot API objects

To convert the results of methods to bot API objects you can use the MTProtoToBotAPI method.

$bot_API_object
 =
 $MadelineProto
->
MTProtoToBotAPI
(
$MadelineProto
->
messages
->
sendMessage
(
peer
:
 '@danogentili'
,
 message
:
 'lel'
));

MadelineProto also supports bot API file IDs when working with files

No result

See ignored async .

Multiple method calls

See multiple async .

Cancellation

See cancellation » .

Next section


- "漢字路" 한글한자자동변환 서비스는 교육부 고전문헌국역지원사업의 지원으로 구축되었습니다.
- "漢字路" 한글한자자동변환 서비스는 전통문화연구회 "울산대학교한국어처리연구실 옥철영(IT융합전공)교수팀"에서 개발한 한글한자자동변환기를 바탕하여 지속적으로 공동 연구 개발하고 있는 서비스입니다.
- 현재 고유명사(인명, 지명등)을 비롯한 여러 변환오류가 있으며 이를 해결하고자 많은 연구 개발을 진행하고자 하고 있습니다. 이를 인지하시고 다른 곳에서 인용시 한자 변환 결과를 한번 더 검토하시고 사용해 주시기 바랍니다.
- 변환오류 및 건의,문의사항은 juntong@juntong.or.kr로 메일로 보내주시면 감사하겠습니다. .
Copyright ⓒ 2020 By '전통문화연구회(傳統文化硏究會)' All Rights reserved.
 한국   대만   중국   일본