mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 22:00:11 +08:00
💩👌 make lint happy
This commit is contained in:
parent
40f1b1c618
commit
fd64016e19
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@ data/SetuTime/search
|
|||||||
data/manager
|
data/manager
|
||||||
.idea/
|
.idea/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
.vscode
|
||||||
2
go.mod
2
go.mod
@ -7,6 +7,7 @@ require (
|
|||||||
github.com/FloatTech/ZeroBot-ACGImage v1.5.5
|
github.com/FloatTech/ZeroBot-ACGImage v1.5.5
|
||||||
github.com/FloatTech/ZeroBot-Plugin-Timer v1.3.4
|
github.com/FloatTech/ZeroBot-Plugin-Timer v1.3.4
|
||||||
github.com/StackExchange/wmi v1.2.1 // indirect
|
github.com/StackExchange/wmi v1.2.1 // indirect
|
||||||
|
github.com/golang/protobuf v1.5.2
|
||||||
github.com/robfig/cron v1.2.0
|
github.com/robfig/cron v1.2.0
|
||||||
github.com/shirou/gopsutil v3.21.7+incompatible
|
github.com/shirou/gopsutil v3.21.7+incompatible
|
||||||
github.com/sirupsen/logrus v1.8.1
|
github.com/sirupsen/logrus v1.8.1
|
||||||
@ -17,5 +18,6 @@ require (
|
|||||||
github.com/wdvxdr1123/ZeroBot v1.2.2
|
github.com/wdvxdr1123/ZeroBot v1.2.2
|
||||||
golang.org/x/text v0.3.6 // indirect
|
golang.org/x/text v0.3.6 // indirect
|
||||||
golang.org/x/tools v0.1.5 // indirect
|
golang.org/x/tools v0.1.5 // indirect
|
||||||
|
google.golang.org/protobuf v1.27.1 // indirect
|
||||||
modernc.org/sqlite v1.12.0
|
modernc.org/sqlite v1.12.0
|
||||||
)
|
)
|
||||||
|
|||||||
12
go.sum
12
go.sum
@ -20,6 +20,8 @@ github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25Kn
|
|||||||
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/go-ole/go-ole v1.2.5 h1:t4MGB5xEDZvXI+0rMjjsfBsD7yAgp/s9ZDkL1JndXwY=
|
github.com/go-ole/go-ole v1.2.5 h1:t4MGB5xEDZvXI+0rMjjsfBsD7yAgp/s9ZDkL1JndXwY=
|
||||||
github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
||||||
|
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||||
|
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY=
|
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY=
|
||||||
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/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
@ -38,6 +40,8 @@ github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMW
|
|||||||
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
|
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
|
||||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
|
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
|
||||||
|
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||||
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||||
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-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
|
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
|
||||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||||
@ -85,23 +89,27 @@ github.com/tklauser/numcpus v0.2.3 h1:nQ0QYpiritP6ViFhrKYsiv6VVxOpum2Gks5GhnJbS/
|
|||||||
github.com/tklauser/numcpus v0.2.3/go.mod h1:vpEPS/JC+oZGGQ/My/vJnNsvMDQL6PwOqt8dsCw5j+E=
|
github.com/tklauser/numcpus v0.2.3/go.mod h1:vpEPS/JC+oZGGQ/My/vJnNsvMDQL6PwOqt8dsCw5j+E=
|
||||||
github.com/wdvxdr1123/ZeroBot v1.2.2 h1:BKEy3l80BMrQWpFWaII0AfFMyf9bqrB0TxfWhTdoV58=
|
github.com/wdvxdr1123/ZeroBot v1.2.2 h1:BKEy3l80BMrQWpFWaII0AfFMyf9bqrB0TxfWhTdoV58=
|
||||||
github.com/wdvxdr1123/ZeroBot v1.2.2/go.mod h1:83nHtG8V5TAxPwH/LCDxLpZk4khIgs29dkr5TBWf7fc=
|
github.com/wdvxdr1123/ZeroBot v1.2.2/go.mod h1:83nHtG8V5TAxPwH/LCDxLpZk4khIgs29dkr5TBWf7fc=
|
||||||
|
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||||
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/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
|
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
|
golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
|
||||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
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-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
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-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0=
|
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0=
|
||||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||||
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/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/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=
|
||||||
@ -127,7 +135,9 @@ 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/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/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||||
golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||||
|
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||||
golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA=
|
golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA=
|
||||||
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
@ -138,6 +148,8 @@ golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8T
|
|||||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
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 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
|
||||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
|
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
|
||||||
|
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
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=
|
||||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
/*
|
// Package aifalse 暂时只有服务器监控
|
||||||
暂时只有服务器监控
|
package aifalse
|
||||||
*/
|
|
||||||
package plugin_ai_false
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math"
|
"math"
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
// Package atri
|
/*
|
||||||
// 本文件基于 https://github.com/Kyomotoi/ATRI
|
Package atri
|
||||||
// 为 Golang 移植版,语料、素材均来自上述项目
|
本文件基于 https://github.com/Kyomotoi/ATRI
|
||||||
// 本项目遵守 AGPL v3 协议进行开源
|
为 Golang 移植版,语料、素材均来自上述项目
|
||||||
|
本项目遵守 AGPL v3 协议进行开源
|
||||||
|
*/
|
||||||
package atri
|
package atri
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -14,25 +16,25 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
// ATRI 所有命令的优先级
|
// ATRI 所有命令的优先级
|
||||||
PRIO = -1
|
prio = -1
|
||||||
// ATRI 表情的 GitHub 镜像位置
|
// ATRI 表情的 GitHub 镜像位置
|
||||||
RES = "https://raw.dihe.moe/Yiwen-Chan/ZeroBot-Plugin/master/plugin_atri/"
|
res = "https://raw.dihe.moe/Yiwen-Chan/ZeroBot-Plugin/master/plugin_atri/"
|
||||||
// ATRI 的总开关
|
// ATRI 的总开关
|
||||||
ENABLE = true
|
enable = true
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() { // 插件主体
|
func init() { // 插件主体
|
||||||
zero.OnFullMatch("ATRI醒醒", zero.AdminPermission).SetBlock(true).SetPriority(PRIO).
|
zero.OnFullMatch("ATRI醒醒", zero.AdminPermission).SetBlock(true).SetPriority(prio).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
ENABLE = true
|
enable = true
|
||||||
ctx.SendChain(randText("嗯呜呜……夏生先生……?"))
|
ctx.SendChain(randText("嗯呜呜……夏生先生……?"))
|
||||||
})
|
})
|
||||||
zero.OnFullMatch("ATRI睡吧", zero.AdminPermission).SetBlock(true).SetPriority(PRIO).
|
zero.OnFullMatch("ATRI睡吧", zero.AdminPermission).SetBlock(true).SetPriority(prio).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
ENABLE = false
|
enable = false
|
||||||
ctx.SendChain(randText("Zzz……Zzz……"))
|
ctx.SendChain(randText("Zzz……Zzz……"))
|
||||||
})
|
})
|
||||||
zero.OnFullMatch("萝卜子", AtriSwitch(), AtriSleep()).SetBlock(true).SetPriority(PRIO).
|
zero.OnFullMatch("萝卜子", atriSwitch(), atriSleep()).SetBlock(true).SetPriority(prio).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
switch rand.Intn(2) {
|
switch rand.Intn(2) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -41,17 +43,17 @@ func init() { // 插件主体
|
|||||||
ctx.SendChain(randRecord("RocketPunch.amr"))
|
ctx.SendChain(randRecord("RocketPunch.amr"))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
zero.OnKeywordGroup([]string{"喜欢", "爱你", "爱", "suki", "daisuki", "すき", "好き", "贴贴", "老婆", "亲一个", "mua"}, AtriSwitch(), AtriSleep(), zero.OnlyToMe).SetBlock(true).SetPriority(PRIO).
|
zero.OnKeywordGroup([]string{"喜欢", "爱你", "爱", "suki", "daisuki", "すき", "好き", "贴贴", "老婆", "亲一个", "mua"}, atriSwitch(), atriSleep(), zero.OnlyToMe).SetBlock(true).SetPriority(prio).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if rand.Intn(10) == 0 {
|
if rand.Intn(10) == 0 {
|
||||||
ctx.SendChain(randImage("SUKI.jpg", "SUKI1.jpg", "SUKI2.png"))
|
ctx.SendChain(randImage("SUKI.jpg", "SUKI1.jpg", "SUKI2.png"))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
zero.OnKeywordGroup([]string{"草你妈", "操你妈", "脑瘫", "废柴", "fw", "five", "废物", "战斗", "爬", "爪巴", "sb", "SB", "傻B"}, AtriSwitch(), AtriSleep(), zero.OnlyToMe).SetBlock(true).SetPriority(PRIO - 1).
|
zero.OnKeywordGroup([]string{"草你妈", "操你妈", "脑瘫", "废柴", "fw", "five", "废物", "战斗", "爬", "爪巴", "sb", "SB", "傻B"}, atriSwitch(), atriSleep(), zero.OnlyToMe).SetBlock(true).SetPriority(prio - 1).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
ctx.SendChain(randImage("FN.jpg", "WQ.jpg", "WQ1.jpg"))
|
ctx.SendChain(randImage("FN.jpg", "WQ.jpg", "WQ1.jpg"))
|
||||||
})
|
})
|
||||||
zero.OnFullMatchGroup([]string{"早安", "早哇", "早上好", "ohayo", "哦哈哟", "お早う"}, AtriSwitch()).SetBlock(true).SetPriority(PRIO).
|
zero.OnFullMatchGroup([]string{"早安", "早哇", "早上好", "ohayo", "哦哈哟", "お早う"}, atriSwitch()).SetBlock(true).SetPriority(prio).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
now := time.Now().Hour()
|
now := time.Now().Hour()
|
||||||
switch {
|
switch {
|
||||||
@ -90,7 +92,7 @@ func init() { // 插件主体
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
zero.OnFullMatchGroup([]string{"中午好", "午安"}, AtriSwitch()).SetBlock(true).SetPriority(PRIO).
|
zero.OnFullMatchGroup([]string{"中午好", "午安"}, atriSwitch()).SetBlock(true).SetPriority(prio).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
now := time.Now().Hour()
|
now := time.Now().Hour()
|
||||||
if now > 11 && now < 15 { // 中午
|
if now > 11 && now < 15 { // 中午
|
||||||
@ -102,7 +104,7 @@ func init() { // 插件主体
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
zero.OnFullMatchGroup([]string{"晚安", "oyasuminasai", "おやすみなさい"}, AtriSwitch()).SetBlock(true).SetPriority(PRIO).
|
zero.OnFullMatchGroup([]string{"晚安", "oyasuminasai", "おやすみなさい"}, atriSwitch()).SetBlock(true).SetPriority(prio).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
now := time.Now().Hour()
|
now := time.Now().Hour()
|
||||||
switch {
|
switch {
|
||||||
@ -144,7 +146,7 @@ func init() { // 插件主体
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
zero.OnKeywordGroup([]string{"高性能", "太棒了", "すごい", "sugoi", "斯国一", "よかった"}, AtriSwitch(), AtriSleep(), zero.OnlyToMe).SetBlock(true).SetPriority(PRIO).
|
zero.OnKeywordGroup([]string{"高性能", "太棒了", "すごい", "sugoi", "斯国一", "よかった"}, atriSwitch(), atriSleep(), zero.OnlyToMe).SetBlock(true).SetPriority(prio).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
ctx.SendChain(randText(
|
ctx.SendChain(randText(
|
||||||
"当然,我是高性能的嘛~!",
|
"当然,我是高性能的嘛~!",
|
||||||
@ -164,7 +166,7 @@ func init() { // 插件主体
|
|||||||
"呣......我的高性能,毫无遗憾地施展出来了......",
|
"呣......我的高性能,毫无遗憾地施展出来了......",
|
||||||
))
|
))
|
||||||
})
|
})
|
||||||
zero.OnKeywordGroup([]string{"没事", "没关系", "大丈夫", "还好", "不要紧", "没出大问题", "没伤到哪"}, AtriSwitch(), AtriSleep(), zero.OnlyToMe).SetBlock(true).SetPriority(PRIO).
|
zero.OnKeywordGroup([]string{"没事", "没关系", "大丈夫", "还好", "不要紧", "没出大问题", "没伤到哪"}, atriSwitch(), atriSleep(), zero.OnlyToMe).SetBlock(true).SetPriority(prio).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
ctx.SendChain(randText(
|
ctx.SendChain(randText(
|
||||||
"当然,我是高性能的嘛~!",
|
"当然,我是高性能的嘛~!",
|
||||||
@ -178,23 +180,23 @@ func init() { // 插件主体
|
|||||||
))
|
))
|
||||||
})
|
})
|
||||||
|
|
||||||
zero.OnKeywordGroup([]string{"好吗", "是吗", "行不行", "能不能", "可不可以"}, AtriSwitch(), AtriSleep()).SetBlock(true).SetPriority(PRIO).
|
zero.OnKeywordGroup([]string{"好吗", "是吗", "行不行", "能不能", "可不可以"}, atriSwitch(), atriSleep()).SetBlock(true).SetPriority(prio).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if rand.Intn(2) == 0 {
|
if rand.Intn(2) == 0 {
|
||||||
ctx.SendChain(randImage("YES.png", "NO.jpg"))
|
ctx.SendChain(randImage("YES.png", "NO.jpg"))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
zero.OnFullMatchGroup([]string{"啊这"}, AtriSwitch(), AtriSleep()).SetBlock(true).SetPriority(PRIO).
|
zero.OnFullMatchGroup([]string{"啊这"}, atriSwitch(), atriSleep()).SetBlock(true).SetPriority(prio).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if rand.Intn(2) == 0 {
|
if rand.Intn(2) == 0 {
|
||||||
ctx.SendChain(randImage("AZ.jpg", "AZ1.jpg"))
|
ctx.SendChain(randImage("AZ.jpg", "AZ1.jpg"))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
zero.OnFullMatchGroup([]string{"我好了"}, AtriSwitch(), AtriSleep()).SetBlock(true).SetPriority(PRIO).
|
zero.OnFullMatchGroup([]string{"我好了"}, atriSwitch(), atriSleep()).SetBlock(true).SetPriority(prio).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
ctx.SendChain(randText("不许好!", "憋回去!"))
|
ctx.SendChain(randText("不许好!", "憋回去!"))
|
||||||
})
|
})
|
||||||
zero.OnFullMatchGroup([]string{"?", "?", "¿"}, AtriSwitch(), AtriSleep()).SetBlock(true).SetPriority(PRIO).
|
zero.OnFullMatchGroup([]string{"?", "?", "¿"}, atriSwitch(), atriSleep()).SetBlock(true).SetPriority(prio).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
switch rand.Intn(5) {
|
switch rand.Intn(5) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -203,7 +205,7 @@ func init() { // 插件主体
|
|||||||
ctx.SendChain(randImage("WH.jpg", "WH1.jpg", "WH2.jpg", "WH3.jpg"))
|
ctx.SendChain(randImage("WH.jpg", "WH1.jpg", "WH2.jpg", "WH3.jpg"))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
zero.OnKeyword("离谱", AtriSwitch(), AtriSleep()).SetBlock(true).SetPriority(PRIO).
|
zero.OnKeyword("离谱", atriSwitch(), atriSleep()).SetBlock(true).SetPriority(prio).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
switch rand.Intn(5) {
|
switch rand.Intn(5) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -212,7 +214,7 @@ func init() { // 插件主体
|
|||||||
ctx.SendChain(randImage("WH.jpg"))
|
ctx.SendChain(randImage("WH.jpg"))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
zero.OnKeyword("答应我", AtriSwitch(), AtriSleep(), zero.OnlyToMe).SetBlock(true).SetPriority(PRIO).
|
zero.OnKeyword("答应我", atriSwitch(), atriSleep(), zero.OnlyToMe).SetBlock(true).SetPriority(prio).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
ctx.SendChain(randText("我无法回应你的请求"))
|
ctx.SendChain(randText("我无法回应你的请求"))
|
||||||
})
|
})
|
||||||
@ -225,23 +227,23 @@ func randText(text ...string) message.MessageSegment {
|
|||||||
|
|
||||||
func randImage(file ...string) message.MessageSegment {
|
func randImage(file ...string) message.MessageSegment {
|
||||||
length := len(file)
|
length := len(file)
|
||||||
return message.Image(RES + file[rand.Intn(length)])
|
return message.Image(res + file[rand.Intn(length)])
|
||||||
}
|
}
|
||||||
|
|
||||||
func randRecord(file ...string) message.MessageSegment {
|
func randRecord(file ...string) message.MessageSegment {
|
||||||
length := len(file)
|
length := len(file)
|
||||||
return message.Record(RES + file[rand.Intn(length)])
|
return message.Record(res + file[rand.Intn(length)])
|
||||||
}
|
}
|
||||||
|
|
||||||
// AtriSwitch 控制 ATRI 的开关
|
// atriSwitch 控制 ATRI 的开关
|
||||||
func AtriSwitch() zero.Rule {
|
func atriSwitch() zero.Rule {
|
||||||
return func(ctx *zero.Ctx) bool {
|
return func(ctx *zero.Ctx) bool {
|
||||||
return ENABLE
|
return enable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// AtriSleep 凌晨0点到6点,ATRI 在睡觉,不回应任何请求
|
// atriSleep 凌晨0点到6点,ATRI 在睡觉,不回应任何请求
|
||||||
func AtriSleep() zero.Rule {
|
func atriSleep() zero.Rule {
|
||||||
return func(ctx *zero.Ctx) bool {
|
return func(ctx *zero.Ctx) bool {
|
||||||
if now := time.Now().Hour(); now >= 1 && now < 6 {
|
if now := time.Now().Hour(); now >= 1 && now < 6 {
|
||||||
return false
|
return false
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
package plugin_bilibili
|
package bilibili
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@ -25,12 +25,12 @@ type follower struct {
|
|||||||
func init() {
|
func init() {
|
||||||
zero.OnFullMatch("/开启粉丝日报", zero.AdminPermission).
|
zero.OnFullMatch("/开启粉丝日报", zero.AdminPermission).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
FansDaily(130591566) // 群号传进去给下面发信息的函数
|
fansDaily(130591566) // 群号传进去给下面发信息的函数
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 定时任务每天晚上最后2分钟执行一次
|
// 定时任务每天晚上最后2分钟执行一次
|
||||||
func FansDaily(groupID int64) {
|
func fansDaily(groupID int64) {
|
||||||
c := cron.New()
|
c := cron.New()
|
||||||
_ = c.AddFunc("0 58 23 * * ?", func() { fansData(groupID) })
|
_ = c.AddFunc("0 58 23 * * ?", func() { fansData(groupID) })
|
||||||
c.Start()
|
c.Start()
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
package plugin_bilibili
|
package bilibili
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/tidwall/gjson"
|
"github.com/tidwall/gjson"
|
||||||
zero "github.com/wdvxdr1123/ZeroBot"
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// 查成分的
|
// 查成分的
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
package plugin_bilibili
|
package bilibili
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
Package plugin_chat
|
Package chat
|
||||||
对话插件 example
|
对话插件 example
|
||||||
*/
|
*/
|
||||||
package plugin_chat
|
package chat
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
|||||||
64
plugin_diana/text.go
Normal file
64
plugin_diana/text.go
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
package diana
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
datapath = "data/Diana"
|
||||||
|
pbfile = datapath + "/text.pb"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
compo Composition
|
||||||
|
ARRAY []string
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
go func() {
|
||||||
|
time.Sleep(time.Second)
|
||||||
|
err := os.MkdirAll(datapath, 0755)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
loadText()
|
||||||
|
ARRAY = compo.Array
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
func loadText() {
|
||||||
|
if _, err := os.Stat(pbfile); err == nil || os.IsExist(err) {
|
||||||
|
f, err := os.Open(pbfile)
|
||||||
|
if err == nil {
|
||||||
|
data, err1 := io.ReadAll(f)
|
||||||
|
if err1 == nil {
|
||||||
|
if len(data) > 0 {
|
||||||
|
compo.Unmarshal(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func addText(txt string) error {
|
||||||
|
if txt != "" {
|
||||||
|
ARRAY = append(ARRAY, txt)
|
||||||
|
data, err := compo.Marshal()
|
||||||
|
if err == nil {
|
||||||
|
if _, err := os.Stat(datapath); err == nil || os.IsExist(err) {
|
||||||
|
f, err1 := os.OpenFile(pbfile, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644)
|
||||||
|
if err1 != nil {
|
||||||
|
return err1
|
||||||
|
} else {
|
||||||
|
defer f.Close()
|
||||||
|
_, err2 := f.Write(data)
|
||||||
|
return err2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
326
plugin_diana/text.pb.go
Normal file
326
plugin_diana/text.pb.go
Normal file
@ -0,0 +1,326 @@
|
|||||||
|
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||||
|
// source: text.proto
|
||||||
|
|
||||||
|
package diana
|
||||||
|
|
||||||
|
import (
|
||||||
|
fmt "fmt"
|
||||||
|
proto "github.com/golang/protobuf/proto"
|
||||||
|
io "io"
|
||||||
|
math "math"
|
||||||
|
math_bits "math/bits"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Reference imports to suppress errors if they are not otherwise used.
|
||||||
|
var _ = proto.Marshal
|
||||||
|
var _ = fmt.Errorf
|
||||||
|
var _ = math.Inf
|
||||||
|
|
||||||
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
|
// is compatible with the proto package it is being compiled against.
|
||||||
|
// A compilation error at this line likely means your copy of the
|
||||||
|
// proto package needs to be updated.
|
||||||
|
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||||
|
|
||||||
|
type Composition struct {
|
||||||
|
Array []string `protobuf:"bytes,1,rep,name=array,proto3" json:"array,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Composition) Reset() { *m = Composition{} }
|
||||||
|
func (m *Composition) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*Composition) ProtoMessage() {}
|
||||||
|
func (*Composition) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_a8e73d1ce47f9297, []int{0}
|
||||||
|
}
|
||||||
|
func (m *Composition) XXX_Unmarshal(b []byte) error {
|
||||||
|
return m.Unmarshal(b)
|
||||||
|
}
|
||||||
|
func (m *Composition) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
if deterministic {
|
||||||
|
return xxx_messageInfo_Composition.Marshal(b, m, deterministic)
|
||||||
|
} else {
|
||||||
|
b = b[:cap(b)]
|
||||||
|
n, err := m.MarshalToSizedBuffer(b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return b[:n], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (m *Composition) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_Composition.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *Composition) XXX_Size() int {
|
||||||
|
return m.Size()
|
||||||
|
}
|
||||||
|
func (m *Composition) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_Composition.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_Composition proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *Composition) GetArray() []string {
|
||||||
|
if m != nil {
|
||||||
|
return m.Array
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
proto.RegisterType((*Composition)(nil), "diana.composition")
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() { proto.RegisterFile("text.proto", fileDescriptor_a8e73d1ce47f9297) }
|
||||||
|
|
||||||
|
var fileDescriptor_a8e73d1ce47f9297 = []byte{
|
||||||
|
// 100 bytes of a gzipped FileDescriptorProto
|
||||||
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2a, 0x49, 0xad, 0x28,
|
||||||
|
0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x4d, 0xc9, 0x4c, 0xcc, 0x4b, 0x54, 0x52, 0xe6,
|
||||||
|
0xe2, 0x4e, 0xce, 0xcf, 0x2d, 0xc8, 0x2f, 0xce, 0x2c, 0xc9, 0xcc, 0xcf, 0x13, 0x12, 0xe1, 0x62,
|
||||||
|
0x4d, 0x2c, 0x2a, 0x4a, 0xac, 0x94, 0x60, 0x54, 0x60, 0xd6, 0xe0, 0x0c, 0x82, 0x70, 0x9c, 0x04,
|
||||||
|
0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x19, 0x8f, 0xe5,
|
||||||
|
0x18, 0x92, 0xd8, 0xc0, 0x86, 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x22, 0x35, 0x44, 0xcb,
|
||||||
|
0x52, 0x00, 0x00, 0x00,
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Composition) Marshal() (dAtA []byte, err error) {
|
||||||
|
size := m.Size()
|
||||||
|
dAtA = make([]byte, size)
|
||||||
|
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return dAtA[:n], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Composition) MarshalTo(dAtA []byte) (int, error) {
|
||||||
|
size := m.Size()
|
||||||
|
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Composition) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||||
|
i := len(dAtA)
|
||||||
|
_ = i
|
||||||
|
var l int
|
||||||
|
_ = l
|
||||||
|
if m.XXX_unrecognized != nil {
|
||||||
|
i -= len(m.XXX_unrecognized)
|
||||||
|
copy(dAtA[i:], m.XXX_unrecognized)
|
||||||
|
}
|
||||||
|
if len(m.Array) > 0 {
|
||||||
|
for iNdEx := len(m.Array) - 1; iNdEx >= 0; iNdEx-- {
|
||||||
|
i -= len(m.Array[iNdEx])
|
||||||
|
copy(dAtA[i:], m.Array[iNdEx])
|
||||||
|
i = encodeVarintText(dAtA, i, uint64(len(m.Array[iNdEx])))
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0xa
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return len(dAtA) - i, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func encodeVarintText(dAtA []byte, offset int, v uint64) int {
|
||||||
|
offset -= sovText(v)
|
||||||
|
base := offset
|
||||||
|
for v >= 1<<7 {
|
||||||
|
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||||
|
v >>= 7
|
||||||
|
offset++
|
||||||
|
}
|
||||||
|
dAtA[offset] = uint8(v)
|
||||||
|
return base
|
||||||
|
}
|
||||||
|
func (m *Composition) Size() (n int) {
|
||||||
|
if m == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
var l int
|
||||||
|
_ = l
|
||||||
|
if len(m.Array) > 0 {
|
||||||
|
for _, s := range m.Array {
|
||||||
|
l = len(s)
|
||||||
|
n += 1 + l + sovText(uint64(l))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if m.XXX_unrecognized != nil {
|
||||||
|
n += len(m.XXX_unrecognized)
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
|
func sovText(x uint64) (n int) {
|
||||||
|
return (math_bits.Len64(x|1) + 6) / 7
|
||||||
|
}
|
||||||
|
func sozText(x uint64) (n int) {
|
||||||
|
return sovText(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||||
|
}
|
||||||
|
func (m *Composition) Unmarshal(dAtA []byte) error {
|
||||||
|
l := len(dAtA)
|
||||||
|
iNdEx := 0
|
||||||
|
for iNdEx < l {
|
||||||
|
preIndex := iNdEx
|
||||||
|
var wire uint64
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowText
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
wire |= uint64(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fieldNum := int32(wire >> 3)
|
||||||
|
wireType := int(wire & 0x7)
|
||||||
|
if wireType == 4 {
|
||||||
|
return fmt.Errorf("proto: composition: wiretype end group for non-group")
|
||||||
|
}
|
||||||
|
if fieldNum <= 0 {
|
||||||
|
return fmt.Errorf("proto: composition: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||||
|
}
|
||||||
|
switch fieldNum {
|
||||||
|
case 1:
|
||||||
|
if wireType != 2 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field Array", wireType)
|
||||||
|
}
|
||||||
|
var stringLen uint64
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowText
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
stringLen |= uint64(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
intStringLen := int(stringLen)
|
||||||
|
if intStringLen < 0 {
|
||||||
|
return ErrInvalidLengthText
|
||||||
|
}
|
||||||
|
postIndex := iNdEx + intStringLen
|
||||||
|
if postIndex < 0 {
|
||||||
|
return ErrInvalidLengthText
|
||||||
|
}
|
||||||
|
if postIndex > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m.Array = append(m.Array, string(dAtA[iNdEx:postIndex]))
|
||||||
|
iNdEx = postIndex
|
||||||
|
default:
|
||||||
|
iNdEx = preIndex
|
||||||
|
skippy, err := skipText(dAtA[iNdEx:])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||||
|
return ErrInvalidLengthText
|
||||||
|
}
|
||||||
|
if (iNdEx + skippy) > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
|
||||||
|
iNdEx += skippy
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if iNdEx > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func skipText(dAtA []byte) (n int, err error) {
|
||||||
|
l := len(dAtA)
|
||||||
|
iNdEx := 0
|
||||||
|
depth := 0
|
||||||
|
for iNdEx < l {
|
||||||
|
var wire uint64
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return 0, ErrIntOverflowText
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return 0, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
wire |= (uint64(b) & 0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wireType := int(wire & 0x7)
|
||||||
|
switch wireType {
|
||||||
|
case 0:
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return 0, ErrIntOverflowText
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return 0, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
iNdEx++
|
||||||
|
if dAtA[iNdEx-1] < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
iNdEx += 8
|
||||||
|
case 2:
|
||||||
|
var length int
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return 0, ErrIntOverflowText
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return 0, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
length |= (int(b) & 0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if length < 0 {
|
||||||
|
return 0, ErrInvalidLengthText
|
||||||
|
}
|
||||||
|
iNdEx += length
|
||||||
|
case 3:
|
||||||
|
depth++
|
||||||
|
case 4:
|
||||||
|
if depth == 0 {
|
||||||
|
return 0, ErrUnexpectedEndOfGroupText
|
||||||
|
}
|
||||||
|
depth--
|
||||||
|
case 5:
|
||||||
|
iNdEx += 4
|
||||||
|
default:
|
||||||
|
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
||||||
|
}
|
||||||
|
if iNdEx < 0 {
|
||||||
|
return 0, ErrInvalidLengthText
|
||||||
|
}
|
||||||
|
if depth == 0 {
|
||||||
|
return iNdEx, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0, io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
ErrInvalidLengthText = fmt.Errorf("proto: negative length found during unmarshaling")
|
||||||
|
ErrIntOverflowText = fmt.Errorf("proto: integer overflow")
|
||||||
|
ErrUnexpectedEndOfGroupText = fmt.Errorf("proto: unexpected end of group")
|
||||||
|
)
|
||||||
6
plugin_diana/text.proto
Normal file
6
plugin_diana/text.proto
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
package diana;
|
||||||
|
|
||||||
|
message composition {
|
||||||
|
repeated string array = 1;
|
||||||
|
}
|
||||||
@ -1,16 +1,18 @@
|
|||||||
package plugin_diana
|
package diana
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
|
||||||
"math"
|
"math"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
zero "github.com/wdvxdr1123/ZeroBot"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
)
|
)
|
||||||
|
|
||||||
type zhiwang struct {
|
type zhiwang struct {
|
||||||
@ -26,7 +28,7 @@ type zhiwang struct {
|
|||||||
|
|
||||||
// 小作文查重: 回复要查的消息 查重
|
// 小作文查重: 回复要查的消息 查重
|
||||||
func init() {
|
func init() {
|
||||||
zero.OnMessage(FullMatchText("查重")).
|
zero.OnMessage(fullMatchText("查重")).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
msg := ctx.Event.Message
|
msg := ctx.Event.Message
|
||||||
if msg[0].Type == "reply" {
|
if msg[0].Type == "reply" {
|
||||||
@ -88,7 +90,7 @@ func zhiwangapi(Text string) *zhiwang {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func FullMatchText(src ...string) zero.Rule {
|
func fullMatchText(src ...string) zero.Rule {
|
||||||
return func(ctx *zero.Ctx) bool {
|
return func(ctx *zero.Ctx) bool {
|
||||||
msg := ctx.Event.Message
|
msg := ctx.Event.Message
|
||||||
for _, elem := range msg {
|
for _, elem := range msg {
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
|
Plugin github
|
||||||
GitHub 仓库搜索
|
GitHub 仓库搜索
|
||||||
*/
|
*/
|
||||||
package plugin_github
|
package github
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
package plugin_image_finder
|
package imagefinder
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@ -11,7 +11,7 @@ import (
|
|||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AutoGenerated struct {
|
type resultjson struct {
|
||||||
Illusts []struct {
|
Illusts []struct {
|
||||||
ID int `json:"id"`
|
ID int `json:"id"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
@ -63,7 +63,7 @@ func init() {
|
|||||||
keyword := ctx.State["regex_matched"].([]string)[1]
|
keyword := ctx.State["regex_matched"].([]string)[1]
|
||||||
soutujson := soutuapi(keyword)
|
soutujson := soutuapi(keyword)
|
||||||
pom1 := "https://i.pixiv.cat"
|
pom1 := "https://i.pixiv.cat"
|
||||||
rannum := Suiji()
|
rannum := rand_int()
|
||||||
pom2 := soutujson.Illusts[rannum].ImageUrls.Large[19:]
|
pom2 := soutujson.Illusts[rannum].ImageUrls.Large[19:]
|
||||||
ctx.SendChain(message.Image(pom1 + pom2))
|
ctx.SendChain(message.Image(pom1 + pom2))
|
||||||
})
|
})
|
||||||
@ -71,7 +71,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// soutuapi 请求api
|
// soutuapi 请求api
|
||||||
func soutuapi(keyword string) *AutoGenerated {
|
func soutuapi(keyword string) *resultjson {
|
||||||
|
|
||||||
url := "https://api.pixivel.moe/pixiv?type=search&page=0&mode=partial_match_for_tags&word=" + keyword
|
url := "https://api.pixivel.moe/pixiv?type=search&page=0&mode=partial_match_for_tags&word=" + keyword
|
||||||
method := "GET"
|
method := "GET"
|
||||||
@ -90,15 +90,15 @@ func soutuapi(keyword string) *AutoGenerated {
|
|||||||
}
|
}
|
||||||
defer res.Body.Close()
|
defer res.Body.Close()
|
||||||
|
|
||||||
result := &AutoGenerated{}
|
result := &resultjson{}
|
||||||
if err := json.NewDecoder(res.Body).Decode(result); err != nil {
|
if err := json.NewDecoder(res.Body).Decode(result); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
// Suiji 从json里的30条数据中随机获取一条返回
|
// rand_int 从json里的30条数据中随机获取一条返回
|
||||||
func Suiji() int {
|
func rand_int() int {
|
||||||
rand.Seed(time.Now().UnixNano())
|
rand.Seed(time.Now().UnixNano())
|
||||||
return rand.Intn(30)
|
return rand.Intn(30)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
|
Package lolicon
|
||||||
基于 https://api.lolicon.app 随机图片
|
基于 https://api.lolicon.app 随机图片
|
||||||
*/
|
*/
|
||||||
package plugin_lolicon
|
package lolicon
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -14,20 +15,20 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
API = "https://api.lolicon.app/setu/v2"
|
api = "https://api.lolicon.app/setu/v2"
|
||||||
CAP = 10
|
capacity = 10
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
QUEUE = make(chan string, CAP)
|
queue = make(chan string, capacity)
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
zero.OnFullMatch("来份萝莉").
|
zero.OnFullMatch("来份萝莉").
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
go func() {
|
go func() {
|
||||||
for i := 0; i < min(cap(QUEUE)-len(QUEUE), 2); i++ {
|
for i := 0; i < min(cap(queue)-len(queue), 2); i++ {
|
||||||
resp, err := http.Get(API)
|
resp, err := http.Get(api)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.SendChain(message.Text("ERROR: ", err))
|
ctx.SendChain(message.Text("ERROR: ", err))
|
||||||
continue
|
continue
|
||||||
@ -45,13 +46,13 @@ func init() {
|
|||||||
}
|
}
|
||||||
url := json.Get("data.0.urls.original").Str
|
url := json.Get("data.0.urls.original").Str
|
||||||
ctx.SendGroupMessage(0, message.Image(url))
|
ctx.SendGroupMessage(0, message.Image(url))
|
||||||
QUEUE <- url
|
queue <- url
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
select {
|
select {
|
||||||
case <-time.After(time.Second * 10):
|
case <-time.After(time.Second * 10):
|
||||||
ctx.SendChain(message.Text("ERROR: 等待填充,请稍后再试......"))
|
ctx.SendChain(message.Text("ERROR: 等待填充,请稍后再试......"))
|
||||||
case url := <-QUEUE:
|
case url := <-queue:
|
||||||
ctx.SendChain(message.Image(url))
|
ctx.SendChain(message.Image(url))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
package plugin_manager
|
package manager
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|||||||
@ -1,12 +1,13 @@
|
|||||||
package plugin_minecraft
|
package minecraft
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
zero "github.com/wdvxdr1123/ZeroBot"
|
|
||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
)
|
)
|
||||||
|
|
||||||
type resultjson struct {
|
type resultjson struct {
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
package plugin_minecraft
|
package minecraft
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
zero "github.com/wdvxdr1123/ZeroBot"
|
|
||||||
"github.com/wdvxdr1123/ZeroBot/message"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
|
"github.com/wdvxdr1123/ZeroBot/message"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 此功能实现依赖MCSManager项目对服务器的管理api,mc服务器如果没有在该管理平台部署此功能无效
|
// 此功能实现依赖MCSManager项目对服务器的管理api,mc服务器如果没有在该管理平台部署此功能无效
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
|
Package music
|
||||||
QQ音乐、网易云、酷狗、酷我 点歌
|
QQ音乐、网易云、酷狗、酷我 点歌
|
||||||
*/
|
*/
|
||||||
package plugin_music
|
package music
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
|
Package runcode
|
||||||
基于 https://tool.runoob.com 的在线运行代码
|
基于 https://tool.runoob.com 的在线运行代码
|
||||||
*/
|
*/
|
||||||
package plugin_runcode
|
package runcode
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
|
Package saucenao
|
||||||
- 根据 P站 ID 搜图
|
- 根据 P站 ID 搜图
|
||||||
- 基于 saucenao 和 ascii2d 搜图
|
- 基于 saucenao 和 ascii2d 搜图
|
||||||
*/
|
*/
|
||||||
package plugin_saucenao
|
package saucenao
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
package plugin_setutime
|
package setutime
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -16,9 +16,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Pools 图片缓冲池
|
// Pools 图片缓冲池
|
||||||
type Pool struct {
|
type imgpool struct {
|
||||||
Lock sync.Mutex
|
Lock sync.Mutex
|
||||||
DB *Sqlite
|
DB *sqlite
|
||||||
Path string
|
Path string
|
||||||
Group int64
|
Group int64
|
||||||
List []string
|
List []string
|
||||||
@ -28,9 +28,9 @@ type Pool struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewPoolsCache 返回一个缓冲池对象
|
// NewPoolsCache 返回一个缓冲池对象
|
||||||
func NewPools() *Pool {
|
func newPools() *imgpool {
|
||||||
cache := &Pool{
|
cache := &imgpool{
|
||||||
DB: &Sqlite{DBPath: "data/SetuTime/SetuTime.db"},
|
DB: &sqlite{DBPath: "data/SetuTime/SetuTime.db"},
|
||||||
Path: "data/SetuTime/cache/",
|
Path: "data/SetuTime/cache/",
|
||||||
Group: 0,
|
Group: 0,
|
||||||
List: []string{"涩图", "二次元", "风景", "车万"}, // 可以自己加类别,得自己加图片进数据库
|
List: []string{"涩图", "二次元", "风景", "车万"}, // 可以自己加类别,得自己加图片进数据库
|
||||||
@ -43,7 +43,7 @@ func NewPools() *Pool {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
for i := range cache.List {
|
for i := range cache.List {
|
||||||
if err := cache.DB.Create(cache.List[i], &pixiv.Illust{}); err != nil {
|
if err := cache.DB.create(cache.List[i], &pixiv.Illust{}); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -51,12 +51,12 @@ func NewPools() *Pool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
POOL = NewPools()
|
pool = newPools()
|
||||||
limit = rate.NewManager(time.Minute*1, 5)
|
limit = rate.NewManager(time.Minute*1, 5)
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() { // 插件主体
|
func init() { // 插件主体
|
||||||
zero.OnRegex(`^来份(.*)$`, firstValueInList(POOL.List)).SetBlock(true).SetPriority(20).
|
zero.OnRegex(`^来份(.*)$`, firstValueInList(pool.List)).SetBlock(true).SetPriority(20).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if !limit.Load(ctx.Event.UserID).Acquire() {
|
if !limit.Load(ctx.Event.UserID).Acquire() {
|
||||||
ctx.SendChain(message.Text("请稍后重试0x0..."))
|
ctx.SendChain(message.Text("请稍后重试0x0..."))
|
||||||
@ -65,43 +65,43 @@ func init() { // 插件主体
|
|||||||
var type_ = ctx.State["regex_matched"].([]string)[1]
|
var type_ = ctx.State["regex_matched"].([]string)[1]
|
||||||
// 补充池子
|
// 补充池子
|
||||||
go func() {
|
go func() {
|
||||||
times := min(POOL.Max-POOL.Size(type_), 2)
|
times := min(pool.Max-pool.size(type_), 2)
|
||||||
for i := 0; i < times; i++ {
|
for i := 0; i < times; i++ {
|
||||||
illust := &pixiv.Illust{}
|
illust := &pixiv.Illust{}
|
||||||
// 查询出一张图片
|
// 查询出一张图片
|
||||||
if err := POOL.DB.Select(type_, illust, "ORDER BY RANDOM() limit 1"); err != nil {
|
if err := pool.DB.find(type_, illust, "ORDER BY RANDOM() limit 1"); err != nil {
|
||||||
ctx.SendChain(message.Text("ERROR: ", err))
|
ctx.SendChain(message.Text("ERROR: ", err))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// 下载图片
|
// 下载图片
|
||||||
if _, err := download(illust, POOL.Path); err != nil {
|
if _, err := download(illust, pool.Path); err != nil {
|
||||||
ctx.SendChain(message.Text("ERROR: ", err))
|
ctx.SendChain(message.Text("ERROR: ", err))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
ctx.SendGroupMessage(POOL.Group, []message.MessageSegment{message.Image(file(illust))})
|
ctx.SendGroupMessage(pool.Group, []message.MessageSegment{message.Image(file(illust))})
|
||||||
// 向缓冲池添加一张图片
|
// 向缓冲池添加一张图片
|
||||||
POOL.Push(type_, illust)
|
pool.push(type_, illust)
|
||||||
|
|
||||||
time.Sleep(time.Second * 1)
|
time.Sleep(time.Second * 1)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
// 如果没有缓存,阻塞5秒
|
// 如果没有缓存,阻塞5秒
|
||||||
if POOL.Size(type_) == 0 {
|
if pool.size(type_) == 0 {
|
||||||
ctx.SendChain(message.Text("INFO: 正在填充弹药......"))
|
ctx.SendChain(message.Text("INFO: 正在填充弹药......"))
|
||||||
<-time.After(time.Second * 5)
|
<-time.After(time.Second * 5)
|
||||||
if POOL.Size(type_) == 0 {
|
if pool.size(type_) == 0 {
|
||||||
ctx.SendChain(message.Text("ERROR: 等待填充,请稍后再试......"))
|
ctx.SendChain(message.Text("ERROR: 等待填充,请稍后再试......"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 从缓冲池里抽一张
|
// 从缓冲池里抽一张
|
||||||
if id := ctx.SendChain(message.Image(file(POOL.Pop(type_)))); id == 0 {
|
if id := ctx.SendChain(message.Image(file(pool.pop(type_)))); id == 0 {
|
||||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
|
|
||||||
zero.OnRegex(`^添加(.*?)(\d+)$`, firstValueInList(POOL.List), zero.SuperUserPermission).SetBlock(true).SetPriority(21).
|
zero.OnRegex(`^添加(.*?)(\d+)$`, firstValueInList(pool.List), zero.SuperUserPermission).SetBlock(true).SetPriority(21).
|
||||||
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]
|
||||||
@ -115,7 +115,7 @@ func init() { // 插件主体
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 下载插画
|
// 下载插画
|
||||||
if _, err := download(illust, POOL.Path); err != nil {
|
if _, err := download(illust, pool.Path); err != nil {
|
||||||
ctx.SendChain(message.Text("ERROR: ", err))
|
ctx.SendChain(message.Text("ERROR: ", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ func init() { // 插件主体
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 添加插画到对应的数据库table
|
// 添加插画到对应的数据库table
|
||||||
if err := POOL.DB.Insert(type_, illust); err != nil {
|
if err := pool.DB.insert(type_, illust); err != nil {
|
||||||
ctx.SendChain(message.Text("ERROR: ", err))
|
ctx.SendChain(message.Text("ERROR: ", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -133,14 +133,14 @@ func init() { // 插件主体
|
|||||||
return
|
return
|
||||||
})
|
})
|
||||||
|
|
||||||
zero.OnRegex(`^删除(.*?)(\d+)$`, firstValueInList(POOL.List), zero.SuperUserPermission).SetBlock(true).SetPriority(22).
|
zero.OnRegex(`^删除(.*?)(\d+)$`, firstValueInList(pool.List), zero.SuperUserPermission).SetBlock(true).SetPriority(22).
|
||||||
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, _ = strconv.ParseInt(ctx.State["regex_matched"].([]string)[2], 10, 64)
|
id, _ = strconv.ParseInt(ctx.State["regex_matched"].([]string)[2], 10, 64)
|
||||||
)
|
)
|
||||||
// 查询数据库
|
// 查询数据库
|
||||||
if err := POOL.DB.Delete(type_, fmt.Sprintf("WHERE pid=%d", id)); err != nil {
|
if err := pool.DB.del(type_, fmt.Sprintf("WHERE pid=%d", id)); err != nil {
|
||||||
ctx.Send(fmt.Sprintf("ERROR: %v", err))
|
ctx.Send(fmt.Sprintf("ERROR: %v", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -152,13 +152,13 @@ func init() { // 插件主体
|
|||||||
zero.OnFullMatchGroup([]string{">setu status"}).SetBlock(true).SetPriority(23).
|
zero.OnFullMatchGroup([]string{">setu status"}).SetBlock(true).SetPriority(23).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
state := []string{"[SetuTime]"}
|
state := []string{"[SetuTime]"}
|
||||||
for i := range POOL.List {
|
for i := range pool.List {
|
||||||
num, err := POOL.DB.Num(POOL.List[i])
|
num, err := pool.DB.num(pool.List[i])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
num = 0
|
num = 0
|
||||||
}
|
}
|
||||||
state = append(state, "\n")
|
state = append(state, "\n")
|
||||||
state = append(state, POOL.List[i])
|
state = append(state, pool.List[i])
|
||||||
state = append(state, ": ")
|
state = append(state, ": ")
|
||||||
state = append(state, fmt.Sprintf("%d", num))
|
state = append(state, fmt.Sprintf("%d", num))
|
||||||
}
|
}
|
||||||
@ -192,28 +192,28 @@ func min(a, b int) int {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Size 返回缓冲池指定类型的现有大小
|
// size 返回缓冲池指定类型的现有大小
|
||||||
func (p *Pool) Size(type_ string) int {
|
func (p *imgpool) size(type_ string) int {
|
||||||
return len(p.Pool[type_])
|
return len(p.Pool[type_])
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsFull 返回缓冲池指定类型是否已满
|
// isFull 返回缓冲池指定类型是否已满
|
||||||
func (p *Pool) IsFull(type_ string) bool {
|
func (p *imgpool) isFull(type_ string) bool {
|
||||||
return len(p.Pool[type_]) >= p.Max
|
return len(p.Pool[type_]) >= p.Max
|
||||||
}
|
}
|
||||||
|
|
||||||
// Push 向缓冲池插入一张图片
|
// push 向缓冲池插入一张图片
|
||||||
func (p *Pool) Push(type_ string, illust *pixiv.Illust) {
|
func (p *imgpool) push(type_ string, illust *pixiv.Illust) {
|
||||||
p.Lock.Lock()
|
p.Lock.Lock()
|
||||||
defer p.Lock.Unlock()
|
defer p.Lock.Unlock()
|
||||||
p.Pool[type_] = append(p.Pool[type_], illust)
|
p.Pool[type_] = append(p.Pool[type_], illust)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Push 在缓冲池拿出一张图片
|
// Push 在缓冲池拿出一张图片
|
||||||
func (p *Pool) Pop(type_ string) (illust *pixiv.Illust) {
|
func (p *imgpool) pop(type_ string) (illust *pixiv.Illust) {
|
||||||
p.Lock.Lock()
|
p.Lock.Lock()
|
||||||
defer p.Lock.Unlock()
|
defer p.Lock.Unlock()
|
||||||
if p.Size(type_) == 0 {
|
if p.size(type_) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
illust = p.Pool[type_][0]
|
illust = p.Pool[type_][0]
|
||||||
@ -224,7 +224,7 @@ func (p *Pool) Pop(type_ string) (illust *pixiv.Illust) {
|
|||||||
func file(i *pixiv.Illust) string {
|
func file(i *pixiv.Illust) string {
|
||||||
filename := fmt.Sprint(i.Pid)
|
filename := fmt.Sprint(i.Pid)
|
||||||
pwd, _ := os.Getwd()
|
pwd, _ := os.Getwd()
|
||||||
filepath := pwd + `/` + POOL.Path + filename
|
filepath := pwd + `/` + pool.Path + filename
|
||||||
if _, err := os.Stat(filepath + ".jpg"); err == nil || os.IsExist(err) {
|
if _, err := os.Stat(filepath + ".jpg"); err == nil || os.IsExist(err) {
|
||||||
return `file:///` + filepath + ".jpg"
|
return `file:///` + filepath + ".jpg"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
package plugin_setutime
|
package setutime
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
@ -8,16 +8,16 @@ import (
|
|||||||
_ "modernc.org/sqlite"
|
_ "modernc.org/sqlite"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Sqlite 数据库对象
|
// sqlite 数据库对象
|
||||||
type Sqlite struct {
|
type sqlite struct {
|
||||||
DB *sql.DB
|
DB *sql.DB
|
||||||
DBPath string
|
DBPath string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create 生成数据库
|
// create 生成数据库
|
||||||
// 默认结构体的第一个元素为主键
|
// 默认结构体的第一个元素为主键
|
||||||
// 返回错误
|
// 返回错误
|
||||||
func (db *Sqlite) Create(table string, objptr interface{}) (err error) {
|
func (db *sqlite) create(table string, objptr interface{}) (err error) {
|
||||||
if db.DB == nil {
|
if db.DB == nil {
|
||||||
database, err := sql.Open("sqlite", db.DBPath)
|
database, err := sql.Open("sqlite", db.DBPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -53,10 +53,10 @@ func (db *Sqlite) Create(table string, objptr interface{}) (err error) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert 插入数据集
|
// insert 插入数据集
|
||||||
// 默认结构体的第一个元素为主键
|
// 默认结构体的第一个元素为主键
|
||||||
// 返回错误
|
// 返回错误
|
||||||
func (db *Sqlite) Insert(table string, objptr interface{}) (err error) {
|
func (db *sqlite) insert(table string, objptr interface{}) (err error) {
|
||||||
rows, err := db.DB.Query("SELECT * FROM " + table)
|
rows, err := db.DB.Query("SELECT * FROM " + table)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -109,11 +109,11 @@ func (db *Sqlite) Insert(table string, objptr interface{}) (err error) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select 查询数据库
|
// find 查询数据库
|
||||||
// condition 可为"WHERE id = 0"
|
// condition 可为"WHERE id = 0"
|
||||||
// 默认字段与结构体元素顺序一致
|
// 默认字段与结构体元素顺序一致
|
||||||
// 返回错误
|
// 返回错误
|
||||||
func (db *Sqlite) Select(table string, objptr interface{}, condition string) (err error) {
|
func (db *sqlite) find(table string, objptr interface{}, condition string) (err error) {
|
||||||
var cmd = []string{}
|
var cmd = []string{}
|
||||||
cmd = append(cmd, "SELECT * FROM ")
|
cmd = append(cmd, "SELECT * FROM ")
|
||||||
cmd = append(cmd, table)
|
cmd = append(cmd, table)
|
||||||
@ -136,10 +136,10 @@ func (db *Sqlite) Select(table string, objptr interface{}, condition string) (er
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete 删除数据库
|
// del 删除数据库
|
||||||
// condition 可为"WHERE id = 0"
|
// condition 可为"WHERE id = 0"
|
||||||
// 返回错误
|
// 返回错误
|
||||||
func (db *Sqlite) Delete(table string, condition string) (err error) {
|
func (db *sqlite) del(table string, condition string) (err error) {
|
||||||
var cmd = []string{}
|
var cmd = []string{}
|
||||||
cmd = append(cmd, "DELETE FROM")
|
cmd = append(cmd, "DELETE FROM")
|
||||||
cmd = append(cmd, table)
|
cmd = append(cmd, table)
|
||||||
@ -155,9 +155,9 @@ func (db *Sqlite) Delete(table string, condition string) (err error) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Num 查询数据库行数
|
// num 查询数据库行数
|
||||||
// 返回行数以及错误
|
// 返回行数以及错误
|
||||||
func (db *Sqlite) Num(table string) (num int, err error) {
|
func (db *sqlite) num(table string) (num int, err error) {
|
||||||
var cmd = []string{}
|
var cmd = []string{}
|
||||||
cmd = append(cmd, "SELECT * FROM")
|
cmd = append(cmd, "SELECT * FROM")
|
||||||
cmd = append(cmd, table)
|
cmd = append(cmd, table)
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
|
Package shindan
|
||||||
基于 https://shindanmaker.com 的测定小功能
|
基于 https://shindanmaker.com 的测定小功能
|
||||||
*/
|
*/
|
||||||
package plugin_shindan
|
package shindan
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user