feat: 添加 CDK 查询功能
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "blazing/modules/config/controller/robot"
|
||||||
_ "blazing/modules/player/controller/robot"
|
_ "blazing/modules/player/controller/robot"
|
||||||
|
|
||||||
// _ "github.com/FloatTech/ZeroBot-Plugin/plugin/antiabuse" // 违禁词
|
// _ "github.com/FloatTech/ZeroBot-Plugin/plugin/antiabuse" // 违禁词
|
||||||
|
|||||||
26
modules/config/controller/robot/cdk.go
Normal file
26
modules/config/controller/robot/cdk.go
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
package robot
|
||||||
|
|
||||||
|
import (
|
||||||
|
"blazing/modules/config/service"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
zero.OnCommand("CDK").
|
||||||
|
Handle(func(ctx *zero.Ctx) {
|
||||||
|
|
||||||
|
var cdks []string
|
||||||
|
for _, v := range service.NewCdkService().All() {
|
||||||
|
if v.ValidEndTime.After(time.Now()) {
|
||||||
|
cdks = append(cdks, v.CDKCode)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.Send(strings.Join(cdks, "\n"))
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -44,6 +44,13 @@ func (s *CdkService) Get(id string) *model.CDKConfig {
|
|||||||
|
|
||||||
return item
|
return item
|
||||||
|
|
||||||
|
}
|
||||||
|
func (s *CdkService) All() []model.CDKConfig {
|
||||||
|
var item []model.CDKConfig
|
||||||
|
dbm_notenable(s.Model).WhereLT("exchange_remain_count", 0).Scan(&item)
|
||||||
|
|
||||||
|
return item
|
||||||
|
|
||||||
}
|
}
|
||||||
func (s *CdkService) Set(id string) bool {
|
func (s *CdkService) Set(id string) bool {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user