2019-01-07 13:24:29 +01:00
|
|
|
<?php
|
|
|
|
|
2023-04-11 01:56:45 +02:00
|
|
|
use danog\MadelineProto\Logger;
|
|
|
|
use TelegramApiServer\EventObservers\LogObserver;
|
|
|
|
|
2020-01-19 04:17:14 +01:00
|
|
|
$settings = [
|
2019-06-20 18:51:58 +02:00
|
|
|
'server' => [
|
2023-04-11 01:56:45 +02:00
|
|
|
'address' => (string)getenv('SERVER_ADDRESS'),
|
|
|
|
'port' => (int)getenv('SERVER_PORT'),
|
2019-01-07 13:24:29 +01:00
|
|
|
],
|
|
|
|
'telegram' => [
|
|
|
|
'app_info' => [ // obtained in https://my.telegram.org
|
2023-04-11 01:56:45 +02:00
|
|
|
'api_id' => (int)getenv('TELEGRAM_API_ID'),
|
|
|
|
'api_hash' => (string)getenv('TELEGRAM_API_HASH'),
|
2019-01-07 13:24:29 +01:00
|
|
|
],
|
|
|
|
'logger' => [ // Logger settings
|
2023-04-11 01:56:45 +02:00
|
|
|
'logger' => Logger::CALLABLE_LOGGER, // 0 - Logs disabled, 3 - echo logs.
|
|
|
|
'logger_param' => LogObserver::class . '::log',
|
|
|
|
'logger_level' => (int)getenv('LOGGER_LEVEL'), // Logging level, available logging levels are: ULTRA_VERBOSE - 5, VERBOSE - 4 , NOTICE - 3, WARNING - 2, ERROR - 1, FATAL_ERROR - 0.
|
2019-01-07 13:24:29 +01:00
|
|
|
],
|
2019-12-28 23:23:46 +01:00
|
|
|
'updates' => [
|
|
|
|
'handle_updates' => true, // Should I handle updates?
|
|
|
|
'handle_old_updates' => false, // Should I handle old updates on startup?
|
|
|
|
],
|
2019-01-07 13:24:29 +01:00
|
|
|
'connection_settings' => [
|
|
|
|
'all' => [
|
2019-06-30 02:47:22 +02:00
|
|
|
'proxy' => '\SocksProxy',
|
2019-03-19 00:36:20 +01:00
|
|
|
'proxy_extra' => [
|
2023-04-11 01:56:45 +02:00
|
|
|
'address' => (string)getenv('TELEGRAM_PROXY_ADDRESS'),
|
|
|
|
'port' => (int)getenv('TELEGRAM_PROXY_PORT'),
|
2019-03-19 00:36:20 +01:00
|
|
|
'username' => getenv('TELEGRAM_PROXY_USERNAME'),
|
|
|
|
'password' => getenv('TELEGRAM_PROXY_PASSWORD'),
|
2019-01-07 13:24:29 +01:00
|
|
|
]
|
2020-11-09 11:28:28 +01:00
|
|
|
],
|
|
|
|
'media_socket_count' => [
|
|
|
|
'max' => 50
|
2019-01-07 13:24:29 +01:00
|
|
|
]
|
2019-04-19 14:49:01 +02:00
|
|
|
],
|
2019-03-31 03:24:23 +02:00
|
|
|
'serialization' => [
|
2020-10-07 02:00:50 +02:00
|
|
|
'serialization_interval' => 30,
|
2019-06-22 19:16:31 +02:00
|
|
|
'cleanup_before_serialization' => true,
|
2019-03-31 03:24:23 +02:00
|
|
|
],
|
2020-04-26 20:50:42 +02:00
|
|
|
'db' => [
|
|
|
|
'type' => getenv('DB_TYPE'),
|
2020-10-03 01:50:56 +02:00
|
|
|
getenv('DB_TYPE') => [
|
2023-04-11 01:56:45 +02:00
|
|
|
'host' => (string)getenv('DB_HOST'),
|
|
|
|
'port' => (int)getenv('DB_PORT'),
|
2020-10-03 01:50:56 +02:00
|
|
|
'user' => getenv('DB_USER'),
|
|
|
|
'password' => getenv('DB_PASSWORD'),
|
|
|
|
'database' => getenv('DB_DATABASE'),
|
2023-04-11 01:56:45 +02:00
|
|
|
'max_connections' => (int)getenv('DB_MAX_CONNECTIONS'),
|
|
|
|
'idle_timeout' => (int)getenv('DB_IDLE_TIMEOUT'),
|
2020-10-03 01:50:56 +02:00
|
|
|
'cache_ttl' => getenv('DB_CACHE_TTL'),
|
2020-04-26 20:50:42 +02:00
|
|
|
]
|
|
|
|
],
|
2023-04-11 01:56:45 +02:00
|
|
|
'download' => [
|
2019-12-08 13:46:54 +01:00
|
|
|
'report_broken_media' => false,
|
2020-10-03 00:50:48 +02:00
|
|
|
],
|
|
|
|
'ipc' => [
|
|
|
|
'slow' => true
|
2019-12-08 13:46:54 +01:00
|
|
|
]
|
2019-01-07 13:24:29 +01:00
|
|
|
],
|
2019-01-20 18:20:41 +01:00
|
|
|
'api' => [
|
2019-03-19 23:56:28 +01:00
|
|
|
'ip_whitelist' => array_filter(
|
|
|
|
array_map(
|
|
|
|
'trim',
|
|
|
|
explode(',', getenv('IP_WHITELIST'))
|
|
|
|
)
|
|
|
|
),
|
2019-01-20 18:20:41 +01:00
|
|
|
],
|
2020-11-09 01:07:34 +01:00
|
|
|
'health_check' => [
|
2023-04-11 01:56:45 +02:00
|
|
|
'enabled' => (bool)filter_var((string)getenv('HEALTHCHECK_ENABLED'), FILTER_VALIDATE_BOOL),
|
|
|
|
'interval' => ((int)getenv('HEALTHCHECK_INTERVAL') ?: 30),
|
|
|
|
'timeout' => ((int)getenv('HEALTHCHECK_REQUEST_TIMEOUT') ?: 60),
|
2020-11-09 01:07:34 +01:00
|
|
|
]
|
2020-01-19 04:17:14 +01:00
|
|
|
];
|
|
|
|
|
2020-01-20 20:53:17 +01:00
|
|
|
if (empty($settings['telegram']['connection_settings']['all']['proxy_extra']['address'])) {
|
|
|
|
$settings['telegram']['connection_settings']['all']['proxy'] = '\Socket';
|
|
|
|
$settings['telegram']['connection_settings']['all']['proxy_extra'] = [];
|
2020-01-19 04:17:14 +01:00
|
|
|
}
|
|
|
|
|
2023-01-17 12:39:06 +01:00
|
|
|
if (empty($settings['telegram']['app_info']['api_id'])) {
|
2023-01-17 14:00:55 +01:00
|
|
|
throw new InvalidArgumentException('Need to fill TELEGRAM_API_ID in .env.docker or .env');
|
2023-01-17 12:39:06 +01:00
|
|
|
}
|
|
|
|
|
2020-01-19 04:17:14 +01:00
|
|
|
return $settings;
|