MadelineProto
Async PHP client API for the telegram MTProto protocol
Install / Use
/learn @danog/MadelineProtoREADME
MadelineProto, a PHP MTProto telegram client
Created by <a href="https://daniil.it" target="_blank" rel="noopener">Daniil Gentili</a>
#StandWithUkraine 🇺🇦
Do join the official channel, @MadelineProto and the support groups!
<a href="https://telegram.org/apps" target="_blank" rel="noopener">Approved by Telegram!</a>
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
// PHP 8.2+ is required.
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->start();
$me = $MadelineProto->getSelf();
$MadelineProto->logger($me);
if (!$me['bot']) {
$MadelineProto->messages->sendMessage(peer: '@stickeroptimizerbot', message: "/start");
$MadelineProto->channels->joinChannel(channel: '@MadelineProto');
try {
$MadelineProto->messages->importChatInvite(hash: 'https://t.me/+Por5orOjwgccnt2w');
} catch (\danog\MadelineProto\RPCErrorException $e) {
$MadelineProto->logger($e);
}
}
$MadelineProto->echo('OK, done!');
Try running 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).
Made with MadelineProto
The following open source projects were created using MadelineProto: you can directly install them, or explore the source code as direct examples on how to use MadelineProto's many features!
- magnaluna webradio - Multifeatured Telegram VoIP webradio
simpleBot.php- Extremely basic exampletgstories_dl_bot.php- Source code of @tgstories_dl_bot - Bot to download any Telegram Story!downloadRenameBot.php- Download files by URL and rename Telegram files using this async parallelized bot!secret_bot.php- Secret chat bot!pipesbot.php- Creating inline bots and using other inline bots via a userbot!bot.php- Examples for how to use filters, updates, get download links for any file, Telegram Stories and much more!
Want to add your own open-source project to this list? Click here!
Some of MadelineProto's core components are also available as separate, standalone libraries:
- danog/async-orm - Async ORM based on AMPHP v3 and fibers.
- danog/telegram-entities - A library to work with Telegram UTF-16 styled text entities.
- danog/tg-file-decoder - A library to work with Telegram bot API file IDs.
- danog/tg-dialog-id - A library to work with Telegram bot API dialog IDs.
- danog/loop - Loop/actor model abstraction for AMPHP.
- danog/better-prometheus - A better Prometheus library for PHP applications.
- danog/ipc - Async IPC component for AMPHP.
- danog/dns-over-https - Async DNS-over-HTTPS resolution for AMPHP.
Documentation
- Creating a client - This page explains how to create a MadelineProto instance.
- Login - There are many ways you can login with MadelineProto.
- Features - MadelineProto can do everything official clients can do, and more!
- Requirements - MadelineProto requires the mbstring, xml, json, fileinfo, gmp, openssl, iconv, gd extensions to function properly.
- MadelineProto on Docker - MadelineProto offers an official MadelineProto docker image for the linux/amd64, linux/arm64 and linux/riscv64 platforms @ hub.madelineproto.xyz/danog/madelineproto.
- Metrics - MadelineProto can expose many useful metrics, that can be visualized using the official MadelineProto Grafana dashboard.
- Installation - There are various ways to install MadelineProto:
- Broadcasting messages to all users - MadelineProto can be used to broadcast messages to all users, chats and channels of a bot or userbot.
- Handling updates (new messages & other events) - Update handling can be done in different ways:
- Async Event driven
- Webhook (for HTTP APIs)
- getUpdates (only for Javascript APIs)
- Noop (default)
- danog\MadelineProto\Broadcast\Progress » - Broadcast progress.
- danog\MadelineProto\EventHandler\AbstractMessage » - Represents an incoming or outgoing message.
- danog\MadelineProto\EventHandler\AbstractPrivateMessage » - Represents a private or secret chat message.
- danog\MadelineProto\EventHandler\AbstractStory » - Represents a Telegram Story.
- danog\MadelineProto\EventHandler\BotCommands » - The command set of a certain bot in a certain chat has changed.
- danog\MadelineProto\EventHandler\CallbackQuery » - Represents a query sent by the user by clicking on a button.
- [danog\MadelineProto\EventHandler\Channel\ChannelParticipant &ra
Related Skills
node-connect
333.7kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
82.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
333.7kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
82.0kCommit, push, and open a PR
