flag for authcode

This commit is contained in:
2021-10-05 18:54:58 +02:00
parent eb9fcbee03
commit 831ced97af
2 changed files with 14 additions and 16 deletions

View File

@@ -1,7 +1,6 @@
package csgo
import (
"bufio"
"encoding/json"
"fmt"
"github.com/an0nfunc/go-steam/v3"
@@ -128,11 +127,12 @@ func (d *DemoMatchLoader) connectToSteam() error {
return nil
}
func (d *DemoMatchLoader) Setup(username string) error {
func (d *DemoMatchLoader) Setup(username string, authCode string) error {
d.steamLogin = new(steam.LogOnDetails)
d.steamLogin.Username = username
d.steamLogin.Password = os.Getenv("STEAM_PASSWORD")
d.steamLogin.ShouldRememberPassword = true
d.steamLogin.AuthCode = authCode
if _, err := os.Stat(SENTRYFILE); err == nil {
hash, err := ioutil.ReadFile(SENTRYFILE)
@@ -208,10 +208,7 @@ func (d *DemoMatchLoader) steamEventHandler() {
log.Warningf("[DL] Steam login denied: %+v", e)
switch e.Result {
case steamlang.EResult_AccountLogonDenied:
log.Warningf("[DL] Asking for auth code now, please provide on stdin.")
scanner := bufio.NewScanner(os.Stdin)
scanner.Scan()
d.steamLogin.AuthCode = scanner.Text()
log.Warningf("[DL] Please provide AuthCode with --authcode")
}
case *steam.DisconnectedEvent:
log.Warningf("Steam disconnected, trying to reconnect...")