Spaces:
Building
Building
fix: use native telegram apiRoot proxying
Browse files- cloudflare-proxy.js +13 -10
- start.sh +2 -1
cloudflare-proxy.js
CHANGED
|
@@ -250,18 +250,21 @@ if (PROXY_URL) {
|
|
| 250 |
}
|
| 251 |
};
|
| 252 |
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
|
|
|
| 258 |
|
| 259 |
-
// Patch the current global dispatcher
|
| 260 |
if (exports.getGlobalDispatcher) {
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
|
|
|
|
|
|
| 265 |
}
|
| 266 |
|
| 267 |
if (exports.fetch && !exports.fetch._patched) {
|
|
|
|
| 250 |
}
|
| 251 |
};
|
| 252 |
|
| 253 |
+
// Discover and patch all Dispatcher-like classes in the module
|
| 254 |
+
for (const key in exports) {
|
| 255 |
+
if (exports[key] && exports[key].prototype && typeof exports[key].prototype.dispatch === 'function') {
|
| 256 |
+
patchDispatch(exports[key].prototype, key);
|
| 257 |
+
}
|
| 258 |
+
}
|
| 259 |
|
| 260 |
+
// Patch the current global dispatcher instance
|
| 261 |
if (exports.getGlobalDispatcher) {
|
| 262 |
+
try {
|
| 263 |
+
const globalDispatcher = exports.getGlobalDispatcher();
|
| 264 |
+
if (globalDispatcher && globalDispatcher.dispatch && !globalDispatcher.dispatch._patched) {
|
| 265 |
+
patchDispatch(globalDispatcher, "GlobalDispatcherInstance");
|
| 266 |
+
}
|
| 267 |
+
} catch (e) {}
|
| 268 |
}
|
| 269 |
|
| 270 |
if (exports.fetch && !exports.fetch._patched) {
|
start.sh
CHANGED
|
@@ -357,11 +357,12 @@ if [ -n "${TELEGRAM_BOT_TOKEN:-}" ]; then
|
|
| 357 |
export TELEGRAM_BOT_TOKEN="$TELEGRAM_BOT_TOKEN"
|
| 358 |
export OPENCLAW_TELEGRAM_DISABLE_AUTO_SELECT_FAMILY=1
|
| 359 |
export OPENCLAW_TELEGRAM_DNS_RESULT_ORDER=ipv4first
|
| 360 |
-
CONFIG_JSON=$(echo "$CONFIG_JSON" | jq --arg token "$TELEGRAM_BOT_TOKEN" '
|
| 361 |
.channels.telegram.enabled = true
|
| 362 |
| .channels.telegram.botToken = $token
|
| 363 |
| .channels.telegram.commands.native = false
|
| 364 |
| .channels.telegram.timeoutSeconds = 60
|
|
|
|
| 365 |
# | .channels.telegram.network.autoSelectFamily = false
|
| 366 |
# | .channels.telegram.network.dnsResultOrder = "ipv4first"
|
| 367 |
| .channels.telegram.retry = {
|
|
|
|
| 357 |
export TELEGRAM_BOT_TOKEN="$TELEGRAM_BOT_TOKEN"
|
| 358 |
export OPENCLAW_TELEGRAM_DISABLE_AUTO_SELECT_FAMILY=1
|
| 359 |
export OPENCLAW_TELEGRAM_DNS_RESULT_ORDER=ipv4first
|
| 360 |
+
CONFIG_JSON=$(echo "$CONFIG_JSON" | jq --arg token "$TELEGRAM_BOT_TOKEN" --arg proxy_url "${CLOUDFLARE_PROXY_URL:-}" '
|
| 361 |
.channels.telegram.enabled = true
|
| 362 |
| .channels.telegram.botToken = $token
|
| 363 |
| .channels.telegram.commands.native = false
|
| 364 |
| .channels.telegram.timeoutSeconds = 60
|
| 365 |
+
| (if $proxy_url != "" then .channels.telegram.apiRoot = $proxy_url else . end)
|
| 366 |
# | .channels.telegram.network.autoSelectFamily = false
|
| 367 |
# | .channels.telegram.network.dnsResultOrder = "ipv4first"
|
| 368 |
| .channels.telegram.retry = {
|