File tree Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,10 @@ TG_WEBHOOK='{"url": "https://bot.com/manager.php"}'
2121TG_ADMINS = ' [123,456]'
2222TG_LOGGING = ' {"error": "${TG_LOGS_DIR}/error.log", "update": "${TG_LOGS_DIR}/update.log"}'
2323
24+ # Request Client
25+ TG_REQUEST_CLIENT_BASE_URI = ' https://client-base-uri.com'
26+ TG_REQUEST_CLIENT_PROXY = ' socks5://client-proxy.com:9050'
27+
2428# Database
2529TG_DB_HOST = ' localhost'
2630TG_DB_PORT = 3306
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
55
66## [ Unreleased]
77### Added
8+ - Possibility to set custom Request Client.
89### Changed
910### Deprecated
1011### Removed
Original file line number Diff line number Diff line change 1515
1616use Dotenv \Dotenv ;
1717use Exception ;
18+ use GuzzleHttp \Client ;
1819use Longman \TelegramBot \DB ;
19- use Longman \TelegramBot \Exception \ TelegramLogException ;
20+ use Longman \TelegramBot \Request ;
2021use Longman \TelegramBot \TelegramLog ;
2122use MatthiasMullie \Scrapbook \Adapters \MySQL ;
2223use MatthiasMullie \Scrapbook \KeyValueStore ;
@@ -73,6 +74,7 @@ function cache(): KeyValueStore
7374 }
7475
7576 initLogging ();
77+ initRequestClient ();
7678
7779 $ bot = new BotManager ($ params );
7880 $ bot ->run ();
@@ -108,3 +110,16 @@ function initLogging(): void
108110
109111 TelegramLog::initialize ($ logger , $ update_logger );
110112}
113+
114+ /**
115+ * Initialise a custom Request Client.
116+ */
117+ function initRequestClient ()
118+ {
119+ $ config = array_filter ([
120+ 'base_uri ' => getenv ('TG_REQUEST_CLIENT_BASE_URI ' ) ?: 'https://api.telegram.org ' ,
121+ 'proxy ' => getenv ('TG_REQUEST_CLIENT_PROXY ' ),
122+ ]);
123+
124+ $ config && Request::setClient (new Client ($ config ));
125+ }
You can’t perform that action at this time.
0 commit comments