mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-20 06:20:08 +08:00
commit
ce326ce977
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,4 +1,5 @@
|
|||||||
data/chat/*
|
data/chat
|
||||||
data/SetuTime/cache/*
|
data/SetuTime/cache
|
||||||
|
data/manager
|
||||||
main.exe
|
main.exe
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|||||||
@ -10,6 +10,8 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/Yiwen-Chan/ZeroBot-Plugin/api/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// urlCache 缓存并返回缓存路径
|
// urlCache 缓存并返回缓存路径
|
||||||
@ -20,9 +22,9 @@ func (this *Illust) PixivPicDown(path string) (savePath string, err error) {
|
|||||||
url = strings.ReplaceAll(url, "_p0", "_p0_master1200")
|
url = strings.ReplaceAll(url, "_p0", "_p0_master1200")
|
||||||
url = strings.ReplaceAll(url, ".png", ".jpg")
|
url = strings.ReplaceAll(url, ".png", ".jpg")
|
||||||
// 文件名为url的hash值
|
// 文件名为url的hash值
|
||||||
savePath = path + Int2Str(pid) + ".jpg"
|
savePath = path + utils.Int2Str(pid) + ".jpg"
|
||||||
// 文件存在或文件大小大于10kb
|
// 文件存在或文件大小大于10kb
|
||||||
if PathExists(savePath) && FileSize(savePath) > 10240 {
|
if utils.PathExists(savePath) && utils.FileSize(savePath) > 10240 {
|
||||||
return savePath, nil
|
return savePath, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,9 +82,9 @@ func (this *Illust) RmPic(path string) (err error) {
|
|||||||
url = strings.ReplaceAll(url, "_p0", "_p0_master1200")
|
url = strings.ReplaceAll(url, "_p0", "_p0_master1200")
|
||||||
url = strings.ReplaceAll(url, ".png", ".jpg")
|
url = strings.ReplaceAll(url, ".png", ".jpg")
|
||||||
// 文件名为url的hash值
|
// 文件名为url的hash值
|
||||||
savePath := path + Int2Str(pid) + ".jpg"
|
savePath := path + utils.Int2Str(pid) + ".jpg"
|
||||||
// 文件存在或文件大小大于10kb
|
// 文件存在或文件大小大于10kb
|
||||||
if PathExists(savePath) {
|
if utils.PathExists(savePath) {
|
||||||
return os.Remove(savePath)
|
return os.Remove(savePath)
|
||||||
} else {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
package pixiv
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
14
go.mod
14
go.mod
@ -4,9 +4,17 @@ go 1.15
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/antchfx/htmlquery v1.2.3
|
github.com/antchfx/htmlquery v1.2.3
|
||||||
github.com/mattn/go-sqlite3 v1.14.6
|
github.com/antchfx/xpath v1.2.0 // indirect
|
||||||
|
github.com/fumiama/ZeroBot-Plugin-Timer v0.0.0-20210606064339-d55b94d71eee
|
||||||
|
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||||
|
github.com/golang/protobuf v1.5.2 // indirect
|
||||||
|
github.com/mattn/go-sqlite3 v1.14.7
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/sirupsen/logrus v1.8.1
|
github.com/sirupsen/logrus v1.8.1
|
||||||
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816
|
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816
|
||||||
github.com/tidwall/gjson v1.7.4
|
github.com/tidwall/gjson v1.8.0
|
||||||
github.com/wdvxdr1123/ZeroBot v1.1.2
|
github.com/tidwall/pretty v1.1.1 // indirect
|
||||||
|
github.com/wdvxdr1123/ZeroBot v1.2.0
|
||||||
|
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 // indirect
|
||||||
|
golang.org/x/sys v0.0.0-20210603125802-9665404d3644 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
57
go.sum
57
go.sum
@ -1,29 +1,39 @@
|
|||||||
github.com/antchfx/htmlquery v1.2.3 h1:sP3NFDneHx2stfNXCKbhHFo8XgNjCACnU/4AO5gWz6M=
|
github.com/antchfx/htmlquery v1.2.3 h1:sP3NFDneHx2stfNXCKbhHFo8XgNjCACnU/4AO5gWz6M=
|
||||||
github.com/antchfx/htmlquery v1.2.3/go.mod h1:B0ABL+F5irhhMWg54ymEZinzMSi0Kt3I2if0BLYa3V0=
|
github.com/antchfx/htmlquery v1.2.3/go.mod h1:B0ABL+F5irhhMWg54ymEZinzMSi0Kt3I2if0BLYa3V0=
|
||||||
github.com/antchfx/xpath v1.1.6 h1:6sVh6hB5T6phw1pFpHRQ+C4bd8sNI+O58flqtg7h0R0=
|
|
||||||
github.com/antchfx/xpath v1.1.6/go.mod h1:Yee4kTMuNiPYJ7nSNorELQMr1J33uOpXDMByNYhvtNk=
|
github.com/antchfx/xpath v1.1.6/go.mod h1:Yee4kTMuNiPYJ7nSNorELQMr1J33uOpXDMByNYhvtNk=
|
||||||
|
github.com/antchfx/xpath v1.2.0 h1:mbwv7co+x0RwgeGAOHdrKy89GvHaGvxxBtPK0uF9Zr8=
|
||||||
|
github.com/antchfx/xpath v1.2.0/go.mod h1:i54GszH55fYfBmoZXapTHN8T8tkcHfRgLyVwwqzXNcs=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY=
|
github.com/fumiama/ZeroBot-Plugin-Timer v0.0.0-20210606064339-d55b94d71eee h1:IfBMBcPUUbmEzXjIVkDiSSPoUBkH8Xbk1K9PllgrAfo=
|
||||||
|
github.com/fumiama/ZeroBot-Plugin-Timer v0.0.0-20210606064339-d55b94d71eee/go.mod h1:RN0gCtafWRu2d7lMg9/5UfZDhtsPgdeUovsyuSwl+oQ=
|
||||||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
|
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
|
||||||
|
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||||
|
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
||||||
|
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||||
|
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
||||||
|
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68=
|
github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMWAQ=
|
||||||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||||
github.com/mattn/go-sqlite3 v1.14.6 h1:dNPt6NO46WmLVt2DLNpwczCmdV5boIZ6g/tlDrlRUbg=
|
github.com/mattn/go-sqlite3 v1.14.7 h1:fxWBnXkxfM6sRiuH3bqJ4CfzZojMOLVc0UTsTglEghA=
|
||||||
github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
github.com/mattn/go-sqlite3 v1.14.7/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
|
|
||||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||||
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
|
github.com/modern-go/reflect2 v1.0.2-0.20210109003243-333559e1834b h1:6Xjqolv/0DDdUqlpnsTomXQvjvvkz7Ux7TcMALvozEw=
|
||||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
github.com/modern-go/reflect2 v1.0.2-0.20210109003243-333559e1834b/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||||
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||||
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||||
@ -41,27 +51,40 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
|||||||
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
|
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
|
||||||
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816 h1:J6v8awz+me+xeb/cUTotKgceAYouhIB3pjzgRd6IlGk=
|
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816 h1:J6v8awz+me+xeb/cUTotKgceAYouhIB3pjzgRd6IlGk=
|
||||||
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816/go.mod h1:tzym/CEb5jnFI+Q0k4Qq3+LvRF4gO3E2pxS8fHP8jcA=
|
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816/go.mod h1:tzym/CEb5jnFI+Q0k4Qq3+LvRF4gO3E2pxS8fHP8jcA=
|
||||||
github.com/tidwall/gjson v1.7.4 h1:19cchw8FOxkG5mdLRkGf9jqIqEyqdZhPqW60XfyFxk8=
|
github.com/tidwall/gjson v1.8.0 h1:Qt+orfosKn0rbNTZqHYDqBrmm3UDA4KRkv70fDzG+PQ=
|
||||||
github.com/tidwall/gjson v1.7.4/go.mod h1:5/xDoumyyDNerp2U36lyolv46b3uF/9Bu6OfyQ9GImk=
|
github.com/tidwall/gjson v1.8.0/go.mod h1:5/xDoumyyDNerp2U36lyolv46b3uF/9Bu6OfyQ9GImk=
|
||||||
github.com/tidwall/match v1.0.3 h1:FQUVvBImDutD8wJLN6c5eMzWtjgONK9MwIBCOrUJKeE=
|
github.com/tidwall/match v1.0.3 h1:FQUVvBImDutD8wJLN6c5eMzWtjgONK9MwIBCOrUJKeE=
|
||||||
github.com/tidwall/match v1.0.3/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
github.com/tidwall/match v1.0.3/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||||
github.com/tidwall/pretty v1.1.0 h1:K3hMW5epkdAVwibsQEfR/7Zj0Qgt4DxtNumTq/VloO8=
|
|
||||||
github.com/tidwall/pretty v1.1.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
github.com/tidwall/pretty v1.1.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||||
github.com/wdvxdr1123/ZeroBot v1.1.2 h1:SGl7lSdFatdSCcVPXTIC56xoMUtXwyz1xWBSkPOAgEU=
|
github.com/tidwall/pretty v1.1.1 h1:nt6/Ot5LtZnJCWwEFlelOixPo0xhPFsuZlKyOL3Xfnc=
|
||||||
github.com/wdvxdr1123/ZeroBot v1.1.2/go.mod h1:N4bGSEHCKOrplRHNM8XJFXcXFsK0OUSvmTVakomS+k8=
|
github.com/tidwall/pretty v1.1.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||||
|
github.com/wdvxdr1123/ZeroBot v1.2.0 h1:GmCkbzMMq3iugViKDtLbsL7joi29uG3/tp1554nboWI=
|
||||||
|
github.com/wdvxdr1123/ZeroBot v1.2.0/go.mod h1:83nHtG8V5TAxPwH/LCDxLpZk4khIgs29dkr5TBWf7fc=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20200421231249-e086a090c8fd h1:QPwSajcTUrFriMF1nJ3XzgoqakqQEsnZf9LdXdi2nkI=
|
|
||||||
golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||||
|
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 h1:wjuX4b5yYQnEQHzd+CBcrcC6OVR2J1CN6mUy0oSxIPo=
|
||||||
|
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884=
|
|
||||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210603125802-9665404d3644 h1:CA1DEQ4NdKphKeL70tvsWNdT5oFh1lOjihRcEDROi0I=
|
||||||
|
golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
|
||||||
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||||
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||||
|
google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
|
||||||
|
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||||
|
|||||||
2
main.go
2
main.go
@ -53,7 +53,7 @@ func main() {
|
|||||||
CommandPrefix: "/",
|
CommandPrefix: "/",
|
||||||
SuperUsers: os.Args[1:], // 必须修改,否则无权限
|
SuperUsers: os.Args[1:], // 必须修改,否则无权限
|
||||||
Driver: []zero.Driver{
|
Driver: []zero.Driver{
|
||||||
driver.NewWebSocketClient("127.0.0.1", "6700", ""),
|
driver.NewWebSocketClient("ws://127.0.0.1:6700/", ""),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
// 帮助
|
// 帮助
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/Yiwen-Chan/ZeroBot-Plugin/api/msgext"
|
timer "github.com/fumiama/ZeroBot-Plugin-Timer"
|
||||||
zero "github.com/wdvxdr1123/ZeroBot"
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
)
|
)
|
||||||
@ -235,15 +235,10 @@ func init() { // 插件主体
|
|||||||
zero.OnRegex(`^在(.{1,2})月(.{1,3}日|每?周.?)的(.{1,3})点(.{1,3})分时(用.+)?提醒大家(.*)`, zero.SuperUserPermission).SetBlock(true).SetPriority(40).
|
zero.OnRegex(`^在(.{1,2})月(.{1,3}日|每?周.?)的(.{1,3})点(.{1,3})分时(用.+)?提醒大家(.*)`, zero.SuperUserPermission).SetBlock(true).SetPriority(40).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
dateStrs := ctx.State["regex_matched"].([]string)
|
dateStrs := ctx.State["regex_matched"].([]string)
|
||||||
ts := getFilledTimeStamp(dateStrs, false)
|
ts := timer.GetFilledTimeStamp(dateStrs, false)
|
||||||
if ts.enable {
|
ts.Grpid = uint64(ctx.Event.GroupID)
|
||||||
go timer(ts, func() {
|
if ts.Enable {
|
||||||
if ts.url == "" {
|
go timer.RegisterTimer(ts, true)
|
||||||
ctx.SendChain(msgext.AtAll(), message.Text(ts.alert))
|
|
||||||
} else {
|
|
||||||
ctx.SendChain(msgext.AtAll(), message.Text(ts.alert), msgext.ImageNoCache(ts.url))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
ctx.Send("记住了~")
|
ctx.Send("记住了~")
|
||||||
} else {
|
} else {
|
||||||
ctx.Send("参数非法!")
|
ctx.Send("参数非法!")
|
||||||
@ -254,12 +249,13 @@ func init() { // 插件主体
|
|||||||
zero.OnRegex(`^取消在(.{1,2})月(.{1,3}日|每?周.?)的(.{1,3})点(.{1,3})分的提醒`, zero.SuperUserPermission).SetBlock(true).SetPriority(40).
|
zero.OnRegex(`^取消在(.{1,2})月(.{1,3}日|每?周.?)的(.{1,3})点(.{1,3})分的提醒`, zero.SuperUserPermission).SetBlock(true).SetPriority(40).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
dateStrs := ctx.State["regex_matched"].([]string)
|
dateStrs := ctx.State["regex_matched"].([]string)
|
||||||
ts := getFilledTimeStamp(dateStrs, true)
|
ts := timer.GetFilledTimeStamp(dateStrs, true)
|
||||||
ti := getTimerInfo(&ts)
|
ti := timer.GetTimerInfo(ts)
|
||||||
t, ok := timers[ti]
|
t, ok := (*timer.Timers)[ti]
|
||||||
if ok {
|
if ok {
|
||||||
t.enable = false
|
t.Enable = false
|
||||||
delete(timers, ti) //避免重复取消
|
delete(*timer.Timers, ti) //避免重复取消
|
||||||
|
timer.SaveTimers()
|
||||||
ctx.Send("取消成功~")
|
ctx.Send("取消成功~")
|
||||||
} else {
|
} else {
|
||||||
ctx.Send("没有这个定时器哦~")
|
ctx.Send("没有这个定时器哦~")
|
||||||
|
|||||||
175
manager/timer.go
175
manager/timer.go
@ -1,175 +0,0 @@
|
|||||||
package manager
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
"unicode"
|
|
||||||
)
|
|
||||||
|
|
||||||
type TimeStamp struct {
|
|
||||||
enable bool
|
|
||||||
alert string
|
|
||||||
url string
|
|
||||||
month int8
|
|
||||||
day int8
|
|
||||||
week int8
|
|
||||||
hour int8
|
|
||||||
minute int8
|
|
||||||
}
|
|
||||||
|
|
||||||
//记录每个定时器以便取消
|
|
||||||
var timers = make(map[string]*TimeStamp)
|
|
||||||
|
|
||||||
func timer(ts TimeStamp, onTimeReached func()) {
|
|
||||||
key := getTimerInfo(&ts)
|
|
||||||
fmt.Printf("[群管]注册计时器: %s\n", key)
|
|
||||||
t, ok := timers[key]
|
|
||||||
if ok { //避免重复注册定时器
|
|
||||||
t.enable = false
|
|
||||||
}
|
|
||||||
timers[key] = &ts
|
|
||||||
judgeHM := func() {
|
|
||||||
if ts.hour < 0 || ts.hour == int8(time.Now().Hour()) {
|
|
||||||
if ts.minute < 0 || ts.minute == int8(time.Now().Minute()) {
|
|
||||||
onTimeReached()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for ts.enable {
|
|
||||||
if ts.month < 0 || ts.month == int8(time.Now().Month()) {
|
|
||||||
if ts.day < 0 || ts.day == int8(time.Now().Day()) {
|
|
||||||
judgeHM()
|
|
||||||
} else if ts.day == 0 {
|
|
||||||
if ts.week < 0 || ts.week == int8(time.Now().Weekday()) {
|
|
||||||
judgeHM()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
time.Sleep(time.Minute)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//获得标准化定时字符串
|
|
||||||
func getTimerInfo(ts *TimeStamp) string {
|
|
||||||
return fmt.Sprintf("%d月%d日%d周%d:%d", ts.month, ts.day, ts.week, ts.hour, ts.minute)
|
|
||||||
}
|
|
||||||
|
|
||||||
//获得填充好的ts
|
|
||||||
func getFilledTimeStamp(dateStrs []string, matchDateOnly bool) TimeStamp {
|
|
||||||
monthStr := []rune(dateStrs[1])
|
|
||||||
dayWeekStr := []rune(dateStrs[2])
|
|
||||||
hourStr := []rune(dateStrs[3])
|
|
||||||
minuteStr := []rune(dateStrs[4])
|
|
||||||
|
|
||||||
var ts TimeStamp
|
|
||||||
ts.month = chineseNum2Int(monthStr)
|
|
||||||
if (ts.month != -1 && ts.month <= 0) || ts.month > 12 { //月份非法
|
|
||||||
fmt.Println("[群管]月份非法!")
|
|
||||||
return ts
|
|
||||||
}
|
|
||||||
lenOfDW := len(dayWeekStr)
|
|
||||||
if lenOfDW == 4 { //包括末尾的"日"
|
|
||||||
dayWeekStr = []rune{dayWeekStr[0], dayWeekStr[2]} //去除中间的十
|
|
||||||
ts.day = chineseNum2Int(dayWeekStr)
|
|
||||||
if (ts.day != -1 && ts.day <= 0) || ts.day > 31 { //日期非法
|
|
||||||
fmt.Println("[群管]日期非法1!")
|
|
||||||
return ts
|
|
||||||
}
|
|
||||||
} else if dayWeekStr[lenOfDW-1] == rune('日') { //xx日
|
|
||||||
dayWeekStr = dayWeekStr[:lenOfDW-1]
|
|
||||||
ts.day = chineseNum2Int(dayWeekStr)
|
|
||||||
if (ts.day != -1 && ts.day <= 0) || ts.day > 31 { //日期非法
|
|
||||||
fmt.Println("[群管]日期非法2!")
|
|
||||||
return ts
|
|
||||||
}
|
|
||||||
} else if dayWeekStr[0] == rune('每') { //每周
|
|
||||||
ts.week = -1
|
|
||||||
} else { //周x
|
|
||||||
ts.week = chineseNum2Int(dayWeekStr[1:])
|
|
||||||
if ts.week == 7 { //周天是0
|
|
||||||
ts.week = 0
|
|
||||||
}
|
|
||||||
if ts.week < 0 || ts.week > 6 { //星期非法
|
|
||||||
ts.week = -11
|
|
||||||
fmt.Println("[群管]星期非法!")
|
|
||||||
return ts
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(hourStr) == 3 {
|
|
||||||
hourStr = []rune{hourStr[0], hourStr[2]} //去除中间的十
|
|
||||||
}
|
|
||||||
ts.hour = chineseNum2Int(hourStr)
|
|
||||||
if ts.hour < -1 || ts.hour > 23 { //小时非法
|
|
||||||
fmt.Println("[群管]小时非法!")
|
|
||||||
return ts
|
|
||||||
}
|
|
||||||
if len(minuteStr) == 3 {
|
|
||||||
minuteStr = []rune{minuteStr[0], minuteStr[2]} //去除中间的十
|
|
||||||
}
|
|
||||||
ts.minute = chineseNum2Int(minuteStr)
|
|
||||||
if ts.minute < -1 || ts.minute > 59 { //分钟非法
|
|
||||||
fmt.Println("[群管]分钟非法!")
|
|
||||||
return ts
|
|
||||||
}
|
|
||||||
if !matchDateOnly {
|
|
||||||
urlStr := dateStrs[5]
|
|
||||||
if urlStr != "" { //是图片url
|
|
||||||
ts.url = urlStr[3:] //utf-8下用为3字节
|
|
||||||
fmt.Println("[群管]" + ts.url)
|
|
||||||
if !strings.HasPrefix(ts.url, "http") {
|
|
||||||
ts.url = "illegal"
|
|
||||||
fmt.Println("[群管]url非法!")
|
|
||||||
return ts
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ts.alert = dateStrs[6]
|
|
||||||
ts.enable = true
|
|
||||||
}
|
|
||||||
return ts
|
|
||||||
}
|
|
||||||
|
|
||||||
//汉字数字转int,仅支持-10~99,最多两位数,其中"每"解释为-1,"每两"为-2,以此类推
|
|
||||||
func chineseNum2Int(rs []rune) int8 {
|
|
||||||
r := -1
|
|
||||||
l := len(rs)
|
|
||||||
mai := rune('每')
|
|
||||||
if unicode.IsDigit(rs[0]) { //默认可能存在的第二位也为int
|
|
||||||
r, _ = strconv.Atoi(string(rs))
|
|
||||||
} else {
|
|
||||||
if rs[0] == mai {
|
|
||||||
if l == 2 {
|
|
||||||
r = -chineseChar2Int(rs[1])
|
|
||||||
}
|
|
||||||
} else if l == 1 {
|
|
||||||
r = chineseChar2Int(rs[0])
|
|
||||||
} else {
|
|
||||||
ten := chineseChar2Int(rs[0])
|
|
||||||
if ten != 10 {
|
|
||||||
ten *= 10
|
|
||||||
}
|
|
||||||
ge := chineseChar2Int(rs[1])
|
|
||||||
if ge == 10 {
|
|
||||||
ge = 0
|
|
||||||
}
|
|
||||||
r = ten + ge
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return int8(r)
|
|
||||||
}
|
|
||||||
|
|
||||||
//处理单个字符的映射0~10
|
|
||||||
func chineseChar2Int(c rune) int {
|
|
||||||
if c == rune('日') || c == rune('天') { //周日/周天
|
|
||||||
return 7
|
|
||||||
} else {
|
|
||||||
match := []rune("零一二三四五六七八九十")
|
|
||||||
for i, m := range match {
|
|
||||||
if c == m {
|
|
||||||
return i
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -10,17 +10,18 @@ import (
|
|||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
|
|
||||||
"github.com/Yiwen-Chan/ZeroBot-Plugin/api/pixiv"
|
"github.com/Yiwen-Chan/ZeroBot-Plugin/api/pixiv"
|
||||||
|
apiutils "github.com/Yiwen-Chan/ZeroBot-Plugin/api/utils"
|
||||||
utils "github.com/Yiwen-Chan/ZeroBot-Plugin/picsearcher/utils"
|
utils "github.com/Yiwen-Chan/ZeroBot-Plugin/picsearcher/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var CACHEPATH = "/tmp/picsch/" // 缓冲图片路径
|
var CACHEPATH = "/tmp/picsch/" // 缓冲图片路径
|
||||||
|
|
||||||
func init() { // 插件主体
|
func init() { // 插件主体
|
||||||
pixiv.CreatePath(CACHEPATH)
|
apiutils.CreatePath(CACHEPATH)
|
||||||
// 根据PID搜图
|
// 根据PID搜图
|
||||||
zero.OnRegex(`^搜图(\d+)$`).SetBlock(true).SetPriority(30).
|
zero.OnRegex(`^搜图(\d+)$`).SetBlock(true).SetPriority(30).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
id := pixiv.Str2Int(ctx.State["regex_matched"].([]string)[1])
|
id := apiutils.Str2Int(ctx.State["regex_matched"].([]string)[1])
|
||||||
ctx.Send("少女祈祷中......")
|
ctx.Send("少女祈祷中......")
|
||||||
// 获取P站插图信息
|
// 获取P站插图信息
|
||||||
illust := &pixiv.Illust{}
|
illust := &pixiv.Illust{}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/Yiwen-Chan/ZeroBot-Plugin/api/pixiv"
|
"github.com/Yiwen-Chan/ZeroBot-Plugin/api/pixiv"
|
||||||
|
"github.com/Yiwen-Chan/ZeroBot-Plugin/api/utils"
|
||||||
xpath "github.com/antchfx/htmlquery"
|
xpath "github.com/antchfx/htmlquery"
|
||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
)
|
)
|
||||||
@ -72,7 +73,7 @@ func Ascii2dSearch(pic string) (message.Message, error) {
|
|||||||
if link == "" || index == -1 {
|
if link == "" || index == -1 {
|
||||||
return nil, fmt.Errorf("Ascii2d not found")
|
return nil, fmt.Errorf("Ascii2d not found")
|
||||||
}
|
}
|
||||||
var id = pixiv.Str2Int(link[index+1:])
|
var id = utils.Str2Int(link[index+1:])
|
||||||
if id == 0 {
|
if id == 0 {
|
||||||
return nil, fmt.Errorf("convert to pid error")
|
return nil, fmt.Errorf("convert to pid error")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,13 +10,14 @@ import (
|
|||||||
"github.com/wdvxdr1123/ZeroBot/extension/rate"
|
"github.com/wdvxdr1123/ZeroBot/extension/rate"
|
||||||
|
|
||||||
"github.com/Yiwen-Chan/ZeroBot-Plugin/api/pixiv"
|
"github.com/Yiwen-Chan/ZeroBot-Plugin/api/pixiv"
|
||||||
|
apiutils "github.com/Yiwen-Chan/ZeroBot-Plugin/api/utils"
|
||||||
"github.com/Yiwen-Chan/ZeroBot-Plugin/setutime/utils"
|
"github.com/Yiwen-Chan/ZeroBot-Plugin/setutime/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var limit = rate.NewManager(time.Minute*1, 5)
|
var limit = rate.NewManager(time.Minute*1, 5)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
BOTPATH = pixiv.PathExecute() // 当前bot运行目录
|
BOTPATH = apiutils.PathExecute() // 当前bot运行目录
|
||||||
DATAPATH = BOTPATH + "data/SetuTime/" // 数据目录
|
DATAPATH = BOTPATH + "data/SetuTime/" // 数据目录
|
||||||
DBPATH = DATAPATH + "SetuTime.db" // 数据库路径
|
DBPATH = DATAPATH + "SetuTime.db" // 数据库路径
|
||||||
|
|
||||||
@ -34,8 +35,8 @@ func init() {
|
|||||||
PoolsCache.Group = CACHEGROUP // 图片缓冲群
|
PoolsCache.Group = CACHEGROUP // 图片缓冲群
|
||||||
PoolsCache.Path = CACHEPATH // 缓冲图片路径
|
PoolsCache.Path = CACHEPATH // 缓冲图片路径
|
||||||
|
|
||||||
pixiv.CreatePath(DBPATH)
|
apiutils.CreatePath(DBPATH)
|
||||||
pixiv.CreatePath(CACHEPATH)
|
apiutils.CreatePath(CACHEPATH)
|
||||||
|
|
||||||
for i := range PoolList {
|
for i := range PoolList {
|
||||||
if err := DB.Create(PoolList[i], &pixiv.Illust{}); err != nil {
|
if err := DB.Create(PoolList[i], &pixiv.Illust{}); err != nil {
|
||||||
@ -54,7 +55,7 @@ func init() { // 插件主体
|
|||||||
var type_ = ctx.State["regex_matched"].([]string)[1]
|
var type_ = ctx.State["regex_matched"].([]string)[1]
|
||||||
// 补充池子
|
// 补充池子
|
||||||
go func() {
|
go func() {
|
||||||
times := pixiv.Min(PoolsCache.Max-PoolsCache.Size(type_), 2)
|
times := apiutils.Min(PoolsCache.Max-PoolsCache.Size(type_), 2)
|
||||||
for i := 0; i < times; i++ {
|
for i := 0; i < times; i++ {
|
||||||
illust := &pixiv.Illust{}
|
illust := &pixiv.Illust{}
|
||||||
// 查询出一张图片
|
// 查询出一张图片
|
||||||
@ -97,7 +98,7 @@ func init() { // 插件主体
|
|||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
var (
|
var (
|
||||||
type_ = ctx.State["regex_matched"].([]string)[1]
|
type_ = ctx.State["regex_matched"].([]string)[1]
|
||||||
id = pixiv.Str2Int(ctx.State["regex_matched"].([]string)[2])
|
id = apiutils.Str2Int(ctx.State["regex_matched"].([]string)[2])
|
||||||
illust = &pixiv.Illust{}
|
illust = &pixiv.Illust{}
|
||||||
)
|
)
|
||||||
ctx.Send("少女祈祷中......")
|
ctx.Send("少女祈祷中......")
|
||||||
@ -130,7 +131,7 @@ func init() { // 插件主体
|
|||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
var (
|
var (
|
||||||
type_ = ctx.State["regex_matched"].([]string)[1]
|
type_ = ctx.State["regex_matched"].([]string)[1]
|
||||||
id = pixiv.Str2Int(ctx.State["regex_matched"].([]string)[2])
|
id = apiutils.Str2Int(ctx.State["regex_matched"].([]string)[2])
|
||||||
)
|
)
|
||||||
// 查询数据库
|
// 查询数据库
|
||||||
if err := DB.Delete(type_, fmt.Sprintf("WHERE pid=%d", id)); err != nil {
|
if err := DB.Delete(type_, fmt.Sprintf("WHERE pid=%d", id)); err != nil {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user