From 746909a309f95c3833a227b787cc61e7ee3c38fd Mon Sep 17 00:00:00 2001 From: ayntgl <90600421+ayntgl@users.noreply.github.com> Date: Mon, 20 Sep 2021 10:39:52 +0400 Subject: [PATCH] Create constant for keyring Service (discordo) (#49) --- main.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index fa713f9..e5ffeea 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,8 @@ import ( "github.com/zalando/go-keyring" ) +const Service = "discordo" + var ( app *tview.Application loginForm *tview.Form @@ -15,7 +17,8 @@ var ( messageInputField *tview.InputField mainFlex *tview.Flex - conf *config + conf *config + session *discordgo.Session selectedChannel *discordgo.Channel selectedMessage *discordgo.Message @@ -43,7 +46,7 @@ func main() { AddItem(rightFlex, 0, 4, false) token := conf.Token - if t, _ := keyring.Get("discordo", "token"); t != "" { + if t, _ := keyring.Get(Service, "token"); t != "" { token = t } @@ -108,7 +111,7 @@ func onLoginFormLoginButtonSelected() { panic(err) } - go keyring.Set("discordo", "token", lr.Token) + go keyring.Set(Service, "token", lr.Token) } else if lr.MFA { // The account has MFA enabled, reattempt login with code and ticket. loginForm = newLoginForm(func() { @@ -132,7 +135,7 @@ func onLoginFormLoginButtonSelected() { panic(err) } - go keyring.Set("discordo", "token", lr.Token) + go keyring.Set(Service, "token", lr.Token) }, true) app.SetRoot(loginForm, true)