Extracted scenario

This commit is contained in:
Artyom Belousov 2021-06-06 11:00:50 +03:00
parent c02435ccaa
commit cc2058090c
13 changed files with 235 additions and 173 deletions

View file

@ -2,7 +2,6 @@ package main
import (
"encoding/json"
"gitlab.com/flygrounder/go-mtg-vk/internal/cardsinfo"
"io/ioutil"
"log"
"math/rand"
@ -10,6 +9,9 @@ import (
"strconv"
"time"
"gitlab.com/flygrounder/go-mtg-vk/internal/cardsinfo"
"gitlab.com/flygrounder/go-mtg-vk/internal/scenario"
"github.com/gin-gonic/gin"
"gitlab.com/flygrounder/go-mtg-vk/internal/caching"
"gitlab.com/flygrounder/go-mtg-vk/internal/vk"
@ -26,17 +28,19 @@ func main() {
var dictMap map[string]string
_ = json.Unmarshal(dictBytes, &dictMap)
handler := vk.Handler{
Scenario: &scenario.Scenario{
Sender: &vk.ApiSender{
Token: os.Getenv("VK_TOKEN"),
Token: os.Getenv("VK_TOKEN"),
},
Logger: log.New(os.Stdout, "", 0),
Cache: caching.NewClient("redis:6379", "", time.Hour*24, 0),
InfoFetcher: &cardsinfo.Fetcher{
Dict: dictMap,
},
},
SecretKey: os.Getenv("VK_SECRET_KEY"),
GroupId: groupId,
ConfirmationString: os.Getenv("VK_CONFIRMATION_STRING"),
Cache: caching.NewClient("redis:6379", "", time.Hour*24, 0),
InfoFetcher: &cardsinfo.Fetcher{
Dict: dictMap,
},
}
r.POST("callback/message", handler.HandleMessage)