mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2026-02-08 16:10:25 +00:00
Compare commits
17 Commits
v1.3.3-bet
...
v1.3.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41c499840f | ||
|
|
f5cef170f0 | ||
|
|
d7922a7c9b | ||
|
|
23fc77e8e1 | ||
|
|
51f3eda09a | ||
|
|
6ec08a5227 | ||
|
|
4855f694cb | ||
|
|
eaef37a831 | ||
|
|
b182ff36bb | ||
|
|
c4e543449c | ||
|
|
c76d9d4461 | ||
|
|
dfd184724b | ||
|
|
fef254031e | ||
|
|
89c4e59bf1 | ||
|
|
2e9acd3276 | ||
|
|
5cab59c93f | ||
|
|
ebfb5878a1 |
10
README.md
10
README.md
@@ -11,7 +11,7 @@
|
||||
|
||||
[](https://goreportcard.com/report/github.com/github.com/FloatTech/ZeroBot-Plugin)
|
||||
[](https://github.com/howmanybots/onebot)
|
||||
[](https://github.com/wdvxdr1123/ZeroBot)
|
||||
[](https://github.com/wdvxdr1123/ZeroBot)
|
||||
[](https://raw.githubusercontent.com/FloatTech/ZeroBot-Plugin/master/LICENSE)
|
||||
[](https://jq.qq.com/?_wv=1027&k=QMb7x1mM)
|
||||
|
||||
@@ -187,7 +187,7 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
- [ ] 撤回[@xxx] [xxx]
|
||||
- [ ] 警告[@xxx]
|
||||
- 注:使用gist加群自动审批,请在群介绍添加以下说明,同时开启`需要回答问题并由管理员审核`:加群请在github新建一个gist,其文件名为本群群号的字符串的md5(小写),内容为一行,是当前unix时间戳(10分钟内有效)。然后请将您的用户名和gist哈希(小写)按照username/gisthash的格式填写到回答即可。
|
||||
- 设置欢迎语可选添加参数说明:{at}可在发送时艾特被欢迎者 {nickname}是被欢迎者名字 {avatar}是被欢迎者头像
|
||||
- 设置欢迎语可选添加参数说明:{at}可在发送时艾特被欢迎者 {nickname}是被欢迎者名字 {avatar}是被欢迎者头像 {uid}是被欢迎者QQ号 {gid}是当前群群号 {groupname} 是当前群群名
|
||||
- **GitHub仓库搜索** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/github"`
|
||||
- [x] >github [xxx]
|
||||
- [x] >github -p [xxx]
|
||||
@@ -405,6 +405,8 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
```
|
||||
- **舔狗日记** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/tiangou"`
|
||||
- [x] 舔狗日记
|
||||
- **聊天热词** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/word_count"`
|
||||
- [x] 热词 [群号] [消息数目]|热词 123456 1000
|
||||
- **TODO...**
|
||||
|
||||
## 使用方法
|
||||
@@ -469,7 +471,3 @@ GOOS=linux GOARCH=mips GOMIPS=softfloat CGO_ENABLED=0 go build -ldflags "-s -w"
|
||||
|
||||
- [ZeroBot](https://github.com/wdvxdr1123/ZeroBot)
|
||||
- [ATRI](https://github.com/Kyomotoi/ATRI)
|
||||
|
||||
## License
|
||||
|
||||
[](https://app.fossa.com/projects/git%2Bgithub.com%2FFloatTech%2FZeroBot-Plugin?ref=badge_large)
|
||||
|
||||
2
data
2
data
Submodule data updated: 7d6739a9b7...b3d25c45fd
18
go.mod
18
go.mod
@@ -3,15 +3,15 @@ module github.com/FloatTech/ZeroBot-Plugin
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/FloatTech/AnimeAPI v1.3.3-0.20220414074426-878b31943a9b
|
||||
github.com/FloatTech/AnimeAPI v1.3.3-0.20220417132103-df55797131af
|
||||
github.com/FloatTech/sqlite v0.2.1
|
||||
github.com/FloatTech/zbputils v1.3.3-0.20220414074216-3fe2fb332371
|
||||
github.com/FloatTech/zbputils v1.3.3-0.20220418145633-c1d3c00da628
|
||||
github.com/antchfx/htmlquery v1.2.4
|
||||
github.com/corona10/goimagehash v1.0.3
|
||||
github.com/fogleman/gg v1.3.0
|
||||
github.com/fumiama/cron v1.3.0
|
||||
github.com/fumiama/go-base16384 v1.4.0
|
||||
github.com/fumiama/go-registry v0.1.3
|
||||
github.com/fumiama/go-registry v0.1.5
|
||||
github.com/fumiama/gofastTEA v0.0.10
|
||||
github.com/fumiama/gotracemoe v0.0.3
|
||||
github.com/fumiama/sqlite3 v1.14.6
|
||||
@@ -19,12 +19,12 @@ require (
|
||||
github.com/jinzhu/gorm v1.9.16
|
||||
github.com/mroth/weightedrand v0.4.1
|
||||
github.com/pkumza/numcn v1.0.0
|
||||
github.com/shirou/gopsutil/v3 v3.22.2
|
||||
github.com/shirou/gopsutil/v3 v3.22.3
|
||||
github.com/sirupsen/logrus v1.8.1
|
||||
github.com/tidwall/gjson v1.14.0
|
||||
github.com/wcharczuk/go-chart/v2 v2.1.0
|
||||
github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220414063422-1ca81bc47496
|
||||
golang.org/x/image v0.0.0-20220321031419-a8550c1d254a
|
||||
github.com/wdvxdr1123/ZeroBot v1.5.0-mid.0.20220415071800-9e52436ab5c0
|
||||
golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9
|
||||
)
|
||||
|
||||
require (
|
||||
@@ -48,10 +48,10 @@ require (
|
||||
github.com/tklauser/go-sysconf v0.3.10 // indirect
|
||||
github.com/tklauser/numcpus v0.4.0 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.2 // indirect
|
||||
golang.org/x/net v0.0.0-20220325170049-de3da57026de // indirect
|
||||
golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f // indirect
|
||||
golang.org/x/net v0.0.0-20220412020605-290c469a71a5 // indirect
|
||||
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect
|
||||
golang.org/x/text v0.3.7 // indirect
|
||||
modernc.org/libc v1.14.12 // indirect
|
||||
modernc.org/libc v1.15.0 // indirect
|
||||
modernc.org/mathutil v1.4.1 // indirect
|
||||
modernc.org/memory v1.0.7 // indirect
|
||||
)
|
||||
|
||||
43
go.sum
43
go.sum
@@ -1,9 +1,9 @@
|
||||
github.com/FloatTech/AnimeAPI v1.3.3-0.20220414074426-878b31943a9b h1:9wvS99e1838XnQWmhW1Ya2OEbydpN5dvNGTpOF/XpXU=
|
||||
github.com/FloatTech/AnimeAPI v1.3.3-0.20220414074426-878b31943a9b/go.mod h1:MGVkR1LFoP6aTQCXlZKG0t9pGIdKESrXAc8SdU5ypHo=
|
||||
github.com/FloatTech/AnimeAPI v1.3.3-0.20220417132103-df55797131af h1:K7Cdrd1jgiTUe8hcITgmwJeIdwfCMM+phw8DD1tALXA=
|
||||
github.com/FloatTech/AnimeAPI v1.3.3-0.20220417132103-df55797131af/go.mod h1:jUOit4oeiKOtRDy5ZLTJQa7aE0972R/KPF15b22Q3vY=
|
||||
github.com/FloatTech/sqlite v0.2.1 h1:9t6Me48XJJCIoPy4nLRvcdhcVKfT0c2lilp7SEKROG8=
|
||||
github.com/FloatTech/sqlite v0.2.1/go.mod h1:6NfHRzqOo9RWeMJEoAQVuo51Omd5LFNxCNQhMF02/9U=
|
||||
github.com/FloatTech/zbputils v1.3.3-0.20220414074216-3fe2fb332371 h1:nb5UF/WXDX5ATh0OYFa1FUU1NMzIBpRhiEhxDMMeIXg=
|
||||
github.com/FloatTech/zbputils v1.3.3-0.20220414074216-3fe2fb332371/go.mod h1:J6+PC/yjgnMEKVbaIyYxSGxKPb9mGjLWeJLfdJZH8RU=
|
||||
github.com/FloatTech/zbputils v1.3.3-0.20220418145633-c1d3c00da628 h1:NC7m06uyenwt4TRyCEkK5lFNId3TB5gKEeOYNQpYTBI=
|
||||
github.com/FloatTech/zbputils v1.3.3-0.20220418145633-c1d3c00da628/go.mod h1:K2IVrhwmrVKZSHSHmNoO9JthN1As9RcnQplf+stQ5BY=
|
||||
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
|
||||
github.com/RomiChan/syncx v0.0.0-20220404072119-d7ea0ae15a4c h1:cNPOdTNiVwxLpROLjXCgbIPvdkE+BwvxDvgmdYmWx6Q=
|
||||
github.com/RomiChan/syncx v0.0.0-20220404072119-d7ea0ae15a4c/go.mod h1:KqZzu7slNKROh3TSYEH/IUMG6f4M+1qubZ5e52QypsE=
|
||||
@@ -34,8 +34,8 @@ github.com/fumiama/cron v1.3.0 h1:ZWlwuexF+HQHl3cYytEE5HNwD99q+3vNZF1GrEiXCFo=
|
||||
github.com/fumiama/cron v1.3.0/go.mod h1:bz5Izvgi/xEUI8tlBN8BI2jr9Moo8N4or0KV8xXuPDY=
|
||||
github.com/fumiama/go-base16384 v1.4.0 h1:4KrtewnmAChrZjPA7/QYc72t+vvsKF+DYB0q1iRPdpo=
|
||||
github.com/fumiama/go-base16384 v1.4.0/go.mod h1:OEn+947GV5gsbTAnyuUW/SrfxJYUdYupSIQXOuGOcXM=
|
||||
github.com/fumiama/go-registry v0.1.3 h1:WvUN2wdziB2+LyYs4zNy1FHGQOvZeto7lbADfSqbMPw=
|
||||
github.com/fumiama/go-registry v0.1.3/go.mod h1:iJT3DVgH7KXpJZs6waXEjnWtJPUBBGhF+ByJIMRfngk=
|
||||
github.com/fumiama/go-registry v0.1.5 h1:5a7n+JwwKQrnW3U0+gOKSx+2x4Zv+2A3BhyQthJL4Ng=
|
||||
github.com/fumiama/go-registry v0.1.5/go.mod h1:dIUVbiOgfk9oZcsgwDvNLC72i+ctibVukSXR/9bLviI=
|
||||
github.com/fumiama/gofastTEA v0.0.10 h1:JJJ+brWD4kie+mmK2TkspDXKzqq0IjXm89aGYfoGhhQ=
|
||||
github.com/fumiama/gofastTEA v0.0.10/go.mod h1:RIdbYZyB4MbH6ZBlPymRaXn3cD6SedlCu5W/HHfMPBk=
|
||||
github.com/fumiama/gotracemoe v0.0.3 h1:iI5EbE9A3UUbfukG6+/soYPjp1S31eCNYf4tw7s6/Jc=
|
||||
@@ -91,13 +91,12 @@ github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c h1:NRoLoZvkB
|
||||
github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||
github.com/shirou/gopsutil/v3 v3.22.2 h1:wCrArWFkHYIdDxx/FSfF5RB4dpJYW6t7rcp3+zL8uks=
|
||||
github.com/shirou/gopsutil/v3 v3.22.2/go.mod h1:WapW1AOOPlHyXr+yOyw3uYx36enocrtSoSBy0L5vUHY=
|
||||
github.com/shirou/gopsutil/v3 v3.22.3 h1:UebRzEomgMpv61e3hgD1tGooqX5trFbdU/ehphbHd00=
|
||||
github.com/shirou/gopsutil/v3 v3.22.3/go.mod h1:D01hZJ4pVHPpCTZ3m3T2+wDF2YAGfd+H4ifUguaQzHM=
|
||||
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
|
||||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/tidwall/gjson v1.14.0 h1:6aeJ0bzojgWLa82gDQHcx3S0Lr/O51I9bJ5nv6JFx5w=
|
||||
@@ -106,16 +105,14 @@ github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
||||
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
|
||||
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||
github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs=
|
||||
github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw=
|
||||
github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk=
|
||||
github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8=
|
||||
github.com/tklauser/numcpus v0.4.0 h1:E53Dm1HjH1/R2/aoCtXtPgzmElmn51aOkhCFSuZq//o=
|
||||
github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ=
|
||||
github.com/wcharczuk/go-chart/v2 v2.1.0 h1:tY2slqVQ6bN+yHSnDYwZebLQFkphK4WNrVwnt7CJZ2I=
|
||||
github.com/wcharczuk/go-chart/v2 v2.1.0/go.mod h1:yx7MvAVNcP/kN9lKXM/NTce4au4DFN99j6i1OwDclNA=
|
||||
github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220414063422-1ca81bc47496 h1:4ANuTo7sm2cjy6cnYEKjr2JnCsaeonVC+QSqDWI5RZo=
|
||||
github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220414063422-1ca81bc47496/go.mod h1:/DiS/UKTmGtOys9am9bA4i4/jOgXaoEHkjJRjuA/oZs=
|
||||
github.com/wdvxdr1123/ZeroBot v1.5.0-mid.0.20220415071800-9e52436ab5c0 h1:SoNu5MZZsbleecVCBth/s610wLXWKIr18KADhZURCDw=
|
||||
github.com/wdvxdr1123/ZeroBot v1.5.0-mid.0.20220415071800-9e52436ab5c0/go.mod h1:K2vu0mslV8s4qhIAu/a03Z7YW24qjM0j3imIR+k21KI=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg=
|
||||
github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
|
||||
@@ -124,11 +121,11 @@ golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACk
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20220321153916-2c7772ba3064 h1:S25/rfnfsMVgORT4/J61MJ7rdyseOZOyvLIrZEZ7s6s=
|
||||
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 h1:kUhD7nTDoI3fVd9G4ORWrbV5NY0liEs/Jg2pv5f+bBA=
|
||||
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.0.0-20200927104501-e162460cd6b5/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.0.0-20220321031419-a8550c1d254a h1:LnH9RNcpPv5Kzi15lXg42lYMPUf0x8CuPv1YnvBWZAg=
|
||||
golang.org/x/image v0.0.0-20220321031419-a8550c1d254a/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
|
||||
golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9 h1:LRtI4W37N+KFebI/qV0OFiLUv4GLOWeEW5hn/KEJvxE=
|
||||
golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
@@ -137,8 +134,8 @@ golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLL
|
||||
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/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-20220325170049-de3da57026de h1:pZB1TWnKi+o4bENlbzAgLrEbY4RMYmUIRobMcSmfeYc=
|
||||
golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/net v0.0.0-20220412020605-290c469a71a5 h1:bRb386wvrE+oBNdF1d/Xh9mQrfQ4ecYhW5qJ5GvTGT4=
|
||||
golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@@ -151,14 +148,13 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20201126233918-771906719818/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210902050250-f475640dd07b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220111092808-5a964db01320/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f h1:rlezHXNlxYWvBCzNses9Dlc7nGFaNMJeqLolcmQSSZY=
|
||||
golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad h1:ntjMns5wyP/fN65tdBD4g8J5w8n015+iIIs9rtjXkY0=
|
||||
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
@@ -193,6 +189,7 @@ modernc.org/cc/v3 v3.35.18/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g
|
||||
modernc.org/cc/v3 v3.35.20/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
||||
modernc.org/cc/v3 v3.35.22/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
||||
modernc.org/cc/v3 v3.35.24/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI=
|
||||
modernc.org/cc/v3 v3.35.25/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI=
|
||||
modernc.org/ccgo/v3 v3.9.5/go.mod h1:umuo2EP2oDSBnD3ckjaVUXMrmeAw8C8OSICVa0iFf60=
|
||||
modernc.org/ccgo/v3 v3.10.0/go.mod h1:c0yBmkRFi7uW4J7fwx/JiijwOjeAeR2NoSaRVFPmjMw=
|
||||
modernc.org/ccgo/v3 v3.11.0/go.mod h1:dGNposbDp9TOZ/1KBxghxtUp/bzErD0/0QW4hhSaBMI=
|
||||
@@ -238,6 +235,7 @@ modernc.org/ccgo/v3 v3.15.14/go.mod h1:144Sz2iBCKogb9OKwsu7hQEub3EVgOlyI8wMUPGKU
|
||||
modernc.org/ccgo/v3 v3.15.15/go.mod h1:z5qltXjU4PJl0pE5nhYQCvA9DhPHiWsl5GWl89+NSYE=
|
||||
modernc.org/ccgo/v3 v3.15.16/go.mod h1:XbKRMeMWMdq712Tr5ECgATYMrzJ+g9zAZEj2ktzBe24=
|
||||
modernc.org/ccgo/v3 v3.15.17/go.mod h1:bofnFkpRFf5gLY+mBZIyTW6FEcp26xi2lgOFk2Rlvs0=
|
||||
modernc.org/ccgo/v3 v3.15.19/go.mod h1:TDJj+DxR26pkDteH2E5WQDj/xlmtsX7JdzkJkaZhOVU=
|
||||
modernc.org/ccorpus v1.11.1/go.mod h1:2gEUTrWqdpH2pXsmTM1ZkjeSrUWDpjMu2T6m29L/ErQ=
|
||||
modernc.org/ccorpus v1.11.6/go.mod h1:2gEUTrWqdpH2pXsmTM1ZkjeSrUWDpjMu2T6m29L/ErQ=
|
||||
modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM=
|
||||
@@ -287,8 +285,9 @@ modernc.org/libc v1.14.6/go.mod h1:2PJHINagVxO4QW/5OQdRrvMYo+bm5ClpUFfyXCYl9ak=
|
||||
modernc.org/libc v1.14.7/go.mod h1:f8xfWXW8LW41qb4X5+huVQo5dcfPlq7Cbny2TDheMv0=
|
||||
modernc.org/libc v1.14.8/go.mod h1:9+JCLb1MWSY23smyOpIPbd5ED+rSS/ieiDWUpdyO3mo=
|
||||
modernc.org/libc v1.14.10/go.mod h1:y1MtIWhwpJFpLYm6grAThtuXJKEsY6xkdZmXbRngIdo=
|
||||
modernc.org/libc v1.14.12 h1:pUBZTYoISfbb4pCf4PECENpbvwDBxeKc+/dS9LyOWFM=
|
||||
modernc.org/libc v1.14.12/go.mod h1:fJdoe23MHu2ruPQkFPPqCpToDi5cckzsbmkI6Ez0LqQ=
|
||||
modernc.org/libc v1.15.0 h1:/CTHjQ1QO5mkLDeQICuA9Vh0YvhQTMqtCF2urQTaod8=
|
||||
modernc.org/libc v1.15.0/go.mod h1:H1OKCu+NYa9+uQG8WsP7DndMBP61I4PWH8ivWhbdoWQ=
|
||||
modernc.org/mathutil v1.1.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
|
||||
modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
|
||||
modernc.org/mathutil v1.4.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
var (
|
||||
info = [...]string{
|
||||
"* OneBot + ZeroBot + Golang",
|
||||
"* Version 1.3.3-beta4 - 2022-04-14 17:09:47 +0800 CST",
|
||||
"* Version 1.3.3-beta6 - 2022-04-16 00:34:43 +0800 CST",
|
||||
"* Copyright © 2020 - 2022 FloatTech. All Rights Reserved.",
|
||||
"* Project: https://github.com/FloatTech/ZeroBot-Plugin",
|
||||
}
|
||||
|
||||
1
main.go
1
main.go
@@ -110,6 +110,7 @@ import (
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/translation" // 翻译
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/vtb_quotation" // vtb语录
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wangyiyun" // 网易云音乐热评
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/word_count" // 聊天热词
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wordle" // 猜单词
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ymgal" // 月幕galgame
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/zaobao" // 早报
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"time"
|
||||
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/img"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
@@ -36,14 +37,21 @@ var engine = control.Register("bilibili", &control.Options{
|
||||
// 查成分的
|
||||
func init() {
|
||||
cachePath := engine.DataFolder() + "cache/"
|
||||
dbfile := engine.DataFolder() + "bilibili.db"
|
||||
go func() {
|
||||
_ = os.MkdirAll(cachePath, 0755)
|
||||
_ = os.RemoveAll(cachePath)
|
||||
_ = os.MkdirAll(cachePath, 0755)
|
||||
var getdb = ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
var err error
|
||||
dbfile := engine.DataFolder() + "bilibili.db"
|
||||
_, _ = file.GetLazyData(dbfile, false, false)
|
||||
vdb = initialize(dbfile)
|
||||
}()
|
||||
vdb, err = initialize(dbfile)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
engine.OnRegex(`^>user info\s?(.{1,25})$`).SetBlock(true).
|
||||
engine.OnRegex(`^>user info\s?(.{1,25})$`, getdb).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
keyword := ctx.State["regex_matched"].([]string)[1]
|
||||
uidRes, err := search(keyword)
|
||||
@@ -95,7 +103,7 @@ func init() {
|
||||
))
|
||||
})
|
||||
|
||||
engine.OnRegex(`^查成分\s?(.{1,25})$`).SetBlock(true).
|
||||
engine.OnRegex(`^查成分\s?(.{1,25})$`, getdb).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
keyword := ctx.State["regex_matched"].([]string)[1]
|
||||
searchRes, err := search(keyword)
|
||||
@@ -256,7 +264,7 @@ func init() {
|
||||
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile))
|
||||
})
|
||||
|
||||
engine.OnRegex(`^设置b站cookie?\s+(.{1,100})$`, zero.SuperUserPermission).SetBlock(true).
|
||||
engine.OnRegex(`^设置b站cookie?\s+(.{1,100})$`, zero.SuperUserPermission, getdb).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
cookie := ctx.State["regex_matched"].([]string)[1]
|
||||
err := vdb.setBilibiliCookie(cookie)
|
||||
@@ -267,7 +275,7 @@ func init() {
|
||||
ctx.SendChain(message.Text("成功设置b站cookie为" + cookie))
|
||||
})
|
||||
|
||||
engine.OnFullMatch("更新vup", zero.SuperUserPermission).SetBlock(true).
|
||||
engine.OnFullMatch("更新vup", zero.SuperUserPermission, getdb).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SendChain(message.Text("少女祈祷中..."))
|
||||
err := updateVup()
|
||||
|
||||
@@ -42,21 +42,21 @@ func (config) TableName() string {
|
||||
}
|
||||
|
||||
// initialize 初始化vtb数据库
|
||||
func initialize(dbpath string) *vupdb {
|
||||
func initialize(dbpath string) (*vupdb, error) {
|
||||
if _, err := os.Stat(dbpath); err != nil || os.IsNotExist(err) {
|
||||
// 生成文件
|
||||
f, err := os.Create(dbpath)
|
||||
if err != nil {
|
||||
return nil
|
||||
return nil, err
|
||||
}
|
||||
defer f.Close()
|
||||
}
|
||||
gdb, err := gorm.Open("sqlite3", dbpath)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return nil, err
|
||||
}
|
||||
gdb.Debug().AutoMigrate(&vup{}).AutoMigrate(&config{})
|
||||
return (*vupdb)(gdb)
|
||||
gdb.AutoMigrate(&vup{}).AutoMigrate(&config{})
|
||||
return (*vupdb)(gdb), nil
|
||||
}
|
||||
|
||||
func (vdb *vupdb) insertVupByMid(mid int64, uname string, roomid int64) (err error) {
|
||||
@@ -66,9 +66,9 @@ func (vdb *vupdb) insertVupByMid(mid int64, uname string, roomid int64) (err err
|
||||
Uname: uname,
|
||||
Roomid: roomid,
|
||||
}
|
||||
if err = db.Debug().Model(&vup{}).First(&v, "mid = ? ", mid).Error; err != nil {
|
||||
if err = db.Model(&vup{}).First(&v, "mid = ? ", mid).Error; err != nil {
|
||||
if gorm.IsRecordNotFoundError(err) {
|
||||
err = db.Debug().Model(&vup{}).Create(&v).Error
|
||||
err = db.Model(&vup{}).Create(&v).Error
|
||||
}
|
||||
}
|
||||
return
|
||||
@@ -77,7 +77,7 @@ func (vdb *vupdb) insertVupByMid(mid int64, uname string, roomid int64) (err err
|
||||
// filterVup 筛选vup
|
||||
func (vdb *vupdb) filterVup(ids []int64) (vups []vup, err error) {
|
||||
db := (*gorm.DB)(vdb)
|
||||
if err = db.Debug().Model(&vup{}).Find(&vups, "mid in (?)", ids).Error; err != nil {
|
||||
if err = db.Model(&vup{}).Find(&vups, "mid in (?)", ids).Error; err != nil {
|
||||
return vups, err
|
||||
}
|
||||
return
|
||||
@@ -112,13 +112,13 @@ func (vdb *vupdb) setBilibiliCookie(cookie string) (err error) {
|
||||
Key: bilibiliCookie,
|
||||
Value: cookie,
|
||||
}
|
||||
if err = db.Debug().Model(&config{}).First(&c, "key = ? ", bilibiliCookie).Error; err != nil {
|
||||
if err = db.Model(&config{}).First(&c, "key = ? ", bilibiliCookie).Error; err != nil {
|
||||
// error handling...
|
||||
if gorm.IsRecordNotFoundError(err) {
|
||||
err = db.Debug().Model(&config{}).Create(&c).Error
|
||||
err = db.Model(&config{}).Create(&c).Error
|
||||
}
|
||||
} else {
|
||||
err = db.Debug().Model(&config{}).Where("key = ? ", bilibiliCookie).Update(
|
||||
err = db.Model(&config{}).Where("key = ? ", bilibiliCookie).Update(
|
||||
map[string]interface{}{
|
||||
"value": cookie,
|
||||
}).Error
|
||||
@@ -128,6 +128,6 @@ func (vdb *vupdb) setBilibiliCookie(cookie string) (err error) {
|
||||
|
||||
func (vdb *vupdb) getBilibiliCookie() (c config) {
|
||||
db := (*gorm.DB)(vdb)
|
||||
db.Debug().Model(&config{}).First(&c, "key = ?", bilibiliCookie)
|
||||
db.Model(&config{}).First(&c, "key = ?", bilibiliCookie)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -59,12 +59,12 @@ func (bdb *bilibilipushdb) insertOrUpdateLiveAndDynamic(bpMap map[string]interfa
|
||||
bp := bilibilipush{}
|
||||
data, _ := json.Marshal(&bpMap)
|
||||
_ = json.Unmarshal(data, &bp)
|
||||
if err = db.Debug().Model(&bilibilipush{}).First(&bp, "bilibili_uid = ? and group_id = ?", bp.BilibiliUID, bp.GroupID).Error; err != nil {
|
||||
if err = db.Model(&bilibilipush{}).First(&bp, "bilibili_uid = ? and group_id = ?", bp.BilibiliUID, bp.GroupID).Error; err != nil {
|
||||
if gorm.IsRecordNotFoundError(err) {
|
||||
err = db.Debug().Model(&bilibilipush{}).Create(&bp).Error
|
||||
err = db.Model(&bilibilipush{}).Create(&bp).Error
|
||||
}
|
||||
} else {
|
||||
err = db.Debug().Model(&bilibilipush{}).Where("bilibili_uid = ? and group_id = ?", bp.BilibiliUID, bp.GroupID).Update(bpMap).Error
|
||||
err = db.Model(&bilibilipush{}).Where("bilibili_uid = ? and group_id = ?", bp.BilibiliUID, bp.GroupID).Update(bpMap).Error
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -72,7 +72,7 @@ func (bdb *bilibilipushdb) insertOrUpdateLiveAndDynamic(bpMap map[string]interfa
|
||||
func (bdb *bilibilipushdb) getAllBuidByLive() (buidList []int64) {
|
||||
db := (*gorm.DB)(bdb)
|
||||
var bpl []bilibilipush
|
||||
db.Debug().Model(&bilibilipush{}).Find(&bpl, "live_disable = 0")
|
||||
db.Model(&bilibilipush{}).Find(&bpl, "live_disable = 0")
|
||||
temp := make(map[int64]bool)
|
||||
for _, v := range bpl {
|
||||
_, ok := temp[v.BilibiliUID]
|
||||
@@ -87,7 +87,7 @@ func (bdb *bilibilipushdb) getAllBuidByLive() (buidList []int64) {
|
||||
func (bdb *bilibilipushdb) getAllBuidByDynamic() (buidList []int64) {
|
||||
db := (*gorm.DB)(bdb)
|
||||
var bpl []bilibilipush
|
||||
db.Debug().Model(&bilibilipush{}).Find(&bpl, "dynamic_disable = 0")
|
||||
db.Model(&bilibilipush{}).Find(&bpl, "dynamic_disable = 0")
|
||||
temp := make(map[int64]bool)
|
||||
for _, v := range bpl {
|
||||
_, ok := temp[v.BilibiliUID]
|
||||
@@ -102,7 +102,7 @@ func (bdb *bilibilipushdb) getAllBuidByDynamic() (buidList []int64) {
|
||||
func (bdb *bilibilipushdb) getAllGroupByBuidAndLive(buid int64) (groupList []int64) {
|
||||
db := (*gorm.DB)(bdb)
|
||||
var bpl []bilibilipush
|
||||
db.Debug().Model(&bilibilipush{}).Find(&bpl, "bilibili_uid = ? and live_disable = 0", buid)
|
||||
db.Model(&bilibilipush{}).Find(&bpl, "bilibili_uid = ? and live_disable = 0", buid)
|
||||
for _, v := range bpl {
|
||||
groupList = append(groupList, v.GroupID)
|
||||
}
|
||||
@@ -112,7 +112,7 @@ func (bdb *bilibilipushdb) getAllGroupByBuidAndLive(buid int64) (groupList []int
|
||||
func (bdb *bilibilipushdb) getAllGroupByBuidAndDynamic(buid int64) (groupList []int64) {
|
||||
db := (*gorm.DB)(bdb)
|
||||
var bpl []bilibilipush
|
||||
db.Debug().Model(&bilibilipush{}).Find(&bpl, "bilibili_uid = ? and dynamic_disable = 0", buid)
|
||||
db.Model(&bilibilipush{}).Find(&bpl, "bilibili_uid = ? and dynamic_disable = 0", buid)
|
||||
for _, v := range bpl {
|
||||
groupList = append(groupList, v.GroupID)
|
||||
}
|
||||
@@ -121,7 +121,7 @@ func (bdb *bilibilipushdb) getAllGroupByBuidAndDynamic(buid int64) (groupList []
|
||||
|
||||
func (bdb *bilibilipushdb) getAllPushByGroup(groupID int64) (bpl []bilibilipush) {
|
||||
db := (*gorm.DB)(bdb)
|
||||
db.Debug().Model(&bilibilipush{}).Find(&bpl, "group_id = ? and (live_disable = 0 or dynamic_disable = 0)", groupID)
|
||||
db.Model(&bilibilipush{}).Find(&bpl, "group_id = ? and (live_disable = 0 or dynamic_disable = 0)", groupID)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -131,13 +131,13 @@ func (bdb *bilibilipushdb) insertBilibiliUp(buid int64, name string) {
|
||||
BilibiliUID: buid,
|
||||
Name: name,
|
||||
}
|
||||
db.Debug().Model(&bilibiliup{}).Create(bu)
|
||||
db.Model(&bilibiliup{}).Create(bu)
|
||||
}
|
||||
|
||||
func (bdb *bilibilipushdb) updateAllUp() {
|
||||
db := (*gorm.DB)(bdb)
|
||||
var bul []bilibiliup
|
||||
db.Debug().Model(&bilibiliup{}).Find(&bul)
|
||||
db.Model(&bilibiliup{}).Find(&bul)
|
||||
for _, v := range bul {
|
||||
upMap[v.BilibiliUID] = v.Name
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/FloatTech/zbputils/binary"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
)
|
||||
@@ -19,24 +20,27 @@ func init() {
|
||||
PublicDataFolder: "BookReview",
|
||||
})
|
||||
|
||||
go func() {
|
||||
getdb := ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
dbpath := engine.DataFolder()
|
||||
db.DBPath = dbpath + "bookreview.db"
|
||||
// os.RemoveAll(dbpath)
|
||||
_, _ = file.GetLazyData(db.DBPath, false, true)
|
||||
err := db.Create("bookreview", &book{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
n, err := db.Count("bookreview")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
log.Printf("[bookreview]读取%d条书评", n)
|
||||
}()
|
||||
log.Infof("[bookreview]读取%d条书评", n)
|
||||
return true
|
||||
})
|
||||
|
||||
// 中文、英文、数字但不包括下划线等符号
|
||||
engine.OnRegex("^书评([\u4E00-\u9FA5A-Za-z0-9]{1,25})$").SetBlock(true).
|
||||
engine.OnRegex("^书评([\u4E00-\u9FA5A-Za-z0-9]{1,25})$", getdb).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
b := getBookReviewByKeyword(ctx.State["regex_matched"].([]string)[1])
|
||||
data, err := text.RenderToBase64(b.BookReview, text.FontFile, 400, 20)
|
||||
@@ -49,7 +53,7 @@ func init() {
|
||||
}
|
||||
})
|
||||
|
||||
engine.OnFullMatch("随机书评").SetBlock(true).
|
||||
engine.OnFullMatch("随机书评", getdb).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
br := getRandomBookReview()
|
||||
data, err := text.RenderToBase64(br.BookReview, text.FontFile, 400, 20)
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
)
|
||||
|
||||
@@ -17,23 +18,26 @@ func init() {
|
||||
PublicDataFolder: "ChouXiangHua",
|
||||
})
|
||||
|
||||
go func() {
|
||||
dbpath := en.DataFolder()
|
||||
db.DBPath = dbpath + "cxh.db"
|
||||
// os.RemoveAll(dbpath)
|
||||
_, _ = file.GetLazyData(db.DBPath, false, true)
|
||||
err := db.Create("pinyin", &pinyin{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
n, err := db.Count("pinyin")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
logrus.Printf("[chouxianghua]读取%d条拼音", n)
|
||||
}()
|
||||
|
||||
en.OnRegex("^抽象翻译((\\s|[\\r\\n]|[\\p{Han}\\p{P}A-Za-z0-9])+)$").SetBlock(true).
|
||||
en.OnRegex("^抽象翻译((\\s|[\\r\\n]|[\\p{Han}\\p{P}A-Za-z0-9])+)$",
|
||||
ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
dbpath := en.DataFolder()
|
||||
db.DBPath = dbpath + "cxh.db"
|
||||
// os.RemoveAll(dbpath)
|
||||
_, _ = file.GetLazyData(db.DBPath, false, true)
|
||||
err := db.Create("pinyin", &pinyin{})
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
n, err := db.Count("pinyin")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
logrus.Printf("[chouxianghua]读取%d条拼音", n)
|
||||
return true
|
||||
}),
|
||||
).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
r := cx(ctx.State["regex_matched"].([]string)[1])
|
||||
ctx.SendChain(message.Text(r))
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/math"
|
||||
)
|
||||
@@ -20,23 +21,26 @@ func init() {
|
||||
PublicDataFolder: "CpStory",
|
||||
})
|
||||
|
||||
go func() {
|
||||
getdb := ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
dbpath := engine.DataFolder()
|
||||
db.DBPath = dbpath + "cp.db"
|
||||
// os.RemoveAll(dbpath)
|
||||
_, _ = file.GetLazyData(db.DBPath, false, true)
|
||||
err := db.Create("cp_story", &cpstory{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
n, err := db.Count("cp_story")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
logrus.Printf("[cpstory]读取%d条故事", n)
|
||||
}()
|
||||
return true
|
||||
})
|
||||
|
||||
engine.OnRegex("^组cp.*?(\\d+).*?(\\d+)", zero.OnlyGroup).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
engine.OnRegex("^组cp.*?(\\d+).*?(\\d+)", zero.OnlyGroup, getdb).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
cs := getRandomCpStory()
|
||||
gong := ctx.CardOrNickName(math.Str2Int64(ctx.State["regex_matched"].([]string)[1]))
|
||||
shou := ctx.CardOrNickName(math.Str2Int64(ctx.State["regex_matched"].([]string)[2]))
|
||||
@@ -46,7 +50,7 @@ func init() {
|
||||
text = strings.ReplaceAll(text, cs.Shou, gong)
|
||||
ctx.SendChain(message.Text(text))
|
||||
})
|
||||
engine.OnPrefix("磕cp").SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
engine.OnPrefix("磕cp", getdb).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
cs := getRandomCpStory()
|
||||
params := strings.Split(ctx.State["args"].(string), " ")
|
||||
if len(params) < 2 {
|
||||
|
||||
@@ -24,34 +24,41 @@ func init() {
|
||||
PublicDataFolder: "Curse",
|
||||
})
|
||||
|
||||
go func() {
|
||||
getdb := ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
dbpath := engine.DataFolder()
|
||||
db.DBPath = dbpath + "curse.db"
|
||||
_, err := file.GetLazyData(db.DBPath, false, true)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
err = db.Create("curse", &curse{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
c, err := db.Count("curse")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
c, _ := db.Count("curse")
|
||||
logrus.Infoln("[curse]加载", c, "条骂人语录")
|
||||
}()
|
||||
return true
|
||||
})
|
||||
|
||||
engine.OnFullMatch("骂我").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
engine.OnFullMatch("骂我", getdb).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
process.SleepAbout1sTo2s()
|
||||
text := getRandomCurseByLevel(minLevel).Text
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text))
|
||||
})
|
||||
|
||||
engine.OnFullMatch("大力骂我").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
engine.OnFullMatch("大力骂我", getdb).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
process.SleepAbout1sTo2s()
|
||||
text := getRandomCurseByLevel(maxLevel).Text
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text))
|
||||
})
|
||||
|
||||
engine.OnKeywordGroup([]string{"他妈", "公交车", "你妈", "操", "屎", "去死", "快死", "我日", "逼", "尼玛", "艾滋", "癌症", "有病", "烦你", "你爹", "屮", "cnm"}, zero.OnlyToMe).SetBlock(true).
|
||||
engine.OnKeywordGroup([]string{"他妈", "公交车", "你妈", "操", "屎", "去死", "快死", "我日", "逼", "尼玛", "艾滋", "癌症", "有病", "烦你", "你爹", "屮", "cnm"}, zero.OnlyToMe, getdb).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
text := getRandomCurseByLevel(maxLevel).Text
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(text))
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/plugin/diana/data"
|
||||
)
|
||||
@@ -21,26 +22,29 @@ var engine = control.Register("diana", &control.Options{
|
||||
})
|
||||
|
||||
func init() {
|
||||
go func() {
|
||||
datapath := engine.DataFolder()
|
||||
dbfile := datapath + "text.db"
|
||||
data.LoadText(dbfile)
|
||||
}()
|
||||
getdb := ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
err := data.LoadText(engine.DataFolder() + "text.db")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
// 随机发送一篇上面的小作文
|
||||
engine.OnFullMatch("小作文").SetBlock(true).
|
||||
engine.OnFullMatch("小作文", getdb).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
// 绕过第一行发病
|
||||
ctx.SendChain(message.Text(data.RandText()))
|
||||
})
|
||||
// 逆天
|
||||
engine.OnFullMatch("发大病").SetBlock(true).
|
||||
engine.OnFullMatch("发大病", getdb).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
// 第一行是发病
|
||||
ctx.SendChain(message.Text(data.HentaiText()))
|
||||
})
|
||||
// 增加小作文
|
||||
engine.OnRegex(`^教你一篇小作文(.*)$`, zero.AdminPermission).SetBlock(true).
|
||||
engine.OnRegex(`^教你一篇小作文(.*)$`, zero.AdminPermission, getdb).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
err := data.AddText(ctx.State["regex_matched"].([]string)[1])
|
||||
if err != nil {
|
||||
|
||||
@@ -19,18 +19,22 @@ type text struct {
|
||||
}
|
||||
|
||||
// LoadText 加载小作文
|
||||
func LoadText(dbfile string) {
|
||||
func LoadText(dbfile string) error {
|
||||
_, err := file.GetLazyData(dbfile, false, false)
|
||||
db.DBPath = dbfile
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return err
|
||||
}
|
||||
err = db.Create("text", &text{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return err
|
||||
}
|
||||
c, err := db.Count("text")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
c, _ := db.Count("text")
|
||||
logrus.Printf("[Diana]读取%d条小作文", c)
|
||||
return nil
|
||||
}
|
||||
|
||||
// AddText 添加小作文
|
||||
|
||||
@@ -61,25 +61,9 @@ func init() {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
go func() {
|
||||
for i, s := range table {
|
||||
index[s] = uint8(i)
|
||||
}
|
||||
data, err := file.GetLazyData(omikujson, true, false)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = json.Unmarshal(data, &omikujis)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
go func() {
|
||||
_, err := file.GetLazyData(font, false, true)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
for i, s := range table {
|
||||
index[s] = uint8(i)
|
||||
}
|
||||
en.OnRegex(`^设置底图\s?(.*)`).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
gid := ctx.Event.GroupID
|
||||
@@ -104,7 +88,26 @@ func init() {
|
||||
}
|
||||
ctx.SendChain(message.Text("没有这个底图哦~"))
|
||||
})
|
||||
en.OnFullMatchGroup([]string{"运势", "抽签"}).SetBlock(true).
|
||||
en.OnFullMatchGroup([]string{"运势", "抽签"}, ctxext.DoOnceOnSuccess(
|
||||
func(ctx *zero.Ctx) bool {
|
||||
data, err := file.GetLazyData(omikujson, true, false)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
err = json.Unmarshal(data, &omikujis)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
_, err = file.GetLazyData(font, false, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
return true
|
||||
},
|
||||
)).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
// 获取该群背景类型,默认车万
|
||||
kind := "车万"
|
||||
|
||||
@@ -29,22 +29,27 @@ func init() {
|
||||
PublicDataFolder: "Funny",
|
||||
})
|
||||
|
||||
go func() {
|
||||
en.OnPrefix("讲个笑话", ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
dbpath := en.DataFolder()
|
||||
db.DBPath = dbpath + "jokes.db"
|
||||
_, err := file.GetLazyData(db.DBPath, false, true)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
err = db.Create("jokes", &joke{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
c, err := db.Count("jokes")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
c, _ := db.Count("jokes")
|
||||
logrus.Infoln("[funny]加载", c, "个笑话")
|
||||
}()
|
||||
|
||||
en.OnPrefix("讲个笑话").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
return true
|
||||
})).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
// 获取名字
|
||||
name := ctx.NickName()
|
||||
var j joke
|
||||
|
||||
@@ -38,18 +38,6 @@ func init() {
|
||||
PublicDataFolder: "Genshin",
|
||||
}).ApplySingle(ctxext.DefaultSingle)
|
||||
|
||||
go func() {
|
||||
zipfile := engine.DataFolder() + "Genshin.zip"
|
||||
_, err := file.GetLazyData(zipfile, false, false)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = parsezip(zipfile)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
|
||||
engine.OnFullMatch("切换原神卡池").SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
c, ok := control.Lookup("genshin")
|
||||
@@ -76,7 +64,22 @@ func init() {
|
||||
}
|
||||
})
|
||||
|
||||
engine.OnFullMatch("原神十连").SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
engine.OnFullMatch("原神十连", ctxext.DoOnceOnSuccess(
|
||||
func(ctx *zero.Ctx) bool {
|
||||
zipfile := engine.DataFolder() + "Genshin.zip"
|
||||
_, err := file.GetLazyData(zipfile, false, false)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
err = parsezip(zipfile)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
return true
|
||||
},
|
||||
)).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
c, ok := control.Lookup("genshin")
|
||||
if !ok {
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/FloatTech/zbputils/binary"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/antchfx/htmlquery"
|
||||
"github.com/sirupsen/logrus"
|
||||
@@ -27,22 +28,25 @@ func init() {
|
||||
PublicDataFolder: "Jandan",
|
||||
})
|
||||
|
||||
go func() {
|
||||
getdb := ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
dbpath := engine.DataFolder()
|
||||
db.DBPath = dbpath + "pics.db"
|
||||
_, _ = file.GetLazyData(db.DBPath, false, false)
|
||||
err := db.Create("picture", &picture{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
n, err := db.Count("picture")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
logrus.Printf("[jandan]读取%d张图片", n)
|
||||
}()
|
||||
return true
|
||||
})
|
||||
|
||||
engine.OnRegex(`来份[屌|弔|吊]图`).SetBlock(true).
|
||||
engine.OnRegex(`来份[屌|弔|吊]图`, getdb).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
u, err := getRandomPicture()
|
||||
if err != nil {
|
||||
@@ -52,7 +56,7 @@ func init() {
|
||||
ctx.SendChain(message.Image(u))
|
||||
})
|
||||
|
||||
engine.OnRegex(`更新[屌|弔|吊]图`, zero.SuperUserPermission).SetBlock(true).
|
||||
engine.OnRegex(`更新[屌|弔|吊]图`, zero.SuperUserPermission, getdb).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.Send("少女更新中...")
|
||||
webpageURL := api
|
||||
|
||||
@@ -46,7 +46,7 @@ const (
|
||||
"- 取消在\"cron\"的提醒\n" +
|
||||
"- 列出所有提醒\n" +
|
||||
"- 翻牌\n" +
|
||||
"- 设置欢迎语XXX 可选添加 [{at}] [{nickname}] [{avatar}] [{id}] {at}可在发送时艾特被欢迎者 {nickname}是被欢迎者名字 {avatar}是被欢迎者头像 {id}是被欢迎者QQ号\n" +
|
||||
"- 设置欢迎语XXX 可选添加 [{at}] [{nickname}] [{avatar}] [{uid}] [{gid}] [{groupname}] {at}可在发送时艾特被欢迎者 {nickname}是被欢迎者名字 {avatar}是被欢迎者头像 {uid}是被欢迎者QQ号 {gid}是当前群群号 {groupname} 是当前群群名\n" +
|
||||
"- 测试欢迎语\n" +
|
||||
"- 设置告别辞 参数同设置欢迎语\n" +
|
||||
"- 测试告别辞\n" +
|
||||
|
||||
@@ -3,11 +3,11 @@ package omikuji
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"math/rand"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
@@ -28,21 +28,6 @@ func init() { // 插件主体
|
||||
PublicDataFolder: "Omikuji",
|
||||
}).ApplySingle(ctxext.DefaultSingle)
|
||||
|
||||
go func() {
|
||||
dbpath := engine.DataFolder()
|
||||
db.DBPath = dbpath + "kuji.db"
|
||||
_, _ = file.GetLazyData(db.DBPath, false, true)
|
||||
err := db.Create("kuji", &kuji{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
n, err := db.Count("kuji")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
log.Printf("[kuji]读取%d条签文", n)
|
||||
}()
|
||||
|
||||
engine.OnFullMatchGroup([]string{"求签", "占卜"}).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
miku, err := bangoToday(ctx.Event.UserID)
|
||||
@@ -56,7 +41,29 @@ func init() { // 插件主体
|
||||
message.Image(fmt.Sprintf(bed, miku, 1)),
|
||||
)
|
||||
})
|
||||
engine.OnFullMatchGroup([]string{"解签"}).SetBlock(true).
|
||||
engine.OnFullMatch("解签", ctxext.DoOnceOnSuccess(
|
||||
func(ctx *zero.Ctx) bool {
|
||||
dbpath := engine.DataFolder()
|
||||
db.DBPath = dbpath + "kuji.db"
|
||||
_, err := file.GetLazyData(db.DBPath, false, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
err = db.Create("kuji", &kuji{})
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
n, err := db.Count("kuji")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
log.Printf("[kuji]读取%d条签文", n)
|
||||
return true
|
||||
},
|
||||
)).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
bg, err := bangoToday(ctx.Event.UserID)
|
||||
if err != nil {
|
||||
|
||||
@@ -5,7 +5,8 @@ import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
wr "github.com/mroth/weightedrand"
|
||||
"github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
@@ -18,26 +19,31 @@ func init() {
|
||||
Help: "投胎\n- reborn",
|
||||
PublicDataFolder: "Reborn",
|
||||
})
|
||||
go func() {
|
||||
datapath := en.DataFolder()
|
||||
jsonfile := datapath + "rate.json"
|
||||
area := make(rate, 226)
|
||||
err := load(&area, jsonfile)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
choices := make([]wr.Choice, len(area))
|
||||
for i, a := range area {
|
||||
choices[i].Item = a.Name
|
||||
choices[i].Weight = uint(a.Weight * 1e9)
|
||||
}
|
||||
areac, err = wr.NewChooser(choices...)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
logrus.Printf("[Reborn]读取%d个国家/地区", len(area))
|
||||
}()
|
||||
en.OnFullMatch("reborn").SetBlock(true).
|
||||
|
||||
en.OnFullMatch("reborn", ctxext.DoOnceOnSuccess(
|
||||
func(ctx *zero.Ctx) bool {
|
||||
datapath := en.DataFolder()
|
||||
jsonfile := datapath + "rate.json"
|
||||
area := make(rate, 226)
|
||||
err := load(&area, jsonfile)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
choices := make([]wr.Choice, len(area))
|
||||
for i, a := range area {
|
||||
choices[i].Item = a.Name
|
||||
choices[i].Weight = uint(a.Weight * 1e9)
|
||||
}
|
||||
areac, err = wr.NewChooser(choices...)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
logrus.Printf("[Reborn]读取%d个国家/地区", len(area))
|
||||
return true
|
||||
},
|
||||
)).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
if rand.Int31() > 1<<27 {
|
||||
ctx.SendChain(message.At(ctx.Event.UserID), message.Text(fmt.Sprintf("投胎成功!\n您出生在 %s, 是 %s。", randcoun(), randgen())))
|
||||
|
||||
@@ -65,7 +65,7 @@ func (sdb *scoredb) Close() error {
|
||||
// GetScoreByUID 取得分数
|
||||
func (sdb *scoredb) GetScoreByUID(uid int64) (s scoretable) {
|
||||
db := (*gorm.DB)(sdb)
|
||||
db.Debug().Model(&scoretable{}).FirstOrCreate(&s, "uid = ? ", uid)
|
||||
db.Model(&scoretable{}).FirstOrCreate(&s, "uid = ? ", uid)
|
||||
return s
|
||||
}
|
||||
|
||||
@@ -76,13 +76,13 @@ func (sdb *scoredb) InsertOrUpdateScoreByUID(uid int64, score int) (err error) {
|
||||
UID: uid,
|
||||
Score: score,
|
||||
}
|
||||
if err = db.Debug().Model(&scoretable{}).First(&s, "uid = ? ", uid).Error; err != nil {
|
||||
if err = db.Model(&scoretable{}).First(&s, "uid = ? ", uid).Error; err != nil {
|
||||
// error handling...
|
||||
if gorm.IsRecordNotFoundError(err) {
|
||||
err = db.Debug().Model(&scoretable{}).Create(&s).Error // newUser not user
|
||||
err = db.Model(&scoretable{}).Create(&s).Error // newUser not user
|
||||
}
|
||||
} else {
|
||||
err = db.Debug().Model(&scoretable{}).Where("uid = ? ", uid).Update(
|
||||
err = db.Model(&scoretable{}).Where("uid = ? ", uid).Update(
|
||||
map[string]interface{}{
|
||||
"score": score,
|
||||
}).Error
|
||||
@@ -93,7 +93,7 @@ func (sdb *scoredb) InsertOrUpdateScoreByUID(uid int64, score int) (err error) {
|
||||
// GetSignInByUID 取得签到次数
|
||||
func (sdb *scoredb) GetSignInByUID(uid int64) (si signintable) {
|
||||
db := (*gorm.DB)(sdb)
|
||||
db.Debug().Model(&signintable{}).FirstOrCreate(&si, "uid = ? ", uid)
|
||||
db.Model(&signintable{}).FirstOrCreate(&si, "uid = ? ", uid)
|
||||
return si
|
||||
}
|
||||
|
||||
@@ -104,13 +104,13 @@ func (sdb *scoredb) InsertOrUpdateSignInCountByUID(uid int64, count int) (err er
|
||||
UID: uid,
|
||||
Count: count,
|
||||
}
|
||||
if err = db.Debug().Model(&signintable{}).First(&si, "uid = ? ", uid).Error; err != nil {
|
||||
if err = db.Model(&signintable{}).First(&si, "uid = ? ", uid).Error; err != nil {
|
||||
// error handling...
|
||||
if gorm.IsRecordNotFoundError(err) {
|
||||
db.Debug().Model(&signintable{}).Create(&si) // newUser not user
|
||||
db.Model(&signintable{}).Create(&si) // newUser not user
|
||||
}
|
||||
} else {
|
||||
err = db.Debug().Model(&signintable{}).Where("uid = ? ", uid).Update(
|
||||
err = db.Model(&signintable{}).Where("uid = ? ", uid).Update(
|
||||
map[string]interface{}{
|
||||
"count": count,
|
||||
}).Error
|
||||
@@ -120,6 +120,6 @@ func (sdb *scoredb) InsertOrUpdateSignInCountByUID(uid int64, count int) (err er
|
||||
|
||||
func (sdb *scoredb) GetScoreRankByTopN(n int) (st []scoretable, err error) {
|
||||
db := (*gorm.DB)(sdb)
|
||||
err = db.Debug().Model(&scoretable{}).Order("score desc").Limit(n).Find(&st).Error
|
||||
err = db.Model(&scoretable{}).Order("score desc").Limit(n).Find(&st).Error
|
||||
return
|
||||
}
|
||||
|
||||
@@ -59,22 +59,25 @@ func init() { // 插件主体
|
||||
PublicDataFolder: "SetuTime",
|
||||
})
|
||||
|
||||
go func() {
|
||||
getdb := ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
// 如果数据库不存在则下载
|
||||
pool.db.DBPath = engine.DataFolder() + "SetuTime.db"
|
||||
_, _ = fileutil.GetLazyData(pool.db.DBPath, false, false)
|
||||
err := pool.db.Open()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
for _, imgtype := range pool.List() {
|
||||
if err := pool.db.Create(imgtype, &pixiv.Illust{}); err != nil {
|
||||
panic(err)
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
}
|
||||
}()
|
||||
return true
|
||||
})
|
||||
|
||||
engine.OnRegex(`^来份(.+)$`, ctxext.FirstValueInList(pool)).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
engine.OnRegex(`^来份(.+)$`, getdb, ctxext.FirstValueInList(pool)).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
var imgtype = ctx.State["regex_matched"].([]string)[1]
|
||||
// 补充池子
|
||||
@@ -94,7 +97,7 @@ func init() { // 插件主体
|
||||
}
|
||||
})
|
||||
|
||||
engine.OnRegex(`^添加(.+)\s?(\d+)$`, zero.SuperUserPermission).SetBlock(true).
|
||||
engine.OnRegex(`^添加(.+)\s?(\d+)$`, zero.SuperUserPermission, getdb).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
var (
|
||||
imgtype = ctx.State["regex_matched"].([]string)[1]
|
||||
@@ -108,7 +111,7 @@ func init() { // 插件主体
|
||||
ctx.SendChain(message.Text("成功向分类", imgtype, "添加图片", id))
|
||||
})
|
||||
|
||||
engine.OnRegex(`^删除(.+)\s?(\d+)$`, ctxext.FirstValueInList(pool), zero.SuperUserPermission).SetBlock(true).
|
||||
engine.OnRegex(`^删除(.+)\s?(\d+)$`, getdb, ctxext.FirstValueInList(pool), zero.SuperUserPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
var (
|
||||
imgtype = ctx.State["regex_matched"].([]string)[1]
|
||||
@@ -123,7 +126,7 @@ func init() { // 插件主体
|
||||
})
|
||||
|
||||
// 查询数据库涩图数量
|
||||
engine.OnFullMatchGroup([]string{">setu status"}).SetBlock(true).
|
||||
engine.OnFullMatch(">setu status", getdb).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
state := []string{"[SetuTime]"}
|
||||
pool.dbmu.RLock()
|
||||
|
||||
@@ -68,20 +68,20 @@ func (sdb *sleepdb) sleep(gid, uid int64) (position int, awakeTime time.Duration
|
||||
UserID: uid,
|
||||
SleepTime: now,
|
||||
}
|
||||
if err := db.Debug().Model(&SleepManage{}).Where("group_id = ? and user_id = ?", gid, uid).First(&st).Error; err != nil {
|
||||
if err := db.Model(&SleepManage{}).Where("group_id = ? and user_id = ?", gid, uid).First(&st).Error; err != nil {
|
||||
// error handling...
|
||||
if gorm.IsRecordNotFoundError(err) {
|
||||
db.Debug().Model(&SleepManage{}).Create(&st) // newUser not user
|
||||
db.Model(&SleepManage{}).Create(&st) // newUser not user
|
||||
}
|
||||
} else {
|
||||
log.Debugln("sleeptime为", st)
|
||||
awakeTime = now.Sub(st.SleepTime)
|
||||
db.Debug().Model(&SleepManage{}).Where("group_id = ? and user_id = ?", gid, uid).Update(
|
||||
db.Model(&SleepManage{}).Where("group_id = ? and user_id = ?", gid, uid).Update(
|
||||
map[string]interface{}{
|
||||
"sleep_time": now,
|
||||
})
|
||||
}
|
||||
db.Debug().Model(&SleepManage{}).Where("group_id = ? and sleep_time <= ? and sleep_time >= ?", gid, now, today).Count(&position)
|
||||
db.Model(&SleepManage{}).Where("group_id = ? and sleep_time <= ? and sleep_time >= ?", gid, now, today).Count(&position)
|
||||
return position, awakeTime
|
||||
}
|
||||
|
||||
@@ -95,19 +95,19 @@ func (sdb *sleepdb) getUp(gid, uid int64) (position int, sleepTime time.Duration
|
||||
UserID: uid,
|
||||
SleepTime: now,
|
||||
}
|
||||
if err := db.Debug().Model(&SleepManage{}).Where("group_id = ? and user_id = ?", gid, uid).First(&st).Error; err != nil {
|
||||
if err := db.Model(&SleepManage{}).Where("group_id = ? and user_id = ?", gid, uid).First(&st).Error; err != nil {
|
||||
// error handling...
|
||||
if gorm.IsRecordNotFoundError(err) {
|
||||
db.Debug().Model(&SleepManage{}).Create(&st) // newUser not user
|
||||
db.Model(&SleepManage{}).Create(&st) // newUser not user
|
||||
}
|
||||
} else {
|
||||
log.Debugln("sleeptime为", st)
|
||||
sleepTime = now.Sub(st.SleepTime)
|
||||
db.Debug().Model(&SleepManage{}).Where("group_id = ? and user_id = ?", gid, uid).Update(
|
||||
db.Model(&SleepManage{}).Where("group_id = ? and user_id = ?", gid, uid).Update(
|
||||
map[string]interface{}{
|
||||
"sleep_time": now,
|
||||
})
|
||||
}
|
||||
db.Debug().Model(&SleepManage{}).Where("group_id = ? and sleep_time <= ? and sleep_time >= ?", gid, now, today).Count(&position)
|
||||
db.Model(&SleepManage{}).Where("group_id = ? and sleep_time <= ? and sleep_time >= ?", gid, now, today).Count(&position)
|
||||
return position, sleepTime
|
||||
}
|
||||
|
||||
@@ -26,22 +26,29 @@ func init() {
|
||||
PublicDataFolder: "Tiangou",
|
||||
})
|
||||
|
||||
go func() {
|
||||
dbpath := en.DataFolder()
|
||||
db.DBPath = dbpath + "tiangou.db"
|
||||
_, err := file.GetLazyData(db.DBPath, false, true)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = db.Create("tiangou", &tiangou{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
c, _ := db.Count("tiangou")
|
||||
logrus.Infoln("[tiangou]加载", c, "条舔狗日记")
|
||||
}()
|
||||
|
||||
en.OnFullMatch("舔狗日记").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
en.OnFullMatch("舔狗日记", ctxext.DoOnceOnSuccess(
|
||||
func(ctx *zero.Ctx) bool {
|
||||
dbpath := en.DataFolder()
|
||||
db.DBPath = dbpath + "tiangou.db"
|
||||
_, err := file.GetLazyData(db.DBPath, false, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
err = db.Create("tiangou", &tiangou{})
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
c, err := db.Count("tiangou")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
logrus.Infoln("[tiangou]加载", c, "条舔狗日记")
|
||||
return true
|
||||
},
|
||||
)).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
var t tiangou
|
||||
err := db.Pick("tiangou", &t)
|
||||
if err != nil {
|
||||
|
||||
@@ -99,7 +99,7 @@ func (vdb *VtbDB) GetAllFirstCategoryMessage() (string, error) {
|
||||
db := (*gorm.DB)(vdb)
|
||||
firstStepMessage := "请选择一个vtb并发送序号:\n"
|
||||
var fcl []FirstCategory
|
||||
err := db.Debug().Model(&FirstCategory{}).Find(&fcl).Error
|
||||
err := db.Model(&FirstCategory{}).Find(&fcl).Error
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -116,7 +116,7 @@ func (vdb *VtbDB) GetAllSecondCategoryMessageByFirstIndex(firstIndex int) (strin
|
||||
var scl []SecondCategory
|
||||
var fc FirstCategory
|
||||
db.Model(FirstCategory{}).Where("first_category_index = ?", firstIndex).First(&fc)
|
||||
err := db.Debug().Model(&SecondCategory{}).Find(&scl, "first_category_uid = ?", fc.FirstCategoryUID).Error
|
||||
err := db.Model(&SecondCategory{}).Find(&scl, "first_category_uid = ?", fc.FirstCategoryUID).Error
|
||||
if err != nil || len(scl) == 0 {
|
||||
return "", err
|
||||
}
|
||||
@@ -133,7 +133,7 @@ func (vdb *VtbDB) GetAllThirdCategoryMessageByFirstIndexAndSecondIndex(firstInde
|
||||
var fc FirstCategory
|
||||
db.Model(FirstCategory{}).Where("first_category_index = ?", firstIndex).First(&fc)
|
||||
var tcl []ThirdCategory
|
||||
err := db.Debug().Model(&ThirdCategory{}).Find(&tcl, "first_category_uid = ? and second_category_index = ?", fc.FirstCategoryUID, secondIndex).Error
|
||||
err := db.Model(&ThirdCategory{}).Find(&tcl, "first_category_uid = ? and second_category_index = ?", fc.FirstCategoryUID, secondIndex).Error
|
||||
if err != nil || len(tcl) == 0 {
|
||||
return "", err
|
||||
}
|
||||
@@ -217,12 +217,12 @@ func (vdb *VtbDB) GetVtbList() (uidList []string, err error) {
|
||||
}
|
||||
log.Debugln(fc)
|
||||
|
||||
if err := db.Debug().Model(&FirstCategory{}).First(&fc, "first_category_uid = ?", fc.FirstCategoryUID).Error; err != nil {
|
||||
if err := db.Model(&FirstCategory{}).First(&fc, "first_category_uid = ?", fc.FirstCategoryUID).Error; err != nil {
|
||||
if gorm.IsRecordNotFoundError(err) {
|
||||
db.Debug().Model(&FirstCategory{}).Create(&fc) // newUser not user
|
||||
db.Model(&FirstCategory{}).Create(&fc) // newUser not user
|
||||
}
|
||||
} else {
|
||||
db.Debug().Model(&FirstCategory{}).Where("first_category_uid = ?", fc.FirstCategoryUID).Update(
|
||||
db.Model(&FirstCategory{}).Where("first_category_uid = ?", fc.FirstCategoryUID).Update(
|
||||
map[string]interface{}{
|
||||
"first_category_index": i,
|
||||
"first_category_name": item.Get("name").String(),
|
||||
@@ -276,13 +276,13 @@ func (vdb *VtbDB) StoreVtb(uid string) (err error) {
|
||||
FirstCategoryUID: uid,
|
||||
}
|
||||
|
||||
if err := db.Debug().Model(&SecondCategory{}).First(&sc, "first_category_uid = ? and second_category_index = ?", uid, secondIndex).Error; err != nil {
|
||||
if err := db.Model(&SecondCategory{}).First(&sc, "first_category_uid = ? and second_category_index = ?", uid, secondIndex).Error; err != nil {
|
||||
// error handling...
|
||||
if gorm.IsRecordNotFoundError(err) {
|
||||
db.Debug().Model(&SecondCategory{}).Create(&sc) // newUser not user
|
||||
db.Model(&SecondCategory{}).Create(&sc) // newUser not user
|
||||
}
|
||||
} else {
|
||||
db.Debug().Model(&SecondCategory{}).Where("first_category_uid = ? and second_category_index = ?", uid, secondIndex).Update(
|
||||
db.Model(&SecondCategory{}).Where("first_category_uid = ? and second_category_index = ?", uid, secondIndex).Update(
|
||||
map[string]interface{}{
|
||||
"second_category_name": secondItem.Get("categoryName").String(),
|
||||
"second_category_author": secondItem.Get("author").String(),
|
||||
@@ -305,13 +305,13 @@ func (vdb *VtbDB) StoreVtb(uid string) (err error) {
|
||||
}
|
||||
log.Debugln(tc)
|
||||
|
||||
if err := db.Debug().Model(&ThirdCategory{}).First(&tc, "first_category_uid = ? and second_category_index = ? and third_category_index = ?",
|
||||
if err := db.Model(&ThirdCategory{}).First(&tc, "first_category_uid = ? and second_category_index = ? and third_category_index = ?",
|
||||
uid, secondIndex, thirdIndex).Error; err != nil {
|
||||
if gorm.IsRecordNotFoundError(err) {
|
||||
db.Debug().Model(&ThirdCategory{}).Create(&tc) // newUser not user
|
||||
db.Model(&ThirdCategory{}).Create(&tc) // newUser not user
|
||||
}
|
||||
} else {
|
||||
db.Debug().Model(&ThirdCategory{}).Where("first_category_uid = ? and second_category_index = ? and third_category_index = ?",
|
||||
db.Model(&ThirdCategory{}).Where("first_category_uid = ? and second_category_index = ? and third_category_index = ?",
|
||||
uid, secondIndex, thirdIndex).Update(
|
||||
map[string]interface{}{
|
||||
"third_category_name": thirdItem.Get("name").String(),
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
@@ -40,14 +41,21 @@ func init() {
|
||||
})
|
||||
dbfile := engine.DataFolder() + "vtb.db"
|
||||
storePath := engine.DataFolder() + "store/"
|
||||
go func() {
|
||||
getdb := ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
err := os.MkdirAll(storePath, 0755)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
_, _ = file.GetLazyData(dbfile, false, false)
|
||||
}()
|
||||
engine.OnFullMatch("vtb语录").SetBlock(true).
|
||||
_, err = file.GetLazyData(dbfile, false, false)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
engine.OnFullMatch("vtb语录", getdb).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
var firstIndex int
|
||||
var secondIndex int
|
||||
@@ -238,7 +246,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
})
|
||||
engine.OnFullMatch("随机vtb").SetBlock(true).
|
||||
engine.OnFullMatch("随机vtb", getdb).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
db, err := model.Open(dbfile)
|
||||
if err != nil {
|
||||
@@ -274,7 +282,7 @@ func init() {
|
||||
ctx.SendChain(message.Record("file:///" + file.BOTPATH + "/" + recordFile))
|
||||
}
|
||||
})
|
||||
engine.OnFullMatch("更新vtb", zero.SuperUserPermission).SetBlock(true).
|
||||
engine.OnFullMatch("更新vtb", zero.SuperUserPermission, getdb).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.Send("少女祈祷中......")
|
||||
db := model.Initialize(dbfile)
|
||||
|
||||
181
plugin/word_count/word_count.go
Normal file
181
plugin/word_count/word_count.go
Normal file
@@ -0,0 +1,181 @@
|
||||
// Package wordcount 聊天热词
|
||||
package wordcount
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/zbputils/binary"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
"github.com/golang/freetype"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/wcharczuk/go-chart/v2"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
var (
|
||||
re = regexp.MustCompile(`^[一-龥]+$`)
|
||||
stopwords []string
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("wordcount", &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "聊天热词\n" +
|
||||
"- 热词 [群号] [消息数目]|热词 123456 1000",
|
||||
PublicDataFolder: "WordCount",
|
||||
})
|
||||
cachePath := engine.DataFolder() + "cache/"
|
||||
_ = os.RemoveAll(cachePath)
|
||||
_ = os.MkdirAll(cachePath, 0755)
|
||||
engine.OnRegex(`^热词\s?(\d*)\s?(\d*)$`, zero.OnlyGroup, ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
_, err := file.GetLazyData(engine.DataFolder()+"stopwords.txt", false, false)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
data, err := os.ReadFile(engine.DataFolder() + "stopwords.txt")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
stopwords = strings.Split(binary.BytesToString(data), "\r\n")
|
||||
sort.Strings(stopwords)
|
||||
logrus.Infoln("[wordcount]加载", len(stopwords), "条停用词")
|
||||
return true
|
||||
})).Limit(ctxext.LimitByUser).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SendChain(message.Text("少女祈祷中..."))
|
||||
gid, _ := strconv.ParseInt(ctx.State["regex_matched"].([]string)[1], 10, 64)
|
||||
p, _ := strconv.ParseInt(ctx.State["regex_matched"].([]string)[2], 10, 64)
|
||||
if p > 10000 {
|
||||
p = 10000
|
||||
}
|
||||
if p == 0 {
|
||||
p = 1000
|
||||
}
|
||||
if gid == 0 {
|
||||
gid = ctx.Event.GroupID
|
||||
}
|
||||
group := ctx.GetGroupInfo(gid, false)
|
||||
if group.MemberCount == 0 {
|
||||
ctx.SendChain(message.Text(zero.BotConfig.NickName[0], "未加入", group.Name, "(", gid, "),无法获得热词呢"))
|
||||
return
|
||||
}
|
||||
today := time.Now().Format("20060102")
|
||||
drawedFile := fmt.Sprintf("%s%d%s%dwordCount.png", cachePath, gid, today, p)
|
||||
if file.IsExist(drawedFile) {
|
||||
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile))
|
||||
return
|
||||
}
|
||||
messageMap := make(map[string]int)
|
||||
h := ctx.CallAction("get_group_msg_history", zero.Params{"group_id": gid}).Data
|
||||
messageSeq := h.Get("messages.0.message_seq").Int()
|
||||
for i := 0; i < int(p/20) && messageSeq != 0; i++ {
|
||||
if i != 0 {
|
||||
h = ctx.CallAction("get_group_msg_history", zero.Params{"group_id": gid, "message_seq": messageSeq}).Data
|
||||
}
|
||||
for _, v := range h.Get("messages.#.message").Array() {
|
||||
tex := strings.TrimSpace(message.ParseMessageFromString(v.Str).ExtractPlainText())
|
||||
if tex == "" {
|
||||
continue
|
||||
}
|
||||
for _, t := range ctx.GetWordSlices(tex).Get("slices").Array() {
|
||||
tex := strings.TrimSpace(t.Str)
|
||||
i := sort.SearchStrings(stopwords, tex)
|
||||
if re.MatchString(tex) && (i >= len(stopwords) || stopwords[i] != tex) {
|
||||
messageMap[tex]++
|
||||
}
|
||||
}
|
||||
}
|
||||
messageSeq = h.Get("messages.0.message_seq").Int()
|
||||
}
|
||||
wc := rankByWordCount(messageMap)
|
||||
if len(wc) > 20 {
|
||||
wc = wc[:20]
|
||||
}
|
||||
// 绘图
|
||||
if len(wc) == 0 {
|
||||
ctx.SendChain(message.Text("ERROR:历史消息为空或者无法获得历史消息"))
|
||||
return
|
||||
}
|
||||
_, err := file.GetLazyData(text.FontFile, false, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
b, err := os.ReadFile(text.FontFile)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
font, err := freetype.ParseFont(b)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
bars := make([]chart.Value, len(wc))
|
||||
for i, v := range wc {
|
||||
bars[i] = chart.Value{
|
||||
Value: float64(v.Value),
|
||||
Label: v.Key,
|
||||
}
|
||||
}
|
||||
graph := chart.BarChart{
|
||||
Font: font,
|
||||
Title: fmt.Sprintf("%s(%d)在%s号的%d条消息的热词top20", group.Name, gid, time.Now().Format("2006-01-02"), p),
|
||||
Background: chart.Style{
|
||||
Padding: chart.Box{
|
||||
Top: 40,
|
||||
},
|
||||
},
|
||||
Height: 500,
|
||||
BarWidth: 25,
|
||||
Bars: bars,
|
||||
}
|
||||
f, err := os.Create(drawedFile)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
err = graph.Render(chart.PNG, f)
|
||||
_ = f.Close()
|
||||
if err != nil {
|
||||
_ = os.Remove(drawedFile)
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile))
|
||||
})
|
||||
}
|
||||
|
||||
func rankByWordCount(wordFrequencies map[string]int) pairlist {
|
||||
pl := make(pairlist, len(wordFrequencies))
|
||||
i := 0
|
||||
for k, v := range wordFrequencies {
|
||||
pl[i] = pair{k, v}
|
||||
i++
|
||||
}
|
||||
sort.Sort(sort.Reverse(pl))
|
||||
return pl
|
||||
}
|
||||
|
||||
type pair struct {
|
||||
Key string
|
||||
Value int
|
||||
}
|
||||
|
||||
type pairlist []pair
|
||||
|
||||
func (p pairlist) Len() int { return len(p) }
|
||||
func (p pairlist) Less(i, j int) bool { return p[i].Value < p[j].Value }
|
||||
func (p pairlist) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
|
||||
@@ -9,10 +9,13 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/tl"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/FloatTech/zbputils/binary"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
@@ -55,10 +58,7 @@ type dictionary map[int]struct {
|
||||
cet4 []string
|
||||
}
|
||||
|
||||
var (
|
||||
words = make(dictionary)
|
||||
wordsmu sync.Mutex
|
||||
)
|
||||
var words = make(dictionary)
|
||||
|
||||
func init() {
|
||||
en := control.Register("wordle", &control.Options{
|
||||
@@ -77,35 +77,55 @@ func init() {
|
||||
)
|
||||
}),
|
||||
))
|
||||
for i := 5; i <= 7; i++ {
|
||||
go func(i int) {
|
||||
dc, err := file.GetLazyData(fmt.Sprintf("%scet-4_%d.txt", en.DataFolder(), i), true, true)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
en.OnRegex(`^(个人|团队)(五阶|六阶|七阶)?猜单词$`, zero.OnlyGroup, ctxext.DoOnceOnSuccess(
|
||||
func(ctx *zero.Ctx) bool {
|
||||
var errcnt uint32
|
||||
var wg sync.WaitGroup
|
||||
var mu sync.Mutex
|
||||
for i := 5; i <= 7; i++ {
|
||||
wg.Add(2)
|
||||
go func(i int) {
|
||||
defer wg.Done()
|
||||
dc, err := file.GetLazyData(fmt.Sprintf("%scet-4_%d.txt", en.DataFolder(), i), true, true)
|
||||
logrus.Debugln("[wordle] get", fmt.Sprintf("%scet-4_%d.txt", en.DataFolder(), i))
|
||||
if err != nil {
|
||||
atomic.AddUint32(&errcnt, 1)
|
||||
return
|
||||
}
|
||||
c := strings.Split(binary.BytesToString(dc), "\n")
|
||||
sort.Strings(c)
|
||||
mu.Lock()
|
||||
tmp := words[i]
|
||||
tmp.cet4 = c
|
||||
words[i] = tmp
|
||||
mu.Unlock()
|
||||
}(i)
|
||||
go func(i int) {
|
||||
defer wg.Done()
|
||||
dd, err := file.GetLazyData(fmt.Sprintf("%sdict_%d.txt", en.DataFolder(), i), true, true)
|
||||
logrus.Debugln("[wordle] get", fmt.Sprintf("%sdict_%d.txt", en.DataFolder(), i))
|
||||
if err != nil {
|
||||
atomic.AddUint32(&errcnt, 1)
|
||||
return
|
||||
}
|
||||
d := strings.Split(binary.BytesToString(dd), "\n")
|
||||
sort.Strings(d)
|
||||
mu.Lock()
|
||||
tmp := words[i]
|
||||
tmp.dict = d
|
||||
words[i] = tmp
|
||||
mu.Unlock()
|
||||
}(i)
|
||||
}
|
||||
c := strings.Split(string(dc), "\n")
|
||||
sort.Strings(c)
|
||||
wordsmu.Lock()
|
||||
tmp := words[i]
|
||||
tmp.cet4 = c
|
||||
words[i] = tmp
|
||||
wordsmu.Unlock()
|
||||
}(i)
|
||||
go func(i int) {
|
||||
dd, err := file.GetLazyData(fmt.Sprintf("%sdict_%d.txt", en.DataFolder(), i), true, true)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
wg.Wait()
|
||||
if errcnt > 0 {
|
||||
ctx.SendChain(message.Text("ERROR:下载字典时发生", errcnt, "个错误"))
|
||||
return false
|
||||
}
|
||||
d := strings.Split(string(dd), "\n")
|
||||
sort.Strings(d)
|
||||
wordsmu.Lock()
|
||||
tmp := words[i]
|
||||
tmp.dict = d
|
||||
words[i] = tmp
|
||||
wordsmu.Unlock()
|
||||
}(i)
|
||||
}
|
||||
en.OnRegex(`(个人|团队)(五阶|六阶|七阶)?猜单词`, zero.OnlyGroup).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
return true
|
||||
},
|
||||
)).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
class := classdict[ctx.State["regex_matched"].([]string)[2]]
|
||||
target := words[class].cet4[rand.Intn(len(words[class].cet4))]
|
||||
|
||||
@@ -38,22 +38,21 @@ func (ymgal) TableName() string {
|
||||
}
|
||||
|
||||
// initialize 初始化ymgaldb数据库
|
||||
func initialize(dbpath string) *ymgaldb {
|
||||
var err error
|
||||
func initialize(dbpath string) (db *ymgaldb, err error) {
|
||||
if _, err = os.Stat(dbpath); err != nil || os.IsNotExist(err) {
|
||||
// 生成文件
|
||||
f, err := os.Create(dbpath)
|
||||
if err != nil {
|
||||
return nil
|
||||
return nil, err
|
||||
}
|
||||
defer f.Close()
|
||||
_ = f.Close()
|
||||
}
|
||||
gdb, err := gorm.Open("sqlite3", dbpath)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return
|
||||
}
|
||||
gdb.AutoMigrate(&ymgal{})
|
||||
return (*ymgaldb)(gdb)
|
||||
return (*ymgaldb)(gdb), nil
|
||||
}
|
||||
|
||||
func (gdb *ymgaldb) insertOrUpdateYmgalByID(id int64, title, pictureType, pictureDescription, pictureList string) (err error) {
|
||||
@@ -65,12 +64,12 @@ func (gdb *ymgaldb) insertOrUpdateYmgalByID(id int64, title, pictureType, pictur
|
||||
PictureDescription: pictureDescription,
|
||||
PictureList: pictureList,
|
||||
}
|
||||
if err = db.Debug().Model(&ymgal{}).First(&y, "id = ? ", id).Error; err != nil {
|
||||
if err = db.Model(&ymgal{}).First(&y, "id = ? ", id).Error; err != nil {
|
||||
if gorm.IsRecordNotFoundError(err) {
|
||||
err = db.Debug().Model(&ymgal{}).Create(&y).Error // newUser not user
|
||||
err = db.Model(&ymgal{}).Create(&y).Error // newUser not user
|
||||
}
|
||||
} else {
|
||||
err = db.Debug().Model(&ymgal{}).Where("id = ? ", id).Update(map[string]interface{}{
|
||||
err = db.Model(&ymgal{}).Where("id = ? ", id).Update(map[string]interface{}{
|
||||
"title": title,
|
||||
"picture_type": pictureType,
|
||||
"picture_description": pictureDescription,
|
||||
@@ -82,14 +81,14 @@ func (gdb *ymgaldb) insertOrUpdateYmgalByID(id int64, title, pictureType, pictur
|
||||
|
||||
func (gdb *ymgaldb) getYmgalByID(id string) (y ymgal) {
|
||||
db := (*gorm.DB)(gdb)
|
||||
db.Debug().Model(&ymgal{}).Where("id = ?", id).Take(&y)
|
||||
db.Model(&ymgal{}).Where("id = ?", id).Take(&y)
|
||||
return
|
||||
}
|
||||
|
||||
func (gdb *ymgaldb) randomYmgal(pictureType string) (y ymgal) {
|
||||
db := (*gorm.DB)(gdb)
|
||||
var count int
|
||||
s := db.Debug().Model(&ymgal{}).Where("picture_type = ?", pictureType).Count(&count)
|
||||
s := db.Model(&ymgal{}).Where("picture_type = ?", pictureType).Count(&count)
|
||||
if count == 0 {
|
||||
return
|
||||
}
|
||||
@@ -100,7 +99,7 @@ func (gdb *ymgaldb) randomYmgal(pictureType string) (y ymgal) {
|
||||
func (gdb *ymgaldb) getYmgalByKey(pictureType, key string) (y ymgal) {
|
||||
db := (*gorm.DB)(gdb)
|
||||
var count int
|
||||
s := db.Debug().Model(&ymgal{}).Where("picture_type = ? and (picture_description like ? or title like ?) ", pictureType, "%"+key+"%", "%"+key+"%").Count(&count)
|
||||
s := db.Model(&ymgal{}).Where("picture_type = ? and (picture_description like ? or title like ?) ", pictureType, "%"+key+"%", "%"+key+"%").Count(&count)
|
||||
if count == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -18,11 +18,20 @@ func init() {
|
||||
PublicDataFolder: "Ymgal",
|
||||
})
|
||||
dbfile := engine.DataFolder() + "ymgal.db"
|
||||
go func() {
|
||||
_, _ = file.GetLazyData(dbfile, false, false)
|
||||
gdb = initialize(dbfile)
|
||||
}()
|
||||
engine.OnRegex("^随机gal(CG|表情包)$").Limit(ctxext.LimitByUser).SetBlock(true).
|
||||
getdb := ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
_, err := file.GetLazyData(dbfile, false, false)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
gdb, err = initialize(dbfile)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
engine.OnRegex("^随机gal(CG|表情包)$", getdb).Limit(ctxext.LimitByUser).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.Send("少女祈祷中......")
|
||||
pictureType := ctx.State["regex_matched"].([]string)[1]
|
||||
@@ -34,7 +43,7 @@ func init() {
|
||||
}
|
||||
sendYmgal(y, ctx)
|
||||
})
|
||||
engine.OnRegex("^gal(CG|表情包)([一-龥ぁ-んァ-ヶA-Za-z0-9]{1,25})$").Limit(ctxext.LimitByUser).SetBlock(true).
|
||||
engine.OnRegex("^gal(CG|表情包)([一-龥ぁ-んァ-ヶA-Za-z0-9]{1,25})$", getdb).Limit(ctxext.LimitByUser).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.Send("少女祈祷中......")
|
||||
pictureType := ctx.State["regex_matched"].([]string)[1]
|
||||
@@ -47,7 +56,7 @@ func init() {
|
||||
}
|
||||
sendYmgal(y, ctx)
|
||||
})
|
||||
engine.OnFullMatch("更新gal", zero.SuperUserPermission).SetBlock(true).Handle(
|
||||
engine.OnFullMatch("更新gal", zero.SuperUserPermission, getdb).SetBlock(true).Handle(
|
||||
func(ctx *zero.Ctx) {
|
||||
ctx.Send("少女祈祷中......")
|
||||
err := updatePic()
|
||||
|
||||
Reference in New Issue
Block a user