mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-30 10:38:59 +01:00
docs@c60f59ffe2 | ||
lua | ||
src | ||
tests | ||
userbots | ||
.babelrc | ||
.env.example | ||
.gitignore | ||
.gitmodules | ||
.php_cs.dist | ||
.travis.yml | ||
asyncify.php | ||
bot.php | ||
build_docs.php | ||
CHANGELOG.md | ||
CODE_OF_CONDUCT.md | ||
combined_bot.php | ||
composer.json | ||
CONTRIBUTING.md | ||
index.php | ||
input.raw | ||
layerdiff.php | ||
LICENSE | ||
magna.php | ||
makephar.php | ||
mtproxyd | ||
phar.php | ||
README.md | ||
secret_bot.php | ||
songs.php | ||
translator.php |
MadelineProto, a PHP MTProto telegram client
Created by Daniil Gentili
Do join the official channel, @MadelineProto and the support groups!
What's this?
This library can be used to easily interact with Telegram without the bot API, just like the official apps.
It can login with a phone number (MTProto API), or with a bot token (MTProto API, no bot API involved!).
Getting started (now fully async!)
<?php
if (!file_exists('madeline.php')) {
copy('https://phar.madelineproto.xyz/madeline.php', 'madeline.php');
}
include 'madeline.php';
$MadelineProto = new \danog\MadelineProto\API('session.madeline');
$MadelineProto->async(true);
$MadelineProto->loop(function () use ($MadelineProto) {
yield $MadelineProto->start();
$me = yield $MadelineProto->get_self();
$MadelineProto->logger($me);
if (!$me['bot']) {
yield $MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => "Hi!\nThanks for creating MadelineProto! <3"]);
yield $MadelineProto->channels->joinChannel(['channel' => '@MadelineProto']);
try {
yield $MadelineProto->messages->importChatInvite(['hash' => 'https://t.me/joinchat/Bgrajz6K-aJKu0IpGsLpBg']);
} catch (\danog\MadelineProto\RPCErrorException $e) {
$MadelineProto->logger($e);
}
yield $MadelineProto->messages->sendMessage(['peer' => 'https://t.me/joinchat/Bgrajz6K-aJKu0IpGsLpBg', 'message' => 'Testing MadelineProto!']);
}
yield $MadelineProto->echo('OK, done!');
});
Try this code now! or run this code in a browser or in a console.
Tip: if you receive an error (or nothing), send us the error message and the MadelineProto.log
file that was created in the same directory (if running from a browser).
Documentation
- Async
- Creating a client
- Login
- Features
- Requirements
- Installation
- Handling updates (new messages)
- Settings
- Getting info about the current user
- Exceptions
- Avoiding FLOOD_WAITs
- Logging
- Telegram VoIP phone calls
- Uploading and downloading files
- Getting info about chats
- Getting all chats (dialogs)
- [Inline buttons (now fully async!)](https://docs.madelineproto.xyz/docs/INLINE_BUTTONS.html)
- Secret chats
- Lua binding
- Using a proxy
- Using methods
- FULL API Documentation with descriptions
- Logout
- Login
- Change 2FA password
- Get all chats, broadcast a message to all chats
- Get the full participant list of a channel/group/supergroup
- Get full info about a user/chat/supergroup/channel
- Get info about a user/chat/supergroup/channel
- Get info about the currently logged-in user
- Upload or download files up to 1.5 GB
- Make a phone call and play a song
- Create a secret chat bot
- Peers
- Files
- Secret chats
- Entities (Markdown & HTML)
- reply_markup (keyboards & inline keyboards)
- bot API objects
- No result
- Queues
- Multiple method calls
- FULL API Documentation with descriptions
- Contributing
- Web templates for
$MadelineProto->start()
Very complex and complete examples
You can find examples for nearly every MadelineProto function in
tests/testing.php
- examples for making/receiving calls, making secret chats, sending secret chat messages, videos, audios, voice recordings, gifs, stickers, photos, sending normal messages, videos, audios, voice recordings, gifs, stickers, photos.bot.php
- examples for sending normal messages, downloading any mediasecret_bot.php
- secret chat botmagna.php
- examples for receiving callsuserbots/pipesbot.php
- examples for creating inline bots and using other inline bots via a userbotuserbots/MadelineProto_bot.php
- Multi-function botuserbots/pwrtelegram_debug_bot
- Multi-function bot