MadelineProto Italia | Canale ufficiale
147 subscribers
1 photo
1 file
42 links
Canale ufficiale di MadelineProto.
Canale inglese: @MadelineProto
Gruppo: @pwrtelegramgroupita
Download Telegram
Forwarded from MadelineProto | Official Channel (Daniil Gentili)
First of all, madelineTon.js:

A pure JS client-side implementation of the Telegram TON blockchain protocol.

Interact directly with the TON blockchain with no middlemans, directly from your browser!

This is possible thanks to a client-side implementation of the ADNL P2P protocol (whitepaper).
Connection to the liteservers is made through a simple websocket proxy that simply acts as a TCP <=> websocket proxy.

All cryptography is done exclusively in the browser, allowing fully secure interaction with the chosen TON node.

The client is fully asynchronous, making use of workers and/or browser webcrypto APIs for cryptography (curves & AES).

TL, ECC w/ TON ADNL, BOC deserialization is implemented.

Possible applications are entirely client-side off-chain components for a distributed TON project; API explorers; and much more!
Forwarded from MadelineProto | Official Channel (Daniil Gentili)
Installation:

yarn add madeline-ton
Forwarded from MadelineProto | Official Channel (Daniil Gentili)
madelineTon.js is actually based on yet another project of mine, a pure JS Telegram MTProto client (madeline.js) which will be released soon ™️™️™️.
Forwarded from MadelineProto | Official Channel (Daniil Gentili)
Next, I am proud to announce support for the TON protocol in MadelineProto.

MadelineProto is now capable of integrating with the Telegram TON blockchain, thanks to a fully native implementation of ADNL and the lite-client protocol.

It allows async interaction with liteservers in the same manner as the official lite-client, only with way more abstractions and ease of use.
Forwarded from MadelineProto | Official Channel (Daniil Gentili)
Instantiation

use danog\MadelineProto\TON\API;

$API = new API(
[
'logger' => [
'logger' => Logger::ECHO_LOGGER
]
]
);


Usage:

$API->async(true);
$API->loop(
function () use ($API) {
yield $API->connect(__DIR__.'/ton-lite-client-test1.config.json');
var_dump(yield $API->liteServer->getTime());
}
);


For a full overview of async in MadelineProtoTon, take a look at the MadelineProto async docs.

For a full list of methods that can be used, simply look at the PHPDOC suggestions in your favorite IDE, or take a look at the ---functions--- section of the lite TL scheme (HTML docs coming soon).

This API can be used to build web-facing HTTP APIs that query the TON blockchain (using the async http-server), off-chain elements for TON applications and so much more!

Since it's in PHP & integrated in MadelineProto, you can also use it in free webhosts (aka use the blockchain on 000webhost AAAAAAAAA ❤️❤️❤️❤️❤️)
Forwarded from MadelineProto | Official Channel (Daniil Gentili)
Finally, feel free to take a look at my submission to the TON contest: https://github.com/danog/toncontest

The repository contains well-documented code for multiple TON smart contracts, a testing suite based on the official TON validator, and a build toolchain for TON.
Forwarded from MadelineProto | Official Channel (Daniil Gentili)
MadelineProto was updated to v5!

Introducing upload by URL, file renaming, parallelized downloads and uploads!

You can now use MadelineProto to rename Telegram files or upload them by URL: all uploads and downloads will be made 100% in parallel, 20 chunks at a time for maximum speed (value tweakable in the settings).
For more info, see the new file documentation.

Also introducing:
- Strictly typed, camelCase public API, now all methods can also be called in camelCase, with PHP type hinting for most parameters and return values.
- Full PHPDOC documentation for all the public API, for perfect documentation in your favorite IDE :)
- Several internal bugfixes, refactoring and general performance and stability improvements.
- Improved tests, to avoid backwards compatiblity issues with previous sessions when pushing.
- Clean composer dependencies, now you just have to require danog/madelineproto ^5.0 and nothing else in your composer.json!

Breaking changes:
- NONE :D; you don't have to change your code!
Forwarded from MadelineProto | Official Channel (Daniil Gentili)
downloadRenameBot.php
7.3 KB
FREEBIES

Here's a fully parallelized file rename + URL download bot based on MadelineProto.

Max file size: 1.5GB

A working instance can be found here: @pwrtelegrambot
Auguri di buon anno a tutti!
❤️❤️❤️
In attesa di MadelineProto 6, ecco un paio di basi a plugin asincrone per MadelineProto:

realGuys/MadelineProtoPluginSystem - Una semplice ma potente base a plugin per MadelineProto

MohsenJS/MadelineProtoPluginSystem - Un sistema plugin per MadelienProto con supporto per pattern e conversazioni persistenti


Pingami pure nei gruppi se hai sviluppato qualcosa di open basato su MadelineProto, lo pubblicherò su questo canale e su @MadelineProto!
Forwarded from MadelineProto | Official Channel (Daniil Gentili)
MadelineProto was updated!

MadelineProto 6 introduces ultra-fast startup with a built-in IPC server, PHP transpilation using phabel.io, MySQL/Postgres/redis database support to reduce RAM usage, and new, IDE-friendly settings.

The main event:
- MadelineProto is now transpiled using phabel.io!

Phabel.io is a PHP transpiler that allows native usage of PHP 8+ features in projects and libraries, while allowing maintainers to publish a version targeting lower versions of php.
Async await syntax is also supported!

Usage:
composer require --dev phabel/phabel

You can now publish your packagist package, and it will be automatically transpiled to any PHP version supported by phabel.

After git tagging a new release, just run:

vendor/bin/phabel publish

💡 Your PHP 7 users can now install your PHP 8 library 💡
💡 All your dependencies will also be transpiled to the correct PHP version. 💡

Supported PHP versions:

Syntax/feature support:
- 8.0+
- async/await syntax

Target:
- 7.1+
- 🐘 5.6, 7.0 in final testing stage.
- 💡 5.4, 5.5 support coming soon!

- Now MadelineProto has a built-in IPC server, this means:

Very fast startup for small scripts: ~0.02 seconds, before was 1-5 seconds

To use this IPC server, just use MadelineProto normally:

$API = new \danog\MadelineProto\API('session.madeline');
$API->start();
$API->messages->sendMessage(['peer' => $_POST['peer'], 'message' => $_POST['message']]);

This is useful for small sendMessage.php scripts, to be called from outside; for maximum performance in bots use an async event handler.

- New IDE-friendly settings API!
- Async MySQL/Postgres/redis integration:

Use a database to reduce memory usage to 1-5 MB even for thousands of groups!
See here for examples and documentation.
Native database integration in the event handler is also now supported!

Other brand-new features in MadelineProto 6:
- New PHP API documentation
- Updated Telegram API to layer 131
- Updated tg-file-decoder library
- New localization keys for all UI elements
- New settings for custom HTML, Javascript and CSS in login page templates
- New PSR logger API
- New session conversion API

Coming up soon: **** **IP implementation ;)

Internal improvements:
- Many, many bugfixes, stability fixes and performance improvements
- RPC requests are containerized by default, when possible
- Complete refactoring of MTProto message subsystem
- Added a periodic garbage collector
- Implemented native PHP prime factorization (C++ factorization is still recommended using prime.madelineproto.xyz)
MadelineProto Italia | Canale ufficiale pinned «MadelineProto was updated! MadelineProto 6 introduces ultra-fast startup with a built-in IPC server, PHP transpilation using phabel.io, MySQL/Postgres/redis database support to reduce RAM usage, and new, IDE-friendly settings. The main event: - MadelineProto…»
Forwarded from MadelineProto | Official Channel (Daniil Gentili)
Introducing MadelineProto 7!

This update is mandatory for all MadelineProto users.

Due to 64-bit user IDs and Telegram's new API TOS, starting from January 1, 2022, old MadelineProto instances will stop working completely: even now, legacy instances can't login due to UPDATE_APP_TO_LOGIN errors.

If you're using MadelineProto 1 through 6, visit the releases page to view changelogs and upgrade tips.
You can also open an issue or visit the support group if you encounter issues while upgrading.

For most usecases, no changes are needed: however, graphical clients based on MadelineProto must implement sponsored messages.

Features:
- MadelineProto 7 provides a simple cached API to work with sponsored messages:
=> getSponsoredMessages
Get sponsored messages for channel, returns a list of sponsored message objects.
=> viewSponsoredMessage
Mark sponsored message as read.

Clients must then handle fetched sponsored messages as described in the API documentation.

- Layer 135! See the API documentation for a list of changed methods and constructors in layer 131-133.
Changes in layer 133-135:

Added methods:
- account.setAuthorizationTTL
- account.changeAuthorizationSettings
- messages.getSearchResultsCalendar
- messages.getSearchResultsPositions
- messages.hideChatJoinRequest
- messages.hideAllChatJoinRequests
- messages.toggleNoForwards
- messages.saveDefaultSendAs
- channels.getSendAs

Changed methods:
Renamed channels.deleteUserHistory to channels.deleteParticipantHistory; the old method still works.
Added base_theme param to account.installTheme
Added min_date, max_date params to messages.deleteHistory
Added send_as param to messages.sendMessage, messages.sendMedia, messages.sendMultiMedia, messages.forwardMessages, messages.sendInlineBotResult
Added request_needed, title params to messages.exportChatInvite, messages.editExportedChatInvite
Added requested, q params to messages.getChatInviteImporters
Renamed user_id=>participant in channels.reportSpam


Changed Constructors
Added requests_pending param to chatFull
Added recent_requesters param to chatFull
Added requests_pending param to channelFull
Added recent_requesters param to channelFull
Added default_send_as param to channelFull
Added request_chat_broadcast param to peerSettings
Added request_chat_title param to peerSettings
Added request_chat_date param to peerSettings
Added private_forward_name param to userFull
Added authorization_ttl_days param to account.authorizations
Added request_needed param to chatInviteExported
Added requested param to chatInviteExported
Added title param to chatInviteExported
Added request_needed param to chatInvite
Added about param to chatInvite
Added via_request param to channelParticipantSelf

New Constructors
- messageActionChatJoinedByRequest
- updatePendingJoinRequests
- updateBotChatInviteRequester
- inputKeyboardButtonUserProfile
- keyboardButtonUserProfile
- channelAdminLogEventActionParticipantJoinByRequest
- channelAdminLogEventActionToggleNoForwards
- channelAdminLogEventActionSendMessage

- New simplified EventHandler::startAndLoop API!
- Added support for t.me/+ invite links!
- New sponsored message API!
- Improved DB ORM API, used for example in the event handler!
- New FFI-based prime.madelineproto.xyz factorization module!
- An all new thread-safe madeline.php autoupdater!
- PHP 8.1 support!
- Zend hashmaps are now periodically reallocated to clean up RAM!

Deprecations:
- Dropped 32-bit support.
Android users can install 64-bit builds of php using Termux.
Raspberry pi users can use a 64-bit distro like archlinuxarm.org.
- madeline.php supports only php 7.1+
- composer supports only php 8+ (7.1+ support coming back soon)

Fixes:
- Fixed a side-channel reported by Theo von Arx and Kenneth G. Paterson @ ETH Zürich.

Internal improvements:
- Many, many internal bugfixes and performance improvements!
- Switched to the new RSA-OAEP-based authkey flow.
- Native openssl integration for faster crypto!
- Removed loads of legacy 32-bit hacks, greatly improving performance!
MadelineProto Italia | Canale ufficiale pinned «Introducing MadelineProto 7! This update is mandatory for all MadelineProto users. Due to 64-bit user IDs and Telegram's new API TOS, starting from January 1, 2022, old MadelineProto instances will stop working completely: even now, legacy instances can't…»
MadelineProto was updated (8.0.0-beta80)!

Features:
- Introducing a new broadcasting API!
- You can now specify a custom serializer type for your ORM properties (one of the variants of the SerializerType enum, or null to choose the best serializer automatically (the default)).

Fixes:
- The documentation was updated, including human-readable descriptions for the latest layer.
- Postgres now uses the new BYTEA amphp APIs
- Multiple fixes and improvements.
MadelineProto now offers a simple broadcast API, that can be used to asynchronously broadcast messages to all users of a bot or userbot in the background, without incurring in timeouts or other issues.

Note that unlike the bot API, MadelineProto can be used to fetch the full list of users, chats and channels of a normal bot, simply using its bot token.

Here's a simple example, explaining how to broadcast a message and a photo to every user of a bot:
<?php
if (!file_exists('madeline.php')) {
copy('https://phar.madelineproto.xyz/madeline.php', 'madeline.php');
}
include 'madeline.php';

$MadelineProto = new \danog\MadelineProto\API('bot.madeline');

// The UI will ask you to insert your bot token here
$MadelineProto->start();

$id = $MadelineProto->broadcastMessages([
['message' => 'This broadcast is powered by @MadelineProto!'],
['message' => 'This media broadcast is powered by @MadelineProto!', 'media' => [
'_' => 'inputMediaUploadedPhoto',
'file' => 'https://docs.madelineproto.xyz/logo-hover.png'
]],
]);

Here's a simplified example, just for bots:

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

$MadelineProto = new \danog\MadelineProto\API('bot.madeline');

$MadelineProto->botLogin('1234:token');

$id = $MadelineProto->broadcastMessages([
['message' => 'This broadcast is powered by @MadelineProto!'],
['message' => 'This media broadcast is powered by @MadelineProto!', 'media' => [
'_' => 'inputMediaUploadedPhoto',
'file' => 'https://docs.madelineproto.xyz/logo-hover.png'
]],
]);

You can also forward messages:

// Send messages, showing the "Forwarded from" header
$id = $MadelineProto->broadcastForwardMessages(
from_peer: 101374607,
message_ids: [1, 2, 3, 4],
drop_author: false,
);

// Send messages WITHOUT showing the "Forwarded from" header
$id = $MadelineProto->broadcastForwardMessages(
from_peer: 101374607,
message_ids: [1, 2, 3, 4],
drop_author: true,
);

The methods return an integer ID that can be used to:

- Get the current broadcast progress with getBroadcastProgress
- Cancel the broadcast using cancelBroadcast

Note that to avoid manually polling the progress, MadelineProto will also periodically emit updateBroadcastProgress updates to the event handler, containing a Progress object for all broadcasts currently in-progress.

Filtering is also available, as well as support for custom broadcast actions.

See here » for a full example of the broadcast API, and here » for the full documentation.
MadelineProto was updated (8.0.0-beta87)!

MadelineProto now offers an official docker image for the linux/amd64, linux/arm64 and linux/riscv64 platforms!

The image comes with all dependencies pre-configured.
Both opcache and JIT are enabled by default, for maximum performance!

To get started, install docker:

curl -fsSL https://get.docker.com | sudo sh


Then increase the max_map_count sysctl configuration to avoid "Fiber stack allocate failed" and "Fiber stack protect failed" errors, since the PHP engine mmaps two memory regions per fiber.

echo 262144 | sudo tee /proc/sys/vm/max_map_count
echo vm.max_map_count=262144 | sudo tee /etc/sysctl.d/40-madelineproto.conf


Then, create the following docker-compose.yml file:

services:
bot:
image: hub.madelineproto.xyz/danog/madelineproto
restart: unless-stopped
tty: true
volumes:
- .:/app
command: php /app/bot.php


Then, create a bot.php file with your code, and run this command to log into the bot:

docker run --rm -it --init -v $PWD:/app hub.madelineproto.xyz/danog/madelineproto php /app/bot.php


After logging in, press ctrl-c to close the temporary container.

Finally, simply run this command to start the bot in the background.

docker compose up --pull always -d


Use docker compose logs to view MadelineProto logs and docker compose ps to view the status of your bot!

See the documentation for more info about the docker image.

Other features:
- Add getType method
- Add support for emojis with <emoji id="1234">👍</emoji>, <tg-emoji emoji-id="1234>👍</tg-emoji> HTML tags and tg://emoji?id=1234 HTML/markdown links, in addition to the pre-existing emoji:id HTML/markdown links.
- Add showPrompt AppInfo setting, to allow throwing an exception instead of showing a readline/UI prompt if no API ID was configured.

Fixes:
- Change name of parameter of broadcastForwardMessages from ids to message_ids to avoid confusion.
MadelineProto Italia | Canale ufficiale pinned «MadelineProto now offers a simple broadcast API, that can be used to asynchronously broadcast messages to all users of a bot or userbot in the background, without incurring in timeouts or other issues. Note that unlike the bot API, MadelineProto can be used…»
Forwarded from MadelineProto | Official Channel (Daniil Gentili)
Introducing MadelineProto's biggest update yet, 8.0.0-beta100!

This version introduces plugins », bound methods », filters », a built-in cron system », IPC support for the event handler » and automatic static analysis for event handler code ».

See the following post for examples!

Other features:
- Thanks to the many translation contributors @ https://weblate.madelineproto.xyz/, MadelineProto is now localized in Hebrew, Persian, Kurdish, Uzbek, Russian, French and Italian!
- Added simplified sendMessage, sendDocument, sendPhoto methods that return abstract Message objects with simplified properties and bound methods!
- You can now use Tools::callFork to fork a new green thread!
- You can now automatically pin messages broadcasted using broadcastMessages, broadcastForwardMessages by using the new pin: true parameter!
- You can now use sendMessageToAdmins to send messages to the bot's admin (the peers returned by getReportPeers).
- Added wrapUpdate, wrapMessage, wrapMedia methods to wrap low-level MTProto updates into an abstracted Message object with bound methods!
- The waveform attribute of Voice objects is now automatically encoded and decoded to an array of 100 integer values!
- Added a custom PeerNotInDbException class for "This peer is not present in the internal peer database" errors
- Added a label property to the Button class, directly indicating the button label (instead of manually fetching it as an array key).
- Added isForum method to check whether a given supergroup is a forum
- Added an entitiesToHtml method to convert a message and a set of Telegram entities to an HTML string!
- You can now use reportMemoryProfile() to generate and send a pprof memory profile to all report peers to debug the causes of high memory usage.
- Added support for pay, loginurl, webapp and tg://user?id= buttons in bot API syntax!
- Added a getAdminIds function that returns the IDs of the admin of the bot (equal to the peers returned by getReportPeers in the event handler).
- Added a new ParseMode enum!
- Added support for HTML lists in parseMode!
- Fixed parsing of markdown code blocks!

Breaking changes:
- Switched to a custom markdown parser with bot API MarkdownV2 syntax, which differs from the previous Markdown syntax supported by parsedown.
- Markdown text can't contain HTML anymore.

Fixes:
- Fixed file uploads with ext-uv!
- Fixed file re-uploads!
- Improve background broadcasting with the broadcast API using a pre-defined list of whitelist IDs!
- Fixed a bug that caused updates to get paused if an exception is thrown during onStart.
- Broadcast IDs are now unique across multiple broadcasts, even if previous broadcasts already completed their ID will never be re-used.
- Now uploadMedia, sendMedia and upload can upload files from string buffers created using ReadableBuffer.
- Reduced memory usage during flood waits by tweaking config defaults.
- Reduced memory usage by clearing the min database automatically as needed.
- Automatically try caching all dialogs if a peer not found error is about to be thrown.
- Fixed some issues with pure phar installs.
- Fixed splitting of HTML and markdown messages
- Fixed formatting of multiline markdown codeblocks
- And many other performance improvements and bugfixes!
Forwarded from MadelineProto | Official Channel (Daniil Gentili)
Here's a more detailed explanation of the most important new features of MadelineProto 8.0.0-beta100!

- Native plugin system

To create a plugin, simply create an event handler that extends PluginEventHandler.

For example, create a plugins/Danogentili/PingPlugin.php file:

<?php declare(strict_types=1);

namespace MadelinePlugin\Danogentili\PingPlugin;

use danog\MadelineProto\PluginEventHandler;
use danog\MadelineProto\EventHandler\Filter\FilterText;
use danog\MadelineProto\EventHandler\Message;
use danog\MadelineProto\EventHandler\SimpleFilter\Incoming;

class PingPlugin extends PluginEventHandler
{
#[FilterCommand('echo')]
public function echoCmd(Incoming & Message $message): void
{
// Contains the arguments of the command
$args = $message->commandArgs;

$message->reply($args[0] ?? '');
}

#[FilterRegex('/.*(mt?proto).*/i')]
public function testRegex(Incoming & Message $message): void
{
$message->reply("Did you mean to write MadelineProto instead of ".$message->matches[1].'?');
}

#[FilterText('ping')]
public function pingCommand(Incoming&Message $message): void
{
$message->reply("Pong");
}
}


And use a plugin base to run all plugins included in the plugins folder.

See the documentation for more info on how to create MadelineProto plugins!

- Message objects with bound methods

Both plugins and normal bots can make use of bound update methods like reply(), delete(), getReply(), getHTML() and simplified properties like chatId, senderId, command, commandArgs and many more, see the documentation for more info!

- Filters

Plugins and bots can now use three different filtering systems, to easily receive only updates satisfying certain conditions (incoming/outgoing, from group, channel, private, from an admin or a specific peer, with an audio/sticker/..., satisfying a certain regex or a certain /command, and much more!), see the documentation for more info!

- Built-in cron system

All event handler methods marked by the Cron attribute are now automatically invoked by MadelineProto every period seconds:

use danog\MadelineProto\EventHandler\Attributes\Cron;

class MyEventHandler extends SimpleEventHandler
{
/**
* This cron function will be executed forever, every 60 seconds.
*/
#[Cron(period: 60.0)]
public function cron1(): void
{
$this->sendMessageToAdmins("The bot is online, current time ".date(DATE_RFC850)."!");
}
}


See the documentation for more info!

- IPC support for the event handler

You can now call event handler and plugin methods from outside of the event handler, using getEventHandler() on an API instance, see the docs for more info!

- Automatic static analysis of event handler code

Finally, all new bots and plugins will be automatically analyzed by MadelineProto, blocking execution if performance or security issues are detected!

See the documentation for info!