PWRTelegram API channel
721 subscribers
12 photos
1 video
7 files
166 links
Official channel for the PWRTelegram bot API.

Installation instructions: https://pwrtelegram.xyz

Creator: @danogentili

Official support group: @pwrtelegramgroup

Italian channel: @pwrtelegramita

Source code: https://github.com/pwrtelegram
Download Telegram
#coolmpstuff
MadelineProto is the most powerful mtproto client out there, and can do everything official telegram apps can do, but one of its most awesome features is the ability to stream files directly from telegram to your browser, without storing them in your hard drive!
This can be done easily with one line of code:

$MadelineProto->download_to_stream($file_id, fopen('php://output', 'w'), function ($percent) { flush(); ob_flush(); });

This one liner downloads (without the bot API, it downloads and decrypts the file in real time from telegram!) the given $file_id (that can be an mtproto file id or a bot API file id; both users and bots can use these file ids in MadelineProto, thanks to the built in conversion module!) to php://output (the browser), and every time a chunk is downloaded the callable provided as third parameter is called: as you can see, it accepts a parameter, $percentage: this number is a floating point number that represents the download status, the flush functions are called to send the file to the browser.
You can also resume downloads, by downloading only certain parts of the file: to see how to do that, and for many more examples see the documentation: Daniil.it/MadelineProto
#coolmpstuff

Here's how you can click buttons using MadelineProto (assuming you have received an http://daniil.it/MadelineProto/API_docs/constructors/updateNewMessage.html or an http://daniil.it/MadelineProto/API_docs/constructors/updateNewChannelMessage.html and that the reply_markup contains a valid keyboard)

$result = $Update['message']['reply_markup']['rows'][$row_number]['buttons'][$button_number]->click()




$result can be one of the following:

A string - If the button is a keyboardButtonUrl

Updates - If the button is a keyboardButton, the message will be sent to the chat, in reply to the message with the keyboard

messages_BotCallbackAnswer - If the button is a keyboardButtonCallback or a keyboardButtonGame the button will be pressed and the result will be returned

false - If the button is an unsupported button, like keyboardButtonRequestPhone, keyboardButtonRequestGeoLocation, keyboardButtonSwitchInlinekeyboardButtonBuy; you will have to parse data from these buttons manually
Forwarded from MadelineProto | Official Channel (Daniil Gentili)
#coolmpstuff
You can export your telegram authorization from MadelineProto using

$authorization = $MadelineProto->export_authorization();


The exported
$authorization

will be an array with two values:

- a number (the DC ID)
- a 256 byte string (the auth key, cannot be encoded with json)

You can pass the returned $authorization to another instance of MadelineProto using $MadelineProto->import_authorization($authorization), just make sure to delete the original instance, or else both instances will stop working.

You can also use import_authorization to import authorization from another telegram client.
For example, you could export the authKey and the dcID from a webogram instance, and import it into madeline.
Just make sure to export the auth key of the main authorized DC (the one to which you get redirected when you call users.getUsers on yourself).
Forwarded from MadelineProto | Official Channel (Daniil Gentili)
#coolmpstuff
You can queue method calls using a synchronized queue.
When making multiple method calls, to make sure the methods are executed in order, you can use a synchronized server-side queue.

For example, if you're sending messages with an increasing number, loaded from a shared state from two separate madeline processes, to make sure the numbers are actually sent in order using the queuename queue do the following:

$MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => $number], ['queue' => 'queuename']);


queuename can be any valid string.
If such a queue doesn't exist, it will be created.