twitchapon

[Twi]tch [Cha]nnel [Po]ints Rewards Redemption Listener
git clone git://bsandro.tech/twitchapon
Log | Files | Refs | README | LICENSE

config.go (779B)


      1 package main
      2 
      3 import (
      4 	"encoding/json"
      5 	"os"
      6 )
      7 
      8 type TConfig struct {
      9 	LocalServer  string `json:"local_server"`
     10 	WssServer    string `json:"wss_server"`
     11 	WssPort      string `json:"wss_port"`
     12 	WssOrigin    string `json:"wss_origin"`
     13 	AnimServer   string `json:"anim_server"`
     14 	UserName     string `json:"user_name"`
     15 	ClientId     string `json:"client_id"`
     16 	ClientSecret string `json:"client_secret"`
     17 }
     18 
     19 func (conf *TConfig) Init() error {
     20 	config_name := "config.json"
     21 	if len(os.Args) > 1 {
     22 		config_name = os.Args[1]
     23 	}
     24 	config_data, err := os.ReadFile(config_name)
     25 	if err != nil {
     26 		return err
     27 	}
     28 	err = json.Unmarshal(config_data, conf)
     29 	if err != nil {
     30 		return err
     31 	}
     32 
     33 	return nil
     34 }
     35 
     36 func (conf *TConfig) IsInited() bool {
     37 	return conf != nil && len(conf.ClientId) > 0
     38 }