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"}'
21
21
TG_ADMINS = ' [123,456]'
22
22
TG_LOGGING = ' {"error": "${TG_LOGS_DIR}/error.log", "update": "${TG_LOGS_DIR}/update.log"}'
23
23
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
+
24
28
# Database
25
29
TG_DB_HOST = ' localhost'
26
30
TG_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
5
5
6
6
## [ Unreleased]
7
7
### Added
8
+ - Possibility to set custom Request Client.
8
9
### Changed
9
10
### Deprecated
10
11
### Removed
Original file line number Diff line number Diff line change 15
15
16
16
use Dotenv \Dotenv ;
17
17
use Exception ;
18
+ use GuzzleHttp \Client ;
18
19
use Longman \TelegramBot \DB ;
19
- use Longman \TelegramBot \Exception \ TelegramLogException ;
20
+ use Longman \TelegramBot \Request ;
20
21
use Longman \TelegramBot \TelegramLog ;
21
22
use MatthiasMullie \Scrapbook \Adapters \MySQL ;
22
23
use MatthiasMullie \Scrapbook \KeyValueStore ;
@@ -73,6 +74,7 @@ function cache(): KeyValueStore
73
74
}
74
75
75
76
initLogging ();
77
+ initRequestClient ();
76
78
77
79
$ bot = new BotManager ($ params );
78
80
$ bot ->run ();
@@ -108,3 +110,16 @@ function initLogging(): void
108
110
109
111
TelegramLog::initialize ($ logger , $ update_logger );
110
112
}
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