mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2026-02-13 02:30:26 +00:00
make lint happy
This commit is contained in:
@@ -2,13 +2,12 @@ package cpstory
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/extension/rate"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/control"
|
||||
"github.com/FloatTech/ZeroBot-Plugin/utils/ctxext"
|
||||
"github.com/FloatTech/ZeroBot-Plugin/utils/math"
|
||||
)
|
||||
|
||||
@@ -16,19 +15,15 @@ const (
|
||||
prio = 20
|
||||
)
|
||||
|
||||
var (
|
||||
engine = control.Register("cpstory", &control.Options{
|
||||
func init() {
|
||||
engine := control.Register("cpstory", &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "cp短打\n- 组cp[@xxx][@xxx]\n- 组cp大老师 雪乃",
|
||||
})
|
||||
limit = rate.NewManager(time.Minute, 20)
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine.OnRegex("^组cp.*?(\\d+).*?(\\d+)").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) {
|
||||
engine.OnRegex("^组cp.*?(\\d+).*?(\\d+)", zero.OnlyGroup).SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) {
|
||||
cs := getRandomCpStory()
|
||||
gong := getCardOrNickName(ctx, math.Str2Int64(ctx.State["regex_matched"].([]string)[1]))
|
||||
shou := getCardOrNickName(ctx, math.Str2Int64(ctx.State["regex_matched"].([]string)[2]))
|
||||
gong := ctxext.CardOrNickName(ctx, math.Str2Int64(ctx.State["regex_matched"].([]string)[1]))
|
||||
shou := ctxext.CardOrNickName(ctx, math.Str2Int64(ctx.State["regex_matched"].([]string)[2]))
|
||||
text := strings.ReplaceAll(cs.Story, "<攻>", gong)
|
||||
text = strings.ReplaceAll(text, "<受>", shou)
|
||||
text = strings.ReplaceAll(text, cs.Gong, gong)
|
||||
@@ -51,11 +46,3 @@ func init() {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func getCardOrNickName(ctx *zero.Ctx, userId int64) (name string) {
|
||||
name = ctx.GetGroupMemberInfo(ctx.Event.GroupID, userId, false).Get("card").String()
|
||||
if name == "" {
|
||||
name = ctx.GetStrangerInfo(userId, false).Get("nickname").String()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ func init() {
|
||||
// os.RemoveAll(dbpath)
|
||||
_ = os.MkdirAll(dbpath, 0755)
|
||||
_, _ = file.GetLazyData(dbfile, false, true)
|
||||
err := db.Create("cp_story", &CpStory{})
|
||||
err := db.Create("cp_story", &cpstory{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package cpstory
|
||||
|
||||
type CpStory struct {
|
||||
Id int64 `db:"id"`
|
||||
type cpstory struct {
|
||||
ID int64 `db:"id"`
|
||||
Gong string `db:"gong"`
|
||||
Shou string `db:"shou"`
|
||||
Story string `db:"story"`
|
||||
}
|
||||
|
||||
func getRandomCpStory() (cs CpStory) {
|
||||
func getRandomCpStory() (cs cpstory) {
|
||||
_ = db.Pick("cp_story", &cs)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user