Add logging for Telegram bot proxy configuration
- Enhanced logging in `Program.cs` to include information about the Telegram bot's proxy settings, improving traceability of network configurations. - This addition logs the proxy scheme, host, and port, aiding in debugging and monitoring of the bot's connectivity.
This commit is contained in:
@@ -77,6 +77,9 @@ builder.Services.AddSingleton<ITelegramBotClient>(sp =>
|
|||||||
proxy.Credentials = new NetworkCredential(credentials[0], credentials.Length > 1 ? credentials[1] : string.Empty);
|
proxy.Credentials = new NetworkCredential(credentials[0], credentials.Length > 1 ? credentials[1] : string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sp.GetRequiredService<ILogger<Program>>().LogInformation(
|
||||||
|
"Telegram bot using proxy {Scheme}://{Host}:{Port}", proxyUri.Scheme, proxyUri.Host, proxyUri.Port);
|
||||||
|
|
||||||
var handler = new SocketsHttpHandler { Proxy = proxy, UseProxy = true };
|
var handler = new SocketsHttpHandler { Proxy = proxy, UseProxy = true };
|
||||||
return new TelegramBotClient(token, new HttpClient(handler));
|
return new TelegramBotClient(token, new HttpClient(handler));
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user