telebot icon indicating copy to clipboard operation
telebot copied to clipboard

support socks5 proxy for dial telebot with proxy to telegram api server

Open ja7ad opened this issue 3 years ago • 0 comments

Telegram API service is blocked by some providers, so you need to use a proxy or a VPN in order to connect to Telegram.

package main

import (
	"gopkg.in/telebot.v3"
	"log"
	"time"
)

func main() {
	bot, err := telebot.NewBot(telebot.Settings{
		Token:  "token",
		Poller: &telebot.LongPoller{Timeout: 10 * time.Second},
		Proxy:  &telebot.Proxy{Address: "ip:port"},
	})
	if err != nil {
		log.Fatal(err)
	}

	bot.Handle("/hello", func(c telebot.Context) error {
		return c.Send("Hello!")
	})

	bot.Start()
}

ja7ad avatar Jul 30 '22 08:07 ja7ad