@@ -44,8 +44,6 @@ func IsWechatRunning() bool {
4444 return strings .Contains (string (output ), "BetterGI.exe" )
4545}
4646
47- var Config = config .Cfg
48-
4947// 向企业微信发送通知(文本)
5048func SendWeChatNotification (content string ) {
5149
@@ -65,7 +63,7 @@ func SendWeChatNotification(content string) {
6563
6664 client := & http.Client {}
6765
68- req , err := http .NewRequest ("POST" , Config .WebhookURL , bytes .NewBuffer (jsonData ))
66+ req , err := http .NewRequest ("POST" , config . Cfg .WebhookURL , bytes .NewBuffer (jsonData ))
6967 if err != nil {
7068
7169 autoLog .Sugar .Error ("Error creating request:" , err )
@@ -122,7 +120,7 @@ func SendWeChatImage(path string) error {
122120
123121 client := & http.Client {}
124122
125- req , err := http .NewRequest ("POST" , Config .WebhookURL , bytes .NewBuffer (jsonData ))
123+ req , err := http .NewRequest ("POST" , config . Cfg .WebhookURL , bytes .NewBuffer (jsonData ))
126124 if err != nil {
127125
128126 autoLog .Sugar .Error ("Error creating request:" , err )
@@ -164,7 +162,7 @@ func CheckBetterGIStatus() {
164162 }
165163 } else {
166164 if ! notified {
167- SendWeChatNotification ("BetterGI 已经关闭:" + Config .Content )
165+ SendWeChatNotification ("BetterGI 已经关闭:" + config . Cfg .Content )
168166 control .CloseYuanShen ()
169167 notified = true
170168 okRun = true
@@ -295,7 +293,7 @@ func TodayHarvest(fileName string) (map[string]int, error) {
295293 autoLog .Sugar .Infof ("今日收获统计" )
296294 re := regexp .MustCompile (`^交互或拾取:"([^"]*)"` )
297295
298- filename := filepath .Clean (fmt .Sprintf ("%s\\ log\\ %s" , Config .BetterGIAddress , fileName ))
296+ filename := filepath .Clean (fmt .Sprintf ("%s\\ log\\ %s" , config . Cfg .BetterGIAddress , fileName ))
299297
300298 file , err := os .Open (filename )
301299 if err != nil {
@@ -333,7 +331,7 @@ type Material struct {
333331
334332func BagStatistics () ([]Material , error ) {
335333 autoLog .Sugar .Infof ("背包统计" )
336- filename := filepath .Clean (fmt .Sprintf ("%s\\ User\\ JsScript\\ 背包材料统计\\ latest_record.txt" , Config .BetterGIAddress ))
334+ filename := filepath .Clean (fmt .Sprintf ("%s\\ User\\ JsScript\\ 背包材料统计\\ latest_record.txt" , config . Cfg .BetterGIAddress ))
337335
338336 // 打开文件
339337 file , err := os .Open (filename )
@@ -348,7 +346,7 @@ func BagStatistics() ([]Material, error) {
348346 // 创建一个正则表达式来匹配日期格式 "YYYY/M/D HH:MM:SS"
349347 re1 := regexp .MustCompile (`\b\d{4}/\d{1,2}/\d{1,2} \d{2}:\d{2}:\d{2}\b` )
350348
351- statistics := Config .BagStatistics
349+ statistics := config . Cfg .BagStatistics
352350
353351 split := strings .Split (statistics , "," )
354352
@@ -401,7 +399,7 @@ func BagStatistics() ([]Material, error) {
401399// 原石统计
402400func YuanShiStatistics () ([]Material , error ) {
403401 autoLog .Sugar .Infof ("原石统计" )
404- filename := filepath .Clean (fmt .Sprintf ("%s\\ User\\ JsScript\\ OCR读取当前抽卡资源并发送通知\\ Resources_log.txt" , Config .BetterGIAddress ))
402+ filename := filepath .Clean (fmt .Sprintf ("%s\\ User\\ JsScript\\ OCR读取当前抽卡资源并发送通知\\ Resources_log.txt" , config . Cfg .BetterGIAddress ))
405403 file , err := os .Open (filename )
406404 if err != nil {
407405 autoLog .Sugar .Errorf ("没有相关JS:OCR读取当前抽卡资源并发送通知" )
@@ -437,7 +435,7 @@ func YuanShiStatistics() ([]Material, error) {
437435func MorasStatistics () ([]Material , error ) {
438436
439437 autoLog .Sugar .Infof ("摩拉统计" )
440- filename := filepath .Clean (fmt .Sprintf ("%s\\ User\\ JsScript\\ OCR读取当前摩拉记录并发送通知\\ mora_log.txt" , Config .BetterGIAddress ))
438+ filename := filepath .Clean (fmt .Sprintf ("%s\\ User\\ JsScript\\ OCR读取当前摩拉记录并发送通知\\ mora_log.txt" , config . Cfg .BetterGIAddress ))
441439 // 打开文件
442440 file , err := os .Open (filename )
443441 if err != nil {
@@ -580,7 +578,7 @@ func ReadVersion(filePath string) string {
580578
581579func GetAutoArtifactsPro () ([]DogFood , error ) {
582580 // 获取当前目录下所有 .txt 文件
583- files , err := filepath .Glob (fmt .Sprintf ("%s\\ User\\ JsScript\\ AutoArtifactsPro\\ records\\ *.txt" , Config .BetterGIAddress ))
581+ files , err := filepath .Glob (fmt .Sprintf ("%s\\ User\\ JsScript\\ AutoArtifactsPro\\ records\\ *.txt" , config . Cfg .BetterGIAddress ))
584582 if err != nil {
585583 return nil , err
586584 }
@@ -639,7 +637,7 @@ type EarningsData struct {
639637func GetAutoArtifactsPro2 (fileName string ) (* EarningsData , error ) {
640638
641639 autoLog .Sugar .Infof ("狗粮查询" )
642- filePath := filepath .Clean (fmt .Sprintf ("%s\\ User\\ JsScript\\ AutoArtifactsPro\\ records\\ %s" , Config .BetterGIAddress , fileName ))
640+ filePath := filepath .Clean (fmt .Sprintf ("%s\\ User\\ JsScript\\ AutoArtifactsPro\\ records\\ %s" , config . Cfg .BetterGIAddress , fileName ))
643641 file , err := os .Open (filePath )
644642 if err != nil {
645643 return nil , err
@@ -816,7 +814,7 @@ func UpdateJsAndPathing() error {
816814 autoLog .Sugar .Infof ("开始更新脚本和地图仓库" )
817815 autoLog .Sugar .Infof ("开始备份user文件夹" )
818816
819- err4 := zipDir (Config .BetterGIAddress + "\\ User\\ " , "Users\\ User" + time .Now ().Format ("20060102" )+ ".zip" )
817+ err4 := zipDir (config . Cfg .BetterGIAddress + "\\ User\\ " , "Users\\ User" + time .Now ().Format ("20060102" )+ ".zip" )
820818 if err4 != nil {
821819 return fmt .Errorf ("备份失败" )
822820 }
@@ -846,9 +844,9 @@ func UpdateJsAndPathing() error {
846844
847845 autoLog .Sugar .Info ("已删除压缩包" )
848846 autoLog .Sugar .Info ("开始备份指定文件" )
849- for _ , path := range Config .Backups {
847+ for _ , path := range config . Cfg .Backups {
850848
851- file := fmt .Sprintf ("%s\\ User\\ %s" , Config .BetterGIAddress , path )
849+ file := fmt .Sprintf ("%s\\ User\\ %s" , config . Cfg .BetterGIAddress , path )
852850
853851 err := copy .Copy (file , "./backups/" + path )
854852 if err != nil {
@@ -860,29 +858,29 @@ func UpdateJsAndPathing() error {
860858 }
861859
862860 autoLog .Sugar .Info ("开始更新脚本文件" )
863- err := copy .Copy ("./repo/js" , Config .BetterGIAddress + "\\ User\\ JsScript" )
861+ err := copy .Copy ("./repo/js" , config . Cfg .BetterGIAddress + "\\ User\\ JsScript" )
864862 if err != nil {
865863 return err
866864 }
867865
868866 autoLog .Sugar .Info ("已更新脚本文件" )
869867 autoLog .Sugar .Info ("开始更新地图追踪文件" )
870868
871- err2 := os .RemoveAll (Config .BetterGIAddress + "\\ User\\ AutoPathing" )
869+ err2 := os .RemoveAll (config . Cfg .BetterGIAddress + "\\ User\\ AutoPathing" )
872870 if err2 != nil {
873871 return err2
874872 }
875- err3 := copy .Copy ("./repo/pathing" , Config .BetterGIAddress + "\\ User\\ AutoPathing" )
873+ err3 := copy .Copy ("./repo/pathing" , config . Cfg .BetterGIAddress + "\\ User\\ AutoPathing" )
876874 if err3 != nil {
877875 return err3
878876 }
879877
880878 autoLog .Sugar .Info ("开始还原备份文件配置文件" )
881879 autoLog .Sugar .Info ("开始还原备份文件配置文件" )
882880
883- for _ , path := range Config .Backups {
881+ for _ , path := range config . Cfg .Backups {
884882
885- file := fmt .Sprintf ("%s\\ User\\ %s" , Config .BetterGIAddress , path )
883+ file := fmt .Sprintf ("%s\\ User\\ %s" , config . Cfg .BetterGIAddress , path )
886884
887885 err := copy .Copy ("./backups/" + path , file )
888886 if err != nil {
@@ -1043,16 +1041,16 @@ func zipDir(sourceDir, zipFilePath string) error {
10431041}
10441042
10451043func Backup () error {
1046- for _ , path := range Config .Backups {
1044+ for _ , path := range config . Cfg .Backups {
10471045
1048- file := fmt .Sprintf ("%s\\ User\\ %s" , Config .BetterGIAddress , path )
1046+ file := fmt .Sprintf ("%s\\ User\\ %s" , config . Cfg .BetterGIAddress , path )
10491047
10501048 copy .Copy (file , "./backups/" + path )
10511049
10521050 autoLog .Sugar .Infof ("已备份文件: %s\n " , path )
10531051 }
10541052 autoLog .Sugar .Infof ("开始备份user文件夹" )
1055- err4 := zipDir (Config .BetterGIAddress + "\\ User\\ " , "Users\\ User" + time .Now ().Format ("2006100215020405" )+ ".zip" )
1053+ err4 := zipDir (config . Cfg .BetterGIAddress + "\\ User\\ " , "Users\\ User" + time .Now ().Format ("2006100215020405" )+ ".zip" )
10561054 if err4 != nil {
10571055 autoLog .Sugar .Errorf ("备份失败: %v" )
10581056 return fmt .Errorf ("备份失败" )
@@ -1112,7 +1110,7 @@ func GroupTime(fileName string) ([]GroupMap, error) {
11121110 today = formatted
11131111 }
11141112
1115- filename := filepath .Clean (fmt .Sprintf ("%s\\ log\\ %s" , Config .BetterGIAddress , fileName ))
1113+ filename := filepath .Clean (fmt .Sprintf ("%s\\ log\\ %s" , config . Cfg .BetterGIAddress , fileName ))
11161114
11171115 file , err := os .Open (filename )
11181116 if err != nil {
@@ -1202,15 +1200,15 @@ func GroupTime(fileName string) ([]GroupMap, error) {
12021200
12031201// 判断配置文件是否正确
12041202func CheckConfig () (bool , error ) {
1205- fmt .Println ("配置文件路径" , Config .BetterGIAddress )
1206- _ , err := os .Stat (Config .BetterGIAddress )
1203+ fmt .Println ("配置文件路径" , config . Cfg .BetterGIAddress )
1204+ _ , err := os .Stat (config . Cfg .BetterGIAddress )
12071205 if err == nil {
12081206 fmt .Println ("Bgi安装目录设置正确" )
12091207 }
12101208 if os .IsNotExist (err ) {
12111209 return false , fmt .Errorf ("Bgi安装目录设置错误目录设置错误,请检查配置文件BetterGIAddress:你有没有加双斜杠呀,没有看网站说明" )
12121210 }
1213- names := Config .ConfigNames
1211+ names := config . Cfg .ConfigNames
12141212 if len (names ) == 7 {
12151213 fmt .Println ("配置组configNames正确" )
12161214 } else {
@@ -1256,7 +1254,7 @@ type GitLogStruct struct {
12561254
12571255// 查询git日志
12581256func GitLog () []GitLogStruct {
1259- localPath := Config .BetterGIAddress + "/Repos/bettergi-scripts-list-git"
1257+ localPath := config . Cfg .BetterGIAddress + "/Repos/bettergi-scripts-list-git"
12601258
12611259 // 打开仓库
12621260 repo , err := git .PlainOpen (localPath )
@@ -1316,7 +1314,7 @@ func GitLog() []GitLogStruct {
13161314// git拉取代码
13171315func GitPull () error {
13181316
1319- localPath := Config .BetterGIAddress + "/Repos/bettergi-scripts-list-git"
1317+ localPath := config . Cfg .BetterGIAddress + "/Repos/bettergi-scripts-list-git"
13201318
13211319 // 尝试打开本地仓库
13221320 repo , err := git .PlainOpen (localPath )
@@ -1368,7 +1366,7 @@ func UpdateJs(jsName string) (string, error) {
13681366 return err .Error (), err
13691367 }
13701368
1371- repoDir := Config .BetterGIAddress + "/Repos/bettergi-scripts-list-git/repo/js"
1369+ repoDir := config . Cfg .BetterGIAddress + "/Repos/bettergi-scripts-list-git/repo/js"
13721370 //
13731371
13741372 subFolderPath , err := findSubFolder (repoDir , jsName )
@@ -1378,7 +1376,7 @@ func UpdateJs(jsName string) (string, error) {
13781376 }
13791377
13801378 // 找到子文件夹后,执行复制操作
1381- targetPath := filepath .Join (Config .BetterGIAddress , "User" , "JsScript" , jsName )
1379+ targetPath := filepath .Join (config . Cfg .BetterGIAddress , "User" , "JsScript" , jsName )
13821380
13831381 if jsName == "AutoArtifactsPro" {
13841382 autoLog .Sugar .Infof ("狗粮pro脚本特殊处理" )
@@ -1437,8 +1435,8 @@ func AutoJs() (string, error) {
14371435 return err .Error (), err
14381436 }
14391437
1440- jsNames := Config .JsName
1441- repoDir := Config .BetterGIAddress + "/Repos/bettergi-scripts-list-git/repo/js"
1438+ jsNames := config . Cfg .JsName
1439+ repoDir := config . Cfg .BetterGIAddress + "/Repos/bettergi-scripts-list-git/repo/js"
14421440 //
14431441 for _ , jsName := range jsNames {
14441442 subFolderPath , err := findSubFolder (repoDir , jsName )
@@ -1448,7 +1446,7 @@ func AutoJs() (string, error) {
14481446 }
14491447
14501448 // 找到子文件夹后,执行复制操作
1451- targetPath := filepath .Join (Config .BetterGIAddress , "User" , "JsScript" , jsName )
1449+ targetPath := filepath .Join (config . Cfg .BetterGIAddress , "User" , "JsScript" , jsName )
14521450
14531451 if jsName == "AutoArtifactsPro" {
14541452 autoLog .Sugar .Infof ("狗粮pro脚本特殊处理" )
@@ -1652,7 +1650,7 @@ func ListArchive() []ArchiveRecords {
16521650// JsVersion 读取脚本的版本号
16531651func JsVersion (jsName , nowVersion string ) string {
16541652
1655- repoDir := Config .BetterGIAddress + "/Repos/bettergi-scripts-list-git/repo/js"
1653+ repoDir := config . Cfg .BetterGIAddress + "/Repos/bettergi-scripts-list-git/repo/js"
16561654
16571655 filePath := filepath .Join (repoDir , jsName , "manifest.json" )
16581656 // 读取文件内容
@@ -1683,7 +1681,7 @@ func JsVersion(jsName, nowVersion string) string {
16831681var BgiStatus bool
16841682
16851683func ReadLog () {
1686- filePath := filepath .Clean (fmt .Sprintf ("%s\\ log" , Config .BetterGIAddress ))
1684+ filePath := filepath .Clean (fmt .Sprintf ("%s\\ log" , config . Cfg .BetterGIAddress ))
16871685 files , err := FindLogFiles (filePath )
16881686 if err != nil || len (files ) == 0 {
16891687 fmt .Println ("找不到日志文件" )
@@ -1768,7 +1766,7 @@ type LogAnalysis2Json struct {
17681766
17691767// 日志分析
17701768func LogAnalysis2 (fileName string ) []LogAnalysis2Struct {
1771- filePath := filepath .Join (Config .BetterGIAddress , "log" )
1769+ filePath := filepath .Join (config . Cfg .BetterGIAddress , "log" )
17721770 fullPath := filepath .Join (filePath , fileName )
17731771
17741772 file , err := os .Open (fullPath )
@@ -1947,7 +1945,7 @@ func JsNamesInfo() []JsNamesInfoStruct {
19471945 return []JsNamesInfoStruct {}
19481946 }
19491947
1950- jsNames := Config .JsName
1948+ jsNames := config . Cfg .JsName
19511949 var jsNamesInfoStructs []JsNamesInfoStruct
19521950 for _ , name := range jsNames {
19531951 var jsNamesInfoStruct JsNamesInfoStruct
@@ -1969,7 +1967,7 @@ func JsNamesInfo() []JsNamesInfoStruct {
19691967
19701968func GetMysSignLog () string {
19711969
1972- url := Config .MySign .Url
1970+ url := config . Cfg .MySign .Url
19731971 readLogURL := "http://" + url + "/read-log"
19741972 resp , err := http .Get (readLogURL )
19751973 if err != nil {
0 commit comments