diff --git a/pkg/device/device.go b/pkg/device/device.go index 3c085b2..e81847b 100644 --- a/pkg/device/device.go +++ b/pkg/device/device.go @@ -19,8 +19,6 @@ import ( log "github.com/sirupsen/logrus" ) -var Path = "device" - func RandDevice(randGen *rand.Rand) *client.DeviceInfo { device := &client.DeviceInfo{ AndroidId: []byte("MIRAI.123456.001"), @@ -111,7 +109,7 @@ func GetDevice(seed int64, clientProtocol int32) *client.DeviceInfo { randGen = rand.New(rand.NewSource(time.Now().UnixNano())) } // 默认 device/device-qq.json - devicePath := path.Join(Path, fmt.Sprintf("device-%d.json", seed)) + devicePath := path.Join("device", fmt.Sprintf("device-%d.json", seed)) // 优先使用参数目录 if config.Device != "" { diff --git a/pkg/gmc/gmc.go b/pkg/gmc/gmc.go index 3f53c1c..9a433b3 100644 --- a/pkg/gmc/gmc.go +++ b/pkg/gmc/gmc.go @@ -24,15 +24,14 @@ import ( ) var ( - sms = false // 参数优先使用短信验证 - wsUrls = "" // websocket url - port = 9000 // 端口号 - uin int64 = 0 // qq - pass = "" //password - device = "" // device file path - help = false // help - auth = "" - LogPath = "logs" + sms = false // 参数优先使用短信验证 + wsUrls = "" // websocket url + port = 9000 // 端口号 + uin int64 = 0 // qq + pass = "" //password + device = "" // device file path + help = false // help + auth = "" ) func init() { @@ -58,10 +57,10 @@ func InitLog() { log.SetOutput(os.Stdout) // 输出到文件 - rotateLogs, err := rotatelogs.New(path.Join(LogPath, "%Y-%m-%d.log"), - rotatelogs.WithLinkName(path.Join(LogPath, "latest.log")), // 最新日志软链接 - rotatelogs.WithRotationTime(time.Hour*24), // 每天一个新文件 - rotatelogs.WithMaxAge(time.Hour*24*3), // 日志保留3天 + rotateLogs, err := rotatelogs.New(path.Join("logs", "%Y-%m-%d.log"), + rotatelogs.WithLinkName(path.Join("logs", "latest.log")), // 最新日志软链接 + rotatelogs.WithRotationTime(time.Hour*24), // 每天一个新文件 + rotatelogs.WithMaxAge(time.Hour*24*3), // 日志保留3天 ) if err != nil { util.FatalError(err) diff --git a/service/gmc_android/gmc.go b/service/gmc_android/gmc.go index cfda1bf..ac3be3b 100644 --- a/service/gmc_android/gmc.go +++ b/service/gmc_android/gmc.go @@ -1,8 +1,9 @@ package gmc_android import ( + "os" + "github.com/ProtobufBot/Go-Mirai-Client/pkg/config" - "github.com/ProtobufBot/Go-Mirai-Client/pkg/device" "github.com/ProtobufBot/Go-Mirai-Client/pkg/gmc" log "github.com/sirupsen/logrus" @@ -11,24 +12,13 @@ import ( var logger AndroidLogger -// SetPluginPath 设置插件配置路径 -func SetPluginPath(pluginPath string) { - config.PluginPath = pluginPath -} - // SetSms 设置是否短信优先 func SetSms(sms bool) { config.SMS = sms } -// SetLogPath 设置日志目录 -func SetLogPath(logPath string) { - gmc.LogPath = logPath -} - -// SetDevicePath 设置设备信息路径 -func SetDevicePath(devicePath string) { - device.Path = devicePath +func Chdir(dir string) { + _ = os.Chdir(dir) } // Start 启动主程序