Repository navigation
Expand file tree
/
Copy pathdb.php
More file actions
43 lines (33 loc) · 1.48 KB
/
Copy pathdb.php
File metadata and controls
43 lines (33 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
declare(strict_types=1);
// Switch to another database driver, for testing
if (getenv('ACTIONS_PHAR')) {
include 'madeline.php';
} elseif (!file_exists(__DIR__.'/../vendor/autoload.php') || getenv('ACTIONS_FORCE_PREVIOUS')) {
echo 'You did not run composer update, using madeline.php'.PHP_EOL;
if (!file_exists('madeline.php')) {
copy('https://phar.madelineproto.xyz/madeline.php', 'madeline.php');
}
include 'madeline.php';
} else {
require_once 'vendor/autoload.php';
}
use danog\MadelineProto\API;
use danog\MadelineProto\Settings\Database\Memory;
use danog\MadelineProto\Settings\Database\Mysql;
use danog\MadelineProto\Settings\Database\Postgres;
use danog\MadelineProto\Settings\Database\Redis;
use danog\MadelineProto\Settings\Database\SerializerType;
$MadelineProto = new API(__DIR__.'/../testing.madeline');
$map = [
'memory' => new Memory,
'mysql' => (new Mysql)->setUri('tcp://mariadb')->setUsername('MadelineProtoUser')->setPassword('test')->setDatabase('MadelineProtoDb'),
'postgres' => (new Postgres)->setUri('tcp://postgres')->setUsername('MadelineProtoUser')->setPassword('test')->setDatabase('MadelineProtoDb'),
'redis' => (new Redis)->setUri('redis://redis'),
];
$settings = $map[$argv[1]];
if (!$settings instanceof Memory) {
$settings->setSerializer($argv[2] === 'igbinary' ? SerializerType::IGBINARY : SerializerType::SERIALIZE);
}
$MadelineProto->updateSettings($settings);
var_dump($MadelineProto->getFullInfo('danogentili'));