/
main.go
49 lines (41 loc) · 1.18 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"context"
"fmt"
"log"
"net/http"
"os"
"github.com/Korpenter/tg-midbot/midbot-in/pkg/agent"
"github.com/Korpenter/tg-midbot/midbot-in/pkg/repo/ydb"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/sqs"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
"github.com/joho/godotenv"
"github.com/labstack/echo/v4"
)
var Version string
func main() {
log.Println("Release info: ", fmt.Sprintf("Version: %s ", Version))
godotenv.Load()
bot, err := tgbotapi.NewBotAPI(os.Getenv("TELEGRAM_APITOKEN"))
if err != nil {
panic(err)
}
customResolver := aws.EndpointResolverWithOptionsFunc(func(service, region string, options ...interface{}) (aws.Endpoint, error) {
return aws.Endpoint{
URL: "https://message-queue.api.cloud.yandex.net",
SigningRegion: "ru-central1",
}, nil
})
cfg, err := config.LoadDefaultConfig(
context.Background(),
config.WithEndpointResolverWithOptions(customResolver),
)
r := ydb.New()
c := sqs.NewFromConfig(cfg)
a := agent.New(bot, c, r, http.DefaultClient)
e := echo.New()
e.POST("/", a.HandleUpdate)
e.Start(":" + os.Getenv("PORT"))
}