moved to pkgs
This commit is contained in:
parent
7ea6ba6809
commit
843a357428
8 changed files with 44 additions and 41 deletions
|
@ -11,6 +11,8 @@ import (
|
|||
"github.com/disgoorg/disgo/webhook"
|
||||
"github.com/disgoorg/log"
|
||||
"github.com/disgoorg/snowflake/v2"
|
||||
"grow.rievo.dev/discordBots/cmd/dealsbot/api"
|
||||
"grow.rievo.dev/discordBots/cmd/dealsbot/repository"
|
||||
"os"
|
||||
"os/signal"
|
||||
"reflect"
|
||||
|
@ -41,7 +43,7 @@ func main() {
|
|||
client := webhook.New(webhookID, webhookToken)
|
||||
defer client.Close(context.TODO())
|
||||
|
||||
repo := InitDb()
|
||||
repo := repository.InitDb()
|
||||
defer repo.Close()
|
||||
|
||||
ticker := time.NewTicker(10 * time.Minute)
|
||||
|
@ -52,17 +54,17 @@ func main() {
|
|||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
var apis []Api
|
||||
apis = append(apis, newUbsioftApi(), newEpicApi(), newSteamApi(), newGogApi(), newHumbleBundleApi())
|
||||
var apis []api.Api
|
||||
apis = append(apis, api.NewUbsioftApi(), api.NewEpicApi(), api.NewSteamApi(), api.NewGogApi(), api.NewHumbleBundleApi())
|
||||
for _, api := range apis {
|
||||
err := api.load()
|
||||
err := api.Load()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
}
|
||||
var deals []Deal
|
||||
var deals []api.Deal
|
||||
for _, api := range apis {
|
||||
apiDeals := api.get()
|
||||
apiDeals := api.Get()
|
||||
deals = append(deals, apiDeals...)
|
||||
}
|
||||
|
||||
|
@ -104,7 +106,7 @@ func main() {
|
|||
<-s
|
||||
}
|
||||
|
||||
func sendWebhook(client webhook.Client, deal Deal) {
|
||||
func sendWebhook(client webhook.Client, deal api.Deal) {
|
||||
var status string
|
||||
|
||||
status = fmt.Sprintf("currently free: %v\n", deal.Url)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue