From 16f05d04e9c886a179877df4b4fe30cc31d69d22 Mon Sep 17 00:00:00 2001 From: ebiak Date: Mon, 2 Nov 2020 11:24:48 +0330 Subject: [PATCH] proxy password and user name --- bot/bot.cs | 5 ++++- config.impostorCord.json | 4 +++- main.cs | 9 ++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/bot/bot.cs b/bot/bot.cs index acfbc66..a41c429 100644 --- a/bot/bot.cs +++ b/bot/bot.cs @@ -16,9 +16,12 @@ public class Bot public static DiscordClient client; static CommandsNextExtension commands; static private WebProxy _proxy; - public Bot(string token, string prefix, string proxy) + static private ICredentials credentials; + public Bot(string token, string prefix, string proxy,string proxyUserName,string proxyPassword) { + credentials = new NetworkCredential(proxyUserName,proxyPassword); _proxy = new WebProxy(proxy); + _proxy.Credentials = credentials; MainAsync(token).ConfigureAwait(false).GetAwaiter().GetResult(); commands = client.UseCommandsNext(new CommandsNextConfiguration { diff --git a/config.impostorCord.json b/config.impostorCord.json index 12c8ee4..a4b3cb4 100644 --- a/config.impostorCord.json +++ b/config.impostorCord.json @@ -2,5 +2,7 @@ "token": "", "prefix": ";", "botProxyEnabled": false, - "botProxyAddress": "" + "botProxyAddress": "", + "botProxyUsername": "", + "botProxyPassword": "" } \ No newline at end of file diff --git a/main.cs b/main.cs index df150b7..e597bd1 100644 --- a/main.cs +++ b/main.cs @@ -32,7 +32,7 @@ public ImpostorCord(ILogger logger, IEventManager eventManager) { proxyAddress = config.BotProxyAddress; } - _bot = new Bot(config.Token, config.Prefix, proxyAddress); + _bot = new Bot(config.Token, config.Prefix, proxyAddress, config.BotProxyUsername, config.BotProxyPassword); eventManager.RegisterListener(new GameEventListener(logger, _bot)); } @@ -50,5 +50,12 @@ public class Config [JsonPropertyName("botProxyAddress")] public string BotProxyAddress { get; set; } + + [JsonPropertyName("botProxyUsername")] + public string BotProxyUsername { get; set; } + + [JsonPropertyName("botProxyPassword")] + public string BotProxyPassword { get; set; } + } } \ No newline at end of file