aboutsummaryrefslogtreecommitdiffstats
path: root/telebot
diff options
context:
space:
mode:
authorterminaldweller <devi@terminaldweller.com>2024-05-31 12:34:13 +0000
committerterminaldweller <devi@terminaldweller.com>2024-05-31 12:34:13 +0000
commit02eb854bffb4bba4585a589c5dda62c503d89363 (patch)
tree3e550e3be7bf33c5dee444d679aa80453fa7dcfd /telebot
parentadded cmc as a provider (diff)
downloadhived-02eb854bffb4bba4585a589c5dda62c503d89363.tar.gz
hived-02eb854bffb4bba4585a589c5dda62c503d89363.zip
WIP
Diffstat (limited to '')
-rw-r--r--telebot/.golangci.yml19
-rw-r--r--telebot/go.mod2
-rw-r--r--telebot/telebot.go21
3 files changed, 32 insertions, 10 deletions
diff --git a/telebot/.golangci.yml b/telebot/.golangci.yml
new file mode 100644
index 0000000..c31a774
--- /dev/null
+++ b/telebot/.golangci.yml
@@ -0,0 +1,19 @@
+run:
+ concurrency: 16
+ timeout: 5m
+ modules-download-mode: readonly
+ allow-parallel-runners: true
+ allow-serial-runners: true
+ go: '1.22'
+linters-settings:
+ depguard:
+ rules:
+ srcs:
+ listMode: "Strict"
+ allow:
+ - $gostd
+ - github.com/go-telegram-bot-api/telegram-bot-api
+ - github.com/rs/zerolog/log
+ - github.com/terminaldweller/grpc/telebot/v1
+ - golang.org/x/net/proxy
+ - google.golang.org/grpc
diff --git a/telebot/go.mod b/telebot/go.mod
index 89df502..32444e9 100644
--- a/telebot/go.mod
+++ b/telebot/go.mod
@@ -1,6 +1,6 @@
module telebot
-go 1.22.3
+go 1.22
require (
github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible
diff --git a/telebot/telebot.go b/telebot/telebot.go
index d4a8255..91eebcb 100644
--- a/telebot/telebot.go
+++ b/telebot/telebot.go
@@ -17,10 +17,9 @@ import (
"google.golang.org/grpc"
)
-// FIXME-the client should provide the channel ID.
var botChannelID = flag.Int64(
"botchannelid",
- 146328407, //nolint: gomnd
+ 146328407, //nolint: mnd,gomnd
"determines the channel id the telgram bot should send messages to")
const (
@@ -34,6 +33,7 @@ type server struct {
func GetProxiedClient() (*http.Client, error) {
var isProxied bool
+
proxyURL := os.Getenv("ALL_PROXY")
if proxyURL == "" {
proxyURL = os.Getenv("HTTPS_PROXY")
@@ -43,19 +43,22 @@ func GetProxiedClient() (*http.Client, error) {
isProxied = false
}
- var dialer_proxy proxy.Dialer
+ var dialerProxy proxy.Dialer
+
var dialer net.Dialer
+
var err error
if isProxied {
- dialer_proxy, err = proxy.SOCKS5("tcp", proxyURL, nil, proxy.Direct)
+ dialerProxy, err = proxy.SOCKS5("tcp", proxyURL, nil, proxy.Direct)
if err != nil {
return nil, fmt.Errorf("[GetProxiedClient] : %w", err)
}
} else {
dialer = net.Dialer{
- Timeout: 5 * time.Second,
+ Timeout: 5 * time.Second, //nolint: mnd,gomnd
}
+
if err != nil {
return nil, fmt.Errorf("[GetProxiedClient] : %w", err)
}
@@ -63,7 +66,7 @@ func GetProxiedClient() (*http.Client, error) {
dialContext := func(ctx context.Context, network, address string) (net.Conn, error) {
if isProxied {
- netConn, err := dialer_proxy.Dial(network, address)
+ netConn, err := dialerProxy.Dial(network, address)
if err == nil {
return netConn, nil
}
@@ -104,7 +107,7 @@ func getTGBot() *tgbotapi.BotAPI {
// bot, err := tgbotapi.NewBotAPIWithClient(token[1:len(token)-1], client)
bot, err := tgbotapi.NewBotAPI(token[1 : len(token)-1])
if err != nil {
- log.Fatal().Err(err)
+ log.Fatal().Err(err).Send()
}
return bot
@@ -141,7 +144,7 @@ func (s *server) Notify(
func startServer(port uint16) {
listener, err := net.Listen("tcp", fmt.Sprintf("0.0.0.0:%d", port))
if err != nil {
- log.Fatal().Err(err)
+ log.Fatal().Err(err).Send()
}
var opts []grpc.ServerOption
@@ -150,7 +153,7 @@ func startServer(port uint16) {
pb.RegisterNotificationServiceServer(grpcServer, &server{})
if err := grpcServer.Serve(listener); err != nil {
- log.Fatal().Err(err)
+ log.Fatal().Err(err).Send()
}
}