🎨 🔥 优化代码结构

This commit is contained in:
fumiama
2022-02-15 20:50:49 +08:00
parent 121403231a
commit 4ca5038ae9
52 changed files with 441 additions and 795 deletions

View File

@@ -18,6 +18,7 @@ type bottle struct {
Msg string `db:"msg"` // Msg 消息,纯文本
}
var sea = &sql.Sqlite{}
var seamu sync.RWMutex
func newBottle(qq, grp int64, name, msg string) *bottle {

View File

@@ -1,23 +0,0 @@
package driftbottle
import (
"os"
sql "github.com/FloatTech/sqlite"
)
const (
dbpath = "data/driftbottle/"
dbfile = dbpath + "sea.db"
)
var sea = &sql.Sqlite{DBPath: dbfile}
func init() {
_ = os.MkdirAll(dbpath, 0755)
err := sea.Open()
if err != nil {
panic(err)
}
_ = createChannel(sea, "global")
}

View File

@@ -16,9 +16,16 @@ import (
func init() {
en := control.Register("driftbottle", order.AcquirePrio(), &control.Options{
DisableOnDefault: false,
Help: "漂流瓶\n- (在群xxx)丢漂流瓶(到频道xxx) [消息]\n- (从频道xxx)捡漂流瓶\n- @BOT 创建频道 xxx\n- 跳入(频道)海中\n- 注:不显式限制时,私聊发送可在所有群抽到,群聊发送仅可在本群抽到,默认频道为 global",
DisableOnDefault: false,
Help: "漂流瓶\n- (在群xxx)丢漂流瓶(到频道xxx) [消息]\n- (从频道xxx)捡漂流瓶\n- @BOT 创建频道 xxx\n- 跳入(频道)海中\n- 注:不显式限制时,私聊发送可在所有群抽到,群聊发送仅可在本群抽到,默认频道为 global",
PrivateDataFolder: "driftbottle",
})
sea.DBPath = en.DataFolder() + "sea.db"
err := sea.Open()
if err != nil {
panic(err)
}
_ = createChannel(sea, "global")
en.OnRegex(`^(在群\d+)?丢漂流瓶(到频道\w+)?\s+(.*)$`).SetBlock(true).
Handle(func(ctx *zero.Ctx) {
msgs := ctx.State["regex_matched"].([]string)