-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting socks5 proxy for long polling bot #57
Comments
Sorry for the late reponse, I just added SOCKS support to the ScalajHttpClient, there's a big update coming soon, check the refactor branch. A proxied bot (via long polling) would look like this: import java.net.{InetSocketAddress, Proxy}
import info.mukel.telegrambot4s.api.Polling
import info.mukel.telegrambot4s.api.declarative.Commands
import info.mukel.telegrambot4s.clients.ScalajHttpClient
/**
* Tunnel the bot through a SOCKS proxy.
*
* To test locally via [[https://linux.die.net/man/8/sshd sshd]] use:
* ssh -D 1337 -C -N you_user_name@localhost
*/
class ProxyBot(token: String) extends ExampleBot(token)
with Polling
with Commands {
val proxy = new Proxy(Proxy.Type.SOCKS, InetSocketAddress.createUnresolved("localhost", 1337))
override val client = new ScalajHttpClient(token, proxy)
onCommand('hello) { implicit msg =>
reply("Hi " + msg.from.fold("Mr. X")(_.firstName))
}
} See instructions below on how to get the latest build (with proxy support). |
To pull 3.1.0-RC1 please add to your build.sbt
Example bot + runner: import info.mukel.telegrambot4s.api.{Polling, TelegramBot}
import info.mukel.telegrambot4s.api.declarative.Commands
import scala.concurrent.Await
import scala.concurrent.duration.Duration
class Botogram extends TelegramBot with Polling with Commands {
override def token: String = "TOKEN"
onCommand('hello) { implicit msg =>
reply("Botogram")
}
}
object Main {
def main(args: Array[String]): Unit = {
val bot = new Botogram()
val eol = bot.run()
scala.io.StdIn.readLine()
bot.shutdown()
Await.result(eol, Duration.Inf)
}
} Please report any issues. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello! It is possible to set socks5 proxy for long polling bot? And how it can be done if it is?
The text was updated successfully, but these errors were encountered: