Skip to content

Commit

Permalink
android chdir
Browse files Browse the repository at this point in the history
  • Loading branch information
lz1998 committed Dec 19, 2021
1 parent 061a2c1 commit 71aa44e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 30 deletions.
4 changes: 1 addition & 3 deletions pkg/device/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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 != "" {
Expand Down
25 changes: 12 additions & 13 deletions pkg/gmc/gmc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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)
Expand Down
18 changes: 4 additions & 14 deletions service/gmc_android/gmc.go
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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 启动主程序
Expand Down

0 comments on commit 71aa44e

Please sign in to comment.