mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-30 06:18:58 +01:00
Fixes
This commit is contained in:
parent
392ecdf08c
commit
df1019c941
@ -17,15 +17,17 @@ Features:
|
||||
- Added support for `pay`, `login_url`, `web_app` and `tg://user?id=` buttons in bot API syntax!
|
||||
- Added a `getAdmin` function that returns the ID of the admin of the bot (which is equal to the first peer returned by getReportPeers in the event handler).
|
||||
- getPlugin can now be used from IPC clients!
|
||||
- `getReply`, `sendMessage`, `reply`
|
||||
- `getReply`, `sendMessage`, `sendDocument`, `sendPhoto`, `reply`, `delete`
|
||||
|
||||
Fixes:
|
||||
- Fixed file uploads with ext-uv!
|
||||
- Many performance improvements and bugfixes!
|
||||
- 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`.
|
||||
- Reduce memory usage during flood waits by tweaking config defaults.
|
||||
- Reduce 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
|
||||
- Fix some issues with pure phar installs
|
||||
- And many performance improvements and bugfixes!
|
||||
|
@ -22,7 +22,6 @@
|
||||
use danog\MadelineProto\API;
|
||||
use danog\MadelineProto\Broadcast\Progress;
|
||||
use danog\MadelineProto\Broadcast\Status;
|
||||
use danog\MadelineProto\EventHandler;
|
||||
use danog\MadelineProto\EventHandler\Attributes\Cron;
|
||||
use danog\MadelineProto\EventHandler\Attributes\Handler;
|
||||
use danog\MadelineProto\EventHandler\Filter\FilterCommand;
|
||||
@ -34,6 +33,7 @@ use danog\MadelineProto\Settings;
|
||||
use danog\MadelineProto\Settings\Database\Mysql;
|
||||
use danog\MadelineProto\Settings\Database\Postgres;
|
||||
use danog\MadelineProto\Settings\Database\Redis;
|
||||
use danog\MadelineProto\SimpleEventHandler;
|
||||
|
||||
// MadelineProto is already loaded
|
||||
if (class_exists(API::class)) {
|
||||
@ -52,7 +52,7 @@ if (class_exists(API::class)) {
|
||||
*
|
||||
* All properties returned by __sleep are automatically stored in the database.
|
||||
*/
|
||||
class MyEventHandler extends EventHandler
|
||||
class MyEventHandler extends SimpleEventHandler
|
||||
{
|
||||
/**
|
||||
* @var int|string Username or ID of bot admin
|
||||
@ -145,11 +145,9 @@ class MyEventHandler extends EventHandler
|
||||
if (!isset($this->notifiedChats[$message->chatId])) {
|
||||
$this->notifiedChats[$message->chatId] = true;
|
||||
|
||||
$this->messages->sendMessage(
|
||||
peer: $message->chatId,
|
||||
$message->reply(
|
||||
message: "This userbot is powered by [MadelineProto](https://t.me/MadelineProto)!",
|
||||
reply_to_msg_id: $message->id,
|
||||
parse_mode: 'Markdown'
|
||||
parseMode: 'Markdown'
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -170,11 +168,7 @@ class MyEventHandler extends EventHandler
|
||||
// We can broadcast messages to all users.
|
||||
if ($message->senderId === $this->adminId) {
|
||||
if (!$message->replyToMsgId) {
|
||||
$this->messages->sendMessage(
|
||||
peer: $message->senderId,
|
||||
message: "You should reply to the message you want to broadcast.",
|
||||
reply_to_msg_id: $message->id,
|
||||
);
|
||||
$message->reply("You should reply to the message you want to broadcast.");
|
||||
return;
|
||||
}
|
||||
$this->broadcastForwardMessages(
|
||||
@ -190,7 +184,7 @@ class MyEventHandler extends EventHandler
|
||||
#[FilterText('ping')]
|
||||
public function pingCommand(Incoming&Message $message): void
|
||||
{
|
||||
$this->messages->sendMessage(['message' => 'pong', 'peer' => $message->chatId]);
|
||||
$message->reply('pong');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,7 @@ use PhpParser\Node\Expr\Include_;
|
||||
use PhpParser\Node\Expr\New_;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Scalar\LNumber;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PhpParser\Node\Stmt\DeclareDeclare;
|
||||
use PhpParser\NodeFinder;
|
||||
use PhpParser\NodeVisitor\NameResolver;
|
||||
@ -470,7 +471,11 @@ abstract class EventHandler extends AbstractAPI
|
||||
}
|
||||
}
|
||||
|
||||
if ($finder->findFirstInstanceOf($file, Include_::class)) {
|
||||
/** @var Include_ $include */
|
||||
$include = $finder->findFirstInstanceOf($file, Include_::class);
|
||||
if ($include
|
||||
&& !($include->expr instanceof String_ && \in_array($include->expr->value, ['vendor/autoload.php', 'madeline.php', 'madeline.phar'], true))
|
||||
) {
|
||||
throw new AssertionError("An error occurred while analyzing plugin $class: for performance reasons, plugins can only automatically include or require other files present in the plugins folder by triggering the PSR-4 autoloader (not by manually require()'ing them).");
|
||||
}
|
||||
}
|
||||
|
@ -487,9 +487,12 @@ final class MTProto implements TLCallback, LoggerGetter
|
||||
|
||||
$initDeferred = new DeferredFuture;
|
||||
$this->initPromise = $initDeferred->getFuture();
|
||||
try {
|
||||
$this->initialize($settings);
|
||||
} finally {
|
||||
$initDeferred->complete();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialization function.
|
||||
@ -976,6 +979,7 @@ final class MTProto implements TLCallback, LoggerGetter
|
||||
$deferred = new DeferredFuture;
|
||||
$this->initPromise = $deferred->getFuture();
|
||||
|
||||
try {
|
||||
// Cleanup old properties, init new stuffs
|
||||
$this->cleanupProperties();
|
||||
|
||||
@ -1048,9 +1052,10 @@ final class MTProto implements TLCallback, LoggerGetter
|
||||
foreach ($this->broadcasts as $broadcast) {
|
||||
$broadcast->resume();
|
||||
}
|
||||
|
||||
} finally {
|
||||
$deferred->complete();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Unreference instance, allowing destruction.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user