mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-18 20:50:12 +08:00
chore: update deps
This commit is contained in:
parent
f5e1c197dd
commit
83ca8c344b
20
go.mod
20
go.mod
@ -4,15 +4,15 @@ go 1.20
|
||||
|
||||
require (
|
||||
github.com/Baidu-AIP/golang-sdk v1.1.1
|
||||
github.com/FloatTech/AnimeAPI v1.7.1-0.20241014163126-6979a83dd88f
|
||||
github.com/FloatTech/floatbox v0.0.0-20240505082030-226ec6713e14
|
||||
github.com/FloatTech/AnimeAPI v1.7.1-0.20241106140713-04a12240c99c
|
||||
github.com/FloatTech/floatbox v0.0.0-20241106130736-5aea0a935024
|
||||
github.com/FloatTech/gg v1.1.3
|
||||
github.com/FloatTech/imgfactory v0.2.2-0.20230413152719-e101cc3606ef
|
||||
github.com/FloatTech/rendercard v0.2.0
|
||||
github.com/FloatTech/sqlite v1.6.3
|
||||
github.com/FloatTech/sqlite v1.7.0
|
||||
github.com/FloatTech/ttl v0.0.0-20240716161252-965925764562
|
||||
github.com/FloatTech/zbpctrl v1.6.2-0.20240904160347-1317e11a15bb
|
||||
github.com/FloatTech/zbputils v1.7.2-0.20241013175349-67b3df244b08
|
||||
github.com/FloatTech/zbpctrl v1.7.0
|
||||
github.com/FloatTech/zbputils v1.7.2-0.20241106140112-708bfd074ddd
|
||||
github.com/RomiChan/syncx v0.0.0-20240418144900-b7402ffdebc7
|
||||
github.com/RomiChan/websocket v1.4.3-0.20220227141055-9b2c6168c9c5
|
||||
github.com/antchfx/htmlquery v1.3.3
|
||||
@ -26,7 +26,7 @@ require (
|
||||
github.com/fumiama/gotracemoe v0.0.3
|
||||
github.com/fumiama/jieba v0.0.0-20221203025406-36c17a10b565
|
||||
github.com/fumiama/slowdo v0.0.0-20241001074058-27c4fe5259a4
|
||||
github.com/fumiama/terasu v0.0.0-20240710095334-67a8daa3a979
|
||||
github.com/fumiama/terasu v0.0.0-20241027183601-987ab91031ce
|
||||
github.com/fumiama/unibase2n v0.0.0-20240530074540-ec743fd5a6d6
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
|
||||
github.com/jinzhu/gorm v1.9.16
|
||||
@ -41,7 +41,7 @@ require (
|
||||
github.com/sirupsen/logrus v1.9.3
|
||||
github.com/tidwall/gjson v1.18.0
|
||||
github.com/wcharczuk/go-chart/v2 v2.1.2
|
||||
github.com/wdvxdr1123/ZeroBot v1.7.5
|
||||
github.com/wdvxdr1123/ZeroBot v1.8.0
|
||||
gitlab.com/gomidi/midi/v2 v2.1.7
|
||||
golang.org/x/image v0.21.0
|
||||
golang.org/x/sys v0.26.0
|
||||
@ -86,11 +86,11 @@ require (
|
||||
github.com/yusufpapurcu/wmi v1.2.4 // indirect
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8 // indirect
|
||||
golang.org/x/mobile v0.0.0-20190415191353-3e0bab5405d6 // indirect
|
||||
golang.org/x/net v0.25.0 // indirect
|
||||
modernc.org/libc v1.49.3 // indirect
|
||||
golang.org/x/net v0.27.0 // indirect
|
||||
modernc.org/libc v1.61.0 // indirect
|
||||
modernc.org/mathutil v1.6.0 // indirect
|
||||
modernc.org/memory v1.8.0 // indirect
|
||||
modernc.org/sqlite v1.20.0 // indirect
|
||||
modernc.org/sqlite v1.33.1 // indirect
|
||||
)
|
||||
|
||||
replace modernc.org/sqlite => github.com/fumiama/sqlite3 v1.29.10-simp
|
||||
|
||||
35
go.sum
35
go.sum
@ -1,24 +1,24 @@
|
||||
github.com/Baidu-AIP/golang-sdk v1.1.1 h1:RQsAmgDSAkiq22I6n7XJ2t3afgzFeqjY46FGhvrx4cw=
|
||||
github.com/Baidu-AIP/golang-sdk v1.1.1/go.mod h1:bXnGw7xPeKt8aF7UCELKrV6UZ/46spItONK1RQBQj1Y=
|
||||
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
|
||||
github.com/FloatTech/AnimeAPI v1.7.1-0.20241014163126-6979a83dd88f h1:mA7EpXusH4GzvjVw+zUxLOURybLkZ0JU+7Egg4w+2Tc=
|
||||
github.com/FloatTech/AnimeAPI v1.7.1-0.20241014163126-6979a83dd88f/go.mod h1:PxrcdFk46Io/vChKUk/tu7LV/oSmq842hQl36ksHtkM=
|
||||
github.com/FloatTech/floatbox v0.0.0-20240505082030-226ec6713e14 h1:8O0Iq9MnKsKowltY9txhOqcJdmGTjxHPQ4gEYzbJc9A=
|
||||
github.com/FloatTech/floatbox v0.0.0-20240505082030-226ec6713e14/go.mod h1:OzGLhvmtz1TKIdGaJDd8pQumvD36UqK+dWsiCISmzQQ=
|
||||
github.com/FloatTech/AnimeAPI v1.7.1-0.20241106140713-04a12240c99c h1:AxcdfANP8yzj6FTRZwVPOIZdep1NZs2t6ypzt9hd82A=
|
||||
github.com/FloatTech/AnimeAPI v1.7.1-0.20241106140713-04a12240c99c/go.mod h1:PLvoLJU+v3/44UXtixfcjVrnXeK4H9m9cRCsmXA4+l8=
|
||||
github.com/FloatTech/floatbox v0.0.0-20241106130736-5aea0a935024 h1:mrvWpiwfRklt9AyiQjKgDGJjf4YL6FZ3yC+ydbkuF2o=
|
||||
github.com/FloatTech/floatbox v0.0.0-20241106130736-5aea0a935024/go.mod h1:+P3hs+Cvl10/Aj3SNE96TuBvKAXCe+XD1pKphTZyiwk=
|
||||
github.com/FloatTech/gg v1.1.3 h1:+GlL02lTKsxJQr4WCuNwVxC1/eBZrCvypCIBtxuOFb4=
|
||||
github.com/FloatTech/gg v1.1.3/go.mod h1:/9oLP54CMfq4r+71XL26uaFTJ1uL1boAyX67680/1HE=
|
||||
github.com/FloatTech/imgfactory v0.2.2-0.20230413152719-e101cc3606ef h1:CJbK/2FRwPuZpeb6M4sWK2d7oXDnBEGhpkQuQrgc91A=
|
||||
github.com/FloatTech/imgfactory v0.2.2-0.20230413152719-e101cc3606ef/go.mod h1:el5hGpj1C1bDRxcTXYRwEivDCr40zZeJpcrLrB1fajs=
|
||||
github.com/FloatTech/rendercard v0.2.0 h1:PBTZ2gCEy/dAEGSfWecrGTrWDYpiBJD1dVzNDDaOxh4=
|
||||
github.com/FloatTech/rendercard v0.2.0/go.mod h1:Sbojcy1t3NfFz7/WicZRmR/uKFxNMYkKF8qHx69dxY0=
|
||||
github.com/FloatTech/sqlite v1.6.3 h1:MQkqBNlkPuCoKQQgoNLuTL/2Ci3tBTFAnVYBdD0Wy4M=
|
||||
github.com/FloatTech/sqlite v1.6.3/go.mod h1:zFbHzRfB+CJ+VidfjuVbrcin3DAz283F7hF1hIeHzpY=
|
||||
github.com/FloatTech/sqlite v1.7.0 h1:FGSn4pCR12kESozn7IvNx3U39dwR/AcFM9oPyGACsl0=
|
||||
github.com/FloatTech/sqlite v1.7.0/go.mod h1:/4tzfCGhrZnnjC1U8vcfwGQeF6eR649fhOsS3+Le0+s=
|
||||
github.com/FloatTech/ttl v0.0.0-20240716161252-965925764562 h1:snfw7FNFym1eNnLrQ/VCf80LiQo9C7jHgrunZDwiRcY=
|
||||
github.com/FloatTech/ttl v0.0.0-20240716161252-965925764562/go.mod h1:fHZFWGquNXuHttu9dUYoKuNbm3dzLETnIOnm1muSfDs=
|
||||
github.com/FloatTech/zbpctrl v1.6.2-0.20240904160347-1317e11a15bb h1:sGqwCiMDyUD/znWEVVRVxbd6Kg1KLgGnnIuq5bCUWaQ=
|
||||
github.com/FloatTech/zbpctrl v1.6.2-0.20240904160347-1317e11a15bb/go.mod h1:I+MetM++1sJhNPg3zww1aw04BicYsNohvHC4Jh52XSo=
|
||||
github.com/FloatTech/zbputils v1.7.2-0.20241013175349-67b3df244b08 h1:fwVPkvJ5dR0/GisRomaDHEJ5whQBu6dSLQJpAP1gbwA=
|
||||
github.com/FloatTech/zbputils v1.7.2-0.20241013175349-67b3df244b08/go.mod h1:J/uDSgIGr8exK1B49XebRKAKphgg/Gpfh1bpjb6t6GY=
|
||||
github.com/FloatTech/zbpctrl v1.7.0 h1:Hxo6EIhJo+pHjcQP9QgIJgluaT1pHH99zkk3njqTNMo=
|
||||
github.com/FloatTech/zbpctrl v1.7.0/go.mod h1:xmM4dSwHA02Gei3ogCRiG+RTrw/7Z69PfrN5NYf8BPE=
|
||||
github.com/FloatTech/zbputils v1.7.2-0.20241106140112-708bfd074ddd h1:++VtjWPe4jTJJsDgmjc2le6nf56+Qz6yIhmuDo6X89E=
|
||||
github.com/FloatTech/zbputils v1.7.2-0.20241106140112-708bfd074ddd/go.mod h1:XQt3tWKXpGhKF2i/zGcOileTGJ1Rjratn4QGYvH0z98=
|
||||
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
|
||||
github.com/RomiChan/syncx v0.0.0-20240418144900-b7402ffdebc7 h1:S/ferNiehVjNaBMNNBxUjLtVmP/YWD6Yh79RfPv4ehU=
|
||||
github.com/RomiChan/syncx v0.0.0-20240418144900-b7402ffdebc7/go.mod h1:vD7Ra3Q9onRtojoY5sMCLQ7JBgjUsrXDnDKyFxqpf9w=
|
||||
@ -77,8 +77,8 @@ github.com/fumiama/slowdo v0.0.0-20241001074058-27c4fe5259a4 h1:zN9e09TYKXI1mNku
|
||||
github.com/fumiama/slowdo v0.0.0-20241001074058-27c4fe5259a4/go.mod h1:iZf1H/Jcw5gjOOFb4C5nlweJtViWc7uwUxRCe14pbYk=
|
||||
github.com/fumiama/sqlite3 v1.29.10-simp h1:c5y3uKyU0q9t0/SyfynzYyuslQ5zP+5CD8e0yYY554A=
|
||||
github.com/fumiama/sqlite3 v1.29.10-simp/go.mod h1:ItX2a1OVGgNsFh6Dv60JQvGfJfTPHPVpV6DF59akYOA=
|
||||
github.com/fumiama/terasu v0.0.0-20240710095334-67a8daa3a979 h1:1xSO4SvPfiw5TVeaS5ASFcl82rXH3jG8Obab0+JOC/8=
|
||||
github.com/fumiama/terasu v0.0.0-20240710095334-67a8daa3a979/go.mod h1:UVx8YP1jKKL1Cj+uy+OnQRM2Ih6U36Mqy9GSf7jabsI=
|
||||
github.com/fumiama/terasu v0.0.0-20241027183601-987ab91031ce h1:T6iDDU16rFyxV/FwfJJR6qcgkIlXJEIFlUTSmTD1h6s=
|
||||
github.com/fumiama/terasu v0.0.0-20241027183601-987ab91031ce/go.mod h1:UVx8YP1jKKL1Cj+uy+OnQRM2Ih6U36Mqy9GSf7jabsI=
|
||||
github.com/fumiama/unibase2n v0.0.0-20240530074540-ec743fd5a6d6 h1:LtDgr628eji8jRpjPCxsk7ibjcfi97QieZVCTjxLCBw=
|
||||
github.com/fumiama/unibase2n v0.0.0-20240530074540-ec743fd5a6d6/go.mod h1:lEaZsT4FRSqcjnQ5q8y+mkenkzR/r1D3BJmfdp0vqDg=
|
||||
github.com/gabriel-vasile/mimetype v1.0.4 h1:uBejfH8l3/2f+5vjl1e4xIaSyNEhRBZ5N/ij7ohpNd8=
|
||||
@ -190,8 +190,8 @@ github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+F
|
||||
github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
|
||||
github.com/wcharczuk/go-chart/v2 v2.1.2 h1:Y17/oYNuXwZg6TFag06qe8sBajwwsuvPiJJXcUcLL6E=
|
||||
github.com/wcharczuk/go-chart/v2 v2.1.2/go.mod h1:Zi4hbaqlWpYajnXB2K22IUYVXRXaLfSGNNR7P4ukyyQ=
|
||||
github.com/wdvxdr1123/ZeroBot v1.7.5 h1:a/zOc7AaBOmxMon/YAHXLJFr4bg+iS8QucrM+KxkSPQ=
|
||||
github.com/wdvxdr1123/ZeroBot v1.7.5/go.mod h1:C86nQ0gIdAri4K2vg8IIQIslt08zzrKMcqYt8zhkx1M=
|
||||
github.com/wdvxdr1123/ZeroBot v1.8.0 h1:v7m+0kGtL6XQlUH9O/LzmOntDJs2clzVj93YsAWWMbk=
|
||||
github.com/wdvxdr1123/ZeroBot v1.8.0/go.mod h1:C86nQ0gIdAri4K2vg8IIQIslt08zzrKMcqYt8zhkx1M=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
|
||||
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
|
||||
@ -203,8 +203,8 @@ golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPh
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
|
||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
|
||||
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
||||
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8 h1:idBdZTd9UioThJp8KpM/rTSinK/ChZFBE43/WtIy8zg=
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/image v0.0.0-20190220214146-31aff87c08e9/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
@ -234,8 +234,9 @@ golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
|
||||
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
|
||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
|
||||
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@ -289,8 +290,8 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||
golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
|
||||
@ -95,7 +95,7 @@ func init() { // 插件主体
|
||||
// 获取回复的文本
|
||||
reply := message.ParseMessageFromString(r.TalkPlain(ctx.Event.UserID, msg, zero.BotConfig.NickName[0]))
|
||||
// 过滤掉文字消息
|
||||
filterMsg := make([]message.MessageSegment, 0, len(reply))
|
||||
filterMsg := make([]message.Segment, 0, len(reply))
|
||||
sb := strings.Builder{}
|
||||
for _, v := range reply {
|
||||
if v.Type != "text" {
|
||||
|
||||
@ -30,7 +30,7 @@ var (
|
||||
)
|
||||
|
||||
func newantidb(path string) (*antidb, error) {
|
||||
db := &antidb{Sqlite: sqlite.Sqlite{DBPath: path}}
|
||||
db := &antidb{Sqlite: sqlite.New(path)}
|
||||
err := db.Open(bandur)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -46,7 +46,7 @@ func newantidb(path string) (*antidb, error) {
|
||||
cache.Touch(nilbt.ID, -time.Since(t))
|
||||
return nil
|
||||
})
|
||||
_ = db.Del("__bantime__", "WHERE time<="+strconv.FormatInt(time.Now().Add(time.Minute-bandur).Unix(), 10))
|
||||
_ = db.Del("__bantime__", "WHERE time <= ?", strconv.FormatInt(time.Now().Add(time.Minute-bandur).Unix(), 10))
|
||||
return db, nil
|
||||
}
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ import (
|
||||
|
||||
type datagetter func(string, bool) ([]byte, error)
|
||||
|
||||
func (dgtr datagetter) randImage(file ...string) message.MessageSegment {
|
||||
func (dgtr datagetter) randImage(file ...string) message.Segment {
|
||||
data, err := dgtr(file[rand.Intn(len(file))], true)
|
||||
if err != nil {
|
||||
return message.Text("ERROR: ", err)
|
||||
@ -27,7 +27,7 @@ func (dgtr datagetter) randImage(file ...string) message.MessageSegment {
|
||||
return message.ImageBytes(data)
|
||||
}
|
||||
|
||||
func (dgtr datagetter) randRecord(file ...string) message.MessageSegment {
|
||||
func (dgtr datagetter) randRecord(file ...string) message.Segment {
|
||||
data, err := dgtr(file[rand.Intn(len(file))], true)
|
||||
if err != nil {
|
||||
return message.Text("ERROR: ", err)
|
||||
@ -35,7 +35,7 @@ func (dgtr datagetter) randRecord(file ...string) message.MessageSegment {
|
||||
return message.Record("base64://" + base64.StdEncoding.EncodeToString(data))
|
||||
}
|
||||
|
||||
func randText(text ...string) message.MessageSegment {
|
||||
func randText(text ...string) message.Segment {
|
||||
return message.Text(text[rand.Intn(len(text))])
|
||||
}
|
||||
|
||||
|
||||
@ -224,7 +224,7 @@ func (g *group) reply(bdres *baiduRes) message.Message {
|
||||
g.mu.Lock()
|
||||
defer g.mu.Unlock()
|
||||
// 建立消息段
|
||||
msgs := make([]message.MessageSegment, 0, 8)
|
||||
msgs := make([]message.Segment, 0, 8)
|
||||
// 生成简略审核结果回复
|
||||
msgs = append(msgs, message.Text(bdres.Conclusion, "\n"))
|
||||
// 查看是否开启详细审核内容提示, 并确定审核内容值为疑似, 或者不合规
|
||||
|
||||
@ -156,7 +156,7 @@ func handleLive(ctx *zero.Ctx) {
|
||||
}
|
||||
|
||||
// getVideoSummary AI视频总结
|
||||
func getVideoSummary(cookiecfg *bz.CookieConfig, card bz.Card) (msg []message.MessageSegment, err error) {
|
||||
func getVideoSummary(cookiecfg *bz.CookieConfig, card bz.Card) (msg []message.Segment, err error) {
|
||||
var (
|
||||
data []byte
|
||||
videoSummary bz.VideoSummary
|
||||
@ -177,7 +177,7 @@ func getVideoSummary(cookiecfg *bz.CookieConfig, card bz.Card) (msg []message.Me
|
||||
return
|
||||
}
|
||||
err = json.Unmarshal(data, &videoSummary)
|
||||
msg = make([]message.MessageSegment, 0, 16)
|
||||
msg = make([]message.Segment, 0, 16)
|
||||
msg = append(msg, message.Text("已为你生成视频总结\n\n"))
|
||||
msg = append(msg, message.Text(videoSummary.Data.ModelResult.Summary, "\n\n"))
|
||||
for _, v := range videoSummary.Data.ModelResult.Outline {
|
||||
|
||||
@ -388,7 +388,7 @@ func sendLive(ctx *zero.Ctx) error {
|
||||
if lCover == "" {
|
||||
lCover = value.Get("keyframe").String()
|
||||
}
|
||||
var msg []message.MessageSegment
|
||||
var msg []message.Segment
|
||||
msg = append(msg, message.Text(lName+" 正在直播:\n"))
|
||||
msg = append(msg, message.Text(lTitle))
|
||||
msg = append(msg, message.Image(lCover))
|
||||
@ -399,7 +399,7 @@ func sendLive(ctx *zero.Ctx) error {
|
||||
switch {
|
||||
case gid > 0:
|
||||
if res := bdb.getAtAll(gid); res == 1 {
|
||||
msg = append([]message.MessageSegment{message.AtAll()}, msg...)
|
||||
msg = append([]message.Segment{message.AtAll()}, msg...)
|
||||
}
|
||||
ctx.SendGroupMessage(gid, msg)
|
||||
case gid < 0:
|
||||
|
||||
@ -25,13 +25,13 @@ var (
|
||||
)
|
||||
|
||||
// dynamicCard2msg 处理DynCard
|
||||
func dynamicCard2msg(dynamicCard *bz.DynamicCard) (msg []message.MessageSegment, err error) {
|
||||
func dynamicCard2msg(dynamicCard *bz.DynamicCard) (msg []message.Segment, err error) {
|
||||
var (
|
||||
card bz.Card
|
||||
vote bz.Vote
|
||||
cType int
|
||||
)
|
||||
msg = make([]message.MessageSegment, 0, 16)
|
||||
msg = make([]message.Segment, 0, 16)
|
||||
// 初始化结构体
|
||||
err = json.Unmarshal(binary.StringToBytes(dynamicCard.Card), &card)
|
||||
if err != nil {
|
||||
@ -50,7 +50,7 @@ func dynamicCard2msg(dynamicCard *bz.DynamicCard) (msg []message.MessageSegment,
|
||||
msg = append(msg, message.Text(card.User.Uname, msgType[cType], "\n",
|
||||
card.Item.Content, "\n",
|
||||
"转发的内容: \n"))
|
||||
var originMsg []message.MessageSegment
|
||||
var originMsg []message.Segment
|
||||
var co bz.Card
|
||||
co, err = bz.LoadCardDetail(card.Origin)
|
||||
if err != nil {
|
||||
@ -146,18 +146,18 @@ func dynamicCard2msg(dynamicCard *bz.DynamicCard) (msg []message.MessageSegment,
|
||||
}
|
||||
|
||||
// card2msg cType=1, 2, 4, 8, 16, 64, 256, 2048, 4200, 4308时,处理Card字符串,cType为card类型
|
||||
func card2msg(dynamicCard *bz.DynamicCard, card *bz.Card, cType int) (msg []message.MessageSegment, err error) {
|
||||
func card2msg(dynamicCard *bz.DynamicCard, card *bz.Card, cType int) (msg []message.Segment, err error) {
|
||||
var (
|
||||
vote bz.Vote
|
||||
)
|
||||
msg = make([]message.MessageSegment, 0, 16)
|
||||
msg = make([]message.Segment, 0, 16)
|
||||
// 生成消息
|
||||
switch cType {
|
||||
case 1:
|
||||
msg = append(msg, message.Text(card.User.Uname, msgType[cType], "\n",
|
||||
card.Item.Content, "\n",
|
||||
"转发的内容: \n"))
|
||||
var originMsg []message.MessageSegment
|
||||
var originMsg []message.Segment
|
||||
var co bz.Card
|
||||
co, err = bz.LoadCardDetail(card.Origin)
|
||||
if err != nil {
|
||||
@ -253,7 +253,7 @@ func card2msg(dynamicCard *bz.DynamicCard, card *bz.Card, cType int) (msg []mess
|
||||
}
|
||||
|
||||
// dynamicDetail 用动态id查动态信息
|
||||
func dynamicDetail(cookiecfg *bz.CookieConfig, dynamicIDStr string) (msg []message.MessageSegment, err error) {
|
||||
func dynamicDetail(cookiecfg *bz.CookieConfig, dynamicIDStr string) (msg []message.Segment, err error) {
|
||||
dyc, err := bz.GetDynamicDetail(cookiecfg, dynamicIDStr)
|
||||
if err != nil {
|
||||
return
|
||||
@ -262,8 +262,8 @@ func dynamicDetail(cookiecfg *bz.CookieConfig, dynamicIDStr string) (msg []messa
|
||||
}
|
||||
|
||||
// articleCard2msg 专栏转消息
|
||||
func articleCard2msg(card bz.Card, defaultID string) (msg []message.MessageSegment) {
|
||||
msg = make([]message.MessageSegment, 0, 16)
|
||||
func articleCard2msg(card bz.Card, defaultID string) (msg []message.Segment) {
|
||||
msg = make([]message.Segment, 0, 16)
|
||||
for i := 0; i < len(card.OriginImageUrls); i++ {
|
||||
msg = append(msg, message.Image(card.OriginImageUrls[i]))
|
||||
}
|
||||
@ -274,8 +274,8 @@ func articleCard2msg(card bz.Card, defaultID string) (msg []message.MessageSegme
|
||||
}
|
||||
|
||||
// liveCard2msg 直播卡片转消息
|
||||
func liveCard2msg(card bz.RoomCard) (msg []message.MessageSegment) {
|
||||
msg = make([]message.MessageSegment, 0, 16)
|
||||
func liveCard2msg(card bz.RoomCard) (msg []message.Segment) {
|
||||
msg = make([]message.Segment, 0, 16)
|
||||
msg = append(msg, message.Image(card.RoomInfo.Keyframe))
|
||||
msg = append(msg, message.Text("\n", card.RoomInfo.Title, "\n",
|
||||
"主播: ", card.AnchorInfo.BaseInfo.Uname, "\n",
|
||||
@ -302,9 +302,9 @@ func liveCard2msg(card bz.RoomCard) (msg []message.MessageSegment) {
|
||||
}
|
||||
|
||||
// videoCard2msg 视频卡片转消息
|
||||
func videoCard2msg(card bz.Card) (msg []message.MessageSegment, err error) {
|
||||
func videoCard2msg(card bz.Card) (msg []message.Segment, err error) {
|
||||
var mCard bz.MemberCard
|
||||
msg = make([]message.MessageSegment, 0, 16)
|
||||
msg = make([]message.Segment, 0, 16)
|
||||
mCard, err = bz.GetMemberCard(card.Owner.Mid)
|
||||
if err != nil {
|
||||
return
|
||||
|
||||
@ -10,6 +10,7 @@ import (
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
@ -24,7 +25,7 @@ func init() {
|
||||
})
|
||||
|
||||
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
db.DBPath = engine.DataFolder() + "bookreview.db"
|
||||
db = sql.New(engine.DataFolder() + "bookreview.db")
|
||||
// os.RemoveAll(dbpath)
|
||||
_, _ = engine.GetLazyData("bookreview.db", true)
|
||||
err := db.Open(time.Hour)
|
||||
|
||||
@ -7,11 +7,11 @@ type book struct {
|
||||
BookReview string `db:"bookreview"`
|
||||
}
|
||||
|
||||
var db = &sql.Sqlite{}
|
||||
var db sql.Sqlite
|
||||
|
||||
// 暂时随机选择一个书评
|
||||
func getBookReviewByKeyword(keyword string) (b book) {
|
||||
_ = db.Find("bookreview", &b, "where bookreview LIKE '%"+keyword+"%'")
|
||||
_ = db.Find("bookreview", &b, "WHERE bookreview LIKE ?", "%"+keyword+"%")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@ -235,7 +235,7 @@ func play(groupCode, senderUin int64, moveStr string) (msg message.Message, err
|
||||
chessRoomMap.Store(groupCode, room)
|
||||
}
|
||||
// 生成棋盘图片
|
||||
var boardImgEle message.MessageSegment
|
||||
var boardImgEle message.Segment
|
||||
if !room.isBlindfold {
|
||||
boardImgEle, err = getBoardElement(groupCode)
|
||||
if err != nil {
|
||||
@ -400,7 +400,7 @@ func createGame(isBlindfold bool, groupCode, senderUin int64, senderName string)
|
||||
room.blackPlayer = senderUin
|
||||
room.blackName = senderName
|
||||
chessRoomMap.Store(groupCode, room)
|
||||
var boardImgEle message.MessageSegment
|
||||
var boardImgEle message.Segment
|
||||
if !room.isBlindfold {
|
||||
boardImgEle, err = getBoardElement(groupCode)
|
||||
if err != nil {
|
||||
@ -442,7 +442,7 @@ func abortGame(room chessRoom, groupCode int64, hint string) (message.Message, e
|
||||
}
|
||||
|
||||
// getBoardElement 获取棋盘图片的消息内容
|
||||
func getBoardElement(groupCode int64) (imgMsg message.MessageSegment, err error) {
|
||||
func getBoardElement(groupCode int64) (imgMsg message.Segment, err error) {
|
||||
fontdata, err := file.GetLazyData(text.GNUUnifontFontFile, control.Md5File, true)
|
||||
if err != nil {
|
||||
return
|
||||
|
||||
@ -9,6 +9,7 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
)
|
||||
@ -23,7 +24,7 @@ func init() {
|
||||
|
||||
en.OnRegex("^抽象翻译((\\s|[\\r\\n]|[\\p{Han}\\p{P}A-Za-z0-9])+)$",
|
||||
fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
db.DBPath = en.DataFolder() + "cxh.db"
|
||||
db = sql.New(en.DataFolder() + "cxh.db")
|
||||
// os.RemoveAll(dbpath)
|
||||
_, _ = en.GetLazyData("cxh.db", true)
|
||||
err := db.Open(time.Hour)
|
||||
|
||||
@ -11,11 +11,11 @@ type emoji struct {
|
||||
Emoji string `db:"emoji"`
|
||||
}
|
||||
|
||||
var db = &sql.Sqlite{}
|
||||
var db sql.Sqlite
|
||||
|
||||
func getPinyinByWord(word string) string {
|
||||
var p pinyin
|
||||
_ = db.Find("pinyin", &p, "where word = '"+word+"'")
|
||||
_ = db.Find("pinyin", &p, "WHERE word = ?", word)
|
||||
return p.Pronun
|
||||
}
|
||||
|
||||
@ -25,6 +25,6 @@ func getPronunByDWord(w0, w1 rune) string {
|
||||
|
||||
func getEmojiByPronun(pronun string) string {
|
||||
var e emoji
|
||||
_ = db.Find("emoji", &e, "where pronunciation = '"+pronun+"'")
|
||||
_ = db.Find("emoji", &e, "WHERE pronunciation = ?", pronun)
|
||||
return e.Emoji
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ import (
|
||||
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
"github.com/FloatTech/floatbox/math"
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
)
|
||||
@ -24,7 +25,7 @@ func init() {
|
||||
})
|
||||
|
||||
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
db.DBPath = engine.DataFolder() + "cp.db"
|
||||
db = sql.New(engine.DataFolder() + "cp.db")
|
||||
// os.RemoveAll(dbpath)
|
||||
_, _ = engine.GetLazyData("cp.db", true)
|
||||
err := db.Open(time.Hour)
|
||||
|
||||
@ -9,7 +9,7 @@ type cpstory struct {
|
||||
Story string `db:"story"`
|
||||
}
|
||||
|
||||
var db = &sql.Sqlite{}
|
||||
var db sql.Sqlite
|
||||
|
||||
func getRandomCpStory() (cs cpstory) {
|
||||
_ = db.Pick("cp_story", &cs)
|
||||
|
||||
@ -10,6 +10,7 @@ import (
|
||||
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
"github.com/FloatTech/floatbox/process"
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
@ -29,7 +30,7 @@ func init() {
|
||||
})
|
||||
|
||||
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
db.DBPath = engine.DataFolder() + "curse.db"
|
||||
db = sql.New(engine.DataFolder() + "curse.db")
|
||||
_, err := engine.GetLazyData("curse.db", true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
|
||||
@ -8,9 +8,9 @@ type curse struct {
|
||||
Level string `db:"level"`
|
||||
}
|
||||
|
||||
var db = &sql.Sqlite{}
|
||||
var db sql.Sqlite
|
||||
|
||||
func getRandomCurseByLevel(level string) (c curse) {
|
||||
_ = db.Find("curse", &c, "where level = '"+level+"' ORDER BY RANDOM() limit 1")
|
||||
_ = db.Find("curse", &c, "WHERE level = ? ORDER BY RANDOM() limit 1", level)
|
||||
return
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@ type text struct {
|
||||
// LoadText 加载小作文
|
||||
func LoadText(dbfile string) error {
|
||||
_, err := file.GetLazyData(dbfile, control.Md5File, false)
|
||||
db.DBPath = dbfile
|
||||
db = sql.New(dbfile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -63,7 +63,7 @@ func RandText() string {
|
||||
// HentaiText 发大病
|
||||
func HentaiText() string {
|
||||
var t text
|
||||
err := db.Find("text", &t, "where id = -3802576048116006195")
|
||||
err := db.Find("text", &t, "WHERE id = -3802576048116006195")
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
package dish
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -25,7 +24,7 @@ type dish struct {
|
||||
}
|
||||
|
||||
var (
|
||||
db = &sql.Sqlite{}
|
||||
db sql.Sqlite
|
||||
initialized = false
|
||||
)
|
||||
|
||||
@ -37,7 +36,7 @@ func init() {
|
||||
PublicDataFolder: "Dish",
|
||||
})
|
||||
|
||||
db.DBPath = en.DataFolder() + "dishes.db"
|
||||
db = sql.New(en.DataFolder() + "dishes.db")
|
||||
|
||||
if _, err := en.GetLazyData("dishes.db", true); err != nil {
|
||||
logrus.Warnln("[dish]获取菜谱数据库文件失败")
|
||||
@ -77,7 +76,7 @@ func init() {
|
||||
}
|
||||
|
||||
var d dish
|
||||
if err := db.Find("dish", &d, fmt.Sprintf("WHERE name like '%%%s%%'", dishName)); err != nil {
|
||||
if err := db.Find("dish", &d, "WHERE name LIKE ?", "%"+dishName+"%"); err != nil {
|
||||
ctx.SendChain(message.Text("客官,本店没有" + dishName))
|
||||
return
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ type sea struct {
|
||||
Time string `db:"time"` // we need to know the current time,master>
|
||||
}
|
||||
|
||||
var seaSide = &sql.Sqlite{}
|
||||
var seaSide sql.Sqlite
|
||||
var seaLocker sync.RWMutex
|
||||
|
||||
// We need a container to inject what we need :(
|
||||
@ -39,15 +39,15 @@ func init() {
|
||||
Help: "- @bot pick" + "- @bot throw xxx (xxx为投递内容)",
|
||||
PrivateDataFolder: "driftbottle",
|
||||
})
|
||||
seaSide.DBPath = en.DataFolder() + "sea.db"
|
||||
seaSide = sql.New(en.DataFolder() + "sea.db")
|
||||
err := seaSide.Open(time.Hour)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
_ = createChannel(seaSide)
|
||||
_ = createChannel(&seaSide)
|
||||
en.OnFullMatch("pick", zero.OnlyToMe, zero.OnlyGroup).Limit(ctxext.LimitByGroup).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
be, err := fetchBottle(seaSide)
|
||||
be, err := fetchBottle(&seaSide)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERR:", err))
|
||||
}
|
||||
@ -75,7 +75,7 @@ func init() {
|
||||
senderFormatTime,
|
||||
ctx.CardOrNickName(ctx.Event.UserID),
|
||||
rawMessageCallBack,
|
||||
).throw(seaSide)
|
||||
).throw(&seaSide)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
|
||||
@ -79,7 +79,7 @@ func match(ctx *zero.Ctx) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func face2emoji(face message.MessageSegment) rune {
|
||||
func face2emoji(face message.Segment) rune {
|
||||
if face.Type == "text" {
|
||||
r := []rune(face.Data["text"])
|
||||
if len(r) != 1 {
|
||||
|
||||
@ -21,7 +21,7 @@ type joke struct {
|
||||
Text string `db:"text"`
|
||||
}
|
||||
|
||||
var db = &sql.Sqlite{}
|
||||
var db sql.Sqlite
|
||||
|
||||
func init() {
|
||||
en := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
@ -32,7 +32,7 @@ func init() {
|
||||
})
|
||||
|
||||
en.OnPrefixGroup([]string{"讲个笑话", "夸夸"}, fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
db.DBPath = en.DataFolder() + "jokes.db"
|
||||
db = sql.New(en.DataFolder() + "jokes.db")
|
||||
_, err := en.GetLazyData("jokes.db", true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
|
||||
@ -246,11 +246,7 @@ func init() {
|
||||
ctx.SendChain(message.Text(serviceErr, err))
|
||||
return
|
||||
}
|
||||
if err == nil {
|
||||
ctx.SendChain(message.Text("成功!"))
|
||||
} else {
|
||||
ctx.SendChain(message.Text(serviceErr, err))
|
||||
}
|
||||
ctx.SendChain(message.Text("成功!"))
|
||||
})
|
||||
// 下载歌曲到对应的歌单里面
|
||||
engine.OnRegex(`^下载歌单\s*((https:\/\/music\.163\.com\/#\/playlist\?id=)?(\d+)|http:\/\/music\.163\.com\/playlist\/(\d+).*[^\s$])\s*到\s*(.*)$`, zero.SuperUserPermission).SetBlock(true).Limit(ctxext.LimitByGroup).
|
||||
|
||||
@ -130,10 +130,10 @@ func init() {
|
||||
after := time.NewTimer(120 * time.Second)
|
||||
wg := sync.WaitGroup{}
|
||||
var (
|
||||
messageStr message.MessageSegment // 文本信息
|
||||
tickCount = 0 // 音频数量
|
||||
answerCount = 0 // 问答次数
|
||||
win bool // 是否赢得游戏
|
||||
messageStr message.Segment // 文本信息
|
||||
tickCount = 0 // 音频数量
|
||||
answerCount = 0 // 问答次数
|
||||
win bool // 是否赢得游戏
|
||||
)
|
||||
for {
|
||||
select {
|
||||
@ -281,7 +281,7 @@ func cutMusic(musicName, pathOfMusic, outputPath string) (err error) {
|
||||
}
|
||||
|
||||
// 数据匹配(结果信息,答题次数,提示次数,是否结束游戏)
|
||||
func gameMatch(c *zero.Ctx, beginner int64, musicInfo []string, answerTimes, tickTimes int) (message.MessageSegment, int, int, bool) {
|
||||
func gameMatch(c *zero.Ctx, beginner int64, musicInfo []string, answerTimes, tickTimes int) (message.Segment, int, int, bool) {
|
||||
answer := strings.Replace(c.Event.Message.String(), "-", "", 1)
|
||||
// 回答内容转小写,比对时再把标准答案转小写
|
||||
answer = ConvertText(answer)
|
||||
|
||||
@ -535,7 +535,7 @@ func getFileURLbyFileName(ctx *zero.Ctx, fileName string) (fileSearchName, fileU
|
||||
for _, fileNameOflist := range files {
|
||||
if strings.Contains(fileNameOflist.Get("file_name").String(), fileName) {
|
||||
fileSearchName = fileNameOflist.Get("file_name").String()
|
||||
fileURL = ctx.GetThisGroupFileUrl(fileNameOflist.Get("busid").Int(), fileNameOflist.Get("file_id").String())
|
||||
fileURL = ctx.GetThisGroupFileURL(fileNameOflist.Get("busid").Int(), fileNameOflist.Get("file_id").String())
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -561,7 +561,7 @@ func getFileURLbyfolderID(ctx *zero.Ctx, fileName, folderid string) (fileSearchN
|
||||
for _, fileNameOflist := range files {
|
||||
if strings.Contains(fileNameOflist.Get("file_name").String(), fileName) {
|
||||
fileSearchName = fileNameOflist.Get("file_name").String()
|
||||
fileURL = ctx.GetThisGroupFileUrl(fileNameOflist.Get("busid").Int(), fileNameOflist.Get("file_id").String())
|
||||
fileURL = ctx.GetThisGroupFileURL(fileNameOflist.Get("busid").Int(), fileNameOflist.Get("file_id").String())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ import (
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
)
|
||||
|
||||
var db = &sql.Sqlite{}
|
||||
var db sql.Sqlite
|
||||
var mu sync.RWMutex
|
||||
|
||||
type picture struct {
|
||||
|
||||
@ -10,6 +10,7 @@ import (
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/antchfx/htmlquery"
|
||||
@ -31,7 +32,7 @@ func init() {
|
||||
})
|
||||
|
||||
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
db.DBPath = engine.DataFolder() + "pics.db"
|
||||
db = sql.New(engine.DataFolder() + "pics.db")
|
||||
_, _ = engine.GetLazyData("pics.db", false)
|
||||
err := db.Open(time.Hour)
|
||||
if err != nil {
|
||||
@ -95,7 +96,7 @@ func init() {
|
||||
u := "https:" + v.Attr[0].Val
|
||||
i := crc64.Checksum(binary.StringToBytes(u), crc64.MakeTable(crc64.ISO))
|
||||
mu.RLock()
|
||||
ok := db.CanFind("picture", "where id="+strconv.FormatUint(i, 10))
|
||||
ok := db.CanFind("picture", "WHERE id = ?", i)
|
||||
mu.RUnlock()
|
||||
if !ok {
|
||||
mu.Lock()
|
||||
|
||||
@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
@ -26,7 +27,7 @@ func init() { // 插件主体
|
||||
})
|
||||
|
||||
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
db.DBPath = engine.DataFolder() + "item.db"
|
||||
db = sql.New(engine.DataFolder() + "item.db")
|
||||
_, err := engine.GetLazyData("item.db", true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
|
||||
@ -17,14 +17,16 @@ type item struct {
|
||||
Datetime time.Time `db:"datetime"`
|
||||
}
|
||||
|
||||
var db = &sql.Sqlite{}
|
||||
var db sql.Sqlite
|
||||
|
||||
func getRandomAudioByCategory(category string) (t item) {
|
||||
_ = db.Find("item", &t, "where category = '"+category+"' ORDER BY RANDOM() limit 1")
|
||||
_ = db.Find("item", &t, "WHERE category = ? ORDER BY RANDOM() limit 1", category)
|
||||
return
|
||||
}
|
||||
|
||||
func getRandomAudioByCategoryAndKeyword(category string, keyword string) (t item) {
|
||||
_ = db.Find("item", &t, "where category = '"+category+"' and (title like '%"+keyword+"%' or content like '%"+keyword+"%') ORDER BY RANDOM() limit 1")
|
||||
_ = db.Find("item", &t,
|
||||
"WHERE category = ? and (title LIKE ? OR content LIKE ?) ORDER BY RANDOM() limit 1",
|
||||
category, "%"+keyword+"%", "%"+keyword+"%")
|
||||
return
|
||||
}
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -20,8 +20,8 @@ import (
|
||||
)
|
||||
|
||||
type fishdb struct {
|
||||
db *sql.Sqlite
|
||||
sync.RWMutex
|
||||
db sql.Sqlite
|
||||
}
|
||||
|
||||
// FishLimit 钓鱼次数上限
|
||||
@ -121,9 +121,7 @@ var (
|
||||
durationList = make(map[string]int, 50) // 装备耐久分布
|
||||
discountList = make(map[string]int, 50) // 价格波动信息
|
||||
enchantLevel = []string{"0", "Ⅰ", "Ⅱ", "Ⅲ"}
|
||||
dbdata = &fishdb{
|
||||
db: &sql.Sqlite{},
|
||||
}
|
||||
dbdata fishdb
|
||||
)
|
||||
|
||||
var (
|
||||
@ -153,7 +151,7 @@ var (
|
||||
PublicDataFolder: "McFish",
|
||||
}).ApplySingle(ctxext.DefaultSingle)
|
||||
getdb = fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
dbdata.db.DBPath = engine.DataFolder() + "fishdata.db"
|
||||
dbdata.db = sql.New(engine.DataFolder() + "fishdata.db")
|
||||
err := dbdata.db.Open(time.Hour * 24)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR at main.go.1]:", err))
|
||||
@ -245,7 +243,7 @@ func (sql *fishdb) updateFishInfo(uid int64, number int) (residue int, err error
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
_ = sql.db.Find("fishState", &userInfo, "where ID = "+strconv.FormatInt(uid, 10))
|
||||
_ = sql.db.Find("fishState", &userInfo, "WHERE ID = ?", uid)
|
||||
if time.Unix(userInfo.Duration, 0).Day() != time.Now().Day() {
|
||||
userInfo.Fish = 0
|
||||
userInfo.Duration = time.Now().Unix()
|
||||
@ -278,7 +276,7 @@ func (sql *fishdb) updateCurseFor(uid int64, info string, number int) (err error
|
||||
changeCheck := false
|
||||
add := 0
|
||||
buffName := "宝藏诅咒"
|
||||
_ = sql.db.Find("fishState", &userInfo, "where ID = "+strconv.FormatInt(uid, 10))
|
||||
_ = sql.db.Find("fishState", &userInfo, "WHERE ID = ?", uid)
|
||||
if info == "fish" {
|
||||
userInfo.Bless += number
|
||||
for userInfo.Bless >= 75 {
|
||||
@ -306,7 +304,7 @@ func (sql *fishdb) updateCurseFor(uid int64, info string, number int) (err error
|
||||
Name: buffName,
|
||||
Type: "treasure",
|
||||
}
|
||||
_ = sql.db.Find(table, &thing, "where Name = '"+buffName+"'")
|
||||
_ = sql.db.Find(table, &thing, "WHERE Name = ?", buffName)
|
||||
thing.Number += add
|
||||
return sql.db.Insert(table, &thing)
|
||||
}
|
||||
@ -325,10 +323,10 @@ func (sql *fishdb) checkEquipFor(uid int64) (ok bool, err error) {
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if !sql.db.CanFind("fishState", "where ID = "+strconv.FormatInt(uid, 10)) {
|
||||
if !sql.db.CanFind("fishState", "WHERE ID = ?", uid) {
|
||||
return true, nil
|
||||
}
|
||||
err = sql.db.Find("fishState", &userInfo, "where ID = "+strconv.FormatInt(uid, 10))
|
||||
err = sql.db.Find("fishState", &userInfo, "WHERE ID = ?", uid)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@ -346,7 +344,7 @@ func (sql *fishdb) setEquipFor(uid int64) (err error) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_ = sql.db.Find("fishState", &userInfo, "where ID = "+strconv.FormatInt(uid, 10))
|
||||
_ = sql.db.Find("fishState", &userInfo, "WHERE ID = ?", uid)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -362,10 +360,10 @@ func (sql *fishdb) getUserEquip(uid int64) (userInfo equip, err error) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if !sql.db.CanFind("equips", "where ID = "+strconv.FormatInt(uid, 10)) {
|
||||
if !sql.db.CanFind("equips", "WHERE ID = ?", uid) {
|
||||
return
|
||||
}
|
||||
err = sql.db.Find("equips", &userInfo, "where ID = "+strconv.FormatInt(uid, 10))
|
||||
err = sql.db.Find("equips", &userInfo, "WHERE ID = ?", uid)
|
||||
return
|
||||
}
|
||||
|
||||
@ -378,7 +376,7 @@ func (sql *fishdb) updateUserEquip(userInfo equip) (err error) {
|
||||
return
|
||||
}
|
||||
if userInfo.Durable == 0 {
|
||||
return sql.db.Del("equips", "where ID = "+strconv.FormatInt(userInfo.ID, 10))
|
||||
return sql.db.Del("equips", "WHERE ID = ?", userInfo.ID)
|
||||
}
|
||||
return sql.db.Insert("equips", &userInfo)
|
||||
}
|
||||
@ -400,13 +398,13 @@ func (sql *fishdb) pickFishFor(uid int64, number int) (fishNames map[string]int,
|
||||
if count == 0 {
|
||||
return
|
||||
}
|
||||
if !sql.db.CanFind(name, "where Type is 'fish'") {
|
||||
if !sql.db.CanFind(name, "WHERE Type = 'fish'") {
|
||||
return
|
||||
}
|
||||
fishInfo := article{}
|
||||
k := 0
|
||||
for i := number * 2; i > 0 && k < len(fishList); {
|
||||
_ = sql.db.Find(name, &fishInfo, "where Name is '"+fishList[k]+"'")
|
||||
_ = sql.db.Find(name, &fishInfo, "WHERE Name = ?", fishList[k])
|
||||
if fishInfo.Number <= 0 {
|
||||
k++
|
||||
continue
|
||||
@ -422,7 +420,7 @@ func (sql *fishdb) pickFishFor(uid int64, number int) (fishNames map[string]int,
|
||||
i = 0
|
||||
}
|
||||
if fishInfo.Number <= 0 {
|
||||
err = sql.db.Del(name, "where Duration = "+strconv.FormatInt(fishInfo.Duration, 10))
|
||||
err = sql.db.Del(name, "WHERE Duration = ?", fishInfo.Duration)
|
||||
} else {
|
||||
err = sql.db.Insert(name, &fishInfo)
|
||||
}
|
||||
@ -477,13 +475,13 @@ func (sql *fishdb) getUserThingInfo(uid int64, thing string) (thingInfos []artic
|
||||
if count == 0 {
|
||||
return
|
||||
}
|
||||
if !sql.db.CanFind(name, "where Name = '"+thing+"'") {
|
||||
if !sql.db.CanFind(name, "WHERE Name = ?", thing) {
|
||||
return
|
||||
}
|
||||
err = sql.db.FindFor(name, &userInfo, "where Name = '"+thing+"'", func() error {
|
||||
err = sql.db.FindFor(name, &userInfo, "WHERE Name = ?", func() error {
|
||||
thingInfos = append(thingInfos, userInfo)
|
||||
return nil
|
||||
})
|
||||
}, thing)
|
||||
return
|
||||
}
|
||||
|
||||
@ -497,7 +495,7 @@ func (sql *fishdb) updateUserThingInfo(uid int64, userInfo article) (err error)
|
||||
return
|
||||
}
|
||||
if userInfo.Number == 0 {
|
||||
return sql.db.Del(name, "where Duration = "+strconv.FormatInt(userInfo.Duration, 10))
|
||||
return sql.db.Del(name, "WHERE Duration = ?", userInfo.Duration)
|
||||
}
|
||||
return sql.db.Insert(name, &userInfo)
|
||||
}
|
||||
@ -519,14 +517,14 @@ func (sql *fishdb) getNumberFor(uid int64, thing string) (number int, err error)
|
||||
if count == 0 {
|
||||
return
|
||||
}
|
||||
if !sql.db.CanFind(name, "where Name glob '*"+thing+"*'") {
|
||||
if !sql.db.CanFind(name, "WHERE Name glob ?", "*"+thing+"*") {
|
||||
return
|
||||
}
|
||||
info := article{}
|
||||
err = sql.db.FindFor(name, &info, "where Name glob '*"+thing+"*'", func() error {
|
||||
err = sql.db.FindFor(name, &info, "WHERE Name glob ?", func() error {
|
||||
number += info.Number
|
||||
return nil
|
||||
})
|
||||
}, "*"+thing+"*")
|
||||
return
|
||||
}
|
||||
|
||||
@ -540,13 +538,13 @@ func (sql *fishdb) getUserTypeInfo(uid int64, thingType string) (thingInfos []ar
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if !sql.db.CanFind(name, "where Type = '"+thingType+"'") {
|
||||
if !sql.db.CanFind(name, "WHERE Type = ?", thingType) {
|
||||
return
|
||||
}
|
||||
err = sql.db.FindFor(name, &userInfo, "where Type = '"+thingType+"'", func() error {
|
||||
err = sql.db.FindFor(name, &userInfo, "WHERE Type = ?", func() error {
|
||||
thingInfos = append(thingInfos, userInfo)
|
||||
return nil
|
||||
})
|
||||
}, thingType)
|
||||
return
|
||||
}
|
||||
|
||||
@ -567,7 +565,7 @@ func (sql *fishdb) refreshStroeInfo() (ok bool, err error) {
|
||||
return false, err
|
||||
}
|
||||
lastTime := storeDiscount{}
|
||||
_ = sql.db.Find("stroeDiscount", &lastTime, "where Name = 'lastTime'")
|
||||
_ = sql.db.Find("stroeDiscount", &lastTime, "WHERE Name = 'lastTime'")
|
||||
refresh := false
|
||||
timeNow := time.Now().Day()
|
||||
if timeNow != lastTime.Discount {
|
||||
@ -591,7 +589,7 @@ func (sql *fishdb) refreshStroeInfo() (ok bool, err error) {
|
||||
Discount: thingDiscount,
|
||||
}
|
||||
thingInfo := store{}
|
||||
_ = sql.db.Find("store", &thingInfo, "where Name = '"+name+"'")
|
||||
_ = sql.db.Find("store", &thingInfo, "WHERE Name = ?", name)
|
||||
if thingInfo.Number > 150 {
|
||||
// 商品贬值,价格区间 -50%到0%
|
||||
thing.Discount = 50 + rand.Intn(50)
|
||||
@ -601,7 +599,7 @@ func (sql *fishdb) refreshStroeInfo() (ok bool, err error) {
|
||||
return
|
||||
}
|
||||
default:
|
||||
_ = sql.db.Find("stroeDiscount", &thing, "where Name = '"+name+"'")
|
||||
_ = sql.db.Find("stroeDiscount", &thing, "WHERE Name = ?", name)
|
||||
}
|
||||
if thing.Discount != 0 {
|
||||
discountList[name] = thing.Discount
|
||||
@ -611,14 +609,14 @@ func (sql *fishdb) refreshStroeInfo() (ok bool, err error) {
|
||||
}
|
||||
thing := store{}
|
||||
oldThing := []store{}
|
||||
_ = sql.db.FindFor("stroeDiscount", &thing, "where type = 'pole'", func() error {
|
||||
_ = sql.db.FindFor("stroeDiscount", &thing, "WHERE type = 'pole'", func() error {
|
||||
if time.Since(time.Unix(thing.Duration, 0)) > 24 {
|
||||
oldThing = append(oldThing, thing)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
for _, info := range oldThing {
|
||||
_ = sql.db.Del("stroeDiscount", "where Duration = "+strconv.FormatInt(info.Duration, 10))
|
||||
_ = sql.db.Del("stroeDiscount", "WHERE Duration = ?", info.Duration)
|
||||
}
|
||||
if refresh {
|
||||
// 每天调控1种鱼
|
||||
@ -629,7 +627,7 @@ func (sql *fishdb) refreshStroeInfo() (ok bool, err error) {
|
||||
Type: "fish",
|
||||
Price: priceList[fish] * discountList[fish] / 100,
|
||||
}
|
||||
_ = sql.db.Find("store", &thingInfo, "where Name = '"+fish+"'")
|
||||
_ = sql.db.Find("store", &thingInfo, "WHERE Name = ?", fish)
|
||||
thingInfo.Number += (100 - discountList[fish])
|
||||
if thingInfo.Number < 1 {
|
||||
thingInfo.Number = 100
|
||||
@ -642,7 +640,7 @@ func (sql *fishdb) refreshStroeInfo() (ok bool, err error) {
|
||||
Type: "article",
|
||||
Price: priceList["净化书"] * discountList["净化书"] / 100,
|
||||
}
|
||||
_ = sql.db.Find("store", &thingInfo, "where Name = '净化书'")
|
||||
_ = sql.db.Find("store", &thingInfo, "WHERE Name = '净化书'")
|
||||
thingInfo.Number = 20
|
||||
_ = sql.db.Insert("store", &thingInfo)
|
||||
}
|
||||
@ -688,13 +686,13 @@ func (sql *fishdb) getStoreThingInfo(thing string) (thingInfos []store, err erro
|
||||
if count == 0 {
|
||||
return
|
||||
}
|
||||
if !sql.db.CanFind("store", "where Name = '"+thing+"'") {
|
||||
if !sql.db.CanFind("store", "WHERE Name = ?", thing) {
|
||||
return
|
||||
}
|
||||
err = sql.db.FindFor("store", &thingInfo, "where Name = '"+thing+"'", func() error {
|
||||
err = sql.db.FindFor("store", &thingInfo, "WHERE Name = ?", func() error {
|
||||
thingInfos = append(thingInfos, thingInfo)
|
||||
return nil
|
||||
})
|
||||
}, thing)
|
||||
return
|
||||
}
|
||||
|
||||
@ -713,10 +711,10 @@ func (sql *fishdb) checkStoreFor(thing store, number int) (ok bool, err error) {
|
||||
if count == 0 {
|
||||
return false, nil
|
||||
}
|
||||
if !sql.db.CanFind("store", "where Duration = "+strconv.FormatInt(thing.Duration, 10)) {
|
||||
if !sql.db.CanFind("store", "WHERE Duration = ?", thing.Duration) {
|
||||
return false, nil
|
||||
}
|
||||
err = sql.db.Find("store", &thing, "where Duration = "+strconv.FormatInt(thing.Duration, 10))
|
||||
err = sql.db.Find("store", &thing, "WHERE Duration = ?", thing.Duration)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -735,7 +733,7 @@ func (sql *fishdb) updateStoreInfo(thingInfo store) (err error) {
|
||||
return
|
||||
}
|
||||
if thingInfo.Number == 0 {
|
||||
return sql.db.Del("store", "where Duration = "+strconv.FormatInt(thingInfo.Duration, 10))
|
||||
return sql.db.Del("store", "WHERE Duration = ?", thingInfo.Duration)
|
||||
}
|
||||
return sql.db.Insert("store", &thingInfo)
|
||||
}
|
||||
@ -749,7 +747,7 @@ func (sql *fishdb) updateBuyTimeFor(uid int64, add int) (err error) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_ = sql.db.Find("buff", &userInfo, "where ID = "+strconv.FormatInt(uid, 10))
|
||||
_ = sql.db.Find("buff", &userInfo, "WHERE ID = ?", uid)
|
||||
userInfo.BuyTimes += add
|
||||
if userInfo.BuyTimes > 20 {
|
||||
userInfo.BuyTimes -= 20
|
||||
@ -768,7 +766,7 @@ func (sql *fishdb) useCouponAt(uid int64, times int) (int, error) {
|
||||
if err != nil {
|
||||
return useTimes, err
|
||||
}
|
||||
_ = sql.db.Find("buff", &userInfo, "where ID = "+strconv.FormatInt(uid, 10))
|
||||
_ = sql.db.Find("buff", &userInfo, "WHERE ID = ?", uid)
|
||||
if userInfo.Coupon > 0 {
|
||||
useTimes = math.Min(userInfo.Coupon, times)
|
||||
userInfo.Coupon -= useTimes
|
||||
@ -786,7 +784,7 @@ func (sql *fishdb) checkCanSalesFor(uid int64, sales bool) (int, error) {
|
||||
if err != nil {
|
||||
return residue, err
|
||||
}
|
||||
_ = sql.db.Find("buff", &userInfo, "where ID = "+strconv.FormatInt(uid, 10))
|
||||
_ = sql.db.Find("buff", &userInfo, "WHERE ID = ?", uid)
|
||||
if time.Now().Day() != time.Unix(userInfo.Duration, 0).Day() {
|
||||
userInfo.Duration = time.Now().Unix()
|
||||
userInfo.SalesPole = 0
|
||||
@ -823,7 +821,7 @@ func (sql *fishdb) selectCanSalesFishFor(uid int64, sales int) int {
|
||||
if err != nil {
|
||||
return residue
|
||||
}
|
||||
_ = sql.db.Find("buff", &userInfo, "where ID = "+strconv.FormatInt(uid, 10))
|
||||
_ = sql.db.Find("buff", &userInfo, "WHERE ID = ?", uid)
|
||||
if time.Now().Day() != time.Unix(userInfo.Duration, 0).Day() {
|
||||
userInfo.Duration = time.Now().Unix()
|
||||
// 在 checkCanSalesFor 也有更新buff时间,TODO:重构 *CanSalesFishFor 俩个函数
|
||||
@ -854,7 +852,7 @@ func (sql *fishdb) updateCanSalesFishFor(uid int64, sales int) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_ = sql.db.Find("buff", &userInfo, "where ID = "+strconv.FormatInt(uid, 10))
|
||||
_ = sql.db.Find("buff", &userInfo, "WHERE ID = ?", uid)
|
||||
userInfo.SalesFish += sales
|
||||
return sql.db.Insert("buff", &userInfo)
|
||||
}
|
||||
|
||||
@ -229,7 +229,7 @@ func init() {
|
||||
return path.Ext(ctx.Event.File.Name) == ".mid"
|
||||
}).SetBlock(false).Limit(ctxext.LimitByGroup).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
fileURL := ctx.GetThisGroupFileUrl(ctx.Event.File.BusID, ctx.Event.File.ID)
|
||||
fileURL := ctx.GetThisGroupFileURL(ctx.Event.File.BusID, ctx.Event.File.ID)
|
||||
data, err := web.GetData(fileURL)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
@ -242,12 +242,12 @@ func init() {
|
||||
}
|
||||
for i := 0; i < int(s.NumTracks()); i++ {
|
||||
midStr := mid2txt(data, i)
|
||||
fileName := strings.ReplaceAll(cachePath+"/"+ctx.Event.File.Name, ".mid", fmt.Sprintf("-%d.txt", i))
|
||||
err := os.WriteFile(fileName, binary.StringToBytes(midStr), 0666)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
fileName := strings.ReplaceAll(cachePath+"/"+ctx.Event.File.Name, ".mid", fmt.Sprintf("-%d.txt", i))
|
||||
_ = os.WriteFile(fileName, binary.StringToBytes(midStr), 0666)
|
||||
ctx.UploadThisGroupFile(file.BOTPATH+"/"+fileName, filepath.Base(fileName), "")
|
||||
}
|
||||
})
|
||||
@ -255,7 +255,7 @@ func init() {
|
||||
return path.Ext(ctx.Event.File.Name) == ".txt" && strings.Contains(ctx.Event.File.Name, "midi制作")
|
||||
}).SetBlock(false).Limit(ctxext.LimitByGroup).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
fileURL := ctx.GetThisGroupFileUrl(ctx.Event.File.BusID, ctx.Event.File.ID)
|
||||
fileURL := ctx.GetThisGroupFileURL(ctx.Event.File.BusID, ctx.Event.File.ID)
|
||||
data, err := web.GetData(fileURL)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
|
||||
@ -49,7 +49,7 @@ func init() {
|
||||
}
|
||||
|
||||
// migu 返回咪咕音乐卡片
|
||||
func migu(keyword string) message.MessageSegment {
|
||||
func migu(keyword string) message.Segment {
|
||||
headers := http.Header{
|
||||
"Cookie": []string{"audioplayer_exist=1; audioplayer_open=0; migu_cn_cookie_id=3ad476db-f021-4bda-ab91-c485ac3d56a0; Hm_lvt_ec5a5474d9d871cb3d82b846d861979d=1671119573; Hm_lpvt_ec5a5474d9d871cb3d82b846d861979d=1671119573; WT_FPC=id=279ef92eaf314cbb8d01671116477485:lv=1671119583092:ss=1671116477485"},
|
||||
"csrf": []string{"LWKACV45JSQ"},
|
||||
@ -75,7 +75,7 @@ func migu(keyword string) message.MessageSegment {
|
||||
}
|
||||
|
||||
// kuwo 返回酷我音乐卡片
|
||||
func kuwo(keyword string) message.MessageSegment {
|
||||
func kuwo(keyword string) message.Segment {
|
||||
headers := http.Header{
|
||||
"Cookie": []string{"Hm_lvt_cdb524f42f0ce19b169a8071123a4797=1610284708,1610699237; _ga=GA1.2.1289529848.1591618534; kw_token=LWKACV45JSQ; Hm_lpvt_cdb524f42f0ce19b169a8071123a4797=1610699468; _gid=GA1.2.1868980507.1610699238; _gat=1"},
|
||||
"csrf": []string{"LWKACV45JSQ"},
|
||||
@ -109,7 +109,7 @@ func kuwo(keyword string) message.MessageSegment {
|
||||
}
|
||||
|
||||
// kugou 返回酷狗音乐卡片
|
||||
func kugou(keyword string) message.MessageSegment {
|
||||
func kugou(keyword string) message.Segment {
|
||||
stamp := time.Now().UnixNano() / 1e6
|
||||
hash := md5str(
|
||||
fmt.Sprintf(
|
||||
@ -163,7 +163,7 @@ func kugou(keyword string) message.MessageSegment {
|
||||
}
|
||||
|
||||
// cloud163 返回网易云音乐卡片
|
||||
func cloud163(keyword string) (msg message.MessageSegment) {
|
||||
func cloud163(keyword string) (msg message.Segment) {
|
||||
requestURL := "http://music.163.com/api/search/get/web?type=1&limit=1&s=" + url.QueryEscape(keyword)
|
||||
data, err := web.GetData(requestURL)
|
||||
if err != nil {
|
||||
@ -175,7 +175,7 @@ func cloud163(keyword string) (msg message.MessageSegment) {
|
||||
}
|
||||
|
||||
// qqmusic 返回QQ音乐卡片
|
||||
func qqmusic(keyword string) (msg message.MessageSegment) {
|
||||
func qqmusic(keyword string) (msg message.Segment) {
|
||||
requestURL := "https://c.y.qq.com/splcloud/fcgi-bin/smartbox_new.fcg?platform=yqq.json&key=" + url.QueryEscape(keyword)
|
||||
data, err := web.RequestDataWith(web.NewDefaultClient(), requestURL, "GET", "", web.RandUA(), nil)
|
||||
if err != nil {
|
||||
|
||||
@ -24,15 +24,15 @@ type setuclass struct {
|
||||
Path string `db:"path"` // Path 图片路径
|
||||
}
|
||||
|
||||
var ns = &nsetu{db: &sql.Sqlite{}}
|
||||
var ns nsetu
|
||||
|
||||
type nsetu struct {
|
||||
db *sql.Sqlite
|
||||
db sql.Sqlite
|
||||
mu sync.RWMutex
|
||||
}
|
||||
|
||||
func (n *nsetu) List() (l []string) {
|
||||
if file.IsExist(n.db.DBPath) {
|
||||
if file.IsExist(dbpath) {
|
||||
var err error
|
||||
l, err = n.db.ListTables()
|
||||
if err != nil {
|
||||
@ -46,7 +46,7 @@ func (n *nsetu) scanall(path string) error {
|
||||
model := &setuclass{}
|
||||
root := os.DirFS(path)
|
||||
_ = n.db.Close()
|
||||
_ = os.Remove(n.db.DBPath)
|
||||
_ = os.Remove(dbpath)
|
||||
err := n.db.Open(time.Hour)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@ -13,6 +13,7 @@ import (
|
||||
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
@ -20,6 +21,7 @@ import (
|
||||
|
||||
var (
|
||||
setupath = "/tmp" // 绝对路径,图片根目录
|
||||
dbpath = ""
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -34,7 +36,8 @@ func init() {
|
||||
PrivateDataFolder: "nsetu",
|
||||
})
|
||||
|
||||
ns.db.DBPath = engine.DataFolder() + "data.db"
|
||||
dbpath = engine.DataFolder() + "data.db"
|
||||
ns.db = sql.New(dbpath)
|
||||
cfgfile := engine.DataFolder() + "setupath.txt"
|
||||
if file.IsExist(cfgfile) {
|
||||
b, err := os.ReadFile(cfgfile)
|
||||
@ -48,7 +51,7 @@ func init() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
engine.OnRegex(`^本地(.*)$`, fcext.ValueInList(func(ctx *zero.Ctx) string { return ctx.State["regex_matched"].([]string)[1] }, ns)).SetBlock(true).
|
||||
engine.OnRegex(`^本地(.*)$`, fcext.ValueInList(func(ctx *zero.Ctx) string { return ctx.State["regex_matched"].([]string)[1] }, &ns)).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
imgtype := ctx.State["regex_matched"].([]string)[1]
|
||||
sc := new(setuclass)
|
||||
@ -69,7 +72,7 @@ func init() {
|
||||
ctx.SendChain(message.Text(imgtype, ": ", sc.Name, "\n"), message.Image(p))
|
||||
}
|
||||
})
|
||||
engine.OnRegex(`^刷新本地(.*)$`, fcext.ValueInList(func(ctx *zero.Ctx) string { return ctx.State["regex_matched"].([]string)[1] }, ns), zero.SuperUserPermission).SetBlock(true).
|
||||
engine.OnRegex(`^刷新本地(.*)$`, fcext.ValueInList(func(ctx *zero.Ctx) string { return ctx.State["regex_matched"].([]string)[1] }, &ns), zero.SuperUserPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
imgtype := ctx.State["regex_matched"].([]string)[1]
|
||||
err := ns.scanclass(os.DirFS(setupath), imgtype, imgtype)
|
||||
|
||||
@ -22,14 +22,14 @@ func (g *grammar) string() string {
|
||||
return fmt.Sprintf("ID:\n%d\n\n标签:\n%s\n\n语法名:\n%s\n\n发音:\n%s\n\n用法:\n%s\n\n意思:\n%s\n\n解说:\n%s\n\n示例:\n%s", g.ID, g.Tag, g.Name, g.Pronunciation, g.Usage, g.Meaning, g.Explanation, g.Example)
|
||||
}
|
||||
|
||||
var db = &sql.Sqlite{}
|
||||
var db sql.Sqlite
|
||||
|
||||
func getRandomGrammarByTag(tag string) (g grammar) {
|
||||
_ = db.Find("grammar", &g, "WHERE tag LIKE '%"+tag+"%' ORDER BY RANDOM() limit 1")
|
||||
_ = db.Find("grammar", &g, "WHERE tag LIKE ? ORDER BY RANDOM() limit 1", "%"+tag+"%")
|
||||
return
|
||||
}
|
||||
|
||||
func getRandomGrammarByKeyword(keyword string) (g grammar) {
|
||||
_ = db.Find("grammar", &g, "WHERE (name LIKE '%"+keyword+"%' or pronunciation LIKE '%"+keyword+"%') ORDER BY RANDOM() limit 1")
|
||||
_ = db.Find("grammar", &g, "WHERE (name LIKE ? OR pronunciation LIKE ?) ORDER BY RANDOM() limit 1", "%"+keyword+"%", "%"+keyword+"%")
|
||||
return
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
@ -24,7 +25,7 @@ func init() {
|
||||
})
|
||||
|
||||
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
db.DBPath = engine.DataFolder() + "nihongo.db"
|
||||
db = sql.New(engine.DataFolder() + "nihongo.db")
|
||||
_, err := engine.GetLazyData("nihongo.db", true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
|
||||
@ -20,8 +20,8 @@ import (
|
||||
)
|
||||
|
||||
type model struct {
|
||||
sql sql.Sqlite
|
||||
sync.RWMutex
|
||||
sql sql.Sqlite
|
||||
}
|
||||
|
||||
type userInfo struct {
|
||||
@ -44,7 +44,7 @@ type users []*userInfo
|
||||
var (
|
||||
db = &model{}
|
||||
getdb = fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
db.sql.DBPath = en.DataFolder() + "niuniu.db"
|
||||
db.sql = sql.New(en.DataFolder() + "niuniu.db")
|
||||
err := db.sql.Open(time.Hour * 24)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
@ -351,7 +351,7 @@ func (db *model) findNiuNiu(gid, uid int64) (userInfo, error) {
|
||||
db.RLock()
|
||||
defer db.RUnlock()
|
||||
u := userInfo{}
|
||||
err := db.sql.Find(strconv.FormatInt(gid, 10), &u, "where UID = "+strconv.FormatInt(uid, 10))
|
||||
err := db.sql.Find(strconv.FormatInt(gid, 10), &u, "WHERE UID = ?", uid)
|
||||
return u, err
|
||||
}
|
||||
|
||||
@ -365,12 +365,12 @@ func (db *model) insertNiuNiu(u *userInfo, gid int64) error {
|
||||
func (db *model) deleteniuniu(gid, uid int64) error {
|
||||
db.Lock()
|
||||
defer db.Unlock()
|
||||
return db.sql.Del(strconv.FormatInt(gid, 10), "where UID = "+strconv.FormatInt(uid, 10))
|
||||
return db.sql.Del(strconv.FormatInt(gid, 10), "WHERE UID = ?", uid)
|
||||
}
|
||||
|
||||
func (db *model) readAllTable(gid int64) (users, error) {
|
||||
db.Lock()
|
||||
defer db.Unlock()
|
||||
a, err := sql.FindAll[userInfo](&db.sql, strconv.FormatInt(gid, 10), "where UserCount = 0")
|
||||
a, err := sql.FindAll[userInfo](&db.sql, strconv.FormatInt(gid, 10), "WHERE UserCount = 0")
|
||||
return a, err
|
||||
}
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
package omikuji
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
)
|
||||
|
||||
@ -11,12 +9,12 @@ type kuji struct {
|
||||
Text string `db:"text"`
|
||||
}
|
||||
|
||||
var db = &sql.Sqlite{}
|
||||
var db sql.Sqlite
|
||||
|
||||
// 返回一个解签
|
||||
func getKujiByBango(id uint8) string {
|
||||
var s kuji
|
||||
err := db.Find("kuji", &s, "where id = "+strconv.Itoa(int(id)))
|
||||
err := db.Find("kuji", &s, "WHERE id = ?", id)
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
@ -48,7 +49,7 @@ func init() { // 插件主体
|
||||
})
|
||||
engine.OnFullMatch("解签", fcext.DoOnceOnSuccess(
|
||||
func(ctx *zero.Ctx) bool {
|
||||
db.DBPath = engine.DataFolder() + "kuji.db"
|
||||
db = sql.New(engine.DataFolder() + "kuji.db")
|
||||
_, err := engine.GetLazyData("kuji.db", true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
|
||||
@ -5,7 +5,6 @@ import (
|
||||
"math/rand"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@ -29,8 +28,8 @@ import (
|
||||
)
|
||||
|
||||
type 婚姻登记 struct {
|
||||
db *sql.Sqlite
|
||||
sync.RWMutex
|
||||
db sql.Sqlite
|
||||
}
|
||||
|
||||
// 群设置
|
||||
@ -53,9 +52,7 @@ type userinfo struct {
|
||||
}
|
||||
|
||||
var (
|
||||
民政局 = &婚姻登记{
|
||||
db: &sql.Sqlite{},
|
||||
}
|
||||
民政局 婚姻登记
|
||||
engine = control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "一群一天一夫一妻制群老婆",
|
||||
@ -81,7 +78,7 @@ var (
|
||||
}),
|
||||
))
|
||||
getdb = fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
民政局.db.DBPath = engine.DataFolder() + "结婚登记表.db"
|
||||
民政局.db = sql.New(engine.DataFolder() + "结婚登记表.db")
|
||||
err := 民政局.db.Open(time.Hour)
|
||||
if err == nil {
|
||||
// 创建群配置表
|
||||
@ -281,7 +278,7 @@ func init() {
|
||||
ctx.SendChain(message.Text("该功能只能在群组使用或者指定群组"))
|
||||
return
|
||||
}
|
||||
err = 民政局.清理花名册("group" + strconv.FormatInt(ctx.Event.GroupID, 10))
|
||||
err = 民政局.清理花名册(ctx.Event.GroupID)
|
||||
default:
|
||||
cmd := ctx.State["regex_matched"].([]string)[1]
|
||||
gid, _ := strconv.ParseInt(cmd, 10, 64) // 判断是否为群号
|
||||
@ -289,7 +286,7 @@ func init() {
|
||||
ctx.SendChain(message.Text("请输入正确的群号"))
|
||||
return
|
||||
}
|
||||
err = 民政局.清理花名册("group" + cmd)
|
||||
err = 民政局.清理花名册(gid)
|
||||
}
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR]:", err))
|
||||
@ -307,7 +304,7 @@ func (sql *婚姻登记) 查看设置(gid int64) (dbinfo updateinfo, err error)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if !sql.db.CanFind("updateinfo", "where gid is "+strconv.FormatInt(gid, 10)) {
|
||||
if !sql.db.CanFind("updateinfo", "WHERE gid = ?", gid) {
|
||||
// 没有记录
|
||||
return updateinfo{
|
||||
GID: gid,
|
||||
@ -316,7 +313,7 @@ func (sql *婚姻登记) 查看设置(gid int64) (dbinfo updateinfo, err error)
|
||||
CDtime: 12,
|
||||
}, nil
|
||||
}
|
||||
_ = sql.db.Find("updateinfo", &dbinfo, "where gid is "+strconv.FormatInt(gid, 10))
|
||||
_ = sql.db.Find("updateinfo", &dbinfo, "WHERE gid = ?", gid)
|
||||
return
|
||||
}
|
||||
|
||||
@ -334,7 +331,7 @@ func (sql *婚姻登记) 开门时间(gid int64) error {
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
dbinfo := updateinfo{}
|
||||
_ = sql.db.Find("updateinfo", &dbinfo, "where gid is "+strconv.FormatInt(gid, 10))
|
||||
_ = sql.db.Find("updateinfo", &dbinfo, "WHERE gid = ?", gid)
|
||||
if time.Now().Format("2006/01/02") != dbinfo.Updatetime {
|
||||
// 如果跨天了就删除
|
||||
_ = sql.db.Drop("group" + strconv.FormatInt(gid, 10))
|
||||
@ -355,10 +352,9 @@ func (sql *婚姻登记) 查户口(gid, uid int64) (info userinfo, err error) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
uidstr := strconv.FormatInt(uid, 10)
|
||||
err = sql.db.Find(gidstr, &info, "where user = "+uidstr)
|
||||
err = sql.db.Find(gidstr, &info, "WHERE user = ?", uid)
|
||||
if err != nil {
|
||||
err = sql.db.Find(gidstr, &info, "where target = "+uidstr)
|
||||
err = sql.db.Find(gidstr, &info, "WHERE target = ?", uid)
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -423,7 +419,7 @@ func slicename(name string, canvas *gg.Context) (resultname string) {
|
||||
return
|
||||
}
|
||||
|
||||
func (sql *婚姻登记) 清理花名册(gid ...string) error {
|
||||
func (sql *婚姻登记) 清理花名册(gid ...int64) error {
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
switch gid {
|
||||
@ -439,9 +435,9 @@ func (sql *婚姻登记) 清理花名册(gid ...string) error {
|
||||
}
|
||||
return err
|
||||
default:
|
||||
err := sql.db.Drop(gid[0])
|
||||
err := sql.db.Drop("group" + strconv.FormatInt(gid[0], 10))
|
||||
if err == nil {
|
||||
_ = sql.db.Del("cdsheet", "where GroupID is "+strings.ReplaceAll(gid[0], "group", ""))
|
||||
_ = sql.db.Del("cdsheet", "WHERE GroupID = ?", gid[0])
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@ -214,7 +214,7 @@ func init() {
|
||||
favor := favorability{}
|
||||
delInfo := make([]string, 0, count*2)
|
||||
favorInfo := make(map[string]int, count*2)
|
||||
_ = 民政局.db.FindFor("favorability", &favor, "group by Userinfo", func() error {
|
||||
_ = 民政局.db.FindFor("favorability", &favor, "GROUP BY Userinfo", func() error {
|
||||
delInfo = append(delInfo, favor.Userinfo)
|
||||
// 解析旧数据
|
||||
userList := strings.Split(favor.Userinfo, "+")
|
||||
@ -236,15 +236,10 @@ func init() {
|
||||
}
|
||||
return nil
|
||||
})
|
||||
for _, updateinfo := range delInfo {
|
||||
// 删除旧数据
|
||||
err = 民政局.db.Del("favorability", "where Userinfo = '"+updateinfo+"'")
|
||||
if err != nil {
|
||||
userList := strings.Split(favor.Userinfo, "+")
|
||||
uid1, _ := strconv.ParseInt(userList[0], 10, 64)
|
||||
uid2, _ := strconv.ParseInt(userList[1], 10, 64)
|
||||
ctx.SendChain(message.Text("[ERROR]: 删除", ctx.CardOrNickName(uid1), "和", ctx.CardOrNickName(uid2), "的好感度时发生了错误。\n错误信息:", err))
|
||||
}
|
||||
// 删除旧数据
|
||||
err = 民政局.db.Del("favorability", "WHERE Userinfo IN ?", delInfo)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[ERROR]: 删除好感度时发生了错误。\n错误信息:", err))
|
||||
}
|
||||
for userInfo, favor := range favorInfo {
|
||||
favorInfo := favorability{
|
||||
@ -273,15 +268,15 @@ func (sql *婚姻登记) 查好感度(uid, target int64) (int, error) {
|
||||
info := favorability{}
|
||||
if uid > target {
|
||||
userinfo := strconv.FormatInt(uid, 10) + "+" + strconv.FormatInt(target, 10)
|
||||
err = sql.db.Find("favorability", &info, "where Userinfo is '"+userinfo+"'")
|
||||
err = sql.db.Find("favorability", &info, "WHERE Userinfo = ?", userinfo)
|
||||
if err != nil {
|
||||
_ = sql.db.Find("favorability", &info, "where Userinfo glob '*"+userinfo+"*'")
|
||||
_ = sql.db.Find("favorability", &info, "WHERE Userinfo glob ?", "*"+userinfo+"*")
|
||||
}
|
||||
} else {
|
||||
userinfo := strconv.FormatInt(target, 10) + "+" + strconv.FormatInt(uid, 10)
|
||||
err = sql.db.Find("favorability", &info, "where Userinfo is '"+userinfo+"'")
|
||||
err = sql.db.Find("favorability", &info, "WHERE Userinfo = ?", userinfo)
|
||||
if err != nil {
|
||||
_ = sql.db.Find("favorability", &info, "where Userinfo glob '*"+userinfo+"*'")
|
||||
_ = sql.db.Find("favorability", &info, "WHERE Userinfo glob ?", "*"+userinfo+"*")
|
||||
}
|
||||
}
|
||||
return info.Favor, nil
|
||||
@ -304,7 +299,7 @@ func (sql *婚姻登记) getGroupFavorability(uid int64) (list favorList, err er
|
||||
sql.RLock()
|
||||
defer sql.RUnlock()
|
||||
info := favorability{}
|
||||
err = sql.db.FindFor("favorability", &info, "where Userinfo glob '*"+uidStr+"*'", func() error {
|
||||
err = sql.db.FindFor("favorability", &info, "WHERE Userinfo glob ?", func() error {
|
||||
var target string
|
||||
userList := strings.Split(info.Userinfo, "+")
|
||||
switch {
|
||||
@ -320,7 +315,7 @@ func (sql *婚姻登记) getGroupFavorability(uid int64) (list favorList, err er
|
||||
Favor: info.Favor,
|
||||
})
|
||||
return nil
|
||||
})
|
||||
}, "*"+uidStr+"*")
|
||||
sort.Sort(list)
|
||||
return
|
||||
}
|
||||
@ -338,15 +333,15 @@ func (sql *婚姻登记) 更新好感度(uid, target int64, score int) (favor in
|
||||
targstr := strconv.FormatInt(target, 10)
|
||||
if uid > target {
|
||||
info.Userinfo = uidstr + "+" + targstr
|
||||
err = sql.db.Find("favorability", &info, "where Userinfo is '"+info.Userinfo+"'")
|
||||
err = sql.db.Find("favorability", &info, "WHERE Userinfo = ?", info.Userinfo)
|
||||
} else {
|
||||
info.Userinfo = targstr + "+" + uidstr
|
||||
err = sql.db.Find("favorability", &info, "where Userinfo is '"+info.Userinfo+"'")
|
||||
err = sql.db.Find("favorability", &info, "WHERE Userinfo = ?", info.Userinfo)
|
||||
}
|
||||
if err != nil {
|
||||
err = sql.db.Find("favorability", &info, "where Userinfo glob '*"+targstr+"+"+uidstr+"*'")
|
||||
err = sql.db.Find("favorability", &info, "WHERE Userinfo glob ?", "*"+targstr+"+"+uidstr+"*")
|
||||
if err == nil { // 如果旧数据存在就删除旧数据
|
||||
err = 民政局.db.Del("favorability", "where Userinfo = '"+info.Userinfo+"'")
|
||||
err = 民政局.db.Del("favorability", "WHERE Userinfo = ?", info.Userinfo)
|
||||
}
|
||||
}
|
||||
info.Favor += score
|
||||
|
||||
@ -372,18 +372,16 @@ func (sql *婚姻登记) 判断CD(gid, uid int64, model string, cdtime float64)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
limitID := "where GroupID is " + strconv.FormatInt(gid, 10) +
|
||||
" and UserID is " + strconv.FormatInt(uid, 10) +
|
||||
" and ModeID is '" + model + "'"
|
||||
if !sql.db.CanFind("cdsheet", limitID) {
|
||||
limitID := "WHERE GroupID = ? AND UserID = ? AND ModeID = ?"
|
||||
if !sql.db.CanFind("cdsheet", limitID, gid, uid, model) {
|
||||
// 没有记录即不用比较
|
||||
return true, nil
|
||||
}
|
||||
cdinfo := cdsheet{}
|
||||
_ = sql.db.Find("cdsheet", &cdinfo, limitID)
|
||||
_ = sql.db.Find("cdsheet", &cdinfo, limitID, gid, uid, model)
|
||||
if time.Since(time.Unix(cdinfo.Time, 0)).Hours() > cdtime {
|
||||
// 如果CD已过就删除
|
||||
err = sql.db.Del("cdsheet", limitID)
|
||||
err = sql.db.Del("cdsheet", limitID, gid, uid, model)
|
||||
return true, err
|
||||
}
|
||||
return false, nil
|
||||
@ -404,16 +402,14 @@ func (sql *婚姻登记) 离婚休妻(gid, wife int64) error {
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
gidstr := "group" + strconv.FormatInt(gid, 10)
|
||||
wifestr := strconv.FormatInt(wife, 10)
|
||||
return sql.db.Del(gidstr, "where target = "+wifestr)
|
||||
return sql.db.Del(gidstr, "WHERE target = ?", wife)
|
||||
}
|
||||
|
||||
func (sql *婚姻登记) 离婚休夫(gid, husband int64) error {
|
||||
sql.Lock()
|
||||
defer sql.Unlock()
|
||||
gidstr := "group" + strconv.FormatInt(gid, 10)
|
||||
husbandstr := strconv.FormatInt(husband, 10)
|
||||
return sql.db.Del(gidstr, "where user = "+husbandstr)
|
||||
return sql.db.Del(gidstr, "WHERE user = ?", husband)
|
||||
}
|
||||
|
||||
// 注入判断 是否单身条件
|
||||
|
||||
@ -21,8 +21,8 @@ import (
|
||||
)
|
||||
|
||||
type robberyRepo struct {
|
||||
db *sql.Sqlite
|
||||
sync.RWMutex
|
||||
db sql.Sqlite
|
||||
}
|
||||
|
||||
type robberyRecord struct {
|
||||
@ -32,9 +32,7 @@ type robberyRecord struct {
|
||||
}
|
||||
|
||||
func init() {
|
||||
police := &robberyRepo{
|
||||
db: &sql.Sqlite{},
|
||||
}
|
||||
var police robberyRepo
|
||||
engine := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Brief: "打劫别人的钱包",
|
||||
@ -58,7 +56,7 @@ func init() {
|
||||
}),
|
||||
))
|
||||
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
police.db.DBPath = engine.DataFolder() + "robbery.db"
|
||||
police.db = sql.New(engine.DataFolder() + "robbery.db")
|
||||
err := police.db.Open(time.Hour)
|
||||
if err == nil {
|
||||
// 创建CD表
|
||||
@ -157,9 +155,8 @@ func (sql *robberyRepo) getRecord(victimID, uid int64) (ok int, err error) {
|
||||
return 1, err
|
||||
}
|
||||
// 拼接查询SQL
|
||||
limitID := "where victim_id is " + strconv.FormatInt(victimID, 10) +
|
||||
" or user_id is " + strconv.FormatInt(uid, 10)
|
||||
if !sql.db.CanFind("criminal_record", limitID) {
|
||||
limitID := "WHERE victim_id = ? OR user_id = ?"
|
||||
if !sql.db.CanFind("criminal_record", limitID, victimID, uid) {
|
||||
// 没有记录即不用比较
|
||||
return 0, nil
|
||||
}
|
||||
@ -168,7 +165,7 @@ func (sql *robberyRepo) getRecord(victimID, uid int64) (ok int, err error) {
|
||||
err = sql.db.FindFor("criminal_record", &cdInfo, limitID, func() error {
|
||||
if time.Now().Format("2006/01/02") != cdInfo.Time {
|
||||
// // 如果跨天了就删除
|
||||
err = sql.db.Del("criminal_record", limitID)
|
||||
err = sql.db.Del("criminal_record", limitID, victimID, uid)
|
||||
return nil
|
||||
}
|
||||
// 俩个if是为了保证,重复打劫同一个人,ok == 3
|
||||
@ -180,7 +177,7 @@ func (sql *robberyRepo) getRecord(victimID, uid int64) (ok int, err error) {
|
||||
ok++
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}, victimID, uid)
|
||||
return ok, err
|
||||
}
|
||||
|
||||
|
||||
@ -24,11 +24,11 @@ import (
|
||||
|
||||
// Pools 图片缓冲池
|
||||
type imgpool struct {
|
||||
db *sql.Sqlite
|
||||
db sql.Sqlite
|
||||
dbmu sync.RWMutex
|
||||
path string
|
||||
max int
|
||||
pool map[string][]*message.MessageSegment
|
||||
pool map[string][]*message.Segment
|
||||
poolmu sync.Mutex
|
||||
}
|
||||
|
||||
@ -44,10 +44,9 @@ func (p *imgpool) List() (l []string) {
|
||||
}
|
||||
|
||||
var pool = &imgpool{
|
||||
db: &sql.Sqlite{},
|
||||
path: pixiv.CacheDir,
|
||||
max: 10,
|
||||
pool: make(map[string][]*message.MessageSegment),
|
||||
pool: make(map[string][]*message.Segment),
|
||||
}
|
||||
|
||||
func init() { // 插件主体
|
||||
@ -63,7 +62,7 @@ func init() { // 插件主体
|
||||
|
||||
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
// 如果数据库不存在则下载
|
||||
pool.db.DBPath = engine.DataFolder() + "SetuTime.db"
|
||||
pool.db = sql.New(engine.DataFolder() + "SetuTime.db")
|
||||
_, _ = engine.GetLazyData("SetuTime.db", false)
|
||||
err := pool.db.Open(time.Hour)
|
||||
if err != nil {
|
||||
@ -157,7 +156,7 @@ func (p *imgpool) push(ctx *zero.Ctx, imgtype string, illust *pixiv.Illust) {
|
||||
if len(illust.ImageUrls) == 0 {
|
||||
return
|
||||
}
|
||||
var msg message.MessageSegment
|
||||
var msg message.Segment
|
||||
f := fileutil.BOTPATH + "/" + illust.Path(0)
|
||||
if fileutil.IsNotExist(f) {
|
||||
// 下载图片
|
||||
@ -172,7 +171,7 @@ func (p *imgpool) push(ctx *zero.Ctx, imgtype string, illust *pixiv.Illust) {
|
||||
p.poolmu.Unlock()
|
||||
}
|
||||
|
||||
func (p *imgpool) pop(imgtype string) (msg *message.MessageSegment) {
|
||||
func (p *imgpool) pop(imgtype string) (msg *message.Segment) {
|
||||
p.poolmu.Lock()
|
||||
defer p.poolmu.Unlock()
|
||||
if p.size(imgtype) == 0 {
|
||||
@ -229,5 +228,5 @@ func (p *imgpool) add(ctx *zero.Ctx, imgtype string, id int64) error {
|
||||
func (p *imgpool) remove(imgtype string, id int64) error {
|
||||
p.dbmu.Lock()
|
||||
defer p.dbmu.Unlock()
|
||||
return p.db.Del(imgtype, fmt.Sprintf("WHERE pid=%d", id))
|
||||
return p.db.Del(imgtype, "WHERE pid = ?", id)
|
||||
}
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package steam
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@ -16,7 +15,7 @@ var (
|
||||
database streamDB
|
||||
// 开启并检查数据库链接
|
||||
getDB = fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
database.db.DBPath = engine.DataFolder() + "steam.db"
|
||||
database.db = sql.New(engine.DataFolder() + "steam.db")
|
||||
err := database.db.Open(time.Hour)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[steam] ERROR: ", err))
|
||||
@ -71,8 +70,7 @@ func (sdb *streamDB) update(dbInfo *player) error {
|
||||
func (sdb *streamDB) find(steamID int64) (dbInfo player, err error) {
|
||||
sdb.Lock()
|
||||
defer sdb.Unlock()
|
||||
condition := "where steam_id = " + strconv.FormatInt(steamID, 10)
|
||||
err = sdb.db.Find(tableListenPlayer, &dbInfo, condition)
|
||||
err = sdb.db.Find(tableListenPlayer, &dbInfo, "WHERE steam_id = ?", steamID)
|
||||
if err == sql.ErrNullResult { // 规避没有该用户数据的报错
|
||||
err = nil
|
||||
}
|
||||
@ -83,8 +81,7 @@ func (sdb *streamDB) find(steamID int64) (dbInfo player, err error) {
|
||||
func (sdb *streamDB) findWithGroupID(steamID int64, groupID string) (dbInfo player, err error) {
|
||||
sdb.Lock()
|
||||
defer sdb.Unlock()
|
||||
condition := "where steam_id = " + strconv.FormatInt(steamID, 10) + " AND target LIKE '%" + groupID + "%'"
|
||||
err = sdb.db.Find(tableListenPlayer, &dbInfo, condition)
|
||||
err = sdb.db.Find(tableListenPlayer, &dbInfo, "WHERE steam_id = ? AND target LIKE ?", steamID, "%"+groupID+"%")
|
||||
if err == sql.ErrNullResult { // 规避没有该用户数据的报错
|
||||
err = nil
|
||||
}
|
||||
@ -102,5 +99,5 @@ func (sdb *streamDB) findAll() (dbInfos []*player, err error) {
|
||||
func (sdb *streamDB) del(steamID int64) error {
|
||||
sdb.Lock()
|
||||
defer sdb.Unlock()
|
||||
return sdb.db.Del(tableListenPlayer, "where steam_id = "+strconv.FormatInt(steamID, 10))
|
||||
return sdb.db.Del(tableListenPlayer, "WHERE steam_id = ?", steamID)
|
||||
}
|
||||
|
||||
@ -187,7 +187,7 @@ func init() {
|
||||
}
|
||||
imgurl := bed + reverse[p] + card.ImgURL
|
||||
tarotmsg := message.Message{message.Text(reasons[rand.Intn(len(reasons))], position[p], "的『", name, "』\n")}
|
||||
var imgmsg message.MessageSegment
|
||||
var imgmsg message.Segment
|
||||
var err error
|
||||
if p == 1 {
|
||||
imgmsg, err = poolimg(imgurl, reverse[p][:len(reverse[p])-1]+name, cache)
|
||||
@ -281,7 +281,7 @@ func init() {
|
||||
}
|
||||
var tarotmsg message.Message
|
||||
imgurl := bed + reverse[p] + card.ImgURL
|
||||
var imgmsg message.MessageSegment
|
||||
var imgmsg message.Segment
|
||||
var err error
|
||||
if p == 1 {
|
||||
imgmsg, err = poolimg(imgurl, reverse[p][:len(reverse[p])-1]+name, cache)
|
||||
@ -319,7 +319,7 @@ func init() {
|
||||
})
|
||||
}
|
||||
|
||||
func poolimg(imgurl, imgname, cache string) (msg message.MessageSegment, err error) {
|
||||
func poolimg(imgurl, imgname, cache string) (msg message.Segment, err error) {
|
||||
imgfile := cache + "/" + imgname + ".png"
|
||||
aimgfile := file.BOTPATH + "/" + imgfile
|
||||
if file.IsNotExist(aimgfile) {
|
||||
|
||||
@ -19,7 +19,7 @@ type tiangou struct {
|
||||
Text string `db:"text"`
|
||||
}
|
||||
|
||||
var db = &sql.Sqlite{}
|
||||
var db sql.Sqlite
|
||||
|
||||
func init() {
|
||||
en := control.AutoRegister(&ctrl.Options[*zero.Ctx]{
|
||||
@ -31,7 +31,7 @@ func init() {
|
||||
|
||||
en.OnFullMatch("舔狗日记", fcext.DoOnceOnSuccess(
|
||||
func(ctx *zero.Ctx) bool {
|
||||
db.DBPath = en.DataFolder() + "tiangou.db"
|
||||
db = sql.New(en.DataFolder() + "tiangou.db")
|
||||
_, err := en.GetLazyData("tiangou.db", true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
|
||||
@ -148,7 +148,7 @@ func init() {
|
||||
// })
|
||||
// eng.OnFullMatch(`wf订阅检测`).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
// rwm.Lock()
|
||||
// var msg []message.MessageSegment
|
||||
// var msg []message.Segment
|
||||
// for i, v := range gameTimes {
|
||||
// nt := time.Until(v.NextTime).Seconds()
|
||||
// switch {
|
||||
|
||||
@ -31,8 +31,8 @@ const (
|
||||
)
|
||||
|
||||
type keydb struct {
|
||||
db *sql.Sqlite
|
||||
sync.RWMutex
|
||||
db sql.Sqlite
|
||||
}
|
||||
|
||||
// db内容
|
||||
@ -48,15 +48,11 @@ type apikey struct {
|
||||
}
|
||||
|
||||
var (
|
||||
name = "椛椛"
|
||||
limit int
|
||||
vilginfo = &keydb{
|
||||
db: &sql.Sqlite{},
|
||||
}
|
||||
modelinfo = &keydb{
|
||||
db: &sql.Sqlite{},
|
||||
}
|
||||
dtype = [...]string{
|
||||
name = "椛椛"
|
||||
limit int
|
||||
vilginfo keydb
|
||||
modelinfo keydb
|
||||
dtype = [...]string{
|
||||
"古风", "油画", "水彩画", "卡通画", "二次元", "浮世绘", "蒸汽波艺术", "low poly", "像素风格", "概念艺术", "未来主义", "赛博朋克", "写实风格", "洛丽塔风格", "巴洛克风格", "超现实主义",
|
||||
}
|
||||
)
|
||||
@ -99,7 +95,7 @@ func init() { // 插件主体
|
||||
}),
|
||||
))
|
||||
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
vilginfo.db.DBPath = engine.DataFolder() + "ernieVilg.db"
|
||||
vilginfo.db = sql.New(engine.DataFolder() + "ernieVilg.db")
|
||||
err := vilginfo.db.Open(time.Hour)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(serviceErr, err))
|
||||
@ -301,7 +297,7 @@ func init() { // 插件主体
|
||||
}),
|
||||
))
|
||||
getmodeldb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
modelinfo.db.DBPath = engine.DataFolder() + "ernieModel.db"
|
||||
modelinfo.db = sql.New(engine.DataFolder() + "ernieModel.db")
|
||||
err := modelinfo.db.Open(time.Hour)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(modelErr, err))
|
||||
@ -521,10 +517,10 @@ func (sql *keydb) insert(gid int64, model, akey, skey string) error {
|
||||
}
|
||||
// 获取group信息
|
||||
groupinfo := apikey{} // 用于暂存数据
|
||||
err = sql.db.Find("groupinfo", &groupinfo, "where ID is "+strconv.FormatInt(gid, 10))
|
||||
err = sql.db.Find("groupinfo", &groupinfo, "WHERE ID = ?", gid)
|
||||
if err != nil {
|
||||
// 如果该group没有注册过
|
||||
err = sql.db.Find("groupinfo", &groupinfo, "where APIKey is '"+akey+"' and SecretKey is '"+skey+"'")
|
||||
err = sql.db.Find("groupinfo", &groupinfo, "WHERE APIKey = ? and SecretKey = ?", akey, skey)
|
||||
if err == nil {
|
||||
// 如果key存在过将当前的数据迁移过去
|
||||
groupinfo.ID = gid
|
||||
@ -575,7 +571,7 @@ func (sql *keydb) checkGroup(gid int64, model string) (groupinfo apikey, err err
|
||||
model = "文心"
|
||||
}
|
||||
// 先判断该群是否已经设置过key了
|
||||
if ok := sql.db.CanFind("groupinfo", "where ID is "+strconv.FormatInt(gid, 10)); !ok {
|
||||
if ok := sql.db.CanFind("groupinfo", "WHERE ID = ?", gid); !ok {
|
||||
if gid > 0 {
|
||||
err = errors.New("该群没有设置过apikey,请前往https://wenxin.baidu.com/moduleApi/key获取key值后,发送指令:\n为本群设置" + model + "key [API Key] [Secret Key]\n或\n为自己设置" + model + "key [API Key] [Secret Key]")
|
||||
} else {
|
||||
@ -584,7 +580,7 @@ func (sql *keydb) checkGroup(gid int64, model string) (groupinfo apikey, err err
|
||||
return
|
||||
}
|
||||
// 获取group信息
|
||||
err = sql.db.Find("groupinfo", &groupinfo, "where ID is "+strconv.FormatInt(gid, 10))
|
||||
err = sql.db.Find("groupinfo", &groupinfo, "WHERE ID = ?", gid)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -608,19 +604,16 @@ func (sql *keydb) checkGroup(gid int64, model string) (groupinfo apikey, err err
|
||||
err = sql.db.Insert("groupinfo", &groupinfo)
|
||||
if err == nil {
|
||||
// 更新相同key的他人次数
|
||||
condition := "where not ID is " + strconv.FormatInt(gid, 10) +
|
||||
" and APIKey = '" + groupinfo.APIKey +
|
||||
"' and SecretKey = '" + groupinfo.SecretKey + "'"
|
||||
otherinfo := apikey{}
|
||||
var groups []int64 // 将相同的key的ID暂存
|
||||
// 无视没有找到相同的key的err
|
||||
_ = sql.db.FindFor("groupinfo", &otherinfo, condition, func() error {
|
||||
_ = sql.db.FindFor("groupinfo", &otherinfo, "WHERE ID <> ? AND APIKey = ? AND SecretKey = ?", func() error {
|
||||
groups = append(groups, otherinfo.ID)
|
||||
return nil
|
||||
})
|
||||
}, gid, groupinfo.APIKey, groupinfo.SecretKey)
|
||||
if len(groups) != 0 { // 如果有相同的key就更新
|
||||
for _, group := range groups {
|
||||
err = sql.db.Find("groupinfo", &otherinfo, "where ID is "+strconv.FormatInt(group, 10))
|
||||
err = sql.db.Find("groupinfo", &otherinfo, "WHERE ID = ?", group)
|
||||
if err == nil {
|
||||
otherinfo.Token = groupinfo.Token
|
||||
otherinfo.Updatetime = groupinfo.Updatetime
|
||||
@ -644,7 +637,7 @@ func (sql *keydb) update(gid int64, sub int) error {
|
||||
}
|
||||
groupinfo := apikey{} // 用于暂存数据
|
||||
// 获取group信息
|
||||
err = sql.db.Find("groupinfo", &groupinfo, "where ID is "+strconv.FormatInt(gid, 10))
|
||||
err = sql.db.Find("groupinfo", &groupinfo, "WHERE ID = ?", gid)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -655,19 +648,16 @@ func (sql *keydb) update(gid int64, sub int) error {
|
||||
return err
|
||||
}
|
||||
// 更新相同key的他人次数
|
||||
condition := "where not ID is " + strconv.FormatInt(gid, 10) +
|
||||
" and APIKey = '" + groupinfo.APIKey +
|
||||
"' and SecretKey = '" + groupinfo.SecretKey + "'"
|
||||
otherinfo := apikey{}
|
||||
var groups []int64 // 将相同的key的ID暂存
|
||||
// 无视没有找到相同的key的err
|
||||
_ = sql.db.FindFor("groupinfo", &otherinfo, condition, func() error {
|
||||
_ = sql.db.FindFor("groupinfo", &otherinfo, "WHERE ID <> ? AND APIKey = ? AND SecretKey = ?", func() error {
|
||||
groups = append(groups, otherinfo.ID)
|
||||
return nil
|
||||
})
|
||||
}, gid, groupinfo.APIKey, groupinfo.SecretKey)
|
||||
if len(groups) != 0 { // 如果有相同的key就更新
|
||||
for _, group := range groups {
|
||||
err = sql.db.Find("groupinfo", &otherinfo, "where ID is "+strconv.FormatInt(group, 10))
|
||||
err = sql.db.Find("groupinfo", &otherinfo, "WHERE ID = ?", group)
|
||||
if err == nil {
|
||||
otherinfo.MaxLimit = groupinfo.MaxLimit
|
||||
otherinfo.DayLimit = groupinfo.DayLimit
|
||||
|
||||
Loading…
Reference in New Issue
Block a user