Forwarded from Daniil Gentili
Daniil Gentili The first series of posts I'll be adding here will be some technical deep dives into the performance improvements I've made in Psalm v6, can't wait to share them all with you!
PW @pwrtelegram
Forwarded from Daniil Gentili
Daniil Gentili The first series of posts I'll be adding here will be some technical deep dives into the performance improvements I've made in Psalm v6, can't wait to share them all with you!
Forwarded from Daniil Gentili
Forwarded from Daniil Gentili
Forwarded from MadelineProto | Official Channel (Daniil Gentili)
Forwarded from MadelineProto | Official Channel (Daniil Gentili)
$deleteHistory flag to discardSecretChat!Forwarded from MadelineProto | Official Channel (Daniil Gentili)
Forwarded from Daniil Gentili's news channel (Daniil Gentili)
<?phpI'm really excited for the potential usecases of php-tokio, and its implications for the PHP async ecosystem.
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);
Forwarded from Daniil Gentili's news channel (Daniil Gentili)
<?phpI'm really excited for the potential usecases of php-tokio, and its implications for the PHP async ecosystem.
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);
Forwarded from MadelineProto | Official Channel (Daniil Gentili)
play() audio files of any format, local files, stream URLs or even stream data using AMP streams!play() audio files even on webhosts, by pre-converting the files using @libtgvoip_bot!downloadToReturnedStream method!MadelineProto | Official Channel 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)
Forwarded from MadelineProto | Official Channel (Daniil Gentili)
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.isSelfUser(), isSelfBot() messages to check whether the current user is a user or a bot.getDownloadLink) in the settings.DialogMessagePinned service message with a getPinnedMessage() method.getEventHandler.markdownEscape method accessible.getDownloadLink for non-event-handler web IPC instances.
MadelineProto | Official Channel 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…
Forwarded from MadelineProto | Official Channel (Daniil Gentili)
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!openFileAppendOnly function, that can be used to asynchronously open a file in append-only mode!markdownEscape function!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!).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. Forwarded from MadelineProto | Official Channel (Daniil Gentili)
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!openFileAppendOnly function, that can be used to asynchronously open a file in append-only mode!markdownEscape function!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!).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. Forwarded from MadelineProto | Official Channel (Daniil Gentili)
MadelineProto | Official Channel 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…
getDownloadLink method and much more!Forwarded from MadelineProto | Official Channel (Daniil Gentili)
plugins/Danogentili/PingPlugin.php file: <?php declare(strict_types=1);And use a plugin base to run all plugins included in the
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");
}
}
plugins folder. reply(), delete(), getReply(), getHTML() and simplified properties like chatId, senderId, command, commandArgs and many more, see the documentation for more info!Cron attribute are now automatically invoked by MadelineProto every period seconds: use danog\MadelineProto\EventHandler\Attributes\Cron;See the documentation for more info!
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)."!");
}
}
getEventHandler() on an API instance, see the docs for more info!