private ITelegramBotClient GetTelegramBotClient(IServiceProvider serviceProvider) { var authOptionsAccessor = serviceProvider.GetService <IOptionsMonitor <AuthOptions> >(); var authOptions = authOptionsAccessor.CurrentValue; HttpClient httpClient = GetClient(); var botClient = new TelegramBotClient(authOptions.BirthdaySheduleTelegramBotToken, httpClient); return(botClient); HttpClient GetClient() { if (!authOptions.UseTelegramProxy) { return(new HttpClient()); } var proxy = new HttpToSocks5Proxy(authOptions.Socks5Hostname, authOptions.Socks5Port, authOptions.Socks5Username, authOptions.Socks5Password); proxy.ResolveHostnamesLocally = true; return(new HttpClient(new HttpClientHandler { Proxy = proxy, UseProxy = true, UseDefaultCredentials = false }, true)); } }
/// <summary> /// Создание бот-клиента, инициализация новых команд /// </summary> public Bot() { #region MTProtoProxy //string secret = Guid.NewGuid().ToString().Replace("-", ""); //var mtprotoProxy = new MTProtoProxyServer(secret, 443); //mtprotoProxy.StartAsync(); #endregion #region Proxy //var proxy = new HttpToSocks5Proxy("bot.avinfo17.info", 38157); var proxy = new HttpToSocks5Proxy("ftfkr.teletype.live", 1080, "telegram", "telegram"); proxy.ResolveHostnamesLocally = true; // Allows you to use proxies that are only allowing connections to Telegram #endregion bot = new TelegramBotClient(BotSettings.Key, proxy); commands.Add(new HelloCommand()); commands.Add(new HelpCommand()); commands.Add(new ShowCommand()); commands.Add(new MyCommand()); commands.Add(new BredCommand()); //commands.Add(new iButtonsCommand()); //commands.Add(new rButtonsCommand()); commands.Add(new ZabbixCommand()); commands.Add(new TalkCommand()); commands.Add(new PowerShellCommand()); commands.Add(new SendDocCommand()); commands.Add(new ParseCommand()); }
public async void BeginPolling() { if (ProxyHost != null) { IWebProxy proxy; if (ProxyUser != null && ProxyPassword != null) { proxy = new HttpToSocks5Proxy(ProxyHost, ProxyPort, ProxyUser, ProxyPassword); } else { proxy = new HttpToSocks5Proxy(ProxyHost, ProxyPort); } _bot = new TelegramBotClient(Token, proxy); } else { _bot = new TelegramBotClient(Token); } var me = await _bot.GetMeAsync(); if (ReciveMessages) { _bot.OnMessage += MessageRecivedHandler; _bot.StartReceiving(Array.Empty <UpdateType>()); Logger.Info($"Start receiving for @{me.Username}"); } else { Logger.Info($"Start only sending for @{me.Username}"); } }
public void StartBot() { try { string proxyServer = _settingsService.GetSettings <string>("Hooks_TelegramBot_ProxyServer"); int proxyPort = _settingsService.GetSettings <int>("Hooks_TelegramBot_ProxyPort"); string proxyLogin = _settingsService.GetSettings <string>("Hooks_TelegramBot_ProxyLogin"); string proxyPassword = _settingsService.GetSettings <string>("Hooks_TelegramBot_ProxyPassword"); string key = _settingsService.GetSettings <string>("Hooks_TelegramBot_ApiKey"); var proxy = new HttpToSocks5Proxy( proxyServer, proxyPort, proxyLogin, proxyPassword ); proxy.ResolveHostnamesLocally = false; _botClient = new TelegramBotClient(key, proxy); var me = _botClient.GetMeAsync().Result; _logService.TraceMessage( $"Hello, World! I am user {me.Id} and my name is {me.FirstName}." ); _botClient.OnMessage += Bot_OnMessage; _botClient.StartReceiving(); } catch (Exception e) { _logService.LogError(e); } }
static void Main(string[] args) { Console.WriteLine("Telegram Bot Application!"); var storage = new InMemoryReminderStorage(); var domain = new ReminderDomain(storage); IWebProxy proxy = new HttpToSocks5Proxy("proxy.golyakov.net", 1080); string token = "874002335:AAHCWlQVHGvM6if784HJ0rHTfcUg7SbSR5s"; var sender = new TelegramReminderSender(token, proxy); var receiver = new TelegramReminderReceiver(token, proxy); receiver.MessageReceived += (s, e) => { Console.WriteLine($"Message from contact '{e.ContactId}' with text '{e.Message}'"); //add new reminderitem to the storage var parsedMessage = MessageParser.Parse(e.Message); var item = new ReminderItem(parsedMessage.Date, parsedMessage.Message, e.ContactId); storage.Add(item); }; receiver.Run(); domain.SendReminder = (ReminderItem ri) => { sender.Send(ri.ContactId, ri.Message); }; domain.Run(); Console.WriteLine("Press any key to continue"); Console.ReadKey(); }
public void ConfigureServices(IServiceCollection services) { Log.Logger.Information("Initialization start "); var settings = Configuration.Get <Settings>(); services.AddOptions(); services.Configure <Settings>(Configuration); services.AddLogging(loggingBuilder => loggingBuilder.AddSerilog(dispose: true)); services .AddMvc() .AddJsonOptions(options => options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore); services.AddScoped <IGetRecordService, GetRecordService>(_ => new GetRecordService(settings.CameraImageUrl, settings.CameraAuth)); services.AddScoped <ITelegramService, TelegramService>(); services.AddScoped <IList <string> >(_ => settings.TelegramUsersAccess.Split(";").ToList()); services.AddScoped(_ => { if (string.IsNullOrWhiteSpace(settings.Proxy.Host)) { return(new TelegramBotClient(settings.TelegramBotToken)); } var proxy = new HttpToSocks5Proxy(settings.Proxy.Host, settings.Proxy.Port, settings.Proxy.User, settings.Proxy.Password); return(new TelegramBotClient(settings.TelegramBotToken, proxy)); }); Log.Logger.Information("initialization end"); }
public CommonBot(string apiKey, string proxyUrl = "", int proxyPort = 0) { HttpToSocks5Proxy proxy = null; if (!string.IsNullOrEmpty(proxyUrl) && proxyPort != 0) { proxy = new HttpToSocks5Proxy(proxyUrl, proxyPort) { // Allows you to use proxies that are only allowing connections to Telegram ResolveHostnamesLocally = true } } ; bot = new TelegramBotClient(apiKey, proxy); user = bot.GetMeAsync().Result; polls = new List <TelegramPoll>(); GetCommandsList(); stickers = GetStickers(); // Обработчики сообщений if (bot == null) { return; } bot.OnMessage += BotOnMessageReceived; bot.OnMessageEdited += BotOnMessageReceived; bot.OnCallbackQuery += BotOnCallbackQueryReceived; bot.OnInlineQuery += BotOnInlineQueryReceived; bot.OnInlineResultChosen += BotOnChosenInlineResultReceived; bot.OnReceiveError += BotOnReceiveError; }
private static IImagePuller <HotWebImage> GetImagePuller(IConfigurationRoot config, ILoggerFactory loggerFactory) { IOptions <MemoryCacheOptions> options = new MemoryCacheOptions(); IMemoryCache memoryCache = new MemoryCache(options); var vpnIp = config.GetSection("VpnConfigs:Ip").Value; var vpnPort = config.GetSection("VpnConfigs:Port").Value; var vpnLogin = config.GetSection("VpnConfigs:Login").Value; var vpnPassword = config.GetSection("VpnConfigs:Password").Value; var proxy = new HttpToSocks5Proxy(vpnIp, int.Parse(vpnPort), vpnLogin, vpnPassword); var handler = new HttpClientHandler { Proxy = proxy }; var danbooruHttpClient = new HttpClient(handler, true); var danbooruLogin = config.GetSection("DanbooruAccount:Login").Value; var danbooruApiKey = config.GetSection("DanbooruAccount:ApiKey").Value; var settings = new DanbooruAuthenticationSettings(danbooruLogin, danbooruApiKey); var apiLogger = loggerFactory.CreateLogger <DanbooruApiClient>(); var danbooruApiClient = new DanbooruApiClient(danbooruHttpClient, settings, apiLogger); var imagePullerLogger = loggerFactory.CreateLogger <DanbooruImagePuller>(); var imagePuller = new DanbooruImagePuller(danbooruApiClient, memoryCache, imagePullerLogger); return(imagePuller); }
public static IWebProxy GetWebProxy(AppSettingProxy proxy) { IWebProxy webProxy = new WebProxy(); bool useProxy = proxy.Enable; if (useProxy) { string proxyType = proxy.Type; string proxyHost = proxy.Server; int proxyPort = proxy.Port; string proxyUserName = proxy.Username; string proxyPassword = proxy.Password; bool hasAuth = !string.IsNullOrEmpty(proxy.Username); if (proxyType == "http") { webProxy = new WebProxy { Address = new Uri($"http://{proxyHost}:{proxyPort}"), BypassProxyOnLocal = false, UseDefaultCredentials = !hasAuth, }; if (hasAuth) { webProxy.Credentials = new NetworkCredential(userName: proxyUserName, password: proxyPassword); } } else if (proxyType == "socks5") { webProxy = new HttpToSocks5Proxy(proxyHost, proxyPort); } } return(webProxy); }
static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine("Usage: {0} socks5Hostname socks5Port httpPort", Process.GetCurrentProcess().ProcessName); } string socks5Hostname = "127.0.0.1"; int socks5Port = 1080; int httpPort = 8118; try { socks5Hostname = args[0]; socks5Port = int.Parse(args[1]); httpPort = int.Parse(args[2]); } catch { } Console.WriteLine($"Using socks5 Proxy at {socks5Hostname}:{socks5Port}"); Console.WriteLine($"Start Http Server at Port {httpPort}"); var proxy = new HttpToSocks5Proxy(socks5Hostname, socks5Port, httpPort); Thread.Sleep(Timeout.Infinite); }
private void SetProxy() { if (_lockerQuestions.TryEnterWriteLock(LockerTimeuotMs)) { if (_proxies.Count <= 0) { try { for (int i = m_PortsFrom; i < m_PortsFrom + m_PortsCount; i++) { try { var proxy = new HttpToSocks5Proxy("127.0.0.1", i); _proxies.Add(new ProxyInfo(proxy)); Log.Info($"add proxy to list port: {i}"); } catch (Exception e) { throw new Exception("proxy enable failed, try changes port_from: " + e); } } } finally { _lockerQuestions.ExitWriteLock(); } } // включение и загрузка //_proxyChecker.StartCheck(); } Log.Info($"tor proxies loaded: {_proxies.Count}"); Log.Info($"another proxies loaded: {_proxyChecker.GetCount()}"); }
/// <summary> /// 异步连接代理 /// </summary> /// <returns></returns> private HttpClient AsyncConnProxy(string ip, int port, string username, string pass, int timeout, HttpClientHandler httpClientHandler = null) { HttpToSocks5Proxy proxy; if (string.IsNullOrWhiteSpace(username) && string.IsNullOrWhiteSpace(pass)) { proxy = new HttpToSocks5Proxy(ip, port); } else { proxy = new HttpToSocks5Proxy(ip, port, username, pass); } if (httpClientHandler != null) { httpClientHandler.Proxy = proxy; } else { httpClientHandler = new HttpClientHandler { Proxy = proxy }; } var httpClient = new HttpClient(httpClientHandler, false); // httpClient 配置 httpClient.Timeout = new TimeSpan(0, 0, timeout); return(httpClient); }
private static TelegramBotClient SetupBot(IConfigurationSection proxyConfiguration, string token) { TelegramBotClient bot; if (proxyConfiguration.Exists()) { var proxy = new HttpToSocks5Proxy( proxyConfiguration["Host"], int.Parse(proxyConfiguration["Port"]), proxyConfiguration["User"], proxyConfiguration["Password"] ) { ResolveHostnamesLocally = true }; bot = new TelegramBotClient(token, proxy); } else { bot = new TelegramBotClient(token); } return(bot); }
public async Task CanTestThroughput() { var cancellationToken = new CancellationTokenSource(); var server = Helpers.RunServers(cancellationToken.Token); var proxy = new HttpToSocks5Proxy("127.0.0.1", 5000); var handler = new HttpClientHandler { Proxy = proxy }; HttpClient httpClient = new HttpClient(handler, true); var message = new String('b', 10000); var expected = $"[{message}]"; var content = new StringContent(message, Encoding.UTF8, "application/text"); var start = DateTime.Now; for (int k = 0; k < 50; k++) { var response = await httpClient.PostAsync("http://localhost:5001/", content); response.EnsureSuccessStatusCode(); } var end = DateTime.Now; Console.WriteLine($"This test took {(end - start).TotalMilliseconds} ms."); //Assert.Equal(expected, await response.Content.ReadAsStringAsync()); cancellationToken.Cancel(); }
public BotClient(BotConfiguration configuration) { _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); if (String.IsNullOrWhiteSpace(_configuration.Token)) { throw new ArgumentException("Token must be not null or empty or whitespace", nameof(_configuration.Token)); } if (!_configuration.ChatId.HasValue) { throw new ArgumentException("ChatId must be not null", nameof(_configuration.ChatId)); } if (!_configuration.ChannelId.HasValue) { throw new ArgumentException("ChannelId must be not null", nameof(_configuration.ChannelId)); } if (configuration.Proxy != null) { var proxy = new HttpToSocks5Proxy( configuration.Proxy.Host, configuration.Proxy.Port, configuration.Proxy.Username, configuration.Proxy.Password); _client = new TelegramBotClient(_configuration.Token, proxy); } else { _client = new TelegramBotClient(_configuration.Token); } }
public static TelegramBotClient Get() { //var proxy = new HttpToSocks5Proxy("62.210.92.188", 5950); //var proxy = new HttpToSocks5Proxy("54.38.195.161", 52060); var proxy = new HttpToSocks5Proxy("54.38.195.161", 63525); client = new TelegramBotClient(AppSettings.Key, proxy); commandsList = new List <Command>(); //Регистрация комманд commandsList.Add(new HelloCommand()); commandsList.Add(new MenuCommand()); commandsList.Add(new CreateNewEventCommand()); commandsList.Add(new DescriptionCommand()); commandsList.Add(new ErrorMessageComand()); commandsList.Add(new AdministrationMenuCommand()); commandsList.Add(new RecordNewEventCommand()); commandsList.Add(new EventListCommand()); commandsList.Add(new GetEventCommand()); commandsList.Add(new FutureEventsCommand()); commandsList.Add(new GetMyEventCommand()); commandsList.Add(new MyEventListCommand()); //TODO: Add more commands if (client != null) { return(client); } return(client); }
static void Main(string[] args) { Console.WriteLine("Telegram Bot Application!"); var storage = new InMemoryReminderStorage(); string token = "633428988:AAHLW_LaS7A47PDO2I8sbLkIIM9L0joPOSQ"; IWebProxy proxy = new HttpToSocks5Proxy( "proxy.golyakov.net", 1080); var receiver = new TelegramReminderReceiver(token, proxy); var domain = new ReminderDomain(storage, receiver); var sender = new TelegramReminderSender(token, proxy); domain.SendReminder = (ReminderItem ri) => { sender.Send(ri.ContactId, ri.Message); }; domain.MessageReceived += Domain_MessageReceived; domain.MessageParsingSuccedded += Domain_MessageParsingSuccedded; domain.MessageParsingFailed += Domain_MessageParsingFailed; domain.AddingToStorageSucceeded += Domain_AddingToStorageSucceeded; domain.AddingToStorageFailed += Domain_AddingToStorageFailed; domain.Run(); Console.WriteLine("Press any key to exit."); Console.ReadKey(); }
public static void UseTelegramBot(this ServiceCollection services, IConfiguration config) { var proxySettings = new ProxySettings(config.GetSection("Proxy")); var proxy = new HttpToSocks5Proxy(proxySettings.Socks5Hostname, proxySettings.Sock5Port, proxySettings.Username, proxySettings.Password); services.AddSingleton(x => new TelegramBotClient(config.GetSection("TelegramBot").GetValue <string>("Token"), proxy)); }
private async Task StartListen(CancellationToken cancellationToken) { var configProvider = services.GetService <IConfiguration>(); var section = configProvider.GetSection("BotConfig"); section.Bind(_config); try { if (_config.UseSOCKS5) { var proxy = new HttpToSocks5Proxy(_config.SOCKS5Address, _config.SOCKS5Port, _config.SOCKS5User, _config.SOCKS5Password); client = new TelegramBotClient(_config.Token, proxy); } else { client = new TelegramBotClient(_config.Token); } factory = new EventHandlerFactory(); factory.Find(); var me = await GetMeSafeAsync(cancellationToken); _userName = me.Username; Console.WriteLine($"{Environment.NewLine} {_userName} started!{Environment.NewLine}"); } catch (Exception e) when(e is ArgumentException || e is ArgumentNullException) { Console.WriteLine(e); throw; } catch (Exception e) { Console.WriteLine(e); } if (_config.EnableWebHook) { if (_config.UseCertificate) { //TODO серт // await client.SetWebhookAsync(_config.WebHookURL, new InputFileStream(new FileStream(_config.WebHookCertPath))) } else { //TODO подготовить и заспавнить контроллер await client.SetWebhookAsync(_config.WebHookURL, cancellationToken : cancellationToken); } } else { client.StartReceiving(new DefaultUpdateHandler(HandleUpdateAsync, HandleErrorAsync), cancellationToken); } }
/// <summary> /// Проинициализировать поля. /// </summary> private void Initialize() { ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; var proxy = new HttpToSocks5Proxy("208.102.51.6", 58208); Client = new TelegramBotClient(token, proxy); Client.OnMessage += Bot_OnMessage; }
public DownloaderBase() { HttpToSocks5Proxy proxy = new HttpToSocks5Proxy(Config.ProxyHost, Config.ProxyPort); this.ClientHandler = new HttpClientHandler { Proxy = proxy }; //clientHandler.Proxy.Credentials = new NetworkCredential(PROXY_UID, PROXY_PWD, PROXY_DMN); }
static void Main(string[] args) { // read configuration IConfiguration config = new ConfigurationBuilder() .AddJsonFile("appsettings.json", true, true) .Build(); var storageWebApiUrl = config["storageWebApiUrl"]; var telegramBotApiToken = config["telegramBot.ApiToken"]; var telegramBotUseProxy = bool.Parse(config["telegramBot.UseProxy"]); var telegramBotProxyHost = config["telegramBot.Proxy.Host"]; var telegramBotProxyPort = int.Parse(config["telegramBot.Proxy.Port"]); var telegramBotProxyLogin = config["telegramBot.Proxy.Login"]; var telegramBotProxyPassword = config["telegramBot.Proxy.Password"]; // create objects for DI var reminderStorage = new ReminderStorageWebApiClient(storageWebApiUrl); IWebProxy telegramProxy = null; if (telegramBotUseProxy) { telegramProxy = new HttpToSocks5Proxy( telegramBotProxyHost, telegramBotProxyPort, telegramBotProxyLogin, telegramBotProxyPassword); } var reminderReceiver = new TelegramReminderReceiver(telegramBotApiToken, telegramProxy); var reminderSender = new TelegramReminderSender(telegramBotApiToken, telegramProxy); // create and setup domain logic object var reminderDomain = new ReminderDomain( reminderStorage, reminderReceiver, reminderSender); reminderDomain.AddingSuccedded += ReminderDomain_AddingSuccedded; reminderDomain.SendingSucceded += ReminderDomain_SendingSucceded; reminderDomain.SendingFailed += ReminderDomain_SendingFailed; // run reminderDomain.Run(); string hello = reminderReceiver.GetHelloFromBot(); Console.WriteLine( $"Reminder application is running...\n" + $"{hello}\n" + "Press [Enter] to shutdown."); Console.ReadLine(); }
static void Main(string[] args) { try { string ip = ""; int port = 0; using (StreamReader sr = new StreamReader("settings.txt", System.Text.Encoding.Default)) { string line; while ((line = sr.ReadLine()) != null) { if (line.Contains("proxy")) { try { ip = line.Remove(line.LastIndexOf(@":")); ip = ip.Remove(0, ip.LastIndexOf(@" ") + 1); port = Convert.ToInt32(line.Remove(0, line.LastIndexOf(@":") + 1)); //Console.WriteLine(ip); //Console.WriteLine(port); } catch { //Console.WriteLine("proxy не задан"); } } if (line.Contains("timeout")) { kd = Convert.ToInt32(line.Remove(0, line.LastIndexOf(@" ") + 1)) * 60 * 60 * 1000; //Console.WriteLine(kd); } } } if (ip == "" || port == 0) { Bot = new TelegramBotClient("873090403:AAGZ3Lbh3j1WGuY2JQRGd8dKO1Jn3cpePGE"); } else { var proxy = new HttpToSocks5Proxy(ip, port); Bot = new TelegramBotClient("998416041:AAEt6jRlNJSQlIDOFiCJuHtqHum-VcBytx4", proxy); } var me = Bot.GetMeAsync().Result; Bot.OnMessage += Bot_OnMessageReceived; Console.WriteLine(me.FirstName + " online"); Bot.StartReceiving(); Console.ReadLine(); Bot.StopReceiving(); } catch { Console.WriteLine("Error"); Thread.Sleep(5000); Environment.Exit(0); } }
static void Main(string[] args) { var socksProxy = new HttpToSocks5Proxy("183.102.171.77", 8888); bot = new TelegramBotClient("983922268:AAGxXiplHabEGFUYv92pKe9VjogbPW2793I", socksProxy); StartBot(); Console.ReadLine(); }
/// <summary> /// Начинает загружать файл через прокси тор асинхронно /// </summary> /// <param name="uri">Откуда необходимо скачать файл</param> /// <param name="fileName">Куда необходимо сохранить файл</param> public void FileAsync(Uri uri, string fileName) { WebClient client = new WebClient(); HttpToSocks5Proxy proxy = new HttpToSocks5Proxy("127.0.0.1", 9050); client.Proxy = proxy; client.DownloadFileCompleted += Client_DownloadFileCompleted; client.DownloadFileAsync(uri, fileName); }
public BotController(IOptions <TelegramOptions> tgOptions, IOptions <ProxyOptions> proxyOptions, IOptions <NgrokOptions> ngrokOptions) { _ngrokService = new NgrokService(ngrokOptions.Value.LocalUrl); _tgOptions = tgOptions.Value; _proxyOptions = proxyOptions.Value; var proxy = new HttpToSocks5Proxy(_proxyOptions.Host, _proxyOptions.Port, _proxyOptions.User, _proxyOptions.Password); proxy.ResolveHostnamesLocally = true; _client = new TelegramBotClient(_tgOptions.Token, proxy); }
static void Main(string[] args) { var proxy = new HttpToSocks5Proxy("217.61.130.19", 29202); // Some proxies limit target connections to a single IP address // If that is the case you have to resolve hostnames locally // proxy.ResolveHostnamesLocally = true; TelegramBotClient bot = new TelegramBotClient("974790258:AAFZtdELBh25LpaAjguUNtrl7B5OPX5g6Ek", proxy); //string token = "974790258:AAFZtdELBh25LpaAjguUNtrl7B5OPX5g6Ek"; // Телеграм токен бота //var bot = new TelegramBotClient(token); var markup = new ReplyKeyboardMarkup(new[] { new KeyboardButton("Roll film!"), }) { OneTimeKeyboard = true, ResizeKeyboard = true }; Console.WriteLine("Готово!"); bot.OnMessage += (sender, e) => { //Вывод информации о запросах к серверу string msg = $"{DateTime.Now}: {e.Message.Chat.Id} {e.Message.Chat.FirstName} {e.Message.Chat.Username} {e.Message.Text}"; Console.WriteLine(msg); string response = null; string url = "https://www.kinopoisk.ru/chance/?item=true¬_show_rated=false&count=1"; using (var webClient = new WebClient()) { response = webClient.DownloadString(url); } dynamic data = Json.Decode(response); response = data[0]; string subString = "data-id-film="; var a = response.IndexOf(subString) + 14; //находим начальную позицию для парсинга id фильма из запроса var b = response.IndexOf('\"', a); //находим конечную позицию для парсинга id фильма из запроса string c = response.Substring(a, b - a); int filmId = Int32.Parse(c); string msg2 = "https://www.kinopoisk.ru/film/" + c; Console.WriteLine(filmId); bot.SendTextMessageAsync(e.Message.Chat.Id, msg2, replyMarkup: markup); }; bot.StartReceiving(); Console.ReadKey(); }
public TelegramBot() { var proxy = new HttpToSocks5Proxy("142.93.108.135", 1080, "sockuser", "boogieperets"); WebClient cl = new WebClient(); cl.Proxy = proxy; proxy.ResolveHostnamesLocally = true; InnerClient = new Telegram.Bot.TelegramBotClient("410447550:AAGz1QRPgdoh5tuddcMleFYI9Ttw-Ytn9Fs", proxy); }
/// <summary> /// Начинает загрузку HTML страницы /// </summary> /// <param name="uri">Указывает, какую страницу загружать</param> public void StartDownload(Uri uri) { // Стандартный способ загрузки страниц из AgilityPack не подходит // так как он не может скачивать через Tor прокси WebClient client = new WebClient(); HttpToSocks5Proxy proxy = new HttpToSocks5Proxy("127.0.0.1", 9050); client.Proxy = proxy; client.DownloadDataCompleted += Client_DownloadDataCompleted; client.DownloadDataAsync(uri); }
public static ITelegramBotClient BuildClient(BotConfiguration config) { if (config.UseProxy) { var proxy = new HttpToSocks5Proxy(config.ProxyHost, config.ProxyPort, config.ProxyLogin, config.ProxyPassword); return(new TelegramBotClient(config.AccessToken, proxy)); } return(new TelegramBotClient(config.AccessToken)); }