MCPcopy Create free account
hub / github.com/FloatTech/ZeroBot-Plugin-Playground / init

Function init

plugin/qqci/qqci.go:27–336  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25)
26
27func init() {
28 engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
29 DisableOnDefault: false,
30 Brief: "简易cicd",
31 Help: "- /qqci -a zbp -r git@github.com:FloatTech/ZeroBot-Plugin -dir /usr/local/service -cmd \"zpb\" -act insert\n" +
32 "- /qqci -a zbp -dir D:/test -act update\n" +
33 "- /qqci -a zbp -act select\n" +
34 "- /qqci -a zbp -act folder -f /23bc19be-6b54-4542-b42e-d97a6bea81fd" +
35 "- /qqci -a zbp -b master -act ci\n" +
36 "- /qqci -a zbp -act restart\n" +
37 "- /qqci -a zbp -act install\n" +
38 "- /qqci -a zbp -act start\n" +
39 "- /qqci -a zbp -act stop\n" +
40 "- /qqci -a zbp -act upload",
41 PublicDataFolder: "Qqci",
42 })
43 cachePath := engine.DataFolder() + "cache/"
44 _ = os.RemoveAll(cachePath)
45 _ = os.MkdirAll(cachePath, 0755)
46 adb = initialize(engine.DataFolder() + "qqci.db")
47 getdb := fcext.DoOnceOnSuccess(func(_ *zero.Ctx) bool {
48 _, _ = engine.GetLazyData("makefile.tpl", true)
49 _, _ = engine.GetLazyData("load.tpl", true)
50 return true
51 })
52 engine.OnShell("qqci", application{}, getdb, zero.SuperUserPermission).Handle(func(ctx *zero.Ctx) {
53 var (
54 app application
55 err error
56 cmd *exec.Cmd
57 )
58 _ = os.MkdirAll(app.Directory, 0755)
59 flagapp := ctx.State["flag"].(*application)
60 switch flagapp.Action {
61 case "select":
62 res, err := adb.get(flagapp)
63 if err != nil {
64 ctx.SendChain(message.Text("ERROR:", err))
65 return
66 }
67 ctx.SendChain(message.Text(fmt.Sprintf("执行成功,数据库参数: %+v \n\n", res)))
68 case "insert":
69 err = adb.insert(flagapp)
70 if err != nil {
71 ctx.SendChain(message.Text("ERROR:", err))
72 return
73 }
74 ctx.SendChain(message.Text(fmt.Sprintf("执行成功,命令参数: %+v \n\n", flagapp)))
75 case "update":
76 err = adb.update(flagapp)
77 if err != nil {
78 ctx.SendChain(message.Text("ERROR:", err))
79 return
80 }
81 ctx.SendChain(message.Text(fmt.Sprintf("执行成功,命令参数: %+v \n\n", flagapp)))
82 case "install", "start", "restart", "stop":
83 app, err = adb.getApp(flagapp)
84 if err != nil {

Callers

nothing calls this directly

Calls 7

getConfigFileFunction · 0.85
deCompressFunction · 0.85
getMethod · 0.80
updateMethod · 0.80
getAppMethod · 0.80
initializeFunction · 0.70
insertMethod · 0.45

Tested by

no test coverage detected