x
This commit is contained in:
parent
aa450620d3
commit
4430ecd296
@ -1,11 +1,11 @@
|
||||
mode: parallel
|
||||
containers:
|
||||
- address: http://192.168.31.233:5700
|
||||
username: admin
|
||||
password: admin
|
||||
weigth:
|
||||
mode: parallel
|
||||
limit: 9999
|
||||
# - address: http://192.168.31.233:5700
|
||||
# username: admin
|
||||
# password: admin
|
||||
# weigth:
|
||||
# mode: parallel
|
||||
# limit: 9999
|
||||
theme:
|
||||
static: ./static
|
||||
master:
|
||||
|
||||
@ -31,6 +31,10 @@ type Yaml struct {
|
||||
QbotPublicMode bool `yaml:"qbot_public_mode"`
|
||||
DailyAssetPushCron string `yaml:"daily_asset_push_cron"`
|
||||
Version string `yaml:"version"`
|
||||
Node string
|
||||
Npm string
|
||||
Python string
|
||||
Pip string
|
||||
}
|
||||
|
||||
var Balance = "balance"
|
||||
@ -79,8 +83,8 @@ func initConfig() {
|
||||
//测试
|
||||
if ExecPath == "/Users/cdle/Desktop/xdd" {
|
||||
Cdle = true
|
||||
Config.QQID = 17745270
|
||||
Config.QQGroupID = 610790654
|
||||
// Config.QQID = 17745270
|
||||
// Config.QQGroupID = 610790654
|
||||
}
|
||||
if Config.NoGhproxy {
|
||||
GhProxy = ""
|
||||
@ -88,4 +92,16 @@ func initConfig() {
|
||||
if Config.Database == "" {
|
||||
Config.Database = ExecPath + "/.xdd.db"
|
||||
}
|
||||
if Config.Npm == "" {
|
||||
Config.Npm = "npm"
|
||||
}
|
||||
if Config.Node == "" {
|
||||
Config.Node = "node"
|
||||
}
|
||||
if Config.Python == "" {
|
||||
Config.Python = "python3"
|
||||
}
|
||||
if Config.Pip == "" {
|
||||
Config.Pip = "Pip3"
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,4 +25,5 @@ func init() {
|
||||
initCron()
|
||||
go initTgBot()
|
||||
InitReplies()
|
||||
initTask()
|
||||
}
|
||||
|
||||
@ -1,14 +1,78 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/beego/beego/v2/client/httplib"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
)
|
||||
|
||||
type Task struct {
|
||||
ID int
|
||||
Cron string
|
||||
Path string
|
||||
Enable bool
|
||||
Mode string //obo alo
|
||||
Word string
|
||||
Run func()
|
||||
Name string
|
||||
}
|
||||
|
||||
type Env struct {
|
||||
Name string
|
||||
Value string
|
||||
}
|
||||
|
||||
func initTask() {
|
||||
for i := range Config.Tasks {
|
||||
if Config.Tasks[i].Name == "" {
|
||||
slice := strings.Split(Config.Tasks[i].Path, "/")
|
||||
len := len(slice)
|
||||
if len == 0 {
|
||||
return
|
||||
}
|
||||
Config.Tasks[i].Name = slice[len-1]
|
||||
}
|
||||
createTask(&Config.Tasks[i])
|
||||
}
|
||||
}
|
||||
|
||||
func createTask(task *Task) {
|
||||
id, err := c.AddFunc(task.Cron, func() {
|
||||
runTask(task)
|
||||
})
|
||||
if err != nil {
|
||||
logs.Warn(task.Word, "任务创建失败:", err)
|
||||
} else {
|
||||
task.ID = int(id)
|
||||
logs.Info(task.Word, "任务创建成功:", err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func runTask(task *Task) {
|
||||
var path = ExecPath + "/scripts/" + task.Name
|
||||
if strings.Contains(task.Path, "http") {
|
||||
f, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0777)
|
||||
if err != nil {
|
||||
logs.Warn("打开%s失败,", path, err)
|
||||
}
|
||||
url := task.Path
|
||||
if strings.Contains(url, "raw.githubusercontent.com") {
|
||||
url = GhProxy + url
|
||||
}
|
||||
r, err := httplib.Get(url).Response()
|
||||
if err != nil {
|
||||
logs.Warn("下载%s失败,", task.Path, err)
|
||||
}
|
||||
io.Copy(f, r.Body)
|
||||
f.Close()
|
||||
}
|
||||
// lan := Config.Node
|
||||
// if strings.Contains(task.Name, ".py") {
|
||||
// lan = Config.Python
|
||||
// }
|
||||
// cmd := exec.Command(lan, )
|
||||
}
|
||||
|
||||
BIN
qrcode.png
Normal file
BIN
qrcode.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 508 B |
Loading…
Reference in New Issue
Block a user