@@ -24,8 +24,10 @@ import (
24
24
)
25
25
26
26
const (
27
- enableHex = 0x10
28
- unableHex = 0x7fffffff_fffffffd
27
+ enableVideoSummary = int64 (0x10 )
28
+ disableVideoSummary = ^ enableVideoSummary
29
+ enableVideoDownload = int64 (0x20 )
30
+ disableVideoDownload = ^ enableVideoDownload
29
31
bilibiliparseReferer = "https://www.bilibili.com"
30
32
)
31
33
@@ -92,9 +94,9 @@ func init() {
92
94
data := c .GetData (ctx .Event .GroupID )
93
95
switch option {
94
96
case "开启" , "打开" , "启用" :
95
- data |= enableHex
97
+ data |= enableVideoSummary
96
98
case "关闭" , "关掉" , "禁用" :
97
- data &= unableHex
99
+ data &= disableVideoSummary
98
100
default :
99
101
return
100
102
}
@@ -105,6 +107,35 @@ func init() {
105
107
}
106
108
ctx .SendChain (message .Text ("已" , option , "视频总结" ))
107
109
})
110
+ en .OnRegex (`^(开启|打开|启用|关闭|关掉|禁用)视频上传$` , zero .AdminPermission ).SetBlock (true ).
111
+ Handle (func (ctx * zero.Ctx ) {
112
+ gid := ctx .Event .GroupID
113
+ if gid <= 0 {
114
+ // 个人用户设为负数
115
+ gid = - ctx .Event .UserID
116
+ }
117
+ option := ctx .State ["regex_matched" ].([]string )[1 ]
118
+ c , ok := ctx .State ["manager" ].(* ctrl.Control [* zero.Ctx ])
119
+ if ! ok {
120
+ ctx .SendChain (message .Text ("找不到服务!" ))
121
+ return
122
+ }
123
+ data := c .GetData (ctx .Event .GroupID )
124
+ switch option {
125
+ case "开启" , "打开" , "启用" :
126
+ data |= enableVideoDownload
127
+ case "关闭" , "关掉" , "禁用" :
128
+ data &= disableVideoDownload
129
+ default :
130
+ return
131
+ }
132
+ err := c .SetData (gid , data )
133
+ if err != nil {
134
+ ctx .SendChain (message .Text ("出错啦: " , err ))
135
+ return
136
+ }
137
+ ctx .SendChain (message .Text ("已" , option , "视频上传" ))
138
+ })
108
139
en .OnRegex (searchVideo ).SetBlock (true ).Limit (limit .LimitByGroup ).Handle (handleVideo )
109
140
en .OnRegex (searchDynamic ).SetBlock (true ).Limit (limit .LimitByGroup ).Handle (handleDynamic )
110
141
en .OnRegex (searchArticle ).SetBlock (true ).Limit (limit .LimitByGroup ).Handle (handleArticle )
@@ -127,7 +158,7 @@ func handleVideo(ctx *zero.Ctx) {
127
158
return
128
159
}
129
160
c , ok := ctx .State ["manager" ].(* ctrl.Control [* zero.Ctx ])
130
- if ok && c .GetData (ctx .Event .GroupID )& enableHex == enableHex {
161
+ if ok && c .GetData (ctx .Event .GroupID )& enableVideoSummary == enableVideoSummary {
131
162
summaryMsg , err := getVideoSummary (cfg , card )
132
163
if err != nil {
133
164
msg = append (msg , message .Text ("ERROR: " , err ))
@@ -136,12 +167,14 @@ func handleVideo(ctx *zero.Ctx) {
136
167
}
137
168
}
138
169
ctx .SendChain (msg ... )
139
- downLoadMsg , err := getVideoDownload (cfg , card , cachePath )
140
- if err != nil {
141
- ctx .SendChain (message .Text ("ERROR: " , err ))
142
- return
170
+ if ok && c .GetData (ctx .Event .GroupID )& enableVideoDownload == enableVideoDownload {
171
+ downLoadMsg , err := getVideoDownload (cfg , card , cachePath )
172
+ if err != nil {
173
+ ctx .SendChain (message .Text ("ERROR: " , err ))
174
+ return
175
+ }
176
+ ctx .SendChain (downLoadMsg ... )
143
177
}
144
- ctx .SendChain (downLoadMsg ... )
145
178
}
146
179
147
180
func handleDynamic (ctx * zero.Ctx ) {
0 commit comments