Skip to content
This repository has been archived by the owner on Jul 20, 2024. It is now read-only.

Commit

Permalink
make some new fixes and changes for botway init --docker command.
Browse files Browse the repository at this point in the history
  • Loading branch information
abdfnx committed May 13, 2022
1 parent a8eefc1 commit a04759b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.18
require (
github.com/AlecAivazis/survey/v2 v2.3.4
github.com/MakeNowJust/heredoc v1.0.0
github.com/abdfnx/gosh v0.3.9
github.com/abdfnx/looker v0.1.0
github.com/abdfnx/resto v0.1.6
github.com/abdfnx/tran v0.1.31
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ
github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE=
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/abdfnx/gosh v0.3.9 h1:/jZXpHeQkfGScfaLrag/cr5RwG3/kU5GQKqsBBykpQ8=
github.com/abdfnx/gosh v0.3.9/go.mod h1:bho3zdOB7bNUOZDeI5+CSjoiF+MHmzHWqHHDAQiCq1c=
github.com/abdfnx/looker v0.1.0 h1:tMN7E0wKIgbydAPPQ1RkppJ1bGHn+B+y9PZy7mwa+3U=
github.com/abdfnx/looker v0.1.0/go.mod h1:QVfPHnredPBUg4R+MtEkZbMBbqrgtoaj0JHO3KYkvyE=
github.com/abdfnx/resto v0.1.6 h1:yOM9O9bpMP4lb2ox0U7/gcFXO78P5eUZBxWuKrfdrFA=
Expand Down
27 changes: 23 additions & 4 deletions internal/pipes/initx/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"strings"

"github.com/abdfnx/botway/constants"
"github.com/abdfnx/gosh"
"github.com/abdfnx/tran/dfs"
"github.com/gookit/config/v2"
"github.com/gookit/config/v2/yaml"
Expand Down Expand Up @@ -61,22 +62,40 @@ func DockerInit() {
bot_token = "TELEGRAM_TOKEN"
}

viper.SetDefault("botway.bots." + GetBotName() + ".bot_token", os.Getenv(bot_token))
err, out, errOut := gosh.RunOutput("botway vars get " + bot_token)

if err != nil {
panic(errOut)
}

appErr, appOut, appErrOut := gosh.RunOutput("botway vars get " + app_token)

if appErr != nil {
panic(appErrOut)
}

viper.SetDefault("botway.bots." + GetBotName() + ".bot_token", out)

if t != "telegram" {
viper.SetDefault("botway.bots." + GetBotName() + "." + cid, os.Getenv(app_token))
viper.SetDefault("botway.bots." + GetBotName() + "." + cid, appOut)
}

if t == "discord" {
if constants.Gerr != nil {
panic(constants.Gerr)
} else {
guilds := gjson.Get(string(constants.Guilds), "guilds.#")

for x := 0; x < int(guilds.Int()); x++ {
server := gjson.Get(string(constants.Guilds), "guilds." + fmt.Sprint(x)).String()

viper.Set("botway.bots." + GetBotName() + ".guilds." + server + ".server_id", os.Getenv(strings.ToUpper(server + "_GUILD_ID")))
err, out, errOut := gosh.RunOutput("botway vars get " + strings.ToUpper(server + "_GUILD_ID"))

if err != nil {
panic(errOut)
}

viper.Set("botway.bots." + GetBotName() + ".guilds." + server + ".server_id", out)
}
}
}
Expand Down

0 comments on commit a04759b

Please sign in to comment.