PWRTelegram API canale italiano
45 subscribers
1 photo
1 file
48 links
Canale ufficiale della bot API PWRTelegram.

Creatore: @danogentili

Gruppo italiano: @pwrtelegramgroupita

Canale inglese: @pwrtelegram

Istruzioni d'installazione: https://pwrtelegram.xyz

Codice sorgente: https://github.com/pwrtelegram
Download Telegram
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!
❤️❤️❤️
🦄
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!
PWRTelegram API canale italiano pinned «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…»
Forwarded from MadelineProto | Official Channel (Daniil Gentili)
MadelineProto was updated (8.0.0-beta101)!

After introducing plugins », bound methods », filters », a built-in cron system », IPC support for the event handler » and automatic static analysis for event handler code » in beta100, beta101 brings some bugfixes and the getDownloadLink function!

getDownloadLink can be used to fetch a direct download link for any file up to 4GB, even using a bot API file ID!

Other features:
- Added an openFileAppendOnly function, that can be used to asynchronously open a file in append-only mode!

Fixes:
- Improved the markdownEscape function!
- Translated even more MadelineProto UI elements!
- Improve the static analyzer.
- Made some fixes to simple filters.
- Relax markdown parser.


Here's an example on how to use the new getDownloadLink() function:

<?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->start();

$link = $MadelineProto->getDownloadLink($MessageMedia);


$MessageMedia can be a a media object or even a bot API file ID (files up to 4GB are supported!).

You can also use the new getDownloadLink() bound method:

class MyEventHandler extends SimpleEventHandler {
/**
* Gets a download link for any file up to 4GB!
*/
#[FilterCommand('dl')]
public function downloadLink(Incoming&Message $message): void
{
if (!$message->replyToMsgId) {
$message->reply("This command must reply to a media message!");
return;
}
$message = $message->getReply();
if (!$message instanceof Message || !$message->media) {
$message->reply("This command must reply to a media message!");
return;
}
$message->reply("Download link: ".$message->media->getDownloadLink());
}
}


In both cases, the download link will be generated automatically if running via web.

If running via cli (or if URL rewriting is enabled), an additional step is required, see the documentation for more info.
MadelineProto now has alpha support for Telegram Stories in 8.0.0-beta113!

New Methods:
- users.getStoriesMaxIDs
- account.invalidateSignInCodes
- contacts.editCloseFriends
- contacts.toggleStoriesHidden
- channels.clickSponsoredMessage
- stories.sendStory
- stories.editStory
- stories.deleteStories
- stories.togglePinned
- stories.getAllStories
- stories.getUserStories
- stories.getPinnedStories
- stories.getStoriesArchive
- stories.getStoriesByID
- stories.toggleAllStoriesHidden
- stories.getAllReadUserStories
- stories.readStories
- stories.incrementStoryViews
- stories.getStoryViewsList
- stories.getStoriesViews
- stories.exportStoryLink
- stories.report

New Constructors:
- inputMediaStory
- messageMediaStory
- updateStory
- updateReadStories
- updateStoryID
- inputPrivacyKeyAbout
- privacyKeyAbout
- inputPrivacyValueAllowCloseFriends
- privacyValueAllowCloseFriends
- webPageAttributeStory
- messageReplyStoryHeader
- messagePeerVote
- messagePeerVoteInputOption
- messagePeerVoteMultiple
- sponsoredWebPage
- storyViews
- storyItemDeleted
- storyItemSkipped
- storyItem
- userStories
- stories.allStoriesNotModified
- stories.allStories
- stories.stories
- stories.userStories
- storyView
- stories.storyViewsList
- stories.storyViews
- inputReplyToMessage
- inputReplyToStory
- exportedStoryLink

Changed Constructors:
Added close_friend param to user
Added stories_hidden param to user
Added stories_unavailable param to user
Added stories_max_id param to user
Added alt_document param to messageMediaDocument
Added stories_muted param to inputPeerNotifySettings
Added stories_hide_sender param to inputPeerNotifySettings
Added stories_sound param to inputPeerNotifySettings
Added stories_muted param to peerNotifySettings
Added stories_hide_sender param to peerNotifySettings
Added stories_ios_sound param to peerNotifySettings
Added stories_android_sound param to peerNotifySettings
Added stories_other_sound param to peerNotifySettings
Added stories_pinned_available param to userFull
Added stories param to userFull
Added peer param to updateMessagePollVote
Removed user_id param from updateMessagePollVote
Added nosound param to documentAttributeVideo
Added preload_prefix_size param to documentAttributeVideo
Added stories_preload param to autoDownloadSettings
Added small_queue_active_operations_max param to autoDownloadSettings
Added large_queue_active_operations_max param to autoDownloadSettings
Added chats param to messages.votesList
Added keep_archived_unmuted param to globalPrivacySettings
Added keep_archived_folders param to globalPrivacySettings
Added webpage param to sponsoredMessage
Added my param to messagePeerReaction
Forwarded from MadelineProto | Official Channel (Daniil Gentili)
MadelineProto was updated (8.0.0-beta115)!

Features:
- You can now get direct download links for or directly download stories, check out the open-source MadelineProto-based @tgstories_dl_bot to download any Telegram story!
- Added support for parse_mode parsing for story methods.
- getReply now simply returns null if the message doesn't reply to any other message.
- getReply now has an optional parameter that can be used to filter the returned message type.
- Added isSelfUser(), isSelfBot() messages to check whether the current user is a user or a bot.
- Improved IDE typehinting.
- CLI bots: you can now optionally specify a default download link URL (used by getDownloadLink) in the settings.
- Added DialogMessagePinned service message with a getPinnedMessage() method.

Fixes:
- Fixed simple filters with service messages.
- Fixed IDE typehinting for getEventHandler.
- Fixed startAndLoopMulti.
- Tweaked the default drop timeout on media DCs to avoid timeout errors on slow networks.
- Now the admin list only contains user report peers.
- Make markdownEscape method accessible.
- Fixed getDownloadLink for non-event-handler web IPC instances.
Forwarded from MadelineProto | Official Channel (Daniil Gentili)
You can now download any Telegram Story using @tgstories_dl_bot!

Just send it a /dlStory @username command, and it will generate download links for all stories on the user's profile!

@tgstories_dl_bot is powered by @MadelineProto, and it's fully open source!
Forwarded from MadelineProto | Official Channel (Daniil Gentili)
As a birthday present for Telegram's 🥳th birthday, MadelineProto now supports VoIP calls again!

Try calling the Magna Luna webradio @magicalcrazypony to hear some cool songs, powered by @MadelineProto!

The new MadelineProto VoIP implementation is written in pure PHP, so it works even on free webhosts!

Check out the new VoIP documentation for more info on how to write your very own Telegram webradio using MadelineProto!

Features (8.0.0-beta131):
- VoIP calls!
- You can now play() audio files of any format, local files, stream URLs or even stream data using AMP streams!
- You can now play() audio files even on webhosts, by pre-converting the files using @libtgvoip_bot!
- Added a downloadToReturnedStream method!
- Updated to layer 161!

New Methods:
- contacts.setBlocked
- stories.activateStealthMode
- stories.sendReaction

Changed Methods:
Added my_stories_from param to contacts.block
Added my_stories_from param to contacts.unblock
Added my_stories_from param to contacts.getBlocked
Added media_areas param to stories.sendStory
Added media_areas param to stories.editStory
Added just_contacts param to stories.getStoryViewsList
Added reactions_first param to stories.getStoryViewsList
Added q param to stories.getStoryViewsList
Added offset param to stories.getStoryViewsList
Removed offset_date param from stories.getStoryViewsList
Removed offset_id param from stories.getStoryViewsList

New Constructors:
- updateStoriesStealthMode
- updateSentStoryReaction
- storiesStealthMode
- mediaAreaCoordinates
- mediaAreaVenue
- inputMediaAreaVenue
- mediaAreaGeoPoint

Changed Constructors:
Added blocked_my_stories_from param to userFull
Added blocked_my_stories_from param to updatePeerBlocked
Added reactions_count param to storyViews
Added media_areas param to storyItem
Added sent_reaction param to storyItem
Added stealth_mode param to stories.allStoriesNotModified
Added stealth_mode param to stories.allStories
Added blocked param to storyView
Added blocked_my_stories_from param to storyView
Added reaction param to storyView
Added reactions_count param to stories.storyViewsList
Added next_offset param to stories.storyViewsList

Fixes:
- Greatly improved performance by deferring all ORM operations!
- CDN fixes!
- Fix connection to the database when a password is accidentally provided but none is needed
- Removed all generator polyfilling code and deprecated generator functions!


As a side note, I'm very happy of how the current VoIP implementation turned out, and it was a lot of fun to write!

Adding native webhost support required me to write a pure PHP OGG OPUS muxer and demuxer, as well as a full reimplementation of the GrVP protocol in pure PHP: doing it in such a high-level language allowed me to easily use amphp's libraries to easily add support for URLs, streams and all audio formats.

I also wrote a PHP FFI wrapper for libopus for this project, I'll probably split it to a separate package along with the OGG muxer/demuxer because it's really useful :)
Please open Telegram to view this post
VIEW IN TELEGRAM
Forwarded from Daniil Gentili's news channel (Daniil Gentili)
I'm very happy to announce the first release of https://github.com/danog/php-tokio: you can now use any async Rust library from PHP!

It's fully integrated with revolt: this allows full compatibility with amphp, PSL and reactphp, and with any Rust library powered by tokio.rs.

Here's an example from the repo, using the async Rust reqwest library to make asynchronous HTTP requests from PHP:

<?php

use Reqwest\Client;

use function Amp\async;
use function Amp\Future\await;

require 'vendor/autoload.php';

Client::init();

function test(int $delay): void {
$url = "https://httpbin.org/delay/$delay";
$t = time();
echo "Making async reqwest to $url that will return after $delay seconds...".PHP_EOL;
Client::get($url);
$t = time() - $t;
echo "Got response from $url after ~".$t." seconds!".PHP_EOL;
};

$futures = [];
$futures []= async(test(...), 5);
$futures []= async(test(...), 5);
$futures []= async(test(...), 5);

await($futures);

I'm really excited for the potential usecases of php-tokio, and its implications for the PHP async ecosystem.

I've created this library because I'm building an async MongoDB client for PHP (https://github.com/Nicelocal/mongo-php-async-driver), and realized that using the official rust mongodb library directly from PHP would be way easier (and faster!) than writing a MongoDB client in pure PHP :)
PWRTelegram API canale italiano pinned «I'm very happy to announce the first release of https://github.com/danog/php-tokio: you can now use any async Rust library from PHP! It's fully integrated with revolt: this allows full compatibility with amphp, PSL and reactphp, and with any Rust library…»
Forwarded from MadelineProto | Official Channel (Daniil Gentili)
MadelineProto was updated!

8.0.0 is the first stable release of MadelineProto v8!

For the full changelog, see the messages on the official MadelineProto channel, starting from here!

Here are the main highlights:
- Amp v3 & revolt (fibers) support!
- A new simplified, stable and object-oriented event handler API based on filters and plugins!
- New sendVideo, sendAudio, sendDocument, etc methods with automatic metadata extraction via ffmpeg.
- A new getDownloadLink method for files up to 4gb!
- A new broadcast API, that can be used to asynchronously broadcast messages to all users of a bot or userbot in the background, automatically fetching all users of the bot!
- A pure PHP async VoIP implementation to make Telegram voice calls even on limited webhosts!
- An official docker image!
- Built-in static analysis of event handler code!
- Major performance and stability improvements!
- Many other new features and UX improvements, see all messages starting from https://tttttt.me/MadelineProto/591 for more info!

Major parts of the MadelineProto core were split into standalone libraries that can be used without requiring all of MadelineProto:
- https://github.com/danog/AsyncOrm - Async ORM based on AMPHP v3 and fibers.
- https://github.com/danog/telegram-entities - A library to work with Telegram UTF-16 styled text entities.
- https://github.com/danog/tg-file-decoder - A library to work with Telegram bot API file IDs (recently updated).


The next releases will focus on even more features and performance improvements, such as prometheus and grafana statistics, a static TL parser and much, much more!

Cheers!