1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-30 09:38:57 +01:00
This commit is contained in:
Daniil Gentili 2023-06-25 15:33:14 +02:00
parent 2e4d79c94e
commit 70e645373c
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
3 changed files with 4 additions and 38 deletions

2
docs

@ -1 +1 @@
Subproject commit e9367965d55d24b1c415cd9aa288eac10e02a28d
Subproject commit 57e8692da7a9c79ae82026b575cc1f527384d028

View File

@ -19,14 +19,12 @@
use danog\MadelineProto\Broadcast\Progress;
use danog\MadelineProto\Broadcast\Status;
use danog\MadelineProto\Db\DbArray;
use danog\MadelineProto\EventHandler;
use danog\MadelineProto\Logger;
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\Settings\Database\SerializerType;
// If a stable version of MadelineProto was installed via composer, load composer autoloader
if (file_exists('vendor/autoload.php')) {
@ -40,6 +38,8 @@ if (file_exists('vendor/autoload.php')) {
}
/**
* Event handler class.
*
* All properties are automatically stored in the database.
*/
class MyEventHandler extends EventHandler
{
@ -49,44 +49,10 @@ class MyEventHandler extends EventHandler
const ADMIN = "@me"; // !!! Change this to your username !!!
/**
* List of properties automatically stored in database (MySQL, Postgres, redis or memory).
*
* Note that **all** class properties will be stored in the database, regardless of whether they're specified here.
* The only difference is that properties *not* specified in this array will also always have a full copy in RAM.
*
* Also, properties specified in this array are NOT thread-safe, meaning you should also use a synchronization primitive
* from https://github.com/amphp/sync/ to use them in a thread-safe manner (i.e. when checking-and-setting with isset=>set, et cetera).
*
* Remember: **ALL** onUpdate... handler methods are called in separate green threads, so at the end of the day,
* unless your property is too large to be comfortably stored in memory (say >100MB), you should use normal properties to avoid race conditions.
*
* @see https://docs.madelineproto.xyz/docs/DATABASE.html
*/
protected static array $dbProperties = [
'dataStoredOnDb' => ['serializer' => SerializerType::SERIALIZE],
];
/**
* Use this *only* if the data you will store here is huge (>100MB).
* @var DbArray<array-key, array>
*/
protected DbArray $dataStoredOnDb;
/**
* Otherwise use this.
* This property is also saved in the db, but it's also always kept in memory, unlike $dataStoredInDb which is exclusively stored in the db.
*/
protected array $dataAlsoStoredOnDbAndInRam = [];
/**
* This property is also saved in the db, but it's also always kept in memory, unlike $dataStoredInDb which is exclusively stored in the db.
* @var array<int, bool>
*/
protected array $notifiedChats = [];
/**
* This property is also saved in the db, but it's also always kept in memory, unlike $dataStoredInDb which is exclusively stored in the db.
*/
private int $adminId;
/**

View File

@ -29,7 +29,7 @@ use const PHP_SAPI;
/**
* Basic exception.
*/
final class Exception extends \Exception
class Exception extends \Exception
{
use TL\PrettyException;
public function __toString(): string