Make Telegram.UseProxy logical

This commit is contained in:
Nikolay Kochulin 2019-08-12 14:37:49 +00:00
parent a8485edcf9
commit 536d315341

View File

@ -31,15 +31,15 @@ namespace JetHerald
public async Task Init() public async Task Init()
{ {
if (Config.UseProxy) if (Config.UseProxy)
{
Client = new TelegramBotClient(Config.ApiKey);
}
else
{ {
var httpProxy = new WebProxy(Config.ProxyUrl) var httpProxy = new WebProxy(Config.ProxyUrl)
{ Credentials = new NetworkCredential(Config.ProxyLogin, Config.ProxyPassword) }; { Credentials = new NetworkCredential(Config.ProxyLogin, Config.ProxyPassword) };
Client = new TelegramBotClient(Config.ApiKey, httpProxy); Client = new TelegramBotClient(Config.ApiKey, httpProxy);
} }
else
{
Client = new TelegramBotClient(Config.ApiKey);
}
Me = await Client.GetMeAsync(); Me = await Client.GetMeAsync();
Commands = new ChatCommandRouter(Me.Username, Log); Commands = new ChatCommandRouter(Me.Username, Log);