Get Mystery Box with random crypto!

MadelineProto | Official Channel

Logo of telegram channel madelineproto — MadelineProto | Official Channel M
Logo of telegram channel madelineproto — MadelineProto | Official Channel
Channel address: @madelineproto
Categories: Technologies
Language: English
Subscribers: 5.42K
Description from channel

Official MadelineProto channel.
Italian Channel: @MadelineProtoIta
Group: @pwrtelegramgroup

Ratings & Reviews

2.67

3 reviews

Reviews can be left only by registered users. All reviews are moderated by admins.

5 stars

1

4 stars

0

3 stars

0

2 stars

1

1 stars

1


The latest Messages 3

2020-12-31 22:30:33 The pony behind MadelineProto officially wishes everyone a very happy 2021, with lots of interesting new APIs, languages and juicy CS theory.

As a new year's present, I've actually finished the composer integration in phabel, and stabilized the transpiler API to fully integrate it in the next release of MadelineProto.
15.1K viewsDaniil Gentili, 19:30
Open / Comment
2020-09-30 21:25:01 All main MadelineProto 6 features are ready, release coming as soon as I finish the phabel transpiler ;)
19.9K viewsDaniil Gentili, 18:25
Open / Comment
2020-08-23 19:52:02 While we all wait for MadelineProto 6, here are a few really neat fully async plugin sources for MadelineProto:


realGuys/MadelineProtoPluginSystem - A simple to use yet powerful async plugin MadelineProto source base

MohsenJS/MadelineProtoPluginSystem - A MadelineProto plugin system with support for patterns and conversations


Feel free to ping me in the groups if you have developed anything else based on MadelineProto, I will publish it on this channel!
23.5K viewsDaniil Gentili, edited  16:52
Open / Comment
2020-05-20 15:54:19 PSA: please DO NOT remove the madeline.phar.version and madeline.phar files in your sources.

This will greatly slow down your source on each startup, and it has already caused me some issues due to excessive composer install reports.

Please, remove all unlink('madeline.phar'); unlink('madeline.phar.version'); codes from your sources.
31.0K viewsDaniil Gentili, 12:54
Open / Comment
2020-03-15 22:10:02 On the importance of logging.

For a programmer, programming without logs is like driving with closed eyes: at any moment you could crash against a wall, and you wouldn't even see it coming.

Many times I see MadelineProto users asking me for help, saying that their "bots don't work" or "it worked yesterday", often blaming me for their mistakes.

This is precisely why you need logging: with logging, you can figure out exactly what went wrong in your (or my!) code, and fix the error immediately.

MadelineProto now allows automatic error reporting with full logs and exception traces as soon as the script crashes (automatically recovering the bot from any errors).
It is enabled if you use getReportPeers + startAndLoop: it is a very useful feature for devs, and can help you to find and fix problems before they are noticed by your users.

Resources:
- Error reporting
- Logging
- Exceptions
37.2K viewsDaniil Gentili, 19:10
Open / Comment
2020-03-15 22:05:02 Among other new features, the onStart async method can be used to execute methods on bot startup (instead of calling $MadelineProto->loop() outside of the bot).
25.3K viewsDaniil Gentili, 19:05
Open / Comment
2020-03-15 22:00:03 MadelineProto 5.1 introduces one especially useful feature: native error reporting.

Native error reporting greatly simplifies the development process of MadelineProto bots.
Simply by specifying the username of the bot admin, all errors raised by the bot (or MadelineProto itself!) are automatically reported to the admin, along with the logfile.

Starting with this version of MadelineProto, doing unlink('MadelineProto.log'); will crash MadelineProto.
If you need to reduce the size of the logfile, change $settings['logger']['max_size'] (minimum 100kb = 100*1000).

Here is an example source for MadelineProto 5.1:


if (!file_exists('madeline.php')) {
copy('https://phar.madelineproto.xyz/madeline.php', 'madeline.php');
}
include 'madeline.php';

use danog\MadelineProto\EventHandler;
use danog\MadelineProto\Tools;
use danog\MadelineProto\API;
use danog\MadelineProto\Logger;
use danog\MadelineProto\RPCErrorException;

/**
* Event handler class.
*/
class MyEventHandler extends EventHandler
{
/**
* @var int|string Username or ID of bot admin
*/
const ADMIN = "danogentili"; // Change this
/**
* Get peer(s) where to report errors
*
* @return int|string|array
*/
public function getReportPeers()
{
return [self::ADMIN];
}
/**
* Called on startup, can contain async calls for initialization of the bot
*
* @return void
*/
public function onStart()
{
}
/**
* Handle updates from supergroups and channels
*
* @param array $update Update
*
* @return void
*/
public function onUpdateNewChannelMessage(array $update): \Generator
{
return $this->onUpdateNewMessage($update);
}
/**
* Handle updates from users.
*
* @param array $update Update
*
* @return \Generator
*/
public function onUpdateNewMessage(array $update): \Generator
{
if ($update['message']['_'] === 'messageEmpty' || $update['message']['out'] ?? false) {
return;
}
$res = \json_encode($update, JSON_PRETTY_PRINT);

try {
yield $this->messages->sendMessage(['peer' => $update, 'message' => "$res", 'reply_to_msg_id' => $update['message']['id'] ?? null, 'parse_mode' => 'HTML']);
if (isset($update['message']['media']) && $update['message']['media']['_'] !== 'messageMediaGame') {
yield $this->messages->sendMedia(['peer' => $update, 'message' => $update['message']['message'], 'media' => $update]);
}
} catch (RPCErrorException $e) {
$this->report("Surfaced: $e");
} catch (Exception $e) {
if (\stripos($e->getMessage(), 'invalid constructor given') === false) {
$this->report("Surfaced: $e");
}
}
}
}

$settings = [];

$MadelineProto = new API('bot.madeline', $settings);
$MadelineProto->startAndLoop(MyEventHandler::class);


The new startAndLoop method automatically initializes MadelineProto, enables async, logs in the user/bot, initializes error reporting, catches and reports all errors surfacing from the event loop to the peers returned by the getReportPeers method.

It also contributes to slashing boilerplate, removing all the $MadelineProto->loop() stuff that cluttered even simple codebases.
23.9K viewsDaniil Gentili, 19:00
Open / Comment
2020-03-15 20:00:02 > What is AMPHP (https://amphp.org)?

Amp is a non-blocking concurrency framework for PHP providing primitives to manage concurrency such as an event loop, promises, and asynchronous iterators.

> OK, in simpler words?

AMPHP is a high-performance, parallelized PHP library that allows you to write extremely fast, efficient programs that work in parallel using green threads.

> * b r a i n m e l t *

Y E S

———

MadelineProto is not written in PHP: MadelineProto is written using AMPHP.
What this means is that when you using MadelineProto (and async is enabled), all incoming messages are handled in parallel, each in a separate thread, even on webhosts.

This allow your bots to always be responsive, even while executing complex tasks.

However, it is vital that you also use AMPHP (not PHP!) when writing your bot.
What this means is that the following PHP functions and extensions cannot be used in MadelineProto bots (otherwise, all the benefits of AMPHP would be nullified): instead, you must use the correct AMPHP library (automatically included in madeline.php).

file_get_contents
amphp/file for files, amphp/http-client and $MadelineProto->fileGetContents for URLs

curl, guzzle
amphp/http-client is async, much faster than other libraries, and also supports HTTP/2!

mysqli, PDO, sqlite
amphp/mysql supports both MySQL and SQLite backends, and is fully async!
You can also use amphp/postgres and amphp/redis for PostgreSQL and Redis!

php-fpm
amphp/http-server is a high-performance async HTTP/2 server, that can be interfaced with MadelineProto to create file download servers!

include, require
Don't use this function very often, and most importantly, don't use it inside of the event handler code.
You should use it only once on bot startup, or else when reloading the bot (plugin source coming soon!)

———

In short, AMPHP is an awesome framework for using async PHP in 2020: you can join the official Telegram support group @amphpchat if you have any questions or suggestions on what else to add to AMPHP!
21.8K viewsDaniil Gentili, 17:00
Open / Comment
2020-03-15 19:38:58 I will also be posting MadelineProto and AMPHP tips on @MadelineProto more regularly, starting very soon.
12.5K viewsDaniil Gentili, edited  16:38
Open / Comment
2020-03-15 19:37:45 I'm also announcing some updates for the MadelineProto social channels.

- Introducing separate OT chat groups, to allow chatting about tech, politics and memes.
- Introducing a new international MadelineProto support group, for MadelineProto help and support.
- Finally introducing the official MadelineProto meme channel, full of only the dankest based memes!
- Introducing an official discussion group for AMPHP, the async, high-performance parallelized PHP library!

Also, finally introducing an official farsi MadelineProto channel: @madeline_farsi.
This channel will post farsi translations of the posts sent on the main channel, along with MadelineProto sources, AMPHP tips and much more!

Also, check out the official arabic MadelineProto channel: @madelineArabic
16.0K viewsDaniil Gentili, edited  16:37
Open / Comment