7
7
"strconv"
8
8
9
9
"github.com/dingdinglz/dingbot/appconfig"
10
+ "github.com/dingdinglz/dingbot/database"
10
11
"github.com/dingdinglz/dingbot/route"
11
12
"github.com/dingdinglz/dingbot/tool"
12
13
"github.com/gofiber/fiber/v2"
@@ -19,6 +20,9 @@ func ServerInit() {
19
20
rootPath , _ := os .Getwd ()
20
21
tEngine := html .New (filepath .Join (rootPath , "web" , "index" ), ".html" )
21
22
tEngine .ShouldReload = true
23
+ tEngine .AddFunc ("Open" , func (Uin uint32 , Typename string ) bool {
24
+ return database .OpenHave (Uin , Typename )
25
+ })
22
26
appconfig .MainServer = fiber .New (fiber.Config {Views : tEngine })
23
27
appconfig .MainServer .Use (recover .New (), logger .New ())
24
28
appconfig .MainServer .Static ("/" , filepath .Join (rootPath , "web" , "public" ))
@@ -47,6 +51,9 @@ func ServerInitRun() {
47
51
func ServerCommonRun () {
48
52
appconfig .MainServer .Get ("/" , route .IndexRoute )
49
53
appconfig .MainServer .Get ("/key" , route .KeyWordRoute )
54
+ appconfig .MainServer .Get ("/plugin-edit/:name" , route .PluginEditRoute )
55
+ appconfig .MainServer .Get ("/group" , route .GroupOpenRoute )
56
+ appconfig .MainServer .Get ("/private" , route .PrivateOpenRoute )
50
57
51
58
apiRoute := appconfig .MainServer .Group ("/api" )
52
59
@@ -63,9 +70,11 @@ func ServerCommonRun() {
63
70
64
71
apiAddRoute := apiRoute .Group ("/add" )
65
72
apiAddRoute .Post ("/keyword" , route .AddKeywordRoute )
73
+ apiAddRoute .Post ("/open" , route .AddOpenRoute )
66
74
67
75
apiDeleteRoute := apiRoute .Group ("/delete" )
68
76
apiDeleteRoute .Post ("/keyword" , route .DeleteKeywordRoute )
77
+ apiDeleteRoute .Post ("/open" , route .DeleteOpenRoute )
69
78
70
79
err := appconfig .MainServer .Listen ("0.0.0.0:" + strconv .Itoa (appconfig .AppConfigVar .Port ))
71
80
if err != nil {
0 commit comments