@@ -2,11 +2,11 @@ package bot
22
33import (
44 "fmt"
5+ "github.com/Mrs4s/MiraiGo/utils"
56 "io/ioutil"
67 "time"
78
89 "github.com/Mrs4s/MiraiGo/client"
9- "github.com/Mrs4s/MiraiGo/utils"
1010 "github.com/ProtobufBot/Go-Mirai-Client/pkg/util"
1111 "github.com/fanliao/go-promise"
1212 log "github.com/sirupsen/logrus"
@@ -15,26 +15,31 @@ import (
1515var Cli * client.QQClient
1616
1717func InitDevice (path string ) {
18- if ! util .PathExists (path ) {
19- log .Warn ("虚拟设备信息不存在, 将自动生成随机设备." )
20- client .GenRandomDevice ()
21- client .SystemDeviceInfo .Display = []byte ("GMC." + utils .RandomStringRange (6 , "0123456789" ) + ".001" )
22- client .SystemDeviceInfo .FingerPrint = []byte ("pbbot/gmc/gmc:10/PBBOT.200324.001/" + utils .RandomStringRange (7 , "0123456789" ) + ":user/release-keys" )
23- client .
SystemDeviceInfo .
ProcVersion = []
byte (
"Linux 5.4.0-54-generic" + utils .
RandomString (
8 )
+ " ([email protected] )" )
24- client .SystemDeviceInfo .AndroidId = client .SystemDeviceInfo .Display
25- client .SystemDeviceInfo .Device = []byte ("gmc" )
26- client .SystemDeviceInfo .Board = []byte ("gmc" )
27- client .SystemDeviceInfo .Model = []byte ("gmc" )
28- client .SystemDeviceInfo .Brand = []byte ("pbbot" )
29- client .SystemDeviceInfo .Product = []byte ("gmc" )
30- client .SystemDeviceInfo .Protocol = client .IPad
31- _ = ioutil .WriteFile (path , client .SystemDeviceInfo .ToJson (), 0644 )
32- log .Infof ("已生成设备信息并保存到 %s 文件." , path )
33- }
34- log .Infof ("将使用 %s 内的设备信息运行" , path )
18+ log .Info ("生成随机设备信息" )
19+ client .GenRandomDevice ()
20+ client .SystemDeviceInfo .Display = []byte ("GMC." + utils .RandomStringRange (6 , "0123456789" ) + ".001" )
21+ client .SystemDeviceInfo .FingerPrint = []byte ("pbbot/gmc/gmc:10/PBBOT.200324.001/" + utils .RandomStringRange (7 , "0123456789" ) + ":user/release-keys" )
22+ client .
SystemDeviceInfo .
ProcVersion = []
byte (
"Linux 5.4.0-54-generic" + utils .
RandomString (
8 )
+ " ([email protected] )" )
23+ client .SystemDeviceInfo .AndroidId = client .SystemDeviceInfo .Display
24+ client .SystemDeviceInfo .Device = []byte ("gmc" )
25+ client .SystemDeviceInfo .Board = []byte ("gmc" )
26+ client .SystemDeviceInfo .Model = []byte ("gmc" )
27+ client .SystemDeviceInfo .Brand = []byte ("pbbot" )
28+ client .SystemDeviceInfo .Product = []byte ("gmc" )
29+ client .SystemDeviceInfo .Protocol = client .IPad
3530 client .SystemDeviceInfo .IpAddress = []byte {192 , 168 , 31 , 101 }
36- if err := client .SystemDeviceInfo .ReadJson ([]byte (util .ReadAllText (path ))); err != nil {
37- util .FatalError (fmt .Errorf ("failed to load device info, err: %+v" , err ))
31+
32+ if util .PathExists (path ) {
33+ log .Infof ("使用 %s 内的设备信息覆盖随机设备信息" , path )
34+ if err := client .SystemDeviceInfo .ReadJson ([]byte (util .ReadAllText (path ))); err != nil {
35+ util .FatalError (fmt .Errorf ("failed to load device info, err: %+v" , err ))
36+ }
37+ }
38+
39+ log .Infof ("保存设备信息到文件 %s" , path )
40+ err := ioutil .WriteFile (path , client .SystemDeviceInfo .ToJson (), 0644 )
41+ if err != nil {
42+ log .Warnf ("写设备信息文件 %s 失败" , path )
3843 }
3944}
4045
0 commit comments