mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2026-02-12 02:00:24 +00:00
chore: update deps
This commit is contained in:
@@ -18,7 +18,7 @@ import (
|
||||
const gistraw = "https://gist.githubusercontent.com/%s/%s/raw/%s"
|
||||
|
||||
func checkNewUser(qq, gid int64, ghun, hash string) (bool, string) {
|
||||
if db.CanFind("member", "where ghun="+ghun) {
|
||||
if db.CanFind("member", "WHERE ghun = ?", ghun) {
|
||||
return false, "该github用户已入群"
|
||||
}
|
||||
gidsum := md5.Sum(helper.StringToBytes(strconv.FormatInt(gid, 10)))
|
||||
|
||||
@@ -63,7 +63,7 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
db = &sql.Sqlite{}
|
||||
db sql.Sqlite
|
||||
clock timer.Clock
|
||||
)
|
||||
|
||||
@@ -76,12 +76,12 @@ func init() { // 插件主体
|
||||
})
|
||||
|
||||
go func() {
|
||||
db.DBPath = engine.DataFolder() + "config.db"
|
||||
db = sql.New(engine.DataFolder() + "config.db")
|
||||
err := db.Open(time.Hour)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
clock = timer.NewClock(db)
|
||||
clock = timer.NewClock(&db)
|
||||
err = db.Create("welcome", &welcome{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -442,7 +442,7 @@ func init() { // 插件主体
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
if ctx.Event.NoticeType == "group_increase" && ctx.Event.SelfID != ctx.Event.UserID {
|
||||
var w welcome
|
||||
err := db.Find("welcome", &w, "where gid = "+strconv.FormatInt(ctx.Event.GroupID, 10))
|
||||
err := db.Find("welcome", &w, "WHERE gid = ?", ctx.Event.GroupID)
|
||||
if err == nil {
|
||||
ctx.SendGroupMessage(ctx.Event.GroupID, message.ParseMessageFromString(welcometocq(ctx, w.Msg)))
|
||||
} else {
|
||||
@@ -494,7 +494,7 @@ func init() { // 插件主体
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
if ctx.Event.NoticeType == "group_decrease" {
|
||||
var w welcome
|
||||
err := db.Find("farewell", &w, "where gid = "+strconv.FormatInt(ctx.Event.GroupID, 10))
|
||||
err := db.Find("farewell", &w, "WHERE gid = ?", ctx.Event.GroupID)
|
||||
if err == nil {
|
||||
collectsend(ctx, message.ParseMessageFromString(welcometocq(ctx, w.Msg))...)
|
||||
} else {
|
||||
@@ -523,7 +523,7 @@ func init() { // 插件主体
|
||||
engine.OnFullMatch("测试欢迎语", zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
var w welcome
|
||||
err := db.Find("welcome", &w, "where gid = "+strconv.FormatInt(ctx.Event.GroupID, 10))
|
||||
err := db.Find("welcome", &w, "WHERE gid = ?", ctx.Event.GroupID)
|
||||
if err == nil {
|
||||
ctx.SendGroupMessage(ctx.Event.GroupID, message.ParseMessageFromString(welcometocq(ctx, w.Msg)))
|
||||
} else {
|
||||
@@ -550,7 +550,7 @@ func init() { // 插件主体
|
||||
engine.OnFullMatch("测试告别辞", zero.OnlyGroup, zero.AdminPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
var w welcome
|
||||
err := db.Find("farewell", &w, "where gid = "+strconv.FormatInt(ctx.Event.GroupID, 10))
|
||||
err := db.Find("farewell", &w, "WHERE gid = ?", ctx.Event.GroupID)
|
||||
if err == nil {
|
||||
ctx.SendGroupMessage(ctx.Event.GroupID, message.ParseMessageFromString(welcometocq(ctx, w.Msg)))
|
||||
} else {
|
||||
|
||||
@@ -9,17 +9,17 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
var slowsenders = syncx.Map[int64, *syncx.Lazy[*slowdo.Job[*zero.Ctx, message.MessageSegment]]]{}
|
||||
var slowsenders = syncx.Map[int64, *syncx.Lazy[*slowdo.Job[*zero.Ctx, message.Segment]]]{}
|
||||
|
||||
func collectsend(ctx *zero.Ctx, msgs ...message.MessageSegment) {
|
||||
func collectsend(ctx *zero.Ctx, msgs ...message.Segment) {
|
||||
id := ctx.Event.GroupID
|
||||
if id == 0 {
|
||||
// only support group
|
||||
return
|
||||
}
|
||||
lazy, _ := slowsenders.LoadOrStore(id, &syncx.Lazy[*slowdo.Job[*zero.Ctx, message.MessageSegment]]{
|
||||
Init: func() *slowdo.Job[*zero.Ctx, message.MessageSegment] {
|
||||
x, err := slowdo.NewJob(time.Second*5, ctx, func(ctx *zero.Ctx, msg []message.MessageSegment) {
|
||||
lazy, _ := slowsenders.LoadOrStore(id, &syncx.Lazy[*slowdo.Job[*zero.Ctx, message.Segment]]{
|
||||
Init: func() *slowdo.Job[*zero.Ctx, message.Segment] {
|
||||
x, err := slowdo.NewJob(time.Second*5, ctx, func(ctx *zero.Ctx, msg []message.Segment) {
|
||||
if len(msg) == 1 {
|
||||
ctx.Send(msg)
|
||||
return
|
||||
|
||||
@@ -22,7 +22,7 @@ func (t *Timer) InsertInto(db *sql.Sqlite) error {
|
||||
|
||||
/*
|
||||
func getTimerFrom(db *sql.Sqlite, id uint32) (t Timer, err error) {
|
||||
err = db.Find("timer", &t, "where id = "+strconv.Itoa(int(id)))
|
||||
err = db.Find("timer", &t, "WHERE id = "+strconv.Itoa(int(id)))
|
||||
return
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
package timer
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -29,7 +28,7 @@ type Clock struct {
|
||||
|
||||
var (
|
||||
// @全体成员
|
||||
atall = message.MessageSegment{
|
||||
atall = message.Segment{
|
||||
Type: "at",
|
||||
Data: map[string]string{
|
||||
"qq": "all",
|
||||
@@ -133,7 +132,7 @@ func (c *Clock) CancelTimer(key uint32) bool {
|
||||
}
|
||||
c.timersmu.Lock()
|
||||
delete(*c.timers, key) // 避免重复取消
|
||||
e := c.db.Del("timer", "where id = "+strconv.Itoa(int(key)))
|
||||
e := c.db.Del("timer", "WHERE id = ?", key)
|
||||
c.timersmu.Unlock()
|
||||
return e == nil
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ func TestNextWakeTime(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClock(t *testing.T) {
|
||||
db := &sql.Sqlite{DBPath: "test.db"}
|
||||
c := NewClock(db)
|
||||
db := sql.New("test.db")
|
||||
c := NewClock(&db)
|
||||
c.AddTimerIntoDB(GetFilledTimer([]string{"", "12", "-1", "12", "0", "", "test"}, 0, 0, false))
|
||||
t.Log(c.ListTimers(0))
|
||||
t.Fail()
|
||||
|
||||
Reference in New Issue
Block a user