mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-26 23:14:38 +01:00
42 lines
1.4 KiB
PHP
42 lines
1.4 KiB
PHP
<?php declare(strict_types=1);
|
|
|
|
if (file_exists('vendor/autoload.php')) {
|
|
require_once 'vendor/autoload.php';
|
|
} else {
|
|
// Otherwise download an !!! alpha !!! version of MadelineProto via madeline.php
|
|
if (!file_exists('madeline.php')) {
|
|
copy('https://phar.madelineproto.xyz/madeline.php', 'madeline.php');
|
|
}
|
|
require_once 'madeline.php';
|
|
}
|
|
|
|
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\SimpleEventHandler;
|
|
|
|
/** Base event handler class that only includes plugins */
|
|
class BaseHandler extends SimpleEventHandler
|
|
{
|
|
public static function getPluginPaths(): array|string|null
|
|
{
|
|
return 'plugins/';
|
|
}
|
|
}
|
|
|
|
$settings = new Settings;
|
|
$settings->getLogger()->setLevel(Logger::LEVEL_ULTRA_VERBOSE);
|
|
|
|
// You can also use Redis, MySQL or PostgreSQL
|
|
// $settings->setDb((new Redis)->setDatabase(0)->setPassword('pony'));
|
|
// $settings->setDb((new Postgres)->setDatabase('MadelineProto')->setUsername('daniil')->setPassword('pony'));
|
|
// $settings->setDb((new Mysql)->setDatabase('MadelineProto')->setUsername('daniil')->setPassword('pony'));
|
|
|
|
// For users or bots
|
|
BaseHandler::startAndLoop('bot.madeline', $settings);
|
|
|
|
// For bots only
|
|
// BaseHandler::startAndLoopBot('bot.madeline', 'bot token', $settings);
|