Comments (2)
It's good and solved my issue, thanks!!
from telegram.bots.
Hello! Thank you for considering Telegram.Bots
for your bot project.
In this library, the ideal way of initializing the BotClient
is through the dependency injection mechanism. The AddBotClient extension method returns an IHttpClientBuilder
which you can then use to setup your proxy, I imagine. I say "I imagine" because I have never set this up myself and so do not fully know whether this will work but I kept the option open nonetheless and here is what I think you can do to get your web proxy working as well:
using System;
using Microsoft.Extensions.DependencyInjection;
using Telegram.Bots;
IServiceProvider provider = new ServiceCollection()
.AddBotClient("<bot-token>")
.ConfigurePrimaryHttpMessageHandler(() => new SocketsHttpHandler
{
Proxy = new WebProxy(Host: "<your-host>", Port: 1234),
UseProxy = true
})
.Services
.BuildServiceProvider();
IBotClient bot = provider.GetRequiredService<IBotClient>();
You can further add more HttpClientHandler
by calling AddHttpMessageHandler
accordingly.
Do let me know if this resolves your issue and I can setup a decent example in the README about using the web proxy then. You can also tell me what you wrote so I can use that as inspiration for the example that can be in the README for future users who also need a web proxy.
from telegram.bots.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from telegram.bots.