mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2026-02-06 23:30:20 +00:00
Compare commits
17 Commits
v1.5.0
...
v1.5.1-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b8ae2e864 | ||
|
|
664cb2f2f9 | ||
|
|
486292434e | ||
|
|
e5f186ace1 | ||
|
|
0c637d4c8e | ||
|
|
0943023a19 | ||
|
|
941d6d2884 | ||
|
|
169af4ccce | ||
|
|
6f1d0f8c02 | ||
|
|
dd970b9a91 | ||
|
|
b997cb650e | ||
|
|
dd3ccf1d2f | ||
|
|
52a7977461 | ||
|
|
70713c0719 | ||
|
|
b4d6e1ef04 | ||
|
|
5295701541 | ||
|
|
43b9cea801 |
21
README.md
21
README.md
@@ -329,7 +329,14 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
</details>
|
||||
|
||||
### *中优先级*
|
||||
<details>
|
||||
<summary>ahsai tts</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/ahsai"`
|
||||
|
||||
- [x] 使[ 伊織弓鶴 | 紲星あかり | 結月ゆかり | 京町セイカ |東北きりたん | 東北イタコ | ついなちゃん標準語 | ついなちゃん関西弁 | 音街ウナ | 琴葉茜 | 吉田くん | 民安ともえ | 桜乃そら | 月読アイ | 琴葉葵 | 東北ずん子 | 月読ショウタ | 水奈瀬コウ ]说(日语)
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>AIfalse</summary>
|
||||
|
||||
@@ -381,7 +388,9 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
- [x] 查成分 [xxx]
|
||||
|
||||
- [x] 设置b站cookie SESSDATA=82da790d,1663822823,06ecf\*31
|
||||
- [x] 查弹幕 [xxx] 2 (最后一个参数是页码)
|
||||
|
||||
- [x] 设置b站cookie SESSDATA=82da790d,1663822823,06ecf\*31 (最好把cookie设全)
|
||||
|
||||
- [x] 更新vup
|
||||
|
||||
@@ -421,6 +430,14 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
- [x] 随机书评
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>打断复读</summary>
|
||||
|
||||
`import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/breakrepeat"`
|
||||
|
||||
- [x] (打断三次以上的复读)
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>藏头诗</summary>
|
||||
@@ -493,8 +510,6 @@ print("run[CQ:image,file="+j["img"]+"]")
|
||||
|
||||
- [x] 教你一篇小作文[作文]
|
||||
|
||||
- [x] [回复]查重
|
||||
|
||||
</details>
|
||||
<details>
|
||||
<summary>漂流瓶</summary>
|
||||
|
||||
20
go.mod
20
go.mod
@@ -3,15 +3,18 @@ module github.com/FloatTech/ZeroBot-Plugin
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/Coloured-glaze/gg v1.3.2
|
||||
github.com/FloatTech/AnimeAPI v1.5.1-0.20220816023211-5e11b0d21958
|
||||
github.com/Coloured-glaze/gg v1.3.4
|
||||
github.com/FloatTech/AnimeAPI v1.5.1-0.20220901132657-2585bbc03bf6
|
||||
github.com/FloatTech/floatbox v0.0.0-20220822040527-f059031fec44
|
||||
github.com/FloatTech/sqlite v0.3.3
|
||||
github.com/FloatTech/zbpctrl v1.4.1-0.20220715042842-93f081cb0133
|
||||
github.com/FloatTech/zbputils v1.5.1-0.20220816020252-0f57a5ae28aa
|
||||
github.com/FloatTech/zbputils v1.5.1-0.20220826103123-0c73a585e38f
|
||||
github.com/RomiChan/syncx v0.0.0-20220404072119-d7ea0ae15a4c
|
||||
github.com/antchfx/htmlquery v1.2.5
|
||||
github.com/corona10/goimagehash v1.0.3
|
||||
github.com/fumiama/ahsai v0.1.0
|
||||
github.com/fumiama/cron v1.3.0
|
||||
github.com/fumiama/go-base16384 v1.5.4
|
||||
github.com/fumiama/go-base16384 v1.5.5
|
||||
github.com/fumiama/go-registry v0.1.6
|
||||
github.com/fumiama/gofastTEA v0.0.10
|
||||
github.com/fumiama/gotracemoe v0.0.3
|
||||
@@ -21,7 +24,7 @@ require (
|
||||
github.com/jozsefsallai/gophersauce v1.0.1
|
||||
github.com/lucas-clemente/quic-go v0.27.2
|
||||
github.com/mroth/weightedrand v0.4.1
|
||||
github.com/pkg/errors v0.8.1
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/pkumza/numcn v1.0.0
|
||||
github.com/shirou/gopsutil/v3 v3.22.3
|
||||
github.com/sirupsen/logrus v1.9.0
|
||||
@@ -34,18 +37,21 @@ require (
|
||||
|
||||
require (
|
||||
github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b // indirect
|
||||
github.com/RomiChan/syncx v0.0.0-20220404072119-d7ea0ae15a4c // indirect
|
||||
github.com/RomiChan/websocket v1.4.3-0.20220123145318-307a86b127bc // indirect
|
||||
github.com/antchfx/xpath v1.2.1 // indirect
|
||||
github.com/cheekybits/genny v1.0.0 // indirect
|
||||
github.com/disintegration/imaging v1.6.2 // indirect
|
||||
github.com/ericpauley/go-quantize v0.0.0-20200331213906-ae555eb2afa4 // indirect
|
||||
github.com/faiface/beep v1.1.0 // indirect
|
||||
github.com/fsnotify/fsnotify v1.4.9 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.0.4 // indirect
|
||||
github.com/go-ole/go-ole v1.2.6 // indirect
|
||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
github.com/hajimehoshi/oto v0.7.1 // indirect
|
||||
github.com/jfreymuth/oggvorbis v1.0.1 // indirect
|
||||
github.com/jfreymuth/vorbis v1.0.0 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
|
||||
github.com/marten-seemann/qpack v0.2.1 // indirect
|
||||
@@ -64,6 +70,8 @@ require (
|
||||
github.com/tklauser/numcpus v0.4.0 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.2 // indirect
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8 // indirect
|
||||
golang.org/x/mobile v0.0.0-20190415191353-3e0bab5405d6 // indirect
|
||||
golang.org/x/mod v0.4.2 // indirect
|
||||
golang.org/x/net v0.0.0-20220805013720-a33c5aa5df48 // indirect
|
||||
golang.org/x/sys v0.0.0-20220804214406-8e32c043e418 // indirect
|
||||
|
||||
55
go.sum
55
go.sum
@@ -8,18 +8,21 @@ dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1
|
||||
dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU=
|
||||
git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/Coloured-glaze/gg v1.3.2 h1:HRWF0qoIxwhO1O0N5eN2eTPwaO+xHpFu1FfNhtls22w=
|
||||
github.com/Coloured-glaze/gg v1.3.2/go.mod h1:Ih5NLNNDHOy3RJbB0EPqGTreIzq/H02TGThIagh8HJg=
|
||||
github.com/FloatTech/AnimeAPI v1.5.1-0.20220816023211-5e11b0d21958 h1:BXjlcvPK/7IwaW1HTEPt/pMvbPrc3id1NfFkJ+lh1e4=
|
||||
github.com/FloatTech/AnimeAPI v1.5.1-0.20220816023211-5e11b0d21958/go.mod h1:vhrzmpfFp9p4V1T+xY2OaFUAx498LmMxdk/UqJmPMTc=
|
||||
github.com/Coloured-glaze/gg v1.3.4 h1:l31zIF/HaVwkzjrj+A56RGQoSKyKuR1IWtIrqXGFStI=
|
||||
github.com/Coloured-glaze/gg v1.3.4/go.mod h1:Ih5NLNNDHOy3RJbB0EPqGTreIzq/H02TGThIagh8HJg=
|
||||
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
|
||||
github.com/FloatTech/AnimeAPI v1.5.1-0.20220901132657-2585bbc03bf6 h1:B4KmWFHA6zXjyvcubwV8MrxbKGLAudiVUGyxE9KojTc=
|
||||
github.com/FloatTech/AnimeAPI v1.5.1-0.20220901132657-2585bbc03bf6/go.mod h1:R8jADxRo02AEuV6kOm+IcBGm7p/jqzngxOzK4y9EJRI=
|
||||
github.com/FloatTech/floatbox v0.0.0-20220822040527-f059031fec44 h1:gnNO7tpxXpTuLuqIK9ekZScvDKt3jwHR+/rkDU838Nw=
|
||||
github.com/FloatTech/floatbox v0.0.0-20220822040527-f059031fec44/go.mod h1:hK2HTQddBomA/sY2oD7VeW0GA5BxlIoYqcAOnamw1EU=
|
||||
github.com/FloatTech/sqlite v0.3.3 h1:cSlpv+DcIehqaUG2YyjW0Twh396FoGsybpEpFZnX3Jg=
|
||||
github.com/FloatTech/sqlite v0.3.3/go.mod h1:i33d92OtR8jcp5fBUvQtospf27+MkfUxnGwnZ95E/dA=
|
||||
github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b h1:tvciXWq2nuvTbFeJGLDNIdRX3BI546D3O7k7vrVueZw=
|
||||
github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b/go.mod h1:fHZFWGquNXuHttu9dUYoKuNbm3dzLETnIOnm1muSfDs=
|
||||
github.com/FloatTech/zbpctrl v1.4.1-0.20220715042842-93f081cb0133 h1:nP9NI4I+vtwAbiU7wCJwjuzCzMZ/yJYg8h3667HGnv0=
|
||||
github.com/FloatTech/zbpctrl v1.4.1-0.20220715042842-93f081cb0133/go.mod h1:72BnjyBwQWUC8mqM9dPk5ZrjxXCilQCVp+jfgHATNdw=
|
||||
github.com/FloatTech/zbputils v1.5.1-0.20220816020252-0f57a5ae28aa h1:nltmv5w1cdB0vU52zkLFI9a5FdBozaAhZZq/GCLi6Xs=
|
||||
github.com/FloatTech/zbputils v1.5.1-0.20220816020252-0f57a5ae28aa/go.mod h1:l06shz0lp4jqMBZDJaRRSUdOlIwg99cIKV4sx4YR0DI=
|
||||
github.com/FloatTech/zbputils v1.5.1-0.20220826103123-0c73a585e38f h1:R13GKhRZfB42nsCEqek/ZlGbKBopQOZFYwBU9qSCfhg=
|
||||
github.com/FloatTech/zbputils v1.5.1-0.20220826103123-0c73a585e38f/go.mod h1:ZT91eCYR6y1HbLRTO5EB7o8K7qEPbCsX7vjhYIuMijc=
|
||||
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=
|
||||
@@ -40,6 +43,7 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk
|
||||
github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/corona10/goimagehash v1.0.3 h1:NZM518aKLmoNluluhfHGxT3LGOnrojrxhGn63DR/CZA=
|
||||
github.com/corona10/goimagehash v1.0.3/go.mod h1:VkvE0mLn84L4aF8vCb6mafVajEb6QYMHl2ZJLn0mOGI=
|
||||
github.com/d4l3k/messagediff v1.2.2-0.20190829033028-7e0a312ae40b/go.mod h1:Oozbb1TVXFac9FtSIxHBMnBCq2qeH/2KkEQxENCrlLo=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
@@ -52,15 +56,19 @@ github.com/ericpauley/go-quantize v0.0.0-20200331213906-ae555eb2afa4 h1:BBade+Jl
|
||||
github.com/ericpauley/go-quantize v0.0.0-20200331213906-ae555eb2afa4/go.mod h1:H7chHJglrhPPzetLdzBleF8d22WYOv7UM/lEKYiwlKM=
|
||||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y=
|
||||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
|
||||
github.com/faiface/beep v1.1.0 h1:A2gWP6xf5Rh7RG/p9/VAW2jRSDEGQm5sbOb38sf5d4c=
|
||||
github.com/faiface/beep v1.1.0/go.mod h1:6I8p6kK2q4opL/eWb+kAkk38ehnTunWeToJB+s51sT4=
|
||||
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
|
||||
github.com/francoispqt/gojay v1.2.13/go.mod h1:ehT5mTG4ua4581f1++1WLG0vPdaA9HaiDsoyrBGkyDY=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/fumiama/ahsai v0.1.0 h1:LXD61Kaj6kJHa3AEGsLIfKNzcgaVxg7JB72OR4yNNZ4=
|
||||
github.com/fumiama/ahsai v0.1.0/go.mod h1:fFeNnqgo44i8FIaguK659aQryuZeFy+4klYLQu/rfdk=
|
||||
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.5.4 h1:UKx925X7cTsqsVWBlBLBs1v38epFT/q3AGjvyP5E0PM=
|
||||
github.com/fumiama/go-base16384 v1.5.4/go.mod h1:OEn+947GV5gsbTAnyuUW/SrfxJYUdYupSIQXOuGOcXM=
|
||||
github.com/fumiama/go-base16384 v1.5.5 h1:gsJW5GVfD0gV18/DnntWU4vDnaCvT5ysK0m2jkCqhU0=
|
||||
github.com/fumiama/go-base16384 v1.5.5/go.mod h1:OEn+947GV5gsbTAnyuUW/SrfxJYUdYupSIQXOuGOcXM=
|
||||
github.com/fumiama/go-registry v0.1.6 h1:Ee/tXCCIR/xt8celhbbw0W/xDMdhAXLwy2YFBB/LWFk=
|
||||
github.com/fumiama/go-registry v0.1.6/go.mod h1:dIUVbiOgfk9oZcsgwDvNLC72i+ctibVukSXR/9bLviI=
|
||||
github.com/fumiama/gofastTEA v0.0.10 h1:JJJ+brWD4kie+mmK2TkspDXKzqq0IjXm89aGYfoGhhQ=
|
||||
@@ -71,8 +79,13 @@ github.com/fumiama/sqlite3 v1.14.6 h1:+e+iygyiDXQJVi7xeXIviBvR7hAc5y20WA9hRwfKn1
|
||||
github.com/fumiama/sqlite3 v1.14.6/go.mod h1:Xx9a2/OtHuy9pBjow0N+bE/RhNeZ7zZz5xh25vqbA5A=
|
||||
github.com/gabriel-vasile/mimetype v1.0.4 h1:uBejfH8l3/2f+5vjl1e4xIaSyNEhRBZ5N/ij7ohpNd8=
|
||||
github.com/gabriel-vasile/mimetype v1.0.4/go.mod h1:6CDPel/o/3/s4+bp6kIbsWATq8pmgOisOPG40CJa6To=
|
||||
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
|
||||
github.com/gdamore/tcell v1.3.0/go.mod h1:Hjvr+Ofd+gLglo7RYKxxnzCBmev3BzsS67MebKS4zMM=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
|
||||
github.com/go-audio/audio v1.0.0/go.mod h1:6uAu0+H2lHkwdGsAY+j2wHPNPpPoeg5AaEFh9FlA+Zs=
|
||||
github.com/go-audio/riff v1.0.0/go.mod h1:l3cQwc85y79NQFCRB7TiPoNiaijp6q8Z0Uv38rVG498=
|
||||
github.com/go-audio/wav v1.0.0/go.mod h1:3yoReyQOsiARkvPl3ERCi8JFjihzG6WhjYpZCf5zAWE=
|
||||
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
|
||||
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
|
||||
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
||||
@@ -128,8 +141,18 @@ github.com/googleapis/gax-go/v2 v2.0.3/go.mod h1:LLvjysVCY1JZeum8Z6l8qUty8fiNwE0
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.5.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw=
|
||||
github.com/hajimehoshi/go-mp3 v0.3.0/go.mod h1:qMJj/CSDxx6CGHiZeCgbiq2DSUkbK0UbtXShQcnfyMM=
|
||||
github.com/hajimehoshi/oto v0.6.1/go.mod h1:0QXGEkbuJRohbJaxr7ZQSxnju7hEhseiPx2hrh6raOI=
|
||||
github.com/hajimehoshi/oto v0.7.1 h1:I7maFPz5MBCwiutOrz++DLdbr4rTzBsbBuV2VpgU9kk=
|
||||
github.com/hajimehoshi/oto v0.7.1/go.mod h1:wovJ8WWMfFKvP587mhHgot/MBr4DnNy9m6EepeVGnos=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/icza/bitio v1.0.0/go.mod h1:0jGnlLAx8MKMr9VGnn/4YrvZiprkvBelsVIbA9Jjr9A=
|
||||
github.com/icza/mighty v0.0.0-20180919140131-cfd07d671de6/go.mod h1:xQig96I1VNBDIWGCdTt54nHt6EeI639SmHycLYL7FkA=
|
||||
github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU=
|
||||
github.com/jfreymuth/oggvorbis v1.0.1 h1:NT0eXBgE2WHzu6RT/6zcb2H10Kxj6Fm3PccT0LE6bqw=
|
||||
github.com/jfreymuth/oggvorbis v1.0.1/go.mod h1:NqS+K+UXKje0FUYUPosyQ+XTVvjmVjps1aEZH1sumIk=
|
||||
github.com/jfreymuth/vorbis v1.0.0 h1:SmDf783s82lIjGZi8EGUUaS7YxPHgRj4ZXW/h7rUi7U=
|
||||
github.com/jfreymuth/vorbis v1.0.0/go.mod h1:8zy3lUAm9K/rJJk223RKy6vjCZTWC61NA2QD06bfOE0=
|
||||
github.com/jinzhu/gorm v1.9.16 h1:+IyIjPEABKRpsu/F8OvDPy9fyQlgsg2luMV2ZIH5i5o=
|
||||
github.com/jinzhu/gorm v1.9.16/go.mod h1:G3LB3wezTOWM2ITLzPxEXgSkOXAntiLHS7UdBefADcs=
|
||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||
@@ -150,6 +173,7 @@ github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4=
|
||||
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lucas-clemente/quic-go v0.27.2 h1:zsMwwniyybb8B/UDNXRSYee7WpQJVOcjQEGgpw2ikXs=
|
||||
github.com/lucas-clemente/quic-go v0.27.2/go.mod h1:vXgO/11FBSKM+js1NxoaQ/bPtVFYfB7uxhfHXyMhl1A=
|
||||
github.com/lucasb-eyer/go-colorful v1.0.2/go.mod h1:0MS4r+7BZKSJ5mw4/S5MPN+qHFF1fYclkSPilDOKW0s=
|
||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
|
||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
|
||||
github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=
|
||||
@@ -165,9 +189,12 @@ github.com/marten-seemann/qtls-go1-18 v0.1.2/go.mod h1:mJttiymBAByA49mhlNZZGrH5u
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||
github.com/mattn/go-sqlite3 v1.14.0 h1:mLyGNKR8+Vv9CAU7PphKa2hkEqxxhn8i32J6FPj1/QA=
|
||||
github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/mewkiz/flac v1.0.7/go.mod h1:yU74UH277dBUpqxPouHSQIar3G1X/QIclVbFahSd1pU=
|
||||
github.com/mewkiz/pkg v0.0.0-20190919212034-518ade7978e2/go.mod h1:3E2FUC/qYUfM8+r9zAwpeHJzqRVVMIYnpzD/clwWxyA=
|
||||
github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
@@ -191,8 +218,9 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y
|
||||
github.com/onsi/gomega v1.13.0 h1:7lLHu94wT9Ij0o6EWWclhu0aOh32VxhkwEJvzuWPeak=
|
||||
github.com/onsi/gomega v1.13.0/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je41yGY=
|
||||
github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8=
|
||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkumza/numcn v1.0.0 h1:ZT5cf9IJkUZgRgEtCiNNykk0RwsrKXSTsvDHOwUTzgE=
|
||||
github.com/pkumza/numcn v1.0.0/go.mod h1:QSeH+al9dWCd8di5HZM/ZqHqhZmUKfph572e9Ev/ETc=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
@@ -277,6 +305,10 @@ golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPh
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8 h1:idBdZTd9UioThJp8KpM/rTSinK/ChZFBE43/WtIy8zg=
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/image v0.0.0-20190220214146-31aff87c08e9/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
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-20220722155232-062f8c9fd539 h1:/eM0PCrQI2xd471rI+snWuu251/+/jpBpZqir2mPdnU=
|
||||
@@ -284,6 +316,8 @@ golang.org/x/image v0.0.0-20220722155232-062f8c9fd539/go.mod h1:doUCurBvlfPMKfmI
|
||||
golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/mobile v0.0.0-20190415191353-3e0bab5405d6 h1:vyLBGJPIl9ZYbcQFM2USFmJBK6KI+t+z6jL0lbwjrnc=
|
||||
golang.org/x/mobile v0.0.0-20190415191353-3e0bab5405d6/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
|
||||
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/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
@@ -325,8 +359,11 @@ golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5h
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190316082340-a2f829d7f35f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190429190828-d89cdac9e872/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
var (
|
||||
info = [...]string{
|
||||
"* OneBot + ZeroBot + Golang",
|
||||
"* Version 1.5.0-beta5 - 2022-07-22 15:39:17 +0800 CST",
|
||||
"* Version 1.5.1-beta1 - 2022-09-01 21:28:59 +0800 CST",
|
||||
"* Copyright © 2020 - 2022 FloatTech. All Rights Reserved.",
|
||||
"* Project: https://github.com/FloatTech/ZeroBot-Plugin",
|
||||
}
|
||||
|
||||
8
main.go
8
main.go
@@ -24,8 +24,8 @@ import (
|
||||
// vvvvvvv高优先级区vvvvvvv //
|
||||
// vvvvvvvvvvvvvv //
|
||||
// vvvv //
|
||||
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/chat" // 基础词库
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/antiabuse" // 违禁词
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/chat" // 基础词库
|
||||
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/sleep_manage" // 统计睡眠时间
|
||||
|
||||
@@ -55,12 +55,14 @@ import (
|
||||
// vvvvvvvvvvvvvv //
|
||||
// vvvv //
|
||||
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ahsai" // ahsai tts
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ai_false" // 服务器监控
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/aiwife" // 随机老婆
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/b14" // base16384加解密
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/baidu" // 百度一下
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/bilibili" // b站相关
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/book_review" // 哀伤雪刃吧推书记录
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/breakrepeat" // 打断复读
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/cangtoushi" // 藏头诗
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/char_reverser" // 英文字符翻转
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/choose" // 选择困难症帮手
|
||||
@@ -153,7 +155,7 @@ import (
|
||||
// //
|
||||
// //
|
||||
// -----------------------以下为内置依赖,勿动------------------------ //
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
"github.com/FloatTech/floatbox/process"
|
||||
"github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/driver"
|
||||
|
||||
92
plugin/ahsai/ahsai.go
Normal file
92
plugin/ahsai/ahsai.go
Normal file
@@ -0,0 +1,92 @@
|
||||
// Package ahsai AH Soft フリーテキスト音声合成 demo API
|
||||
package ahsai
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"sort"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
ahsaitts "github.com/fumiama/ahsai"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
var (
|
||||
namelist = []string{"伊織弓鶴", "紲星あかり", "結月ゆかり", "京町セイカ", "東北きりたん", "東北イタコ", "ついなちゃん標準語", "ついなちゃん関西弁", "音街ウナ", "琴葉茜", "吉田くん", "民安ともえ", "桜乃そら", "月読アイ", "琴葉葵", "東北ずん子", "月読ショウタ", "水奈瀬コウ"}
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("ahsai", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "ahsai tts\n- 使[伊織弓鶴|紲星あかり|結月ゆかり|京町セイカ|東北きりたん|東北イタコ|ついなちゃん標準語|ついなちゃん関西弁|音街ウナ|琴葉茜|吉田くん|民安ともえ|桜乃そら|月読アイ|琴葉葵|東北ずん子|月読ショウタ|水奈瀬コウ]说(日语)\n",
|
||||
PrivateDataFolder: "ahsai",
|
||||
})
|
||||
cachePath := engine.DataFolder() + "cache/"
|
||||
_ = os.RemoveAll(cachePath)
|
||||
_ = os.MkdirAll(cachePath, 0755)
|
||||
engine.OnRegex("^使(.{0,10})说([A-Za-z\\s\\d\u3005\u3040-\u30ff\u4e00-\u9fff\uff11-\uff19\uff21-\uff3a\uff41-\uff5a\uff66-\uff9d\\pP]+)$", selectName).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SendChain(message.Text("少女祈祷中..."))
|
||||
uid := ctx.Event.UserID
|
||||
today := time.Now().Format("20060102150405")
|
||||
ahsaiFile := cachePath + strconv.FormatInt(uid, 10) + today + "ahsai.wav"
|
||||
s := ahsaitts.NewSpeaker()
|
||||
err := s.SetName(ctx.State["ahsainame"].(string))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("Error:", err))
|
||||
return
|
||||
}
|
||||
u, err := s.Speak(ctx.State["ahsaitext"].(string))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("Error:", err))
|
||||
return
|
||||
}
|
||||
err = ahsaitts.SaveOggToFile(u, ahsaiFile)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("Error:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Record("file:///" + file.BOTPATH + "/" + ahsaiFile))
|
||||
})
|
||||
}
|
||||
|
||||
func selectName(ctx *zero.Ctx) bool {
|
||||
regexMatched := ctx.State["regex_matched"].([]string)
|
||||
ctx.State["ahsaitext"] = regexMatched[2]
|
||||
name := regexMatched[1]
|
||||
sort.Strings(namelist)
|
||||
index := sort.SearchStrings(namelist, name)
|
||||
if index < len(namelist) && namelist[index] == name {
|
||||
ctx.State["ahsainame"] = name
|
||||
return true
|
||||
}
|
||||
speaktext := ""
|
||||
for i, v := range namelist {
|
||||
speaktext += fmt.Sprintf("%d. %s\n", i, v)
|
||||
}
|
||||
ctx.SendChain(message.Text("输入的音源为空, 请输入音源序号\n", speaktext))
|
||||
next, cancel := zero.NewFutureEvent("message", 999, false, ctx.CheckSession(), zero.RegexRule(`\d{0,2}`)).Repeat()
|
||||
defer cancel()
|
||||
for {
|
||||
select {
|
||||
case <-time.After(time.Second * 10):
|
||||
ctx.State["ahsainame"] = namelist[rand.Intn(len(namelist))]
|
||||
ctx.SendChain(message.Text("时间太久啦!", zero.BotConfig.NickName[0], "帮你选择", ctx.State["ahsainame"]))
|
||||
return true
|
||||
case c := <-next:
|
||||
msg := c.Event.Message.ExtractPlainText()
|
||||
num, _ := strconv.Atoi(msg)
|
||||
if num < 0 || num >= len(namelist) {
|
||||
ctx.SendChain(message.Text("序号非法!"))
|
||||
continue
|
||||
}
|
||||
ctx.State["ahsainame"] = namelist[num]
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,34 +50,34 @@ func init() { // 插件主体
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
c, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
|
||||
if !ok {
|
||||
ctx.SendChain(message.Text("ERROR:no such plugin"))
|
||||
ctx.SendChain(message.Text("ERROR: no such plugin"))
|
||||
return
|
||||
}
|
||||
m, err := strconv.ParseInt(ctx.State["regex_matched"].([]string)[1], 10, 64)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if ctx.State["regex_matched"].([]string)[2] == "分钟" {
|
||||
m *= 60
|
||||
}
|
||||
if m >= 65536 || m <= 0 {
|
||||
ctx.SendChain(message.Text("ERROR:interval too big"))
|
||||
ctx.SendChain(message.Text("ERROR: interval too big"))
|
||||
return
|
||||
}
|
||||
n, err := strconv.ParseInt(ctx.State["regex_matched"].([]string)[3], 10, 64)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if n >= 65536 || n <= 0 {
|
||||
ctx.SendChain(message.Text("ERROR:burst too big"))
|
||||
ctx.SendChain(message.Text("ERROR: burst too big"))
|
||||
return
|
||||
}
|
||||
ctxext.SetDefaultLimiterManagerParam(time.Duration(m)*time.Second, int(n))
|
||||
err = c.SetData(0, (m&0xffff)|((n<<16)&0xffff0000))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("设置默认限速为每", m, "秒触发", n, "次"))
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package aireply
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/pkumza/numcn"
|
||||
log "github.com/sirupsen/logrus"
|
||||
@@ -11,171 +14,246 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/aireply"
|
||||
"github.com/FloatTech/AnimeAPI/tts"
|
||||
"github.com/FloatTech/AnimeAPI/tts/baidutts"
|
||||
"github.com/FloatTech/AnimeAPI/tts/mockingbird"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
)
|
||||
|
||||
const ttsServiceName = "tts"
|
||||
const (
|
||||
ttsServiceName = "tts"
|
||||
cnapi = "http://233366.proxy.nscc-gz.cn:8888?speaker=%s&text=%s"
|
||||
// testString = "这是测试语言......"
|
||||
)
|
||||
|
||||
var re = regexp.MustCompile(`(\-|\+)?\d+(\.\d+)?`)
|
||||
// 每个角色的测试文案
|
||||
var testRecord = map[string]string{
|
||||
"派蒙": "哎,又是看不懂的东西。我完全不知道这些奇怪的问题和实验,能得到什么结果…",
|
||||
"凯亚": "真是个急性子啊你。",
|
||||
"安柏": "最初的鸟儿是不会飞翔的,飞翔是它们勇敢跃入峡谷的奖励。",
|
||||
"丽莎": "嗨,小可爱,你是新来的助理吗?",
|
||||
"琴": "蒲公英骑士,琴,申请入队。",
|
||||
"香菱": "我是来自璃月的厨师香菱,最擅长的是做各种捞…捞,料理…哎呀,练了那么多次,还是会紧张,嘿。",
|
||||
"枫原万叶": "飘摇风雨中,带刀归来赤脚行。",
|
||||
"迪卢克": "在黎明来临之前,总要有人照亮黑暗。",
|
||||
"温迪": "若你困于无风之地,我将为你奏响高天之歌。",
|
||||
"可莉": "西风骑士团,火花骑士,可莉,前来报到!…呃—后面该说什么词来着?可莉背不下来啦...",
|
||||
"早柚": "终末番,早柚,参上。 呼——",
|
||||
"托马": "初次见面,异乡的旅人,你的名字我可是早就听说了。只要你不嫌弃,我托马,从今天起就是你的朋友了。",
|
||||
"芭芭拉": "芭芭拉,闪耀登场~治疗就交给我吧,不会让你失望的!",
|
||||
"优菈": "沉沦是很容易的一件事,但我仍想冻住这股潮流。",
|
||||
"云堇": "曲高未必人不识,自有知音和清词。",
|
||||
"钟离": "人间归离复归离,借一浮生逃浮生。",
|
||||
"魈": "三眼五显仙人,魈,听召,前来守护",
|
||||
"凝光": "就算古玩价值连城,给人的快乐,也只有刚拥有的一瞬",
|
||||
"雷电将军": "浮世千百年来风景依旧,人之在世却如白露与泡影。",
|
||||
"北斗": "不知道如何向前的话,总之先迈出第一步,后面的道路就会自然而然地展开了。",
|
||||
"甘雨": "这项工作,该划掉了。",
|
||||
"七七": "椰羊的奶,好喝!比一般的羊奶,好喝!",
|
||||
"刻晴": "劳逸结合是不错,但也别放松过头。",
|
||||
"神里绫华": "若知是梦何须醒,不比真如一相会。",
|
||||
"雷泽": "你是朋友。我和你一起狩猎。",
|
||||
"神里绫人": "此前听绫华屡次提起阁下,不料公务繁忙,直至今日才有机会相见。",
|
||||
"罗莎莉亚": "哪怕如今你已经走上截然不同的道路,也不要否认从前的自己,从前的每一个你都是你脚下的基石,不要害怕过去,不要畏惧与它抗衡。",
|
||||
"阿贝多": "用自己的双脚丈量土地,将未知变为知识。",
|
||||
"八重神子": "我的神明,就托付给你了。",
|
||||
"宵宫": "即使只是片刻的火花,也能在仰望黑夜的人心中留下久久不灭的美丽光芒。",
|
||||
"荒泷一斗": "更好地活下去,绝不该靠牺牲同类换取,应该是,一起更好地活着,才对。",
|
||||
"九条裟罗": "想要留住雪花。但在手心里,它只会融化的更快。",
|
||||
"夜兰": "线人来信了,嗯,看来又出现了新的变数。",
|
||||
"珊瑚宫心海": "成为了现任人神巫女之后,我也慢慢习惯了这样的生活,更重要的是我也因此和你相遇了,不是吗?",
|
||||
"五郎": "海祇岛反抗军大将,五郎,前来助阵!",
|
||||
"达达利亚": "许下的诺言就好好遵守,做错了事情就承担责任,这才是家人应有的样子吧。",
|
||||
"莫娜": "正是因为无法更改,无可违逆,只能接受,命运才会被称之为命运。",
|
||||
"班尼特": "只要有大家在,伤口就不会痛!",
|
||||
"申鹤": "不知道你是喜欢人间的灯火,还是山林的月光?",
|
||||
"行秋": "有时明月无人夜,独向昭潭制恶龙。",
|
||||
"烟绯": "律法即是约束,也是工具。",
|
||||
"久岐忍": "有麻烦事要处理的话,直接告诉我就好,我来摆平。",
|
||||
"辛焱": "马上就要演出了,你也一起来嗨吗?",
|
||||
"砂糖": "我是砂糖,炼金术的…研究员。",
|
||||
"胡桃": "阴阳有序,命运无常,死亡难以预测,却也有它的规矩。",
|
||||
"重云": "我名重云,家族久居璃月,世代以驱邪除魔为业。",
|
||||
"菲谢尔": "我即断罪之皇女,真名为菲谢尔。应命运的召唤降临在此间——哎?你也是,异世界的旅人吗…?",
|
||||
"诺艾尔": "我是诺艾尔,西风骑士团的女仆,从今天起会陪你一起去冒险。",
|
||||
"迪奥娜": "猫尾酒馆的招牌调酒师,迪奥娜,我的出场费可是很贵的。",
|
||||
"鹿野院平藏": "我叫鹿野院平藏,是天领奉行里破案最多最快的侦探……",
|
||||
}
|
||||
|
||||
var (
|
||||
re = regexp.MustCompile(`(\-|\+)?\d+(\.\d+)?`)
|
||||
soundList = [...]string{
|
||||
"派蒙", "凯亚", "安柏", "丽莎", "琴",
|
||||
"香菱", "枫原万叶", "迪卢克", "温迪", "可莉",
|
||||
"早柚", "托马", "芭芭拉", "优菈", "云堇",
|
||||
"钟离", "魈", "凝光", "雷电将军", "北斗",
|
||||
"甘雨", "七七", "刻晴", "神里绫华", "雷泽",
|
||||
"神里绫人", "罗莎莉亚", "阿贝多", "八重神子", "宵宫",
|
||||
"荒泷一斗", "九条裟罗", "夜兰", "珊瑚宫心海", "五郎",
|
||||
"达达利亚", "莫娜", "班尼特", "申鹤", "行秋",
|
||||
"烟绯", "久岐忍", "辛焱", "砂糖", "胡桃",
|
||||
"重云", "菲谢尔", "诺艾尔", "迪奥娜", "鹿野院平藏",
|
||||
}
|
||||
)
|
||||
|
||||
type ttsInstances struct {
|
||||
sync.RWMutex
|
||||
m map[string]tts.TTS
|
||||
l []string
|
||||
defaultSoundMode string
|
||||
soundMode []string
|
||||
}
|
||||
|
||||
func (t *ttsInstances) List() []string {
|
||||
t.RLock()
|
||||
cl := make([]string, len(t.l))
|
||||
_ = copy(cl, t.l)
|
||||
t.RUnlock()
|
||||
return cl
|
||||
func list(list []string, num int) string {
|
||||
s := ""
|
||||
for i, value := range list {
|
||||
s += value
|
||||
if (i+1)%num == 0 {
|
||||
s += "\n"
|
||||
} else {
|
||||
s += " | "
|
||||
}
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
func init() {
|
||||
t := &ttsInstances{
|
||||
m: map[string]tts.TTS{
|
||||
"百度女声": baidutts.NewBaiduTTS(0),
|
||||
"百度男声": baidutts.NewBaiduTTS(1),
|
||||
"百度度逍遥": baidutts.NewBaiduTTS(3),
|
||||
"百度度丫丫": baidutts.NewBaiduTTS(4),
|
||||
"拟声鸟阿梓": nil,
|
||||
"拟声鸟文静": nil,
|
||||
"拟声鸟药水哥": nil,
|
||||
},
|
||||
l: []string{"拟声鸟阿梓", "拟声鸟文静", "拟声鸟药水哥", "百度女声", "百度男声", "百度度逍遥", "百度度丫丫"},
|
||||
tts := &ttsInstances{
|
||||
defaultSoundMode: "派蒙",
|
||||
soundMode: soundList[:],
|
||||
}
|
||||
engine := control.Register(ttsServiceName, &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: true,
|
||||
Help: "语音回复(包括拟声鸟和百度)\n" +
|
||||
Help: "语音回复(大家一起来炼丹)\n" +
|
||||
"- @Bot 任意文本(任意一句话回复)\n" +
|
||||
"- 设置语音模式[拟声鸟阿梓 | 拟声鸟文静 | 拟声鸟药水哥 | 百度女声 | 百度男声| 百度度逍遥 | 百度度丫丫]\n" +
|
||||
"- 设置默认语音模式[拟声鸟阿梓 | 拟声鸟文静 | 拟声鸟药水哥 | 百度女声 | 百度男声| 百度度逍遥 | 百度度丫丫]\n",
|
||||
"- 设置语音模式[原神人物]\n" +
|
||||
"- 设置默认语音模式[原神人物]\n" +
|
||||
"当前适用的原神人物含有以下:\n" + list(soundList[:], 5),
|
||||
})
|
||||
engine.OnMessage(zero.OnlyToMe).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
msg := ctx.ExtractPlainText()
|
||||
// 获取回复模式
|
||||
r := aireply.NewAIReply(getReplyMode(ctx))
|
||||
tts, err := t.new(t.getSoundMode(ctx))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
// 获取回复的文本
|
||||
reply := r.TalkPlain(msg, zero.BotConfig.NickName[0])
|
||||
// 获取角色
|
||||
name := tts.getSoundMode(ctx)
|
||||
if _, ok := testRecord[name]; !ok {
|
||||
ctx.SendChain(message.Text("配置的语言人物数据丢失!请重新设置语言人物。"))
|
||||
return
|
||||
}
|
||||
var reply string
|
||||
if tts != nil {
|
||||
rec, err := tts.Speak(ctx.Event.UserID, func() string {
|
||||
reply = r.TalkPlain(msg, zero.BotConfig.NickName[0])
|
||||
reply = re.ReplaceAllStringFunc(reply, func(s string) string {
|
||||
f, err := strconv.ParseFloat(s, 64)
|
||||
if err != nil {
|
||||
log.Errorln("[tts]:", err)
|
||||
return s
|
||||
}
|
||||
return numcn.EncodeFromFloat64(f)
|
||||
})
|
||||
log.Debugln("[tts]:", reply)
|
||||
return reply
|
||||
})
|
||||
if err == nil {
|
||||
ctx.SendChain(message.Record(rec))
|
||||
} else {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(reply))
|
||||
}
|
||||
// 获取语言
|
||||
record := message.Record(fmt.Sprintf(cnapi, url.QueryEscape(name), url.QueryEscape(
|
||||
// 将数字转文字
|
||||
re.ReplaceAllStringFunc(reply, func(s string) string {
|
||||
f, err := strconv.ParseFloat(s, 64)
|
||||
if err != nil {
|
||||
log.Errorln("[tts]:", err)
|
||||
return s
|
||||
}
|
||||
return numcn.EncodeFromFloat64(f)
|
||||
}),
|
||||
))).Add("cache", 0)
|
||||
if record.Data == nil {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(reply))
|
||||
}
|
||||
// 发送语音
|
||||
if ID := ctx.SendChain(record); ID.ID() == 0 {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(reply))
|
||||
}
|
||||
})
|
||||
engine.OnRegex(`^设置语音模式(.*)$`, ctxext.ValueInList(func(ctx *zero.Ctx) string { return ctx.State["regex_matched"].([]string)[1] }, t)).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
param := ctx.State["regex_matched"].([]string)[1]
|
||||
err := t.setSoundMode(ctx, param)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("设置成功,当前模式为", param))
|
||||
})
|
||||
engine.OnRegex(`^设置默认语音模式(.*)$`, ctxext.ValueInList(func(ctx *zero.Ctx) string { return ctx.State["regex_matched"].([]string)[1] }, t)).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
param := ctx.State["regex_matched"].([]string)[1]
|
||||
t.setDefaultSoundMode(param)
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("设置成功,默认模式为", param))
|
||||
})
|
||||
}
|
||||
|
||||
// new 语音简单工厂
|
||||
func (t *ttsInstances) new(name string) (ts tts.TTS, err error) {
|
||||
t.RLock()
|
||||
ts = t.m[name]
|
||||
t.RUnlock()
|
||||
if ts == nil {
|
||||
switch name {
|
||||
case "拟声鸟阿梓":
|
||||
t.Lock()
|
||||
ts, err = mockingbird.NewMockingBirdTTS(0)
|
||||
t.Unlock()
|
||||
case "拟声鸟文静":
|
||||
t.Lock()
|
||||
ts, err = mockingbird.NewMockingBirdTTS(1)
|
||||
t.Unlock()
|
||||
case "拟声鸟药水哥":
|
||||
t.Lock()
|
||||
ts, err = mockingbird.NewMockingBirdTTS(2)
|
||||
t.Unlock()
|
||||
engine.OnRegex(`^设置语音模式(.*)$`, func(ctx *zero.Ctx) bool {
|
||||
param := ctx.State["regex_matched"].([]string)[1]
|
||||
if _, ok := testRecord[param]; !ok {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return
|
||||
return true
|
||||
}).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
param := ctx.State["regex_matched"].([]string)[1]
|
||||
// 保存设置
|
||||
err := tts.setSoundMode(ctx, param)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(err))
|
||||
return
|
||||
}
|
||||
// 设置验证
|
||||
name := tts.getSoundMode(ctx)
|
||||
if _, ok := testRecord[name]; !ok {
|
||||
ctx.SendChain(message.Text("配置的语言人物数据丢失!请重新设置语言人物。"))
|
||||
return
|
||||
}
|
||||
record := message.Record(fmt.Sprintf(cnapi, url.QueryEscape(name), url.QueryEscape(testRecord[name]))).Add("cache", 0)
|
||||
if ID := ctx.SendChain(record); ID.ID() == 0 {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("设置失败!无法发送测试语言,请重试。"))
|
||||
return
|
||||
}
|
||||
time.Sleep(time.Second * 2)
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("设置成功,默认模式为", name))
|
||||
})
|
||||
engine.OnRegex(`^设置默认语音模式(.*)$`, func(ctx *zero.Ctx) bool {
|
||||
param := ctx.State["regex_matched"].([]string)[1]
|
||||
if _, ok := testRecord[param]; !ok {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
param := ctx.State["regex_matched"].([]string)[1]
|
||||
// 保存设置
|
||||
tts.setDefaultSoundMode(param)
|
||||
// 设置验证
|
||||
name := tts.defaultSoundMode
|
||||
record := message.Record(fmt.Sprintf(cnapi, url.QueryEscape(name), url.QueryEscape(testRecord[name]))).Add("cache", 0)
|
||||
if ID := ctx.SendChain(record); ID.ID() == 0 {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("设置失败!无法发送测试语言,请重试。"))
|
||||
return
|
||||
}
|
||||
time.Sleep(time.Second * 2)
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("设置成功,默认模式为", name))
|
||||
})
|
||||
}
|
||||
|
||||
func (t *ttsInstances) setSoundMode(ctx *zero.Ctx, name string) error {
|
||||
func (tts *ttsInstances) setSoundMode(ctx *zero.Ctx, name string) error {
|
||||
gid := ctx.Event.GroupID
|
||||
if gid == 0 {
|
||||
gid = -ctx.Event.UserID
|
||||
}
|
||||
var index int64
|
||||
t.RLock()
|
||||
for i, s := range t.l {
|
||||
tts.RLock()
|
||||
for i, s := range tts.soundMode {
|
||||
if s == name {
|
||||
index = int64(i)
|
||||
break
|
||||
}
|
||||
}
|
||||
t.RUnlock()
|
||||
tts.RUnlock()
|
||||
m := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
|
||||
return m.SetData(gid, index)
|
||||
}
|
||||
|
||||
func (t *ttsInstances) getSoundMode(ctx *zero.Ctx) (name string) {
|
||||
func (tts *ttsInstances) getSoundMode(ctx *zero.Ctx) (name string) {
|
||||
gid := ctx.Event.GroupID
|
||||
if gid == 0 {
|
||||
gid = -ctx.Event.UserID
|
||||
}
|
||||
m, ok := ctx.State["manager"].(*ctrl.Control[*zero.Ctx])
|
||||
if ok {
|
||||
t.RLock()
|
||||
defer t.RUnlock()
|
||||
tts.RLock()
|
||||
defer tts.RUnlock()
|
||||
index := m.GetData(gid)
|
||||
if int(index) < len(t.l) {
|
||||
return t.l[index]
|
||||
if int(index) < len(tts.soundMode) {
|
||||
return tts.soundMode[index]
|
||||
}
|
||||
}
|
||||
return "拟声鸟阿梓"
|
||||
return tts.defaultSoundMode
|
||||
}
|
||||
|
||||
func (t *ttsInstances) setDefaultSoundMode(name string) {
|
||||
var index int
|
||||
t.RLock()
|
||||
for _, s := range t.l {
|
||||
func (tts *ttsInstances) setDefaultSoundMode(name string) {
|
||||
var index int64
|
||||
tts.RLock()
|
||||
for i, s := range tts.soundMode {
|
||||
if s == name {
|
||||
index = int64(i)
|
||||
break
|
||||
}
|
||||
index++
|
||||
}
|
||||
t.RUnlock()
|
||||
t.Lock()
|
||||
t.l[0], t.l[index] = t.l[index], t.l[0]
|
||||
t.Unlock()
|
||||
tts.defaultSoundMode = tts.soundMode[index]
|
||||
tts.RUnlock()
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ func init() { // 插件主体
|
||||
engine := control.Register(replyServiceName, &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "人工智能回复\n" +
|
||||
"- @Bot 任意文本(任意一句话回复)\n- 设置回复模式[青云客 | 小爱]\n- ",
|
||||
"- @Bot 任意文本(任意一句话回复)\n- 设置回复模式[青云客|小爱]",
|
||||
})
|
||||
// 回复 @和包括名字
|
||||
engine.OnMessage(zero.OnlyToMe).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
|
||||
76
plugin/antiabuse/anti.go
Normal file
76
plugin/antiabuse/anti.go
Normal file
@@ -0,0 +1,76 @@
|
||||
// Package antiabuse defines anti_abuse plugin ,support abuse words check and add/remove abuse words
|
||||
package antiabuse
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("anti_abuse", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "违禁词检测",
|
||||
PrivateDataFolder: "anti_abuse",
|
||||
})
|
||||
onceRule := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
db.DBPath = engine.DataFolder() + "anti_abuse.db"
|
||||
err := db.Open(time.Hour * 4)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("open db error: ", err))
|
||||
return false
|
||||
}
|
||||
err = db.Create("banUser", &banUser{})
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("create table error: ", err))
|
||||
return false
|
||||
}
|
||||
err = db.Create("banWord", &banWord{})
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("create table error: ", err))
|
||||
return false
|
||||
}
|
||||
err = recoverUser()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("recover data error: ", err))
|
||||
return false
|
||||
}
|
||||
err = recoverWord()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("recover data error: ", err))
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
engine.OnMessage(zero.OnlyGroup, onceRule, banRule)
|
||||
engine.OnCommand("添加违禁词", zero.OnlyGroup, zero.AdminPermission, onceRule).Handle(
|
||||
func(ctx *zero.Ctx) {
|
||||
if err := insertWord(ctx.Event.GroupID, ctx.State["args"].(string)); err != nil {
|
||||
ctx.SendChain(message.Text("add ban word error:", err))
|
||||
}
|
||||
})
|
||||
engine.OnCommand("删除违禁词", zero.OnlyGroup, zero.AdminPermission, onceRule).Handle(
|
||||
func(ctx *zero.Ctx) {
|
||||
if err := deleteWord(ctx.Event.GroupID, ctx.State["args"].(string)); err != nil {
|
||||
ctx.SendChain(message.Text("add ban word error:", err))
|
||||
}
|
||||
})
|
||||
engine.OnCommand("查看违禁词", zero.OnlyGroup, onceRule).Handle(
|
||||
func(ctx *zero.Ctx) {
|
||||
gidPrefix := fmt.Sprintf("%d-", ctx.Event.GroupID)
|
||||
var words []string
|
||||
_ = wordSet.Iter(func(s string) error {
|
||||
trueWord := strings.SplitN(s, gidPrefix, 1)[1]
|
||||
words = append(words, trueWord)
|
||||
return nil
|
||||
})
|
||||
ctx.SendChain(message.Text("本群违禁词有:\n", strings.Join(words, " |")))
|
||||
})
|
||||
|
||||
}
|
||||
81
plugin/antiabuse/database.go
Normal file
81
plugin/antiabuse/database.go
Normal file
@@ -0,0 +1,81 @@
|
||||
package antiabuse
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
sqlite "github.com/FloatTech/sqlite"
|
||||
)
|
||||
|
||||
var db = &sqlite.Sqlite{}
|
||||
|
||||
type banUser struct {
|
||||
UUID string `db:"uuid"`
|
||||
DueTime int64 `db:"due_time"`
|
||||
}
|
||||
|
||||
func insertUser(gid, uid int64) error {
|
||||
obj := &banUser{fmt.Sprintf("%d-%d", gid, uid), time.Now().Add(4 * time.Hour).UnixNano()}
|
||||
return db.Insert("banUser", obj)
|
||||
}
|
||||
|
||||
func deleteUser(gid, uid int64) error {
|
||||
sql := fmt.Sprintf("WHERE uuid=%d-%d", gid, uid)
|
||||
return db.Del("banUser", sql)
|
||||
}
|
||||
|
||||
func recoverUser() error {
|
||||
if !db.CanFind("banUser", "") {
|
||||
return nil
|
||||
}
|
||||
obj := &banUser{}
|
||||
var uuids []string
|
||||
err := db.FindFor("banUser", obj, "", func() error {
|
||||
if time.Now().UnixNano() < obj.DueTime {
|
||||
uuids = append(uuids, obj.UUID)
|
||||
} else {
|
||||
if err := db.Del("banUser", "WHERE uuid="+obj.UUID); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
banSet.AddMany(uuids)
|
||||
return nil
|
||||
}
|
||||
|
||||
type banWord struct {
|
||||
GroupWord string `db:"group_word"`
|
||||
}
|
||||
|
||||
func insertWord(gid int64, word string) error {
|
||||
obj := &banWord{fmt.Sprintf("%d-%s", gid, word)}
|
||||
return db.Insert("banWord", obj)
|
||||
}
|
||||
|
||||
func deleteWord(gid int64, word string) error {
|
||||
sql := fmt.Sprintf("WHERE group_word = %d-%s", gid, word)
|
||||
return db.Del("banWord", sql)
|
||||
}
|
||||
|
||||
func recoverWord() error {
|
||||
if !db.CanFind("banWord", "") {
|
||||
return nil
|
||||
}
|
||||
obj := &banWord{}
|
||||
var groupWords []string
|
||||
err := db.FindFor("banWord", obj, "", func() error {
|
||||
groupWords = append(groupWords, obj.GroupWord)
|
||||
return nil
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
wordSet.AddMany(groupWords)
|
||||
return nil
|
||||
}
|
||||
57
plugin/antiabuse/set.go
Normal file
57
plugin/antiabuse/set.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package antiabuse
|
||||
|
||||
import "sync"
|
||||
|
||||
//Set defines HashSet structure
|
||||
type Set struct {
|
||||
sync.RWMutex
|
||||
m map[string]struct{}
|
||||
}
|
||||
|
||||
var banSet = &Set{m: make(map[string]struct{})}
|
||||
var wordSet = &Set{m: make(map[string]struct{})}
|
||||
|
||||
// Add adds element to Set
|
||||
func (s *Set) Add(key string) {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
s.m[key] = struct{}{}
|
||||
}
|
||||
|
||||
// Include asserts element in Set
|
||||
func (s *Set) Include(key string) bool {
|
||||
s.RLock()
|
||||
defer s.RUnlock()
|
||||
_, ok := s.m[key]
|
||||
return ok
|
||||
}
|
||||
|
||||
// Iter calls f when traversing Set
|
||||
func (s *Set) Iter(f func(string) error) error {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
var err error
|
||||
for key := range s.m {
|
||||
err = f(key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Remove removes element from Set
|
||||
func (s *Set) Remove(key string) {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
delete(s.m, key)
|
||||
}
|
||||
|
||||
// AddMany adds multiple elements to Set
|
||||
func (s *Set) AddMany(keys []string) {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
for _, k := range keys {
|
||||
s.m[k] = struct{}{}
|
||||
}
|
||||
}
|
||||
47
plugin/antiabuse/utils.go
Normal file
47
plugin/antiabuse/utils.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package antiabuse
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
func banRule(ctx *zero.Ctx) bool {
|
||||
if !ctx.Event.IsToMe {
|
||||
return false
|
||||
}
|
||||
gid := ctx.Event.GroupID
|
||||
uid := ctx.Event.UserID
|
||||
uuid := fmt.Sprintf("%d-%d", gid, uid)
|
||||
if banSet.Include(uuid) {
|
||||
return false
|
||||
}
|
||||
gidPrefix := fmt.Sprintf("%d-", ctx.Event.GroupID)
|
||||
var words []string
|
||||
_ = wordSet.Iter(func(s string) error {
|
||||
trueWord := strings.SplitN(s, gidPrefix, 1)[1]
|
||||
words = append(words, trueWord)
|
||||
return nil
|
||||
})
|
||||
for _, word := range words {
|
||||
if strings.Contains(ctx.MessageString(), word) {
|
||||
if err := insertUser(gid, uid); err != nil {
|
||||
ctx.SendChain(message.Text("ban error: ", err))
|
||||
}
|
||||
banSet.Add(uuid)
|
||||
ctx.SetGroupBan(gid, uid, 4*3600)
|
||||
time.AfterFunc(4*time.Hour, func() {
|
||||
banSet.Remove(uuid)
|
||||
if err := deleteUser(gid, uid); err != nil {
|
||||
ctx.SendChain(message.Text("ban error: ", err))
|
||||
}
|
||||
})
|
||||
ctx.SendChain(message.Text("检测到违禁词,已封禁/屏蔽4小时"))
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -12,9 +12,9 @@ import (
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/floatbox/process"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/FloatTech/zbputils/binary"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
@@ -18,19 +18,32 @@ var (
|
||||
|
||||
// searchUser 查找b站用户
|
||||
func searchUser(keyword string) (r []searchResult, err error) {
|
||||
data, err := web.GetData(fmt.Sprintf(searchUserURL, keyword))
|
||||
client := &http.Client{}
|
||||
req, err := http.NewRequest("GET", fmt.Sprintf(searchUserURL, keyword), nil)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
j := gjson.ParseBytes(data)
|
||||
if j.Get("data.numResults").Int() == 0 {
|
||||
err = errors.New("查无此人")
|
||||
return
|
||||
}
|
||||
err = json.Unmarshal(binary.StringToBytes(j.Get("data.result").Raw), &r)
|
||||
err = reflushBilibiliCookie()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
req.Header.Add("cookie", cfg.BilibiliCookie)
|
||||
res, err := client.Do(req)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer res.Body.Close()
|
||||
if res.StatusCode != http.StatusOK {
|
||||
s := fmt.Sprintf("status code: %d", res.StatusCode)
|
||||
err = errors.New(s)
|
||||
return
|
||||
}
|
||||
var sd searchData
|
||||
err = json.NewDecoder(res.Body).Decode(&sd)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
r = sd.Data.Result
|
||||
return
|
||||
}
|
||||
|
||||
@@ -66,8 +79,11 @@ func getMedalwall(uid string) (result []medal, err error) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
c := vdb.getBilibiliCookie()
|
||||
req.Header.Add("cookie", c.Value)
|
||||
err = reflushBilibiliCookie()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
req.Header.Add("cookie", cfg.BilibiliCookie)
|
||||
res, err := client.Do(req)
|
||||
if err != nil {
|
||||
return
|
||||
|
||||
@@ -2,10 +2,13 @@
|
||||
package bilibili
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"encoding/binary"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"image"
|
||||
"image/color"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"regexp"
|
||||
@@ -14,29 +17,42 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/Coloured-glaze/gg"
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/img/writer"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"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"
|
||||
"github.com/FloatTech/zbputils/img/writer"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
log "github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
var re = regexp.MustCompile(`^\d+$`)
|
||||
var (
|
||||
re = regexp.MustCompile(`^\d+$`)
|
||||
danmakuTypeMap = map[int64]string{
|
||||
0: "普通消息",
|
||||
1: "礼物",
|
||||
2: "上舰",
|
||||
3: "Superchat",
|
||||
4: "进入直播间",
|
||||
5: "标题变动",
|
||||
}
|
||||
cfgFile = "data/Bilibili/config.json"
|
||||
cfg config
|
||||
)
|
||||
|
||||
// 查成分的
|
||||
func init() {
|
||||
engine := control.Register("bilibili", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "bilibili\n" +
|
||||
Help: "bilibili (412就是拦截的意思,建议私聊把cookie设全)\n" +
|
||||
"- >vup info [xxx]\n" +
|
||||
"- >user info [xxx]\n" +
|
||||
"- 查成分 [xxx]\n" +
|
||||
"- 查弹幕 [xxx]\n" +
|
||||
"- 设置b站cookie SESSDATA=82da790d,1663822823,06ecf*31\n" +
|
||||
"- 更新vup",
|
||||
PublicDataFolder: "Bilibili",
|
||||
@@ -44,7 +60,7 @@ func init() {
|
||||
cachePath := engine.DataFolder() + "cache/"
|
||||
_ = os.RemoveAll(cachePath)
|
||||
_ = os.MkdirAll(cachePath, 0755)
|
||||
var getdb = ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
var getdb = fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
var err error
|
||||
_, _ = engine.GetLazyData("bilibili.db", false)
|
||||
vdb, err = initializeVup(engine.DataFolder() + "bilibili.db")
|
||||
@@ -54,13 +70,12 @@ func init() {
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
engine.OnRegex(`^>user info\s?(.{1,25})$`, getPara).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
id := ctx.State["uid"].(string)
|
||||
card, err := getMemberCard(id)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text(
|
||||
@@ -79,7 +94,7 @@ func init() {
|
||||
// 获取详情
|
||||
fo, err := getVtbDetail(id)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text(
|
||||
@@ -96,7 +111,7 @@ func init() {
|
||||
))
|
||||
})
|
||||
|
||||
engine.OnRegex(`^查成分\s?(.{1,25})$`, getdb, getPara).SetBlock(true).
|
||||
engine.OnRegex(`^查成分\s?(.{1,25})$`, getPara, getdb).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
id := ctx.State["uid"].(string)
|
||||
today := time.Now().Format("20060102")
|
||||
@@ -107,19 +122,19 @@ func init() {
|
||||
}
|
||||
u, err := getMemberCard(id)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
vups, err := vdb.filterVup(u.Attentions)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
vupLen := len(vups)
|
||||
medals, err := getMedalwall(id)
|
||||
sort.Sort(medalSlice(medals))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
}
|
||||
frontVups := make([]vup, 0)
|
||||
medalMap := make(map[int64]medal)
|
||||
@@ -147,12 +162,12 @@ func init() {
|
||||
if path.Ext(u.Face) != ".webp" {
|
||||
err = initFacePic(facePath, u.Face)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
back, err = gg.LoadImage(facePath)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
back = img.Size(back, backX, backY).Im
|
||||
@@ -171,10 +186,10 @@ func init() {
|
||||
canvas.SetColor(color.Black)
|
||||
_, err = file.GetLazyData(text.BoldFontFile, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
}
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, fontSize); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
sl, _ := canvas.MeasureString("好")
|
||||
@@ -248,29 +263,284 @@ func init() {
|
||||
_, err = writer.WriteTo(canvas.Image(), f)
|
||||
_ = f.Close()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile))
|
||||
})
|
||||
|
||||
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)
|
||||
engine.OnRegex(`^查弹幕\s?(\S{1,25})\s?(\d*)$`, getPara).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
id := ctx.State["uid"].(string)
|
||||
pagenum := ctx.State["regex_matched"].([]string)[2]
|
||||
if pagenum == "" {
|
||||
pagenum = "0"
|
||||
}
|
||||
u, err := getMemberCard(id)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
var danmaku danmakusuki
|
||||
tr := &http.Transport{
|
||||
DisableKeepAlives: true,
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||
}
|
||||
|
||||
client := &http.Client{Transport: tr}
|
||||
data, err := web.RequestDataWith(client, fmt.Sprintf(danmakuAPI, id, pagenum), "GET", "", web.RandUA())
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("Error:", err))
|
||||
return
|
||||
}
|
||||
err = json.Unmarshal(data, &danmaku)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("Error:", err))
|
||||
return
|
||||
}
|
||||
today := time.Now().Format("20060102150415")
|
||||
drawedFile := cachePath + id + today + "vupLike.png"
|
||||
facePath := cachePath + id + "vupFace" + path.Ext(u.Face)
|
||||
backX := 500
|
||||
backY := 500
|
||||
var back image.Image
|
||||
if path.Ext(u.Face) != ".webp" {
|
||||
err = initFacePic(facePath, u.Face)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
back, err = gg.LoadImage(facePath)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
back = img.Size(back, backX, backY).Im
|
||||
}
|
||||
canvas := gg.NewContext(100, 100)
|
||||
fontSize := 50.0
|
||||
_, err = file.GetLazyData(text.BoldFontFile, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
}
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, fontSize); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
dz, h := canvas.MeasureString("好")
|
||||
danmuH := h * 2
|
||||
faceH := float64(510)
|
||||
|
||||
totalDanmuku := 0
|
||||
for i := 0; i < len(danmaku.Data.Data); i++ {
|
||||
totalDanmuku += len(danmaku.Data.Data[i].Danmakus) + 1
|
||||
}
|
||||
cw := 10000
|
||||
mcw := float64(2000)
|
||||
ch := 550 + len(danmaku.Data.Data)*int(faceH) + totalDanmuku*int(danmuH)
|
||||
canvas = gg.NewContext(cw, ch)
|
||||
canvas.SetColor(color.White)
|
||||
canvas.Clear()
|
||||
canvas.SetColor(color.Black)
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, fontSize); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
facestart := 100
|
||||
fontH := h * 1.6
|
||||
startWidth := float64(700)
|
||||
startWidth2 := float64(20)
|
||||
|
||||
if back != nil {
|
||||
canvas.DrawImage(back, facestart, 0)
|
||||
}
|
||||
length, _ := canvas.MeasureString(u.Mid)
|
||||
n, _ := canvas.MeasureString(u.Name)
|
||||
canvas.DrawString(u.Name, startWidth, 122.5)
|
||||
canvas.DrawRoundedRectangle(900+n-length*0.1, 66, length*1.2, 75, fontSize*0.2)
|
||||
canvas.SetRGB255(221, 221, 221)
|
||||
canvas.Fill()
|
||||
canvas.SetColor(color.Black)
|
||||
canvas.DrawString(u.Mid, 900+n, 122.5)
|
||||
canvas.DrawString(fmt.Sprintf("粉丝:%d 关注:%d", u.Fans, u.Attention), startWidth, 222.5)
|
||||
canvas.DrawString(fmt.Sprintf("页码:[%d/%d]", danmaku.Data.PageNum, (danmaku.Data.Total-1)/5), startWidth, 322.5)
|
||||
canvas.DrawString("网页链接: "+fmt.Sprintf(danmakuURL, u.Mid), startWidth, 422.5)
|
||||
var channelStart float64
|
||||
channelStart = float64(550)
|
||||
for i := 0; i < len(danmaku.Data.Data); i++ {
|
||||
item := danmaku.Data.Data[i]
|
||||
facePath = cachePath + strconv.Itoa(int(item.Channel.UID)) + "vupFace" + path.Ext(item.Channel.FaceURL)
|
||||
if path.Ext(item.Channel.FaceURL) != ".webp" {
|
||||
err = initFacePic(facePath, item.Channel.FaceURL)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
back, err = gg.LoadImage(facePath)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
back = img.Size(back, backX, backY).Im
|
||||
}
|
||||
if back != nil {
|
||||
canvas.DrawImage(back, facestart, int(channelStart))
|
||||
}
|
||||
canvas.SetRGB255(24, 144, 255)
|
||||
canvas.DrawString("标题: "+item.Live.Title, startWidth, channelStart+fontH)
|
||||
canvas.DrawString("主播: "+item.Channel.Name, startWidth, channelStart+fontH*2)
|
||||
canvas.SetColor(color.Black)
|
||||
canvas.DrawString("开始时间: "+time.UnixMilli(item.Live.StartDate).Format("2006-01-02 15:04:05"), startWidth, channelStart+fontH*3)
|
||||
if item.Live.IsFinish {
|
||||
canvas.DrawString("结束时间: "+time.UnixMilli(item.Live.StopDate).Format("2006-01-02 15:04:05"), startWidth, channelStart+fontH*4)
|
||||
canvas.DrawString("直播时长: "+strconv.FormatFloat(float64(item.Live.StopDate-item.Live.StartDate)/3600000.0, 'f', 1, 64)+"小时", startWidth, channelStart+fontH*5)
|
||||
} else {
|
||||
t := "结束时间:"
|
||||
l, _ := canvas.MeasureString(t)
|
||||
canvas.DrawString(t, startWidth, channelStart+fontH*4)
|
||||
|
||||
canvas.SetRGB255(0, 128, 0)
|
||||
t = "正在直播"
|
||||
canvas.DrawString(t, startWidth+l*1.1, channelStart+fontH*4)
|
||||
canvas.SetColor(color.Black)
|
||||
|
||||
canvas.DrawString("直播时长: "+strconv.FormatFloat(float64(time.Now().UnixMilli()-item.Live.StartDate)/3600000.0, 'f', 1, 64)+"小时", startWidth, channelStart+fontH*5)
|
||||
}
|
||||
canvas.DrawString("弹幕数量: "+strconv.Itoa(int(item.Live.DanmakusCount)), startWidth, channelStart+fontH*6)
|
||||
canvas.DrawString("观看次数: "+strconv.Itoa(int(item.Live.WatchCount)), startWidth, channelStart+fontH*7)
|
||||
|
||||
t := "收益:"
|
||||
l, _ := canvas.MeasureString(t)
|
||||
canvas.DrawString(t, startWidth, channelStart+fontH*8)
|
||||
|
||||
t = "¥" + strconv.Itoa(int(item.Live.TotalIncome))
|
||||
canvas.SetRGB255(255, 0, 0)
|
||||
canvas.DrawString(t, startWidth+l*1.1, channelStart+fontH*8)
|
||||
canvas.SetColor(color.Black)
|
||||
|
||||
DanmakuStart := channelStart + faceH
|
||||
for i := 0; i < len(item.Danmakus); i++ {
|
||||
moveW := startWidth2
|
||||
danmuNow := DanmakuStart + danmuH*float64(i+1)
|
||||
danItem := item.Danmakus[i]
|
||||
|
||||
t := time.UnixMilli(danItem.SendDate).Format("15:04:05")
|
||||
l, _ := canvas.MeasureString(t)
|
||||
canvas.DrawString(t, moveW, danmuNow)
|
||||
moveW += l + dz
|
||||
|
||||
t = danItem.Name
|
||||
l, _ = canvas.MeasureString(t)
|
||||
canvas.SetRGB255(24, 144, 255)
|
||||
canvas.DrawString(t, moveW, danmuNow)
|
||||
canvas.SetColor(color.Black)
|
||||
moveW += l + dz
|
||||
|
||||
switch danItem.Type {
|
||||
case 0:
|
||||
t = danItem.Message
|
||||
l, _ = canvas.MeasureString(t)
|
||||
canvas.DrawString(t, moveW, danmuNow)
|
||||
moveW += l + dz
|
||||
case 1:
|
||||
t = danmakuTypeMap[danItem.Type]
|
||||
l, _ = canvas.MeasureString(t)
|
||||
canvas.SetRGB255(255, 0, 0)
|
||||
canvas.DrawString(t, moveW, danmuNow)
|
||||
moveW += l + dz
|
||||
|
||||
t = danItem.Message
|
||||
l, _ = canvas.MeasureString(t)
|
||||
canvas.DrawString(t, moveW, danmuNow)
|
||||
canvas.SetColor(color.Black)
|
||||
moveW += l + dz
|
||||
case 2, 3:
|
||||
t = danmakuTypeMap[danItem.Type]
|
||||
l, _ = canvas.MeasureString(t)
|
||||
if danItem.Type == 3 {
|
||||
canvas.SetRGB255(0, 85, 255)
|
||||
} else {
|
||||
canvas.SetRGB255(128, 0, 128)
|
||||
}
|
||||
|
||||
canvas.DrawString(t, moveW, danmuNow)
|
||||
moveW += l + dz
|
||||
|
||||
t = danItem.Message
|
||||
l, _ = canvas.MeasureString(t)
|
||||
canvas.DrawString(t, moveW, danmuNow)
|
||||
moveW += l
|
||||
|
||||
t = "["
|
||||
l, _ = canvas.MeasureString(t)
|
||||
canvas.DrawString(t, moveW, danmuNow)
|
||||
moveW += l
|
||||
|
||||
t = "¥" + strconv.FormatFloat(danItem.Price, 'f', 1, 64)
|
||||
l, _ = canvas.MeasureString(t)
|
||||
canvas.SetRGB255(255, 0, 0)
|
||||
canvas.DrawString(t, moveW, danmuNow)
|
||||
if danItem.Type == 3 {
|
||||
canvas.SetRGB255(0, 85, 255)
|
||||
} else {
|
||||
canvas.SetRGB255(128, 0, 128)
|
||||
}
|
||||
moveW += l
|
||||
|
||||
t = "]"
|
||||
l, _ = canvas.MeasureString(t)
|
||||
canvas.DrawString(t, moveW, danmuNow)
|
||||
canvas.SetColor(color.Black)
|
||||
moveW += l + dz
|
||||
case 4, 5:
|
||||
t = danmakuTypeMap[danItem.Type]
|
||||
canvas.SetRGB255(0, 128, 0)
|
||||
l, _ = canvas.MeasureString(t)
|
||||
canvas.DrawString(t, moveW, danmuNow)
|
||||
canvas.SetColor(color.Black)
|
||||
moveW += l + dz
|
||||
}
|
||||
if moveW > mcw {
|
||||
mcw = moveW
|
||||
}
|
||||
}
|
||||
channelStart = DanmakuStart + float64(len(item.Danmakus)+1)*danmuH
|
||||
}
|
||||
im := canvas.Image().(*image.RGBA)
|
||||
nim := im.SubImage(image.Rect(0, 0, int(mcw), ch))
|
||||
f, err := os.Create(drawedFile)
|
||||
if err != nil {
|
||||
log.Errorln("[bilibili]", err)
|
||||
data, cl := writer.ToBytes(nim)
|
||||
ctx.SendChain(message.ImageBytes(data))
|
||||
cl()
|
||||
return
|
||||
}
|
||||
_, err = writer.WriteTo(nim, f)
|
||||
_ = f.Close()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile))
|
||||
})
|
||||
|
||||
engine.OnRegex(`^设置b站cookie?\s+(.*)$`, zero.SuperUserPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
cookie := ctx.State["regex_matched"].([]string)[1]
|
||||
err := setBilibiliCookie(cookie)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("成功设置b站cookie为" + cookie))
|
||||
})
|
||||
|
||||
engine.OnFullMatch("更新vup", zero.SuperUserPermission, getdb).SetBlock(true).
|
||||
engine.OnFullMatch("更新vup", zero.SuperUserPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SendChain(message.Text("少女祈祷中..."))
|
||||
err := updateVup()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("vup已更新"))
|
||||
@@ -303,7 +573,7 @@ func getPara(ctx *zero.Ctx) bool {
|
||||
if !re.MatchString(keyword) {
|
||||
searchRes, err := searchUser(keyword)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
ctx.State["uid"] = strconv.FormatInt(searchRes[0].Mid, 10)
|
||||
@@ -336,7 +606,7 @@ func getPara(ctx *zero.Ctx) bool {
|
||||
} else if num == 1 {
|
||||
searchRes, err := searchUser(keyword)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
ctx.State["uid"] = strconv.FormatInt(searchRes[0].Mid, 10)
|
||||
|
||||
@@ -67,12 +67,12 @@ func handleVideo(ctx *zero.Ctx) {
|
||||
}
|
||||
card, err := getVideoInfo(id)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
msg, err := videoCard2msg(card)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(msg...)
|
||||
@@ -81,7 +81,7 @@ func handleVideo(ctx *zero.Ctx) {
|
||||
func handleDynamic(ctx *zero.Ctx) {
|
||||
msg, err := dynamicDetail(ctx.State["regex_matched"].([]string)[2])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(msg...)
|
||||
@@ -90,7 +90,7 @@ func handleDynamic(ctx *zero.Ctx) {
|
||||
func handleArticle(ctx *zero.Ctx) {
|
||||
card, err := getArticleInfo(ctx.State["regex_matched"].([]string)[1])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(articleCard2msg(card, ctx.State["regex_matched"].([]string)[1])...)
|
||||
@@ -99,7 +99,7 @@ func handleArticle(ctx *zero.Ctx) {
|
||||
func handleLive(ctx *zero.Ctx) {
|
||||
card, err := getLiveRoomInfo(ctx.State["regex_matched"].([]string)[1])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(liveCard2msg(card)...)
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
package bilibili
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"os"
|
||||
|
||||
"github.com/FloatTech/zbputils/binary"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
_ "github.com/fumiama/sqlite3" // use sql
|
||||
"github.com/jinzhu/gorm"
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
const (
|
||||
bilibiliCookie = "bilbili_cookie"
|
||||
)
|
||||
|
||||
var (
|
||||
vtbURLs = [...]string{"https://api.vtbs.moe/v1/short", "https://api.tokyo.vtbs.moe/v1/short", "https://vtbs.musedash.moe/v1/short"}
|
||||
vdb *vupdb
|
||||
@@ -32,15 +31,6 @@ func (vup) TableName() string {
|
||||
return "vup"
|
||||
}
|
||||
|
||||
type config struct {
|
||||
Key string `gorm:"column:key;primary_key"`
|
||||
Value string `gorm:"column:value"`
|
||||
}
|
||||
|
||||
func (config) TableName() string {
|
||||
return "config"
|
||||
}
|
||||
|
||||
// initializeVup 初始化vup数据库
|
||||
func initializeVup(dbpath string) (*vupdb, error) {
|
||||
if _, err := os.Stat(dbpath); err != nil || os.IsNotExist(err) {
|
||||
@@ -55,7 +45,7 @@ func initializeVup(dbpath string) (*vupdb, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
gdb.AutoMigrate(&vup{}).AutoMigrate(&config{})
|
||||
gdb.AutoMigrate(&vup{})
|
||||
return (*vupdb)(gdb), nil
|
||||
}
|
||||
|
||||
@@ -103,28 +93,31 @@ func updateVup() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (vdb *vupdb) setBilibiliCookie(cookie string) (err error) {
|
||||
db := (*gorm.DB)(vdb)
|
||||
c := config{
|
||||
Key: bilibiliCookie,
|
||||
Value: cookie,
|
||||
func setBilibiliCookie(cookie string) (err error) {
|
||||
cfg = config{
|
||||
BilibiliCookie: cookie,
|
||||
}
|
||||
if err = db.Model(&config{}).First(&c, "key = ? ", bilibiliCookie).Error; err != nil {
|
||||
// error handling...
|
||||
if gorm.IsRecordNotFoundError(err) {
|
||||
err = db.Model(&config{}).Create(&c).Error
|
||||
}
|
||||
} else {
|
||||
err = db.Model(&config{}).Where("key = ? ", bilibiliCookie).Update(
|
||||
map[string]interface{}{
|
||||
"value": cookie,
|
||||
}).Error
|
||||
}
|
||||
return
|
||||
return saveConfig(cfg)
|
||||
}
|
||||
|
||||
func (vdb *vupdb) getBilibiliCookie() (c config) {
|
||||
db := (*gorm.DB)(vdb)
|
||||
db.Model(&config{}).First(&c, "key = ?", bilibiliCookie)
|
||||
return
|
||||
func reflushBilibiliCookie() (err error) {
|
||||
if file.IsNotExist(cfgFile) {
|
||||
err = errors.New("未初始化配置")
|
||||
return
|
||||
}
|
||||
reader, err := os.Open(cfgFile)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer reader.Close()
|
||||
return json.NewDecoder(reader).Decode(&cfg)
|
||||
}
|
||||
|
||||
func saveConfig(cfg config) (err error) {
|
||||
reader, err := os.Create(cfgFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer reader.Close()
|
||||
return json.NewEncoder(reader).Encode(&cfg)
|
||||
}
|
||||
|
||||
@@ -13,11 +13,11 @@ import (
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/binary"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -58,7 +58,7 @@ func init() {
|
||||
buid, _ := strconv.ParseInt(ctx.State["uid"].(string), 10, 64)
|
||||
name, err := getName(buid)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
gid := ctx.Event.GroupID
|
||||
@@ -66,7 +66,7 @@ func init() {
|
||||
gid = -ctx.Event.UserID
|
||||
}
|
||||
if err := subscribe(buid, gid); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("已添加" + name + "的订阅"))
|
||||
@@ -75,7 +75,7 @@ func init() {
|
||||
buid, _ := strconv.ParseInt(ctx.State["uid"].(string), 10, 64)
|
||||
name, err := getName(buid)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
gid := ctx.Event.GroupID
|
||||
@@ -83,7 +83,7 @@ func init() {
|
||||
gid = -ctx.Event.UserID
|
||||
}
|
||||
if err := unsubscribe(buid, gid); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("已取消" + name + "的订阅"))
|
||||
@@ -92,7 +92,7 @@ func init() {
|
||||
buid, _ := strconv.ParseInt(ctx.State["uid"].(string), 10, 64)
|
||||
name, err := getName(buid)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
gid := ctx.Event.GroupID
|
||||
@@ -100,7 +100,7 @@ func init() {
|
||||
gid = -ctx.Event.UserID
|
||||
}
|
||||
if err := unsubscribeDynamic(buid, gid); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("已取消" + name + "的动态订阅"))
|
||||
@@ -113,11 +113,11 @@ func init() {
|
||||
}
|
||||
name, err := getName(buid)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if err := unsubscribeLive(buid, gid); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("已取消" + name + "的直播订阅"))
|
||||
@@ -149,11 +149,11 @@ func init() {
|
||||
}
|
||||
data, err := text.RenderToBase64(msg, text.FontFile, 600, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if id := ctx.SendChain(message.Image("base64://" + binary.BytesToString(data))); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR:可能被风控了"))
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
})
|
||||
en.OnFullMatch("拉取b站推送").SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/zbputils/binary"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
"github.com/tidwall/gjson"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
@@ -31,6 +31,10 @@ const (
|
||||
spaceHistoryURL = "https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history?host_uid=%v&offset_dynamic_id=%v&need_top=0"
|
||||
// liveListURL 获得直播状态
|
||||
liveListURL = "https://api.live.bilibili.com/room/v1/Room/get_status_info_by_uids"
|
||||
// danmakuAPI 弹幕网获得用户弹幕api
|
||||
danmakuAPI = "https://danmaku.suki.club/api/search/user/detail?uid=%v&pagenum=%v&pagesize=5"
|
||||
// danmakuURL 弹幕网链接
|
||||
danmakuURL = "https://danmaku.suki.club/user/%v"
|
||||
)
|
||||
|
||||
// dynamicCard 总动态结构体,包括desc,card
|
||||
@@ -215,6 +219,14 @@ type roomCard struct {
|
||||
} `json:"anchor_info"`
|
||||
}
|
||||
|
||||
// searchData 查找b站用户总结构体
|
||||
type searchData struct {
|
||||
Data struct {
|
||||
NumResults int `json:"numResults"`
|
||||
Result []searchResult `json:"result"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
// searchResult 查找b站用户结果
|
||||
type searchResult struct {
|
||||
Mid int64 `json:"mid"`
|
||||
@@ -271,3 +283,49 @@ type vtbDetail struct {
|
||||
GuardNum int `json:"guardNum"`
|
||||
AreaRank int `json:"areaRank"`
|
||||
}
|
||||
|
||||
// danmakusuki 弹幕网结构体
|
||||
type danmakusuki struct {
|
||||
Code int64 `json:"code"`
|
||||
Message string `json:"message"`
|
||||
Data struct {
|
||||
Data []struct {
|
||||
Channel struct {
|
||||
Name string `json:"name"`
|
||||
IsLiving bool `json:"isLiving"`
|
||||
UID int64 `json:"uId"`
|
||||
RoomID int64 `json:"roomId"`
|
||||
FaceURL string `json:"faceUrl"`
|
||||
LiveCount int64 `json:"liveCount"`
|
||||
} `json:"channel"`
|
||||
Live struct {
|
||||
LiveID string `json:"liveId"`
|
||||
Title string `json:"title"`
|
||||
IsFinish bool `json:"isFinish"`
|
||||
CoverURL string `json:"coverUrl"`
|
||||
StartDate int64 `json:"startDate"`
|
||||
StopDate int64 `json:"stopDate"`
|
||||
DanmakusCount int64 `json:"danmakusCount"`
|
||||
TotalIncome float64 `json:"totalIncome"`
|
||||
WatchCount int64 `json:"watchCount"`
|
||||
} `json:"live"`
|
||||
Danmakus []struct {
|
||||
Name string `json:"name"`
|
||||
Type int64 `json:"type"`
|
||||
UID int64 `json:"uId"`
|
||||
SendDate int64 `json:"sendDate"`
|
||||
Price float64 `json:"price"`
|
||||
Message string `json:"message"`
|
||||
} `json:"danmakus"`
|
||||
} `json:"data"`
|
||||
Total int64 `json:"total"`
|
||||
PageNum int64 `json:"pageNum"`
|
||||
PageSize int64 `json:"pageSize"`
|
||||
HasMore bool `json:"hasMore"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
// 配置结构体
|
||||
type config struct {
|
||||
BilibiliCookie string `json:"bilibili_cookie"`
|
||||
}
|
||||
|
||||
@@ -8,10 +8,10 @@ import (
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/binary"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
)
|
||||
|
||||
@@ -22,23 +22,23 @@ func init() {
|
||||
PublicDataFolder: "BookReview",
|
||||
})
|
||||
|
||||
getdb := ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
db.DBPath = engine.DataFolder() + "bookreview.db"
|
||||
// os.RemoveAll(dbpath)
|
||||
_, _ = engine.GetLazyData("bookreview.db", true)
|
||||
err := db.Open(time.Hour * 24)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
err = db.Create("bookreview", &book{})
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
n, err := db.Count("bookreview")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
log.Infof("[bookreview]读取%d条书评", n)
|
||||
@@ -51,11 +51,11 @@ func init() {
|
||||
b := getBookReviewByKeyword(ctx.State["regex_matched"].([]string)[1])
|
||||
data, err := text.RenderToBase64(b.BookReview, text.FontFile, 400, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if id := ctx.SendChain(message.Image("base64://" + binary.BytesToString(data))); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR:可能被风控了"))
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
})
|
||||
|
||||
@@ -64,11 +64,11 @@ func init() {
|
||||
br := getRandomBookReview()
|
||||
data, err := text.RenderToBase64(br.BookReview, text.FontFile, 400, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if id := ctx.SendChain(message.Image("base64://" + binary.BytesToString(data))); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR:可能被风控了"))
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
62
plugin/breakrepeat/breakrepeat.go
Normal file
62
plugin/breakrepeat/breakrepeat.go
Normal file
@@ -0,0 +1,62 @@
|
||||
// Package breakrepeat 打断复读
|
||||
package breakrepeat
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/RomiChan/syncx"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
)
|
||||
|
||||
const (
|
||||
maxLimit = 3
|
||||
)
|
||||
|
||||
type result struct {
|
||||
Limit int64
|
||||
RawMsg string
|
||||
}
|
||||
|
||||
var (
|
||||
sm syncx.Map[int64, *result]
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("breakrepeat", &ctrl.Options[*zero.Ctx]{
|
||||
DisableOnDefault: false,
|
||||
Help: "打断复读,打断3次以上复读\n",
|
||||
})
|
||||
engine.On(`message/group`, zero.OnlyGroup).SetBlock(false).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
gid := ctx.Event.GroupID
|
||||
raw := ctx.Event.RawMessage
|
||||
if r, ok := sm.Load(gid); !ok || r.RawMsg != raw {
|
||||
sm.Store(gid, &result{
|
||||
Limit: 0,
|
||||
RawMsg: raw,
|
||||
})
|
||||
return
|
||||
}
|
||||
if r, ok := sm.Load(gid); ok {
|
||||
sm.Store(gid, &result{
|
||||
Limit: r.Limit + 1,
|
||||
RawMsg: raw,
|
||||
})
|
||||
}
|
||||
if res, ok := sm.Load(gid); ok && res.Limit >= maxLimit {
|
||||
r := []rune(res.RawMsg)
|
||||
if len(r) > 2 {
|
||||
rand.Shuffle(len(r), func(i, j int) {
|
||||
r[i], r[j] = r[j], r[i]
|
||||
})
|
||||
ctx.Send(string(r))
|
||||
}
|
||||
sm.Store(gid, &result{
|
||||
Limit: 0,
|
||||
RawMsg: res.RawMsg,
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -39,17 +39,17 @@ func init() {
|
||||
kw := ctx.State["regex_matched"].([]string)[1]
|
||||
err := login()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
data, err := search(kw, "7", "0")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
text, err := dealHTML(helper.BytesToString(data))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text(text))
|
||||
@@ -59,17 +59,17 @@ func init() {
|
||||
kw := ctx.State["regex_matched"].([]string)[1]
|
||||
err := login()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
data, err := search(kw, "7", "2")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
text, err := dealHTML(helper.BytesToString(data))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text(text))
|
||||
|
||||
@@ -8,9 +8,9 @@ import (
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -21,23 +21,23 @@ func init() {
|
||||
})
|
||||
|
||||
en.OnRegex("^抽象翻译((\\s|[\\r\\n]|[\\p{Han}\\p{P}A-Za-z0-9])+)$",
|
||||
ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
db.DBPath = en.DataFolder() + "cxh.db"
|
||||
// os.RemoveAll(dbpath)
|
||||
_, _ = en.GetLazyData("cxh.db", true)
|
||||
err := db.Open(time.Hour * 24)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
err = db.Create("pinyin", &pinyin{})
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
n, err := db.Count("pinyin")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
logrus.Printf("[chouxianghua]读取%d条拼音", n)
|
||||
|
||||
@@ -10,10 +10,10 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -31,7 +31,7 @@ func init() {
|
||||
ctx.SendChain(message.Text("少女祈祷中......"))
|
||||
data, err := web.RequestDataWith(web.NewDefaultClient(), coserURL, "GET", "", ua)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
text := gjson.Get(helper.BytesToString(data), "data.Title").String()
|
||||
@@ -50,7 +50,7 @@ func init() {
|
||||
if id := ctx.SendGroupForwardMessage(
|
||||
ctx.Event.GroupID,
|
||||
m).Get("message_id").Int(); id == 0 {
|
||||
ctx.SendChain(message.Text("ERROR:可能被风控或下载图片用时过长,请耐心等待"))
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控或下载图片用时过长,请耐心等待"))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -9,10 +9,10 @@ import (
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
"github.com/FloatTech/floatbox/math"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/math"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -22,23 +22,23 @@ func init() {
|
||||
PublicDataFolder: "CpStory",
|
||||
})
|
||||
|
||||
getdb := ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
db.DBPath = engine.DataFolder() + "cp.db"
|
||||
// os.RemoveAll(dbpath)
|
||||
_, _ = engine.GetLazyData("cp.db", true)
|
||||
err := db.Open(time.Hour * 24)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
err = db.Create("cp_story", &cpstory{})
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
n, err := db.Count("cp_story")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
logrus.Printf("[cpstory]读取%d条故事", n)
|
||||
|
||||
@@ -8,10 +8,11 @@ import (
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
"github.com/FloatTech/floatbox/process"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -26,26 +27,26 @@ func init() {
|
||||
PublicDataFolder: "Curse",
|
||||
})
|
||||
|
||||
getdb := ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
db.DBPath = engine.DataFolder() + "curse.db"
|
||||
_, err := engine.GetLazyData("curse.db", true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
err = db.Open(time.Hour * 24)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
err = db.Create("curse", &curse{})
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
c, err := db.Count("curse")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
logrus.Infoln("[curse]加载", c, "条骂人语录")
|
||||
|
||||
@@ -6,10 +6,10 @@ import (
|
||||
"encoding/hex"
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/danbooru"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/img/writer"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/img/writer"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
@@ -32,7 +32,7 @@ func init() { // 插件主体
|
||||
for _, url := range ctx.State["image_url"].([]string) {
|
||||
t, err := danbooru.TagURL("", url)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
digest := md5.Sum(helper.StringToBytes(url))
|
||||
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/plugin/diana/data"
|
||||
)
|
||||
@@ -17,16 +17,15 @@ var engine = control.Register("diana", &ctrl.Options[*zero.Ctx]{
|
||||
Help: "嘉然\n" +
|
||||
"- 小作文\n" +
|
||||
"- 发大病\n" +
|
||||
"- 教你一篇小作文[作文]\n" +
|
||||
"- [回复]查重",
|
||||
"- 教你一篇小作文[作文]",
|
||||
PublicDataFolder: "Diana",
|
||||
})
|
||||
|
||||
func init() {
|
||||
getdb := ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
err := data.LoadText(engine.DataFolder() + "text.db")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
return true
|
||||
@@ -49,7 +48,7 @@ func init() {
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
err := data.AddText(ctx.State["regex_matched"].([]string)[1])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
} else {
|
||||
ctx.SendChain(message.Text("记住啦!"))
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
"encoding/binary"
|
||||
"time"
|
||||
|
||||
binutils "github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
binutils "github.com/FloatTech/zbputils/binary"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
// Package diana 嘉然相关
|
||||
package diana
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"math"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/zbputils/binary"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
"github.com/tidwall/gjson"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
)
|
||||
|
||||
// 小作文查重: 回复要查的消息 查重
|
||||
func init() {
|
||||
engine.OnMessage(func(ctx *zero.Ctx) bool {
|
||||
msg := ctx.Event.Message
|
||||
if msg[0].Type != "reply" {
|
||||
return false
|
||||
}
|
||||
for _, elem := range msg {
|
||||
if elem.Type == "text" {
|
||||
text := elem.Data["text"]
|
||||
text = strings.ReplaceAll(text, " ", "")
|
||||
text = strings.ReplaceAll(text, "\r", "")
|
||||
text = strings.ReplaceAll(text, "\n", "")
|
||||
if text == "查重" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
msg := ctx.GetMessage(message.NewMessageIDFromString(ctx.Event.Message[0].Data["id"])).Elements[0].Data["text"]
|
||||
result, err := zhiwangapi(msg)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
if result.Get("code").Int() != 0 {
|
||||
ctx.SendChain(message.Text("api返回错误:", result.Get("code").Int()))
|
||||
return
|
||||
}
|
||||
if result.Get("data.related.#").Int() == 0 {
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("枝网没搜到,查重率为0%,鉴定为原创")))
|
||||
return
|
||||
}
|
||||
related := result.Get("data.related.0.reply").Map()
|
||||
rate := result.Get("data.related.0.rate").Float()
|
||||
relatedcontent := related["content"].String()
|
||||
if len(relatedcontent) > 102 {
|
||||
relatedcontent = relatedcontent[:102] + "....."
|
||||
}
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text(
|
||||
"枝网文本复制检测报告(简洁)", "\n",
|
||||
"查重时间: ", time.Now().Format("2006-01-02 15:04:05"), "\n",
|
||||
"总文字复制比: ", math.Floor(rate*100), "%", "\n",
|
||||
"相似小作文:", "\n", relatedcontent, "\n",
|
||||
"获赞数:", related["like_num"].String(), "\n",
|
||||
result.Get("data.related.0.reply_url").String(), "\n",
|
||||
"作者: ", related["m_name"].String(), "\n",
|
||||
"发表时间: ", time.Unix(int64(related["ctime"].Float()), 0).Format("2006-01-02 15:04:05"), "\n",
|
||||
"查重结果仅作参考,请注意辨别是否为原创", "\n",
|
||||
"数据来源: https://asoulcnki.asia/",
|
||||
)))
|
||||
})
|
||||
}
|
||||
|
||||
func zhiwangapi(text string) (*gjson.Result, error) {
|
||||
b, cl := binary.OpenWriterF(func(w *binary.Writer) {
|
||||
w.WriteString("{\n\"text\":\"")
|
||||
w.WriteString(text)
|
||||
w.WriteString("\"\n}")
|
||||
})
|
||||
|
||||
data, err := web.PostData("https://asoulcnki.asia/v1/api/check", "application/json", bytes.NewReader(b))
|
||||
cl()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := gjson.ParseBytes(data)
|
||||
return &result, nil
|
||||
}
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"strconv"
|
||||
"sync"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
"github.com/FloatTech/zbputils/binary"
|
||||
)
|
||||
|
||||
type bottle struct {
|
||||
|
||||
@@ -55,7 +55,7 @@ func init() {
|
||||
msg,
|
||||
).throw(sea, channel)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("你将它扔进大海,希望有人捞到吧~")))
|
||||
@@ -78,7 +78,7 @@ func init() {
|
||||
logrus.Debugln("[driftbottle]", grp, channel)
|
||||
b, err := fetchBottle(sea, channel, grp)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
var wg sync.WaitGroup
|
||||
@@ -96,7 +96,7 @@ func init() {
|
||||
)
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
})
|
||||
@@ -109,7 +109,7 @@ func init() {
|
||||
}
|
||||
err := createChannel(sea, channel)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("成功~")))
|
||||
@@ -125,7 +125,7 @@ func init() {
|
||||
c, err := sea.Count(channel)
|
||||
seamu.RUnlock()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("你缓缓走入大海,感受着海浪轻柔地拍打着你的小腿,膝盖……\n波浪卷着你的腰腹,你感觉有些把握不住平衡了……\n……\n你沉入海中,", c, " 个物体与你一同沉浮。\n不知何处涌来一股暗流,你失去了意识。")))
|
||||
|
||||
@@ -7,10 +7,10 @@ import (
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -64,7 +64,7 @@ func init() {
|
||||
}
|
||||
data, time, err := queryEpidemic(city)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if data == nil {
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
package font
|
||||
|
||||
import (
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/binary"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
@@ -36,7 +36,7 @@ func init() {
|
||||
}
|
||||
b, err := text.RenderToBase64(txt, fnt, 400, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Image("base64://" + binary.BytesToString(b)))
|
||||
|
||||
@@ -17,13 +17,14 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/img/writer"
|
||||
"github.com/FloatTech/floatbox/math"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/img/pool"
|
||||
"github.com/FloatTech/zbputils/img/writer"
|
||||
"github.com/FloatTech/zbputils/math"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -87,21 +88,21 @@ func init() {
|
||||
}
|
||||
ctx.SendChain(message.Text("没有这个底图哦~"))
|
||||
})
|
||||
en.OnFullMatchGroup([]string{"运势", "抽签"}, ctxext.DoOnceOnSuccess(
|
||||
en.OnFullMatchGroup([]string{"运势", "抽签"}, fcext.DoOnceOnSuccess(
|
||||
func(ctx *zero.Ctx) bool {
|
||||
data, err := file.GetLazyData(omikujson, false)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
err = json.Unmarshal(data, &omikujis)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
_, err = file.GetLazyData(font, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
return true
|
||||
@@ -127,19 +128,19 @@ func init() {
|
||||
zipfile := images + kind + ".zip"
|
||||
_, err := file.GetLazyData(zipfile, false)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
|
||||
// 随机获取背景
|
||||
background, index, err := randimage(zipfile, ctx)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
|
||||
// 随机获取签文
|
||||
randtextindex := ctxext.RandSenderPerDayN(ctx.Event.UserID, len(omikujis))
|
||||
randtextindex := fcext.RandSenderPerDayN(ctx.Event.UserID, len(omikujis))
|
||||
title, text := omikujis[randtextindex]["title"], omikujis[randtextindex]["content"]
|
||||
digest := md5.Sum(helper.StringToBytes(zipfile + strconv.Itoa(index) + title + text))
|
||||
cachefile := cache + hex.EncodeToString(digest[:])
|
||||
@@ -154,7 +155,7 @@ func init() {
|
||||
return err
|
||||
}, ctxext.Send(ctx), ctxext.GetMessage(ctx))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
})
|
||||
@@ -171,7 +172,7 @@ func randimage(path string, ctx *zero.Ctx) (im image.Image, index int, err error
|
||||
}
|
||||
defer reader.Close()
|
||||
|
||||
file := reader.File[ctxext.RandSenderPerDayN(ctx.Event.UserID, len(reader.File))]
|
||||
file := reader.File[fcext.RandSenderPerDayN(ctx.Event.UserID, len(reader.File))]
|
||||
f, err := file.Open()
|
||||
if err != nil {
|
||||
return
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
@@ -30,26 +31,26 @@ func init() {
|
||||
PublicDataFolder: "Funny",
|
||||
})
|
||||
|
||||
en.OnPrefixGroup([]string{"讲个笑话", "夸夸"}, ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
en.OnPrefixGroup([]string{"讲个笑话", "夸夸"}, fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
db.DBPath = en.DataFolder() + "jokes.db"
|
||||
_, err := en.GetLazyData("jokes.db", true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
err = db.Open(time.Hour * 24)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
err = db.Create("jokes", &joke{})
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
c, err := db.Count("jokes")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
logrus.Infoln("[funny]加载", c, "个笑话")
|
||||
@@ -60,7 +61,7 @@ func init() {
|
||||
var j joke
|
||||
err := db.Pick("jokes", &j)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text(strings.ReplaceAll(j.Text, "%name", name)))
|
||||
|
||||
@@ -13,11 +13,12 @@ import (
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
"github.com/FloatTech/floatbox/img/writer"
|
||||
"github.com/FloatTech/floatbox/process"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/img/writer"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
"github.com/golang/freetype"
|
||||
"github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
@@ -62,21 +63,21 @@ func init() {
|
||||
err := c.SetData(gid, int64(store))
|
||||
if err != nil {
|
||||
process.SleepAbout1sTo2s()
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
}
|
||||
})
|
||||
|
||||
engine.OnFullMatch("原神十连", ctxext.DoOnceOnSuccess(
|
||||
engine.OnFullMatch("原神十连", fcext.DoOnceOnSuccess(
|
||||
func(ctx *zero.Ctx) bool {
|
||||
zipfile := engine.DataFolder() + "Genshin.zip"
|
||||
_, err := engine.GetLazyData("Genshin.zip", false)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
err = parsezip(zipfile)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
return true
|
||||
@@ -95,7 +96,7 @@ func init() {
|
||||
store := (storage)(c.GetData(gid))
|
||||
img, str, mode, err := randnums(10, store)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
b, cl := writer.ToBytes(img)
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"strconv"
|
||||
"sync"
|
||||
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/zbputils/img"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
package gif
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"image"
|
||||
"image/color"
|
||||
"sync"
|
||||
|
||||
"github.com/Coloured-glaze/gg"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/img/writer"
|
||||
"github.com/FloatTech/zbputils/img"
|
||||
"github.com/FloatTech/zbputils/img/writer"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
)
|
||||
|
||||
// mo 摸
|
||||
func mo(cc *context, value ...string) (string, error) {
|
||||
_ = value
|
||||
var wg sync.WaitGroup
|
||||
var err error
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "摸.gif"
|
||||
c := dlrange("mo", 5, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
errwg = e
|
||||
m.Unlock()
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
tou, err := cc.getLogo(0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
if errwg != nil {
|
||||
return "", errwg
|
||||
}
|
||||
imgs, err := loadFirstFrames(c, 5)
|
||||
if err != nil {
|
||||
@@ -51,17 +51,14 @@ func mo(cc *context, value ...string) (string, error) {
|
||||
func cuo(cc *context, value ...string) (string, error) {
|
||||
_ = value
|
||||
var wg sync.WaitGroup
|
||||
var err error
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "搓.gif"
|
||||
c := dlrange("cuo", 5, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
errwg = e
|
||||
m.Unlock()
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
tou, err := cc.getLogo(110, 110)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -71,8 +68,8 @@ func cuo(cc *context, value ...string) (string, error) {
|
||||
m3 := img.Rotate(tou, 216, 0, 0)
|
||||
m4 := img.Rotate(tou, 288, 0, 0)
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
if errwg != nil {
|
||||
return "", errwg
|
||||
}
|
||||
imgs, err := loadFirstFrames(c, 5)
|
||||
if err != nil {
|
||||
@@ -92,24 +89,21 @@ func cuo(cc *context, value ...string) (string, error) {
|
||||
func qiao(cc *context, value ...string) (string, error) {
|
||||
_ = value
|
||||
var wg sync.WaitGroup
|
||||
var err error
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "敲.gif"
|
||||
c := dlrange("qiao", 2, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
errwg = e
|
||||
m.Unlock()
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
tou, err := cc.getLogo(40, 40)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
if errwg != nil {
|
||||
return "", errwg
|
||||
}
|
||||
imgs, err := loadFirstFrames(c, 2)
|
||||
if err != nil {
|
||||
@@ -126,24 +120,21 @@ func qiao(cc *context, value ...string) (string, error) {
|
||||
func chi(cc *context, value ...string) (string, error) {
|
||||
_ = value
|
||||
var wg sync.WaitGroup
|
||||
var err error
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "吃.gif"
|
||||
c := dlrange("chi", 3, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
errwg = e
|
||||
m.Unlock()
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
tou, err := cc.getLogo(32, 32)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
if errwg != nil {
|
||||
return "", errwg
|
||||
}
|
||||
imgs, err := loadFirstFrames(c, 3)
|
||||
if err != nil {
|
||||
@@ -161,17 +152,14 @@ func chi(cc *context, value ...string) (string, error) {
|
||||
func ceng(cc *context, value ...string) (string, error) {
|
||||
_ = value
|
||||
var wg sync.WaitGroup
|
||||
var err error
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "蹭.gif"
|
||||
c := dlrange("ceng", 6, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
errwg = e
|
||||
m.Unlock()
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
tou, err := cc.getLogo(100, 100)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -181,8 +169,8 @@ func ceng(cc *context, value ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
if errwg != nil {
|
||||
return "", errwg
|
||||
}
|
||||
imgs, err := loadFirstFrames(c, 6)
|
||||
if err != nil {
|
||||
@@ -203,24 +191,21 @@ func ceng(cc *context, value ...string) (string, error) {
|
||||
func ken(cc *context, value ...string) (string, error) {
|
||||
_ = value
|
||||
var wg sync.WaitGroup
|
||||
var err error
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "啃.gif"
|
||||
c := dlrange("ken", 16, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
errwg = e
|
||||
m.Unlock()
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
tou, err := cc.getLogo(100, 100)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
if errwg != nil {
|
||||
return "", errwg
|
||||
}
|
||||
imgs, err := loadFirstFrames(c, 16)
|
||||
if err != nil {
|
||||
@@ -251,24 +236,21 @@ func ken(cc *context, value ...string) (string, error) {
|
||||
func pai(cc *context, value ...string) (string, error) {
|
||||
_ = value
|
||||
var wg sync.WaitGroup
|
||||
var err error
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "拍.gif"
|
||||
c := dlrange("pai", 2, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
errwg = e
|
||||
m.Unlock()
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
tou, err := cc.getLogo(30, 30)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
if errwg != nil {
|
||||
return "", errwg
|
||||
}
|
||||
imgs, err := loadFirstFrames(c, 2)
|
||||
if err != nil {
|
||||
@@ -285,24 +267,21 @@ func pai(cc *context, value ...string) (string, error) {
|
||||
func xqe(cc *context, value ...string) (string, error) {
|
||||
_ = value
|
||||
var wg sync.WaitGroup
|
||||
var err error
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "冲.gif"
|
||||
c := dlrange("xqe", 2, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
errwg = e
|
||||
m.Unlock()
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
tou, err := cc.getLogo(0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
if errwg != nil {
|
||||
return "", errwg
|
||||
}
|
||||
imgs, err := loadFirstFrames(c, 2)
|
||||
if err != nil {
|
||||
@@ -319,24 +298,21 @@ func xqe(cc *context, value ...string) (string, error) {
|
||||
func diu(cc *context, value ...string) (string, error) {
|
||||
_ = value
|
||||
var wg sync.WaitGroup
|
||||
var err error
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "丢.gif"
|
||||
c := dlrange("diu", 8, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
errwg = e
|
||||
m.Unlock()
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
tou, err := cc.getLogo(0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
if errwg != nil {
|
||||
return "", errwg
|
||||
}
|
||||
imgs, err := loadFirstFrames(c, 8)
|
||||
if err != nil {
|
||||
@@ -368,10 +344,10 @@ func kiss(cc *context, value ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
tou, err := cc.getLogo(0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -407,10 +383,10 @@ func garbage(cc *context, value ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 79, 79)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -440,10 +416,10 @@ func thump(cc *context, value ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -473,10 +449,10 @@ func jiujiu(cc *context, value ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 75, 51)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -505,10 +481,10 @@ func knock(cc *context, value ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -538,10 +514,10 @@ func listenMusic(cc *context, value ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
face, err := cc.getLogo(0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -570,10 +546,10 @@ func loveYou(cc *context, value ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -603,10 +579,10 @@ func pat(cc *context, value ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -645,10 +621,10 @@ func jackUp(cc *context, value ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -688,10 +664,10 @@ func pound(cc *context, value ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -721,10 +697,10 @@ func punch(cc *context, value ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 260, 260)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -754,10 +730,10 @@ func roll(cc *context, value ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 210, 210)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -787,10 +763,10 @@ func suck(cc *context, value ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -820,10 +796,10 @@ func hammer(cc *context, value ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -853,10 +829,10 @@ func tightly(cc *context, value ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -896,24 +872,21 @@ func turn(cc *context, value ...string) (string, error) {
|
||||
func taiguan(cc *context, value ...string) (string, error) {
|
||||
_ = value
|
||||
var wg sync.WaitGroup
|
||||
var err error
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "taiguan.gif"
|
||||
c := dlrange("taiguan", 20, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
errwg = e
|
||||
m.Unlock()
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
tou, err := cc.getLogo(0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
if errwg != nil {
|
||||
return "", errwg
|
||||
}
|
||||
imgs, err := loadFirstFrames(c, 20)
|
||||
if err != nil {
|
||||
@@ -948,17 +921,14 @@ func taiguan(cc *context, value ...string) (string, error) {
|
||||
func zou(cc *context, value ...string) (string, error) {
|
||||
_ = value
|
||||
var wg sync.WaitGroup
|
||||
var err error
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "zou.gif"
|
||||
c := dlrange("zou", 3, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
errwg = e
|
||||
m.Unlock()
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
tou, err := cc.getLogo(100, 100)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -968,8 +938,8 @@ func zou(cc *context, value ...string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
if errwg != nil {
|
||||
return "", errwg
|
||||
}
|
||||
imgs, err := loadFirstFrames(c, 3)
|
||||
if err != nil {
|
||||
@@ -987,24 +957,21 @@ func zou(cc *context, value ...string) (string, error) {
|
||||
func ci(cc *context, value ...string) (string, error) {
|
||||
_ = value
|
||||
var wg sync.WaitGroup
|
||||
var err error
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "ci.gif"
|
||||
c := dlrange("ci", 26, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
errwg = e
|
||||
m.Unlock()
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
tou, err := cc.getLogo(100, 100)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
if errwg != nil {
|
||||
return "", errwg
|
||||
}
|
||||
imgs, err := loadFirstFrames(c, 26)
|
||||
if err != nil {
|
||||
@@ -1053,6 +1020,7 @@ func worship(cc *context, value ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -1060,10 +1028,6 @@ func worship(cc *context, value ...string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
imgs, err := loadFirstFrames(c, 9)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -1086,24 +1050,21 @@ func worship(cc *context, value ...string) (string, error) {
|
||||
func ceng2(cc *context, value ...string) (string, error) {
|
||||
_ = value
|
||||
var wg sync.WaitGroup
|
||||
var err error
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "ceng2.gif"
|
||||
c := dlrange("ceng2", 4, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
errwg = e
|
||||
m.Unlock()
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
tou, err := cc.getLogo(100, 100)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
if errwg != nil {
|
||||
return "", errwg
|
||||
}
|
||||
imgs, err := loadFirstFrames(c, 4)
|
||||
if err != nil {
|
||||
@@ -1122,24 +1083,21 @@ func ceng2(cc *context, value ...string) (string, error) {
|
||||
func dun(cc *context, value ...string) (string, error) {
|
||||
_ = value
|
||||
var wg sync.WaitGroup
|
||||
var err error
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "dun.gif"
|
||||
c := dlrange("dun", 5, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
errwg = e
|
||||
m.Unlock()
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
tou, err := cc.getLogo(100, 100)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
if errwg != nil {
|
||||
return "", errwg
|
||||
}
|
||||
imgs, err := loadFirstFrames(c, 5)
|
||||
if err != nil {
|
||||
@@ -1168,10 +1126,10 @@ func push(cc *context, value ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
tou, err := cc.getLogo(0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -1191,17 +1149,14 @@ func push(cc *context, value ...string) (string, error) {
|
||||
func peng(cc *context, value ...string) (string, error) {
|
||||
_ = value
|
||||
var wg sync.WaitGroup
|
||||
var err error
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "peng.gif"
|
||||
c := dlrange("peng", 25, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
errwg = e
|
||||
m.Unlock()
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
tou, err := cc.getLogo(100, 100)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -1210,10 +1165,9 @@ func peng(cc *context, value ...string) (string, error) {
|
||||
m2 := img.Rotate(tou, 30, 80, 80)
|
||||
m3 := img.Rotate(tou, 45, 85, 85)
|
||||
m4 := img.Rotate(tou, 90, 80, 80)
|
||||
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
if errwg != nil {
|
||||
return "", errwg
|
||||
}
|
||||
imgs, err := loadFirstFrames(c, 25)
|
||||
if err != nil {
|
||||
@@ -1262,10 +1216,10 @@ func klee(cc *context, value ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
im, err := img.LoadFirstFrame(cc.headimgsdir[0], 82, 83)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -1286,24 +1240,21 @@ func klee(cc *context, value ...string) (string, error) {
|
||||
func hutaoken(cc *context, value ...string) (string, error) {
|
||||
_ = value
|
||||
var wg sync.WaitGroup
|
||||
var err error
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "hutaoken.gif"
|
||||
c := dlrange("hutaoken", 2, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
errwg = e
|
||||
m.Unlock()
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
tou, err := cc.getLogo(55, 55)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
if errwg != nil {
|
||||
return "", errwg
|
||||
}
|
||||
imgs, err := loadFirstFrames(c, 2)
|
||||
if err != nil {
|
||||
@@ -1320,21 +1271,22 @@ func hutaoken(cc *context, value ...string) (string, error) {
|
||||
func lick(cc *context, value ...string) (string, error) {
|
||||
_ = value
|
||||
var wg sync.WaitGroup
|
||||
var err error
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "lick.gif"
|
||||
c := dlrange("lick", 2, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
errwg = e
|
||||
m.Unlock()
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
tou, err := cc.getLogo(100, 100)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
if errwg != nil {
|
||||
return "", errwg
|
||||
}
|
||||
imgs, err := loadFirstFrames(c, 2)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -1359,10 +1311,10 @@ func tiqiu(cc *context, value ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
tou, err := cc.getLogo(78, 78)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -1383,24 +1335,21 @@ func tiqiu(cc *context, value ...string) (string, error) {
|
||||
func cai(cc *context, value ...string) (string, error) {
|
||||
_ = value
|
||||
var wg sync.WaitGroup
|
||||
var err error
|
||||
var errwg error
|
||||
var m sync.Mutex
|
||||
name := cc.usrdir + "cai.gif"
|
||||
c := dlrange("cai", 5, &wg, func(e error) {
|
||||
m.Lock()
|
||||
err = e
|
||||
errwg = e
|
||||
m.Unlock()
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
tou, err := cc.getLogo(0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
if errwg != nil {
|
||||
return "", errwg
|
||||
}
|
||||
imgs, err := loadFirstFrames(c, 5)
|
||||
if err != nil {
|
||||
@@ -1430,10 +1379,10 @@ func whirl(cc *context, value ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
tou, err := cc.getLogo(0, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -1448,3 +1397,52 @@ func whirl(cc *context, value ...string) (string, error) {
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(7, whirl))
|
||||
}
|
||||
|
||||
// always 一直
|
||||
func alwaysDoGif(cc *context, value ...string) (string, error) {
|
||||
_ = value
|
||||
var err error
|
||||
var face []*image.NRGBA
|
||||
name := cc.usrdir + "AlwaysDo.gif"
|
||||
face, err = img.LoadAllFrames(cc.headimgsdir[0], 500, 500)
|
||||
if err != nil {
|
||||
// 载入失败尝试载入第一帧
|
||||
face = make([]*image.NRGBA, 0)
|
||||
first, err := img.LoadFirstFrame(cc.headimgsdir[0], 500, 500)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
face = append(face, first.Im)
|
||||
}
|
||||
canvas := gg.NewContext(500, 600)
|
||||
canvas.SetColor(color.Black)
|
||||
_, err = file.GetLazyData(text.BoldFontFile, true)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
err = canvas.LoadFontFace(text.BoldFontFile, 40)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
length := len(face)
|
||||
if length > 50 {
|
||||
length = 50
|
||||
}
|
||||
arg := "要我一直"
|
||||
l, _ := canvas.MeasureString(arg)
|
||||
if l > 500 {
|
||||
return "", errors.New("文字消息太长了")
|
||||
}
|
||||
turn := make([]*image.NRGBA, length)
|
||||
for i, f := range face {
|
||||
canvas := gg.NewContext(500, 600)
|
||||
canvas.DrawImage(f, 0, 0)
|
||||
canvas.SetColor(color.Black)
|
||||
_ = canvas.LoadFontFace(text.BoldFontFile, 40)
|
||||
canvas.DrawString(arg, 280-l, 560)
|
||||
canvas.DrawImage(img.Size(f, 90, 90).Im, 280, 505)
|
||||
canvas.DrawString("吗", 370, 560)
|
||||
turn[i] = img.Size(canvas.Image(), 0, 0).Im
|
||||
}
|
||||
return "file:///" + name, writer.SaveGIF2Path(name, img.MergeGif(8, turn))
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/zbputils/img"
|
||||
)
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/Coloured-glaze/gg"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/img/writer"
|
||||
"github.com/FloatTech/zbputils/img"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
"github.com/FloatTech/zbputils/img/writer"
|
||||
)
|
||||
|
||||
// pa 爬
|
||||
@@ -204,10 +204,10 @@ func alike(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
imgs, err := loadFirstFrames(c, 1)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -232,10 +232,10 @@ func marriage(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
imgs, err := loadFirstFrames(c, 2)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -260,10 +260,10 @@ func anyasuki(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
name := cc.usrdir + "Anyasuki.png"
|
||||
back, err := gg.LoadImage(c[0])
|
||||
if err != nil {
|
||||
@@ -306,10 +306,10 @@ func alwaysLike(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
name := cc.usrdir + "AlwaysLike.png"
|
||||
back, err := gg.LoadImage(c[0])
|
||||
if err != nil {
|
||||
@@ -353,10 +353,10 @@ func decentKiss(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
imgs, err := loadFirstFrames(c, 1)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -381,10 +381,10 @@ func chinaFlag(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
imgs, err := loadFirstFrames(c, 1)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -409,10 +409,10 @@ func dontTouch(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
imgs, err := loadFirstFrames(c, 1)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -466,10 +466,10 @@ func interview(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
name := cc.usrdir + "Interview.png"
|
||||
huaji, err := gg.LoadImage(c[0])
|
||||
if err != nil {
|
||||
@@ -517,10 +517,10 @@ func need(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
imgs, err := loadFirstFrames(c, 1)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -545,10 +545,10 @@ func paint(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
imgs, err := loadFirstFrames(c, 1)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -573,10 +573,10 @@ func painter(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
imgs, err := loadFirstFrames(c, 1)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -601,10 +601,10 @@ func perfect(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
imgs, err := loadFirstFrames(c, 1)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -629,10 +629,10 @@ func playGame(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
name := cc.usrdir + "PlayGame.png"
|
||||
back, err := gg.LoadImage(c[0])
|
||||
if err != nil {
|
||||
@@ -675,10 +675,10 @@ func police(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
imgs, err := loadFirstFrames(c, 2)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -703,10 +703,10 @@ func police1(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
imgs, err := loadFirstFrames(c, 2)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -731,10 +731,10 @@ func prpr(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
imgs, err := loadFirstFrames(c, 1)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -759,10 +759,10 @@ func safeSense(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
name := cc.usrdir + "SafeSense.png"
|
||||
back, err := gg.LoadImage(c[0])
|
||||
if err != nil {
|
||||
@@ -807,10 +807,10 @@ func support(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
imgs, err := loadFirstFrames(c, 1)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -835,10 +835,10 @@ func thinkwhat(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
imgs, err := loadFirstFrames(c, 1)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -863,10 +863,10 @@ func wallpaper(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
imgs, err := loadFirstFrames(c, 1)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -891,10 +891,10 @@ func whyatme(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
imgs, err := loadFirstFrames(c, 1)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -919,10 +919,10 @@ func makeFriend(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
name := cc.usrdir + "MakeFriend.png"
|
||||
back, err := gg.LoadImage(c[0])
|
||||
if err != nil {
|
||||
@@ -968,10 +968,10 @@ func backToWork(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
imgs, err := loadFirstFrames(c, 1)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -996,10 +996,10 @@ func coupon(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
name := cc.usrdir + "Coupon.png"
|
||||
if args[0] == "" {
|
||||
args[0] = "群主陪睡券"
|
||||
@@ -1047,10 +1047,10 @@ func distracted(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
imgs, err := loadFirstFrames(c, 2)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -1075,10 +1075,10 @@ func throw(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
imgs, err := loadFirstFrames(c, 1)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -1103,10 +1103,10 @@ func yuanli(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
imgs, err := loadFirstFrames(c, 1)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -1131,10 +1131,10 @@ func nowife(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
imgs, err := loadFirstFrames(c, 1)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -1159,10 +1159,10 @@ func youer(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
name := cc.usrdir + "youer.png"
|
||||
back, err := gg.LoadImage(c[0])
|
||||
if err != nil {
|
||||
@@ -1172,10 +1172,6 @@ func youer(cc *context, args ...string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
canvas := gg.NewContext(690, 690)
|
||||
canvas.DrawImage(back, 0, 0)
|
||||
canvas.DrawImage(img.Size(tou, 350, 350).Im, 55, 165)
|
||||
@@ -1210,10 +1206,10 @@ func xiaotianshi(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
name := cc.usrdir + "xiaotianshi.png"
|
||||
back, err := gg.LoadImage(c[0])
|
||||
if err != nil {
|
||||
@@ -1223,10 +1219,6 @@ func xiaotianshi(cc *context, args ...string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
canvas := gg.NewContext(522, 665)
|
||||
canvas.DrawImage(back, 0, 0)
|
||||
canvas.DrawImage(img.Size(face, 480, 480).Im, 20, 80)
|
||||
@@ -1261,10 +1253,10 @@ func neko(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
imgs, err := loadFirstFrames(c, 1)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -1290,10 +1282,10 @@ func bian(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
imgs, err := loadFirstFrames(c, 1)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -1318,10 +1310,10 @@ func van(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
name := cc.usrdir + "van.png"
|
||||
back, err := gg.LoadImage(c[0])
|
||||
if err != nil {
|
||||
@@ -1331,10 +1323,6 @@ func van(cc *context, args ...string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
canvas := gg.NewContext(522, 665)
|
||||
canvas.DrawImage(back, 0, 0)
|
||||
canvas.DrawImage(img.Size(face, 480, 480).Im, 20, 80)
|
||||
@@ -1369,10 +1357,10 @@ func eihei(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
imgs, err := loadFirstFrames(c, 1)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -1397,10 +1385,10 @@ func fanfa(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
imgs, err := loadFirstFrames(c, 1)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -1426,10 +1414,10 @@ func huai(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
imgs, err := loadFirstFrames(c, 1)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -1454,10 +1442,10 @@ func haowan(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
imgs, err := loadFirstFrames(c, 1)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -1482,10 +1470,10 @@ func mengbi(cc *context, args ...string) (string, error) {
|
||||
err = e
|
||||
m.Unlock()
|
||||
})
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
name := cc.usrdir + "mengbi.png"
|
||||
back, err := gg.LoadImage(c[0])
|
||||
if err != nil {
|
||||
@@ -1495,10 +1483,6 @@ func mengbi(cc *context, args ...string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
wg.Wait()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
canvas := gg.NewContext(1080, 1080)
|
||||
canvas.DrawImage(back, 0, 0)
|
||||
canvas.DrawImage(img.Size(face, 100, 100).Im, 392, 460)
|
||||
|
||||
@@ -5,10 +5,10 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
@@ -118,6 +118,7 @@ var (
|
||||
"我老婆": nowife,
|
||||
"远离": yuanli,
|
||||
"抬棺": taiguan,
|
||||
"一直": alwaysDoGif,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -140,7 +141,7 @@ func init() { // 插件主体
|
||||
"- 抬棺|- 远离|- 我老婆|- 小天使XXX|- 你的XXX|- 不要看\n" +
|
||||
"- 玩一下XXX|- 给我变|- 揍|- 吞|- 膜拜|- 诶嘿|- 2蹭|- 你犯法了\n" +
|
||||
"- 砰|- 注意力涣散|- 蒙蔽|- 踩|- 好玩|- 2转|- 踢球|- 2舔|\n" +
|
||||
"- 可莉吃|- 胡桃啃|- 怀",
|
||||
"- 可莉吃|- 胡桃啃|- 怀|- 一直(支持动图)",
|
||||
PrivateDataFolder: "gif",
|
||||
}).ApplySingle(ctxext.DefaultSingle)
|
||||
datapath = file.BOTPATH + "/" + en.DataFolder()
|
||||
@@ -150,13 +151,13 @@ func init() { // 插件主体
|
||||
list := ctx.State["regex_matched"].([]string)
|
||||
err := c.prepareLogos(list[4]+list[5]+list[6], strconv.FormatInt(ctx.Event.UserID, 10))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
argslist := strings.Split(strings.TrimSuffix(strings.TrimPrefix(list[0], list[1]), list[2]), " ")
|
||||
picurl, err := cmdMap[list[1]](c, argslist...)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Image(picurl))
|
||||
|
||||
@@ -35,12 +35,12 @@ func init() { // 插件主体
|
||||
}.Encode()
|
||||
body, err := netGet(api.String(), header)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
}
|
||||
// 解析请求
|
||||
info := gjson.ParseBytes(body)
|
||||
if info.Get("total_count").Int() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR:没有找到这样的仓库"))
|
||||
ctx.SendChain(message.Text("ERROR: 没有找到这样的仓库"))
|
||||
return
|
||||
}
|
||||
repo := info.Get("items.0")
|
||||
|
||||
@@ -22,11 +22,11 @@ import (
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
"github.com/wdvxdr1123/ZeroBot/extension/single"
|
||||
|
||||
// 图片输出
|
||||
@@ -141,21 +141,21 @@ func init() { // 插件主体
|
||||
}
|
||||
err = os.MkdirAll(cfg.MusicPath, 0755)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("[生成文件夹错误]ERROR:", err))
|
||||
ctx.SendChain(message.Text("[生成文件夹错误]ERROR: ", err))
|
||||
return
|
||||
}
|
||||
cfg.MusicPath = musicPath
|
||||
case "本地":
|
||||
choice, err := strconv.ParseBool(value)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
cfg.Local = choice
|
||||
case "Api":
|
||||
choice, err := strconv.ParseBool(value)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
cfg.API = choice
|
||||
@@ -164,7 +164,7 @@ func init() { // 插件主体
|
||||
if err == nil {
|
||||
ctx.SendChain(message.Text("成功!"))
|
||||
} else {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
}
|
||||
})
|
||||
engine.OnFullMatch("登录网易云", zero.SuperUserPermission, func(ctx *zero.Ctx) bool {
|
||||
@@ -178,25 +178,25 @@ func init() { // 插件主体
|
||||
keyURL := "https://music.cyrilstudio.top/login/qr/key"
|
||||
data, err := web.GetData(keyURL)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("获取网易云key失败, ERROR:", err))
|
||||
ctx.SendChain(message.Text("获取网易云key失败, ERROR: ", err))
|
||||
return
|
||||
}
|
||||
var keyInfo keyInfo
|
||||
err = json.Unmarshal(data, &keyInfo)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("解析网易云key失败, ERROR:", err))
|
||||
ctx.SendChain(message.Text("解析网易云key失败, ERROR: ", err))
|
||||
return
|
||||
}
|
||||
qrURL := "https://music.cyrilstudio.top/login/qr/create?key=" + keyInfo.Data.Unikey + "&qrimg=1"
|
||||
data, err = web.GetData(qrURL)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("获取网易云二维码失败, ERROR:", err))
|
||||
ctx.SendChain(message.Text("获取网易云二维码失败, ERROR: ", err))
|
||||
return
|
||||
}
|
||||
var qrInfo qrInfo
|
||||
err = json.Unmarshal(data, &qrInfo)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("解析网易云二维码失败, ERROR:", err))
|
||||
ctx.SendChain(message.Text("解析网易云二维码失败, ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("[请使用手机APP扫描二维码或者进入网页扫码登录]\n", qrInfo.Data.Qrurl),
|
||||
@@ -208,13 +208,13 @@ func init() { // 插件主体
|
||||
referer := "https://music.cyrilstudio.top"
|
||||
data, err := web.RequestDataWith(web.NewDefaultClient(), apiURL, "GET", referer, ua)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("无法获取登录状态, ERROR:", err))
|
||||
ctx.SendChain(message.Text("无法获取登录状态, ERROR: ", err))
|
||||
return
|
||||
}
|
||||
var cookiesInfo cookyInfo
|
||||
err = json.Unmarshal(data, &cookiesInfo)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("解析登录状态失败, ERROR:", err))
|
||||
ctx.SendChain(message.Text("解析登录状态失败, ERROR: ", err))
|
||||
return
|
||||
}
|
||||
switch cookiesInfo.Code {
|
||||
@@ -224,7 +224,7 @@ func init() { // 插件主体
|
||||
if err == nil {
|
||||
ctx.SendChain(message.Text("成功!"))
|
||||
} else {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
}
|
||||
return
|
||||
case 801:
|
||||
@@ -266,7 +266,7 @@ func init() { // 插件主体
|
||||
referer = "https://music.163.com/"
|
||||
data, err = web.RequestDataWith(web.NewDefaultClient(), apiURL, "GET", referer, ua)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("无法获取歌单列表\n ERROR:", err))
|
||||
ctx.SendChain(message.Text("无法获取歌单列表\n ERROR: ", err))
|
||||
return
|
||||
}
|
||||
var musiclist topMusicInfo
|
||||
@@ -289,7 +289,7 @@ func init() { // 插件主体
|
||||
if err == nil {
|
||||
ctx.SendChain(message.Text("成功!"))
|
||||
} else {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
}
|
||||
})
|
||||
engine.OnRegex(`^删除歌单\s?(.*)$`, zero.SuperUserPermission).SetBlock(true).Limit(ctxext.LimitByGroup).
|
||||
@@ -319,7 +319,7 @@ func init() { // 插件主体
|
||||
if err == nil {
|
||||
ctx.SendChain(message.Text("成功!"))
|
||||
} else {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
}
|
||||
})
|
||||
engine.OnFullMatch("获取歌单列表").SetBlock(true).Limit(ctxext.LimitByGroup).
|
||||
@@ -362,10 +362,10 @@ func init() { // 插件主体
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ctx.SendChain(message.Text("[读取本地列表错误]ERROR:", err))
|
||||
ctx.SendChain(message.Text("[读取本地列表错误]ERROR: ", err))
|
||||
}
|
||||
} else {
|
||||
ctx.SendChain(message.Text("[生成文件夹错误]ERROR:", err))
|
||||
ctx.SendChain(message.Text("[生成文件夹错误]ERROR: ", err))
|
||||
}
|
||||
}
|
||||
if msg == nil {
|
||||
@@ -526,7 +526,8 @@ func init() { // 插件主体
|
||||
tick.Stop()
|
||||
after.Stop()
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID,
|
||||
message.Text("游戏已取消,猜歌答案是\n", answerString)))
|
||||
message.Text("游戏已取消,猜歌答案是\n", answerString, "\n\n\n下面欣赏猜歌的歌曲")))
|
||||
ctx.SendChain(message.Record("file:///" + pathOfMusic + musicName))
|
||||
return
|
||||
}
|
||||
ctx.Send(
|
||||
@@ -557,21 +558,24 @@ func init() { // 插件主体
|
||||
tick.Stop()
|
||||
after.Stop()
|
||||
ctx.Send(message.ReplyWithMessage(c.Event.MessageID,
|
||||
message.Text("太棒了,你猜对歌曲名了!答案是\n", answerString)))
|
||||
message.Text("太棒了,你猜对歌曲名了!答案是\n", answerString, "\n\n下面欣赏猜歌的歌曲")))
|
||||
ctx.SendChain(message.Record("file:///" + pathOfMusic + musicName))
|
||||
return
|
||||
case strings.Contains(musicInfo[1], answer) || strings.EqualFold(musicInfo[1], answer):
|
||||
wait.Stop()
|
||||
tick.Stop()
|
||||
after.Stop()
|
||||
ctx.Send(message.ReplyWithMessage(c.Event.MessageID,
|
||||
message.Text("太棒了,你猜对歌手名了!答案是\n", answerString)))
|
||||
message.Text("太棒了,你猜对歌手名了!答案是\n", answerString, "\n\n下面欣赏猜歌的歌曲")))
|
||||
ctx.SendChain(message.Record("file:///" + pathOfMusic + musicName))
|
||||
return
|
||||
case strings.Contains(musicAlia, answer) || strings.EqualFold(musicAlia, answer):
|
||||
wait.Stop()
|
||||
tick.Stop()
|
||||
after.Stop()
|
||||
ctx.Send(message.ReplyWithMessage(c.Event.MessageID,
|
||||
message.Text("太棒了,你猜对出处了!答案是\n", answerString)))
|
||||
message.Text("太棒了,你猜对出处了!答案是\n", answerString, "\n\n下面欣赏猜歌的歌曲")))
|
||||
ctx.SendChain(message.Record("file:///" + pathOfMusic + musicName))
|
||||
return
|
||||
default:
|
||||
musicCount++
|
||||
@@ -589,7 +593,8 @@ func init() { // 插件主体
|
||||
tick.Stop()
|
||||
after.Stop()
|
||||
ctx.Send(message.ReplyWithMessage(c.Event.MessageID,
|
||||
message.Text("次数到了,没能猜出来。答案是\n", answerString)))
|
||||
message.Text("次数到了,没能猜出来。答案是\n", answerString, "\n\n下面欣赏猜歌的歌曲")))
|
||||
ctx.SendChain(message.Record("file:///" + pathOfMusic + musicName))
|
||||
return
|
||||
default:
|
||||
wait.Reset(40 * time.Second)
|
||||
@@ -626,12 +631,12 @@ func getcatlist(pathOfMusic string) error {
|
||||
}
|
||||
err := os.MkdirAll(pathOfMusic, 0755)
|
||||
if err != nil {
|
||||
err = errors.Errorf("[生成文件夹错误]ERROR:%s", err)
|
||||
err = errors.Errorf("[生成文件夹错误]ERROR: %s", err)
|
||||
return err
|
||||
}
|
||||
files, err := ioutil.ReadDir(pathOfMusic)
|
||||
if err != nil {
|
||||
err = errors.Errorf("[读取本地列表错误]ERROR:%s", err)
|
||||
err = errors.Errorf("[读取本地列表错误]ERROR: %s", err)
|
||||
return err
|
||||
}
|
||||
for i, name := range files {
|
||||
@@ -645,12 +650,12 @@ func musicLottery(mode, musicPath string) (musicName, pathOfMusic string, err er
|
||||
pathOfMusic = musicPath + mode + "/"
|
||||
err = os.MkdirAll(pathOfMusic, 0755)
|
||||
if err != nil {
|
||||
err = errors.Errorf("[生成文件夹错误]ERROR:%s", err)
|
||||
err = errors.Errorf("[生成文件夹错误]ERROR: %s", err)
|
||||
return
|
||||
}
|
||||
files, err := ioutil.ReadDir(pathOfMusic)
|
||||
if err != nil {
|
||||
err = errors.Errorf("[读取本地列表错误]ERROR:%s", err)
|
||||
err = errors.Errorf("[读取本地列表错误]ERROR: %s", err)
|
||||
return
|
||||
}
|
||||
listID, ok := catlist[mode]
|
||||
@@ -666,7 +671,7 @@ func musicLottery(mode, musicPath string) (musicName, pathOfMusic string, err er
|
||||
// 如果没有任何本地就下载歌曲
|
||||
musicName, err = getListMusic(listIDstr, pathOfMusic)
|
||||
if err != nil {
|
||||
err = errors.Errorf("[本地数据为0,歌曲下载错误]ERROR:%s", err)
|
||||
err = errors.Errorf("[本地数据为0,歌曲下载错误]ERROR: %s", err)
|
||||
return
|
||||
}
|
||||
case rand.Intn(2) == 0 || !ok:
|
||||
@@ -693,7 +698,7 @@ func musicLottery(mode, musicPath string) (musicName, pathOfMusic string, err er
|
||||
if cfg.API && ok {
|
||||
musicName, err = getListMusic(listIDstr, pathOfMusic)
|
||||
if err != nil {
|
||||
err = errors.Errorf("[获取API失败,未开启本地数据] ERROR:%s", err)
|
||||
err = errors.Errorf("[获取API失败,未开启本地数据] ERROR: %s", err)
|
||||
return
|
||||
}
|
||||
return
|
||||
@@ -752,7 +757,11 @@ func getListMusic(listID, pathOfMusic string) (musicName string, err error) {
|
||||
musicURL := "http://music.163.com/song/media/outer/url?id=" + strconv.Itoa(musicID)
|
||||
response, err := http.Head(musicURL)
|
||||
if err != nil {
|
||||
err = errors.Errorf("下载音乐失败, ERROR: %s", err)
|
||||
if strings.Contains(err.Error(), "404") {
|
||||
err = errors.Errorf("歌曲丢失, 可能歌曲已下架或者登录状态已过期。\n可尝试重新登录排除后者问题。")
|
||||
} else {
|
||||
err = errors.Errorf("下载音乐失败, ERROR: %s", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
_ = response.Body.Close()
|
||||
@@ -783,7 +792,7 @@ func getListMusic(listID, pathOfMusic string) (musicName string, err error) {
|
||||
func cutMusic(musicName, pathOfMusic, outputPath string) (err error) {
|
||||
err = os.MkdirAll(outputPath, 0755)
|
||||
if err != nil {
|
||||
err = errors.Errorf("[生成歌曲目录错误]ERROR:%s", err)
|
||||
err = errors.Errorf("[生成歌曲目录错误]ERROR: %s", err)
|
||||
return
|
||||
}
|
||||
var stderr bytes.Buffer
|
||||
@@ -795,7 +804,7 @@ func cutMusic(musicName, pathOfMusic, outputPath string) (err error) {
|
||||
cmd.Stderr = &stderr
|
||||
err = cmd.Run()
|
||||
if err != nil {
|
||||
err = errors.Errorf("[生成歌曲错误]ERROR:%s", stderr.String())
|
||||
err = errors.Errorf("[生成歌曲错误]ERROR: %s", stderr.String())
|
||||
return
|
||||
}
|
||||
return
|
||||
|
||||
@@ -11,11 +11,11 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
)
|
||||
|
||||
var reqconf = [...]string{"GET", "https://hs.fbigame.com",
|
||||
@@ -81,7 +81,7 @@ func init() {
|
||||
ctx.Event.GroupID,
|
||||
sk,
|
||||
).Get("message_id").Int(); id == 0 {
|
||||
ctx.SendChain(message.Text("ERROR:可能被风控了"))
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
})
|
||||
// 卡组
|
||||
|
||||
@@ -10,18 +10,18 @@ import (
|
||||
"strconv"
|
||||
"unsafe"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/binary"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
const bed = "https://gitcode.net/u011570312/OguraHyakuninIsshu/-/raw/master/"
|
||||
|
||||
//nolint: asciicheck
|
||||
// nolint: asciicheck
|
||||
type line struct {
|
||||
番号, 歌人, 上の句, 下の句, 上の句ひらがな, 下の句ひらがな string
|
||||
}
|
||||
@@ -107,11 +107,11 @@ func init() {
|
||||
engine.OnRegex(`^百人一首之\s?(\d+)$`).SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
i, err := strconv.Atoi(ctx.State["regex_matched"].([]string)[1])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if i > 100 || i < 1 {
|
||||
ctx.SendChain(message.Text("ERROR:超出范围"))
|
||||
ctx.SendChain(message.Text("ERROR: 超出范围"))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(
|
||||
|
||||
@@ -18,12 +18,12 @@ import (
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/pixiv"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/binary"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/img/pool"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
)
|
||||
|
||||
type resultjson struct {
|
||||
@@ -71,14 +71,14 @@ func init() {
|
||||
keyword := ctx.State["regex_matched"].([]string)[1]
|
||||
soutujson, err := soutuapi(keyword)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
rannum := rand.Intn(len(soutujson.Data.Illusts))
|
||||
il := soutujson.Data.Illusts[rannum]
|
||||
illust, err := pixiv.Works(il.ID)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
u := illust.ImageUrls[0]
|
||||
@@ -101,7 +101,7 @@ func init() {
|
||||
),
|
||||
), ctxext.GetFirstMessageInForward(ctx))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
})
|
||||
|
||||
@@ -8,10 +8,10 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/binary"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/antchfx/htmlquery"
|
||||
"github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
@@ -29,22 +29,22 @@ func init() {
|
||||
PublicDataFolder: "Jandan",
|
||||
})
|
||||
|
||||
getdb := ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
db.DBPath = engine.DataFolder() + "pics.db"
|
||||
_, _ = engine.GetLazyData("pics.db", false)
|
||||
err := db.Open(time.Hour * 24)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
err = db.Create("picture", &picture{})
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
n, err := db.Count("picture")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
logrus.Printf("[jandan]读取%d张图片", n)
|
||||
@@ -55,7 +55,7 @@ func init() {
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
u, err := getRandomPicture()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Image(u))
|
||||
@@ -67,13 +67,13 @@ func init() {
|
||||
webpageURL := api
|
||||
doc, err := htmlquery.LoadURL(webpageURL)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
re := regexp.MustCompile(`\d+`)
|
||||
pageTotal, err := strconv.Atoi(re.FindString(htmlquery.FindOne(doc, "//*[@id='comments']/div[2]/div/span[@class='current-comment-page']/text()").Data))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
LOOP:
|
||||
@@ -81,12 +81,12 @@ func init() {
|
||||
logrus.Debugln("[jandan]", fmt.Sprintf("处理第%d/%d页...", i, pageTotal))
|
||||
doc, err = htmlquery.LoadURL(webpageURL)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
picList, err := htmlquery.QueryAll(doc, "//*[@class='view_img_link']")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if len(picList) != 0 {
|
||||
|
||||
@@ -35,7 +35,7 @@ func init() {
|
||||
case 2:
|
||||
data, err := juejuezi(string(toDealStr[0]), string(toDealStr[1]))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text(gjson.Get(helper.BytesToString(data), "text").String()))
|
||||
@@ -43,7 +43,7 @@ func init() {
|
||||
params := ctx.GetWordSlices(string(toDealStr)).Get("slices").Array()
|
||||
data, err := juejuezi(params[0].String(), params[1].String())
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text(gjson.Get(helper.BytesToString(data), "text").String()))
|
||||
|
||||
@@ -10,13 +10,13 @@ import (
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/floatbox/math"
|
||||
"github.com/FloatTech/floatbox/process"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/img/pool"
|
||||
"github.com/FloatTech/zbputils/math"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -43,7 +43,7 @@ func init() {
|
||||
if custapi != "" {
|
||||
data, err := web.GetData(custapi)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
continue
|
||||
}
|
||||
queue <- "base64://" + base64.StdEncoding.EncodeToString(data)
|
||||
@@ -51,12 +51,12 @@ func init() {
|
||||
}
|
||||
data, err := web.GetData(api)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
continue
|
||||
}
|
||||
json := gjson.ParseBytes(data)
|
||||
if e := json.Get("error").Str; e != "" {
|
||||
ctx.SendChain(message.Text("ERROR:", e))
|
||||
ctx.SendChain(message.Text("ERROR: ", e))
|
||||
continue
|
||||
}
|
||||
url := json.Get("data.0.urls.original").Str
|
||||
@@ -77,14 +77,14 @@ func init() {
|
||||
}()
|
||||
select {
|
||||
case <-time.After(time.Minute):
|
||||
ctx.SendChain(message.Text("ERROR:等待填充,请稍后再试......"))
|
||||
ctx.SendChain(message.Text("ERROR: 等待填充,请稍后再试......"))
|
||||
case img := <-queue:
|
||||
id := ctx.SendChain(message.Image(img))
|
||||
if id.ID() == 0 {
|
||||
process.SleepAbout1sTo2s()
|
||||
id = ctx.SendChain(message.Image(img).Add("cache", "0"))
|
||||
if id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR:图片发送失败,可能被风控了~"))
|
||||
ctx.SendChain(message.Text("ERROR: 图片发送失败,可能被风控了~"))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,7 +93,7 @@ func init() {
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
u := strings.TrimSpace(ctx.State["args"].(string))
|
||||
if !strings.HasPrefix(u, "http") {
|
||||
ctx.SendChain(message.Text("ERROR:url非法!"))
|
||||
ctx.SendChain(message.Text("ERROR: url非法!"))
|
||||
return
|
||||
}
|
||||
custapi = u
|
||||
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
|
||||
"github.com/FloatTech/zbputils/math"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
"github.com/FloatTech/floatbox/math"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
)
|
||||
|
||||
// user hash file
|
||||
|
||||
@@ -13,12 +13,12 @@ import (
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/floatbox/math"
|
||||
"github.com/FloatTech/floatbox/process"
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/math"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/plugin/manager/timer"
|
||||
)
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/floatbox/process"
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
"github.com/fumiama/cron"
|
||||
"github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
|
||||
@@ -14,12 +14,12 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/binary"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
"github.com/pkg/errors"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
@@ -56,7 +56,7 @@ func init() {
|
||||
ctx.UploadThisGroupFile(file.BOTPATH+"/"+midiFile, filepath.Base(midiFile), "")
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("ERROR:无法转换midi文件,", err))
|
||||
ctx.SendChain(message.Text("ERROR: 无法转换midi文件,", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Record("file:///" + file.BOTPATH + "/" + cmidiFile))
|
||||
@@ -91,7 +91,7 @@ func init() {
|
||||
midiFile := cachePath + strconv.FormatInt(uid, 10) + time.Now().Format("20060102150405") + "_midicreate.mid"
|
||||
cmidiFile, err := str2music(ctx, answer, midiFile)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:听音练习结束, 无法转换midi文件, ", err))
|
||||
ctx.SendChain(message.Text("ERROR: 听音练习结束, 无法转换midi文件, ", err))
|
||||
return
|
||||
}
|
||||
time.Sleep(time.Millisecond * 500)
|
||||
@@ -176,7 +176,7 @@ func init() {
|
||||
midiFile = cachePath + strconv.FormatInt(uid, 10) + time.Now().Format("20060102150405") + "_midicreate.mid"
|
||||
cmidiFile, err = str2music(ctx, answer, midiFile)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:听音练习结束, 无法转换midi文件, ", err))
|
||||
ctx.SendChain(message.Text("ERROR: 听音练习结束, 无法转换midi文件, ", err))
|
||||
return
|
||||
}
|
||||
time.Sleep(time.Millisecond * 500)
|
||||
@@ -230,18 +230,18 @@ func init() {
|
||||
fileURL := ctx.GetThisGroupFileUrl(ctx.Event.File.BusID, ctx.Event.File.ID)
|
||||
data, err := web.GetData(fileURL)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
s, err := smf.ReadFrom(bytes.NewReader(data))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
for i := 0; i < int(s.NumTracks()); i++ {
|
||||
midStr := mid2txt(data, i)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
fileName := strings.ReplaceAll(cachePath+"/"+ctx.Event.File.Name, ".mid", fmt.Sprintf("-%d.txt", i))
|
||||
@@ -256,14 +256,14 @@ func init() {
|
||||
fileURL := ctx.GetThisGroupFileUrl(ctx.Event.File.BusID, ctx.Event.File.ID)
|
||||
data, err := web.GetData(fileURL)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
uid := ctx.Event.UserID
|
||||
midiFile := cachePath + strconv.FormatInt(uid, 10) + time.Now().Format("20060102150405") + "_midicreate.mid"
|
||||
cmidiFile, err := str2music(ctx, binary.BytesToString(data), midiFile)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:无法转换midi文件,", err))
|
||||
ctx.SendChain(message.Text("ERROR: 无法转换midi文件,", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Record("file:///" + file.BOTPATH + "/" + cmidiFile))
|
||||
@@ -273,7 +273,7 @@ func init() {
|
||||
param := ctx.State["args"].(string)
|
||||
timbre, err := strconv.Atoi(param)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
}
|
||||
err = setTimbreMode(ctx, int64(timbre))
|
||||
if err != nil {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Package moegoe 日韩 VITS 模型拟声
|
||||
// Package moegoe 日韩中 VITS 模型拟声
|
||||
package moegoe
|
||||
|
||||
import (
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
const (
|
||||
jpapi = "https://moegoe.azurewebsites.net/api/speak?text=%s&id=%d"
|
||||
krapi = "https://moegoe.azurewebsites.net/api/speakkr?text=%s&id=%d"
|
||||
cnapi = "http://233366.proxy.nscc-gz.cn:8888?speaker=%s&text=%s"
|
||||
)
|
||||
|
||||
var speakers = map[string]uint{
|
||||
@@ -28,18 +29,25 @@ func init() {
|
||||
DisableOnDefault: false,
|
||||
Help: "moegoe\n" +
|
||||
"- 让[宁宁|爱瑠|芳乃|茉子|丛雨|小春|七海]说(日语)\n" +
|
||||
"- 让[Sua|Mimiru|Arin|Yeonhwa|Yuhwa|Seonbae]说(韩语)",
|
||||
"- 让[Sua|Mimiru|Arin|Yeonhwa|Yuhwa|Seonbae]说(韩语)\n" +
|
||||
"- 让[派蒙|凯亚|安柏|丽莎|琴|香菱|枫原万叶|迪卢克|温迪|可莉|早柚|托马|芭芭拉|优菈|云堇|钟离|魈|凝光|雷电将军|北斗|甘雨|七七|刻晴|神里绫华|雷泽|神里绫人|罗莎莉亚|阿贝多|八重神子|宵宫|荒泷一斗|九条裟罗|夜兰|珊瑚宫心海|五郎|达达利亚|莫娜|班尼特|申鹤|行秋|烟绯|久岐忍|辛焱|砂糖|胡桃|重云|菲谢尔|诺艾尔|迪奥娜|鹿野院平藏]说(中文)",
|
||||
}).ApplySingle(ctxext.DefaultSingle)
|
||||
en.OnRegex("^让(宁宁|爱瑠|芳乃|茉子|丛雨|小春|七海)说([A-Za-z\\s\\d\u3005\u3040-\u30ff\u4e00-\u9fff\uff11-\uff19\uff21-\uff3a\uff41-\uff5a\uff66-\uff9d.。,,、::;;!!??]+)$").Limit(ctxext.LimitByGroup).SetBlock(true).
|
||||
en.OnRegex("^让(宁宁|爱瑠|芳乃|茉子|丛雨|小春|七海)说([A-Za-z\\s\\d\u3005\u3040-\u30ff\u4e00-\u9fff\uff11-\uff19\uff21-\uff3a\uff41-\uff5a\uff66-\uff9d\\pP]+)$").Limit(ctxext.LimitByGroup).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
text := ctx.State["regex_matched"].([]string)[2]
|
||||
id := speakers[ctx.State["regex_matched"].([]string)[1]]
|
||||
ctx.SendChain(message.Record(fmt.Sprintf(jpapi, url.QueryEscape(text), id)))
|
||||
})
|
||||
en.OnRegex("^让(Sua|Mimiru|Arin|Yeonhwa|Yuhwa|Seonbae)说([A-Za-z\\s\\d\u3131-\u3163\uac00-\ud7ff.。,,、::;;!!??]+)$").Limit(ctxext.LimitByGroup).SetBlock(true).
|
||||
en.OnRegex("^让(Sua|Mimiru|Arin|Yeonhwa|Yuhwa|Seonbae)说([A-Za-z\\s\\d\u3131-\u3163\uac00-\ud7ff\\pP]+)$").Limit(ctxext.LimitByGroup).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
text := ctx.State["regex_matched"].([]string)[2]
|
||||
id := speakers[ctx.State["regex_matched"].([]string)[1]]
|
||||
ctx.SendChain(message.Record(fmt.Sprintf(krapi, url.QueryEscape(text), id)))
|
||||
})
|
||||
en.OnRegex("^让(派蒙|凯亚|安柏|丽莎|琴|香菱|枫原万叶|迪卢克|温迪|可莉|早柚|托马|芭芭拉|优菈|云堇|钟离|魈|凝光|雷电将军|北斗|甘雨|七七|刻晴|神里绫华|雷泽|神里绫人|罗莎莉亚|阿贝多|八重神子|宵宫|荒泷一斗|九条裟罗|夜兰|珊瑚宫心海|五郎|达达利亚|莫娜|班尼特|申鹤|行秋|烟绯|久岐忍|辛焱|砂糖|胡桃|重云|菲谢尔|诺艾尔|迪奥娜|鹿野院平藏)说([\\s\u4e00-\u9fa5\\pP]+)$").Limit(ctxext.LimitByGroup).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
speaker := ctx.State["regex_matched"].([]string)[1]
|
||||
text := ctx.State["regex_matched"].([]string)[2]
|
||||
ctx.SendChain(message.Record(fmt.Sprintf(cnapi, url.QueryEscape(speaker), url.QueryEscape(text))))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
package moyucalendar
|
||||
|
||||
import (
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
@@ -21,7 +21,7 @@ func init() {
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.GetData("https://api.vvhan.com/api/moyu")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.ImageBytes(data))
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
@@ -141,7 +141,7 @@ func cloud163(keyword string) (msg message.MessageSegment) {
|
||||
requestURL := "https://music.cyrilstudio.top/search?keywords=" + url.QueryEscape(keyword)
|
||||
data, err := web.GetData(requestURL)
|
||||
if err != nil {
|
||||
msg = message.Text("ERROR:", err)
|
||||
msg = message.Text("ERROR: ", err)
|
||||
return
|
||||
}
|
||||
msg = message.Music("163", gjson.ParseBytes(data).Get("result.songs.0.id").Int())
|
||||
@@ -153,7 +153,7 @@ func qqmusic(keyword string) (msg message.MessageSegment) {
|
||||
requestURL := "https://c.y.qq.com/soso/fcgi-bin/client_search_cp?w=" + url.QueryEscape(keyword)
|
||||
data, err := web.RequestDataWith(web.NewDefaultClient(), requestURL, "GET", "", web.RandUA())
|
||||
if err != nil {
|
||||
msg = message.Text("ERROR:", err)
|
||||
msg = message.Text("ERROR: ", err)
|
||||
return
|
||||
}
|
||||
info := gjson.ParseBytes(data[9 : len(data)-1]).Get("data.song.list.0")
|
||||
|
||||
@@ -13,8 +13,8 @@ import (
|
||||
"github.com/sirupsen/logrus"
|
||||
_ "golang.org/x/image/webp" // import webp decoding
|
||||
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
)
|
||||
|
||||
// setuclass holds setus in a folder, which is the class name.
|
||||
|
||||
@@ -10,10 +10,11 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -42,7 +43,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
engine.OnRegex(`^本地(.*)$`, ctxext.ValueInList(func(ctx *zero.Ctx) string { return ctx.State["regex_matched"].([]string)[1] }, ns)).SetBlock(true).
|
||||
engine.OnRegex(`^本地(.*)$`, fcext.ValueInList(func(ctx *zero.Ctx) string { return ctx.State["regex_matched"].([]string)[1] }, ns)).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
imgtype := ctx.State["regex_matched"].([]string)[1]
|
||||
sc := new(setuclass)
|
||||
@@ -50,7 +51,7 @@ func init() {
|
||||
err := ns.db.Pick(imgtype, sc)
|
||||
ns.mu.RUnlock()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
} else {
|
||||
p := "file:///" + setupath + "/" + sc.Path
|
||||
if ctx.Event.GroupID != 0 {
|
||||
@@ -63,14 +64,14 @@ func init() {
|
||||
ctx.SendChain(message.Text(imgtype, ": ", sc.Name, "\n"), message.Image(p))
|
||||
}
|
||||
})
|
||||
engine.OnRegex(`^刷新本地(.*)$`, ctxext.ValueInList(func(ctx *zero.Ctx) string { return ctx.State["regex_matched"].([]string)[1] }, ns), zero.SuperUserPermission).SetBlock(true).
|
||||
engine.OnRegex(`^刷新本地(.*)$`, fcext.ValueInList(func(ctx *zero.Ctx) string { return ctx.State["regex_matched"].([]string)[1] }, ns), zero.SuperUserPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
imgtype := ctx.State["regex_matched"].([]string)[1]
|
||||
err := ns.scanclass(os.DirFS(setupath), imgtype, imgtype)
|
||||
if err == nil {
|
||||
ctx.SendChain(message.Text("成功!"))
|
||||
} else {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
}
|
||||
})
|
||||
engine.OnRegex(`^设置本地setu绝对路径(.*)$`, zero.SuperUserPermission).SetBlock(true).
|
||||
@@ -80,7 +81,7 @@ func init() {
|
||||
if err == nil {
|
||||
ctx.SendChain(message.Text("成功!"))
|
||||
} else {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
}
|
||||
})
|
||||
engine.OnFullMatch("刷新所有本地setu", zero.SuperUserPermission).SetBlock(true).
|
||||
@@ -89,7 +90,7 @@ func init() {
|
||||
if err == nil {
|
||||
ctx.SendChain(message.Text("成功!"))
|
||||
} else {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
}
|
||||
})
|
||||
engine.OnFullMatch("所有本地setu分类").SetBlock(true).
|
||||
|
||||
@@ -16,9 +16,9 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -4,10 +4,10 @@ package nihongo
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/binary"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
log "github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
@@ -21,26 +21,26 @@ func init() {
|
||||
PublicDataFolder: "Nihongo",
|
||||
})
|
||||
|
||||
getdb := ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
db.DBPath = engine.DataFolder() + "nihongo.db"
|
||||
_, err := engine.GetLazyData("nihongo.db", true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
err = db.Open(time.Hour * 24)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
err = db.Create("grammar", &grammar{})
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
n, err := db.Count("grammar")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
log.Infof("[nihongo]读取%d条语法", n)
|
||||
@@ -56,11 +56,11 @@ func init() {
|
||||
}
|
||||
data, err := text.RenderToBase64(g.string(), text.FontFile, 400, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if id := ctx.SendChain(message.Image("base64://" + binary.BytesToString(data))); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR:可能被风控了"))
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
|
||||
ub "github.com/FloatTech/floatbox/binary"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
ub "github.com/FloatTech/zbputils/binary"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
@@ -46,18 +46,18 @@ func init() {
|
||||
ctx.SendChain(message.Text("少女祈祷中......"))
|
||||
err := login(username, password)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
searchKey := ctx.State["regex_matched"].([]string)[1]
|
||||
searchHTML, err := search(searchKey)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
doc, err := htmlquery.Parse(strings.NewReader(searchHTML))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
htmlTitle := htmlquery.InnerText(htmlquery.FindOne(doc, "/html/head/title"))
|
||||
@@ -65,7 +65,7 @@ func init() {
|
||||
case websiteTitle:
|
||||
list, err := htmlquery.QueryAll(doc, "//dl[@id='nr']")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if len(list) != 0 {
|
||||
@@ -89,11 +89,11 @@ func init() {
|
||||
}
|
||||
data, err := text.RenderToBase64(txt, text.FontFile, 400, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if id := ctx.SendChain(message.Image("base64://" + helper.BytesToString(data))); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR:可能被风控了"))
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
} else {
|
||||
text := htmlquery.InnerText(htmlquery.FindOne(doc, "//div[@id='tipss']"))
|
||||
|
||||
@@ -3,10 +3,10 @@ package nsfw
|
||||
|
||||
import (
|
||||
"github.com/FloatTech/AnimeAPI/nsfw"
|
||||
"github.com/FloatTech/floatbox/process"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
@@ -26,7 +26,7 @@ func init() {
|
||||
ctx.SendChain(message.Text("少女祈祷中..."))
|
||||
p, err := nsfw.Classify(url[0])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text(judge(p))))
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
@@ -28,34 +29,34 @@ func init() { // 插件主体
|
||||
|
||||
engine.OnFullMatchGroup([]string{"求签", "占卜"}).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
i := ctxext.RandSenderPerDayN(ctx.Event.UserID, 100) + 1
|
||||
i := fcext.RandSenderPerDayN(ctx.Event.UserID, 100) + 1
|
||||
ctx.SendChain(
|
||||
message.At(ctx.Event.UserID),
|
||||
message.Image(fmt.Sprintf(bed, i, 0)),
|
||||
message.Image(fmt.Sprintf(bed, i, 1)),
|
||||
)
|
||||
})
|
||||
engine.OnFullMatch("解签", ctxext.DoOnceOnSuccess(
|
||||
engine.OnFullMatch("解签", fcext.DoOnceOnSuccess(
|
||||
func(ctx *zero.Ctx) bool {
|
||||
db.DBPath = engine.DataFolder() + "kuji.db"
|
||||
_, err := engine.GetLazyData("kuji.db", true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
err = db.Open(time.Hour * 24)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
err = db.Create("kuji", &kuji{})
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
n, err := db.Count("kuji")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
logrus.Infof("[kuji]读取%d条签文", n)
|
||||
@@ -65,16 +66,16 @@ func init() { // 插件主体
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
kujiBytes, err := text.RenderToBase64(
|
||||
getKujiByBango(
|
||||
uint8(ctxext.RandSenderPerDayN(ctx.Event.UserID, 100)+1),
|
||||
uint8(fcext.RandSenderPerDayN(ctx.Event.UserID, 100)+1),
|
||||
),
|
||||
text.FontFile, 400, 20,
|
||||
)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if id := ctx.SendChain(message.At(ctx.Event.UserID), message.Image("base64://"+helper.BytesToString(kujiBytes))); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR:可能被风控了"))
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -11,10 +11,11 @@ import (
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/floatbox/math"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/math"
|
||||
"github.com/wdvxdr1123/ZeroBot/extension/single"
|
||||
|
||||
// 数据库
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
@@ -24,12 +25,13 @@ import (
|
||||
|
||||
// 画图
|
||||
"github.com/Coloured-glaze/gg"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/img/writer"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
"github.com/FloatTech/zbputils/img/writer"
|
||||
)
|
||||
|
||||
//nolint: asciicheck
|
||||
// nolint: asciicheck
|
||||
type 婚姻登记 struct {
|
||||
db *sql.Sqlite
|
||||
dbmu sync.RWMutex
|
||||
@@ -289,8 +291,17 @@ func init() {
|
||||
"- 娶群友\n- 群老婆列表\n" +
|
||||
"--------------------------------\n以下技能每人只能三选一\n CD12H,不跨天刷新\n--------------------------------\n" +
|
||||
"- (娶|嫁)@对方QQ\n- 当[对方Q号|@对方QQ]的小三\n- 闹离婚",
|
||||
})
|
||||
getdb := ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
}).ApplySingle(single.New(
|
||||
single.WithKeyFn(func(ctx *zero.Ctx) int64 { return ctx.Event.GroupID }),
|
||||
single.WithPostFn[int64](func(ctx *zero.Ctx) {
|
||||
ctx.Send(
|
||||
message.ReplyWithMessage(ctx.Event.MessageID,
|
||||
message.Text("民政局门口排长队了!你们一个个来,别着急......"),
|
||||
),
|
||||
)
|
||||
}),
|
||||
))
|
||||
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
民政局.db.DBPath = engine.DataFolder() + "结婚登记表.db"
|
||||
// 如果数据库不存在则下载
|
||||
// _, _ = engine.GetLazyData("结婚登记表.db", false)
|
||||
@@ -545,13 +556,13 @@ func init() {
|
||||
/***********下载字体,可以注销掉***********/
|
||||
_, err = file.GetLazyData(text.BoldFontFile, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
}
|
||||
/***********设置字体颜色为黑色***********/
|
||||
canvas.SetRGB(0, 0, 0)
|
||||
/***********设置字体大小,并获取字体高度用来定位***********/
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, fontSize*2); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
sl, h := canvas.MeasureString("群老婆列表")
|
||||
@@ -560,7 +571,7 @@ func init() {
|
||||
canvas.DrawString("————————————————————", 0, 250-h)
|
||||
/***********设置字体大小,并获取字体高度用来定位***********/
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, fontSize); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
_, h = canvas.MeasureString("焯")
|
||||
|
||||
@@ -3,7 +3,7 @@ package reborn
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
)
|
||||
|
||||
// load 加载rate数据
|
||||
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
wr "github.com/mroth/weightedrand"
|
||||
"github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
@@ -21,14 +21,14 @@ func init() {
|
||||
PublicDataFolder: "Reborn",
|
||||
})
|
||||
|
||||
en.OnFullMatch("reborn", ctxext.DoOnceOnSuccess(
|
||||
en.OnFullMatch("reborn", fcext.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))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
choices := make([]wr.Choice, len(area))
|
||||
@@ -38,7 +38,7 @@ func init() {
|
||||
}
|
||||
areac, err = wr.NewChooser(choices...)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
logrus.Printf("[Reborn]读取%d个国家/地区", len(area))
|
||||
|
||||
@@ -131,7 +131,7 @@ func init() {
|
||||
// 运行失败
|
||||
ctx.SendChain(
|
||||
message.Text("> ", ctx.Event.Sender.NickName, "\n"),
|
||||
message.Text("ERROR:", err),
|
||||
message.Text("ERROR: ", err),
|
||||
)
|
||||
} else {
|
||||
// 运行成功
|
||||
|
||||
@@ -16,11 +16,11 @@ import (
|
||||
"github.com/FloatTech/AnimeAPI/pixiv"
|
||||
"github.com/jozsefsallai/gophersauce"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"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/pool"
|
||||
)
|
||||
|
||||
@@ -58,7 +58,7 @@ func init() { // 插件主体
|
||||
// 获取P站插图信息
|
||||
illust, err := pixiv.Works(id)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if illust.Pid > 0 {
|
||||
@@ -165,7 +165,7 @@ func init() { // 插件主体
|
||||
}
|
||||
// ascii2d 搜索
|
||||
if result, err := ascii2d.Ascii2d(pic); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
continue
|
||||
} else {
|
||||
msg := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Text("ascii2d搜图结果"))}
|
||||
@@ -186,7 +186,7 @@ func init() { // 插件主体
|
||||
ctx.Event.GroupID,
|
||||
msg,
|
||||
).Get("message_id").Int(); id == 0 {
|
||||
ctx.SendChain(message.Text("ERROR:可能被风控了"))
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -199,12 +199,12 @@ func init() { // 插件主体
|
||||
APIKey: ctx.State["regex_matched"].([]string)[1],
|
||||
})
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
err = os.WriteFile(apikeyfile, binary.StringToBytes(saucenaocli.APIKey), 0644)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("成功!"))
|
||||
|
||||
@@ -21,14 +21,14 @@ import (
|
||||
"github.com/FloatTech/AnimeAPI/nsfw"
|
||||
"github.com/FloatTech/AnimeAPI/scale"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/img/writer"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"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"
|
||||
"github.com/FloatTech/zbputils/img/writer"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -54,7 +54,7 @@ func init() {
|
||||
|
||||
p, err := nsfw.Classify(url[0])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if p.Drawings < 0.1 || p.Neutral > 0.8 {
|
||||
@@ -64,12 +64,12 @@ func init() {
|
||||
|
||||
data := <-datachan
|
||||
if errsub != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", errsub))
|
||||
ctx.SendChain(message.Text("ERROR: ", errsub))
|
||||
return
|
||||
}
|
||||
im, _, err := image.Decode(bytes.NewReader(data))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
px := im.Bounds().Size().X * im.Bounds().Size().Y
|
||||
@@ -85,7 +85,7 @@ func init() {
|
||||
defer binary.PutWriter(w)
|
||||
_, err = writer.WriteTo(im, w)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
data, err = scale.Post(bytes.NewReader(w.Bytes()), paras[0], paras[1], 2)
|
||||
@@ -93,14 +93,14 @@ func init() {
|
||||
data, err = scale.Get(url[0], paras[0], paras[1], 2)
|
||||
}
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
|
||||
n := cachedir + strconv.Itoa(int(ctx.Event.UserID))
|
||||
f, err := os.Create(n)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
_, _ = f.Write(data)
|
||||
|
||||
@@ -15,15 +15,15 @@ import (
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/img/writer"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"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"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
"github.com/FloatTech/zbputils/img/writer"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -72,12 +72,12 @@ func init() {
|
||||
}
|
||||
err := initPic(picFile)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
back, err := gg.LoadImage(picFile)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if siUpdateTimeStr != today {
|
||||
@@ -98,11 +98,11 @@ func init() {
|
||||
hourWord := getHourWord(now)
|
||||
_, err = file.GetLazyData(text.BoldFontFile, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if err = canvas.LoadFontFace(text.BoldFontFile, float64(back.Bounds().Size().X)*0.1); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
canvas.SetRGB(0, 0, 0)
|
||||
@@ -111,11 +111,11 @@ func init() {
|
||||
nickName := ctx.CardOrNickName(uid)
|
||||
_, err = file.GetLazyData(text.FontFile, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if err = canvas.LoadFontFace(text.FontFile, float64(back.Bounds().Size().X)*0.04); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
add := 1
|
||||
@@ -156,7 +156,7 @@ func init() {
|
||||
_, err = writer.WriteTo(canvas.Image(), f)
|
||||
_ = f.Close()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile))
|
||||
@@ -187,31 +187,31 @@ func init() {
|
||||
}
|
||||
st, err := sdb.GetScoreRankByTopN(10)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if len(st) == 0 {
|
||||
ctx.SendChain(message.Text("ERROR:目前还没有人签到过"))
|
||||
ctx.SendChain(message.Text("ERROR: 目前还没有人签到过"))
|
||||
return
|
||||
}
|
||||
_, err = file.GetLazyData(text.FontFile, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
b, err := os.ReadFile(text.FontFile)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
font, err := freetype.ParseFont(b)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
f, err := os.Create(drawedFile)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
bars := make([]chart.Value, len(st))
|
||||
@@ -234,7 +234,7 @@ func init() {
|
||||
_ = f.Close()
|
||||
if err != nil {
|
||||
_ = os.Remove(drawedFile)
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile))
|
||||
|
||||
@@ -9,14 +9,15 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/pixiv"
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
fileutil "github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/math"
|
||||
"github.com/FloatTech/floatbox/process"
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
fileutil "github.com/FloatTech/zbputils/file"
|
||||
imagepool "github.com/FloatTech/zbputils/img/pool"
|
||||
"github.com/FloatTech/zbputils/math"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
@@ -60,25 +61,25 @@ func init() { // 插件主体
|
||||
PublicDataFolder: "SetuTime",
|
||||
})
|
||||
|
||||
getdb := ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
// 如果数据库不存在则下载
|
||||
pool.db.DBPath = engine.DataFolder() + "SetuTime.db"
|
||||
_, _ = engine.GetLazyData("SetuTime.db", false)
|
||||
err := pool.db.Open(time.Hour * 24)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
for _, imgtype := range pool.List() {
|
||||
if err := pool.db.Create(imgtype, &pixiv.Illust{}); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
engine.OnRegex(`^来份(.+)$`, getdb, ctxext.ValueInList(func(ctx *zero.Ctx) string { return ctx.State["regex_matched"].([]string)[1] }, pool)).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
engine.OnRegex(`^来份(.+)$`, getdb, fcext.ValueInList(func(ctx *zero.Ctx) string { return ctx.State["regex_matched"].([]string)[1] }, pool)).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
var imgtype = ctx.State["regex_matched"].([]string)[1]
|
||||
// 补充池子
|
||||
@@ -88,13 +89,13 @@ func init() { // 插件主体
|
||||
ctx.SendChain(message.Text("INFO: 正在填充弹药......"))
|
||||
time.Sleep(time.Second * 10)
|
||||
if pool.size(imgtype) == 0 {
|
||||
ctx.SendChain(message.Text("ERROR:等待填充,请稍后再试......"))
|
||||
ctx.SendChain(message.Text("ERROR: 等待填充,请稍后再试......"))
|
||||
return
|
||||
}
|
||||
}
|
||||
// 从缓冲池里抽一张
|
||||
if id := ctx.SendChain(*pool.pop(imgtype)); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR:可能被风控了"))
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
})
|
||||
|
||||
@@ -106,13 +107,13 @@ func init() { // 插件主体
|
||||
)
|
||||
err := pool.add(ctx, imgtype, id)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("成功向分类", imgtype, "添加图片", id))
|
||||
})
|
||||
|
||||
engine.OnRegex(`^删除\s*([^0-9\s]+)\s*(\d+)$`, getdb, ctxext.ValueInList(func(ctx *zero.Ctx) string { return ctx.State["regex_matched"].([]string)[1] }, pool), zero.SuperUserPermission).SetBlock(true).
|
||||
engine.OnRegex(`^删除\s*([^0-9\s]+)\s*(\d+)$`, getdb, fcext.ValueInList(func(ctx *zero.Ctx) string { return ctx.State["regex_matched"].([]string)[1] }, pool), zero.SuperUserPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
var (
|
||||
imgtype = ctx.State["regex_matched"].([]string)[1]
|
||||
@@ -120,7 +121,7 @@ func init() { // 插件主体
|
||||
)
|
||||
// 查询数据库
|
||||
if err := pool.remove(imgtype, id); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("删除成功"))
|
||||
@@ -161,7 +162,7 @@ func (p *imgpool) push(ctx *zero.Ctx, imgtype string, illust *pixiv.Illust) {
|
||||
if fileutil.IsNotExist(f) {
|
||||
// 下载图片
|
||||
if err := illust.DownloadToCache(0); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -199,7 +200,7 @@ func (p *imgpool) fill(ctx *zero.Ctx, imgtype string) {
|
||||
illust := &pixiv.Illust{}
|
||||
// 查询出一张图片
|
||||
if err := p.db.Pick(imgtype, illust); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
continue
|
||||
}
|
||||
// 向缓冲池添加一张图片
|
||||
|
||||
@@ -11,12 +11,12 @@ func init() {
|
||||
engine.OnFullMatch("马丁路德骂我").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
doc, err := htmlquery.LoadURL(ergofabulousURL)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
node, err := htmlquery.Query(doc, "//main[@role=\"main\"]/p[@class=\"larger\"]/text()")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(node.Data))
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
package shadiao
|
||||
|
||||
import (
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
"github.com/tidwall/gjson"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
@@ -39,7 +39,7 @@ func init() {
|
||||
requestURL := sdMap[ctx.State["matched"].(string)]
|
||||
data, err := web.RequestDataWith(web.NewDefaultClient(), requestURL, "GET", sdReferer, ua)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(gjson.GetBytes(data, "data.text").String()))
|
||||
|
||||
@@ -6,15 +6,15 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine.OnFullMatch("来碗绿茶").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.RequestDataWith(web.NewDefaultClient(), chayiURL, "GET", loveliveReferer, ua)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
text := gjson.Get(helper.BytesToString(data), "returnObj.content").String()
|
||||
@@ -24,7 +24,7 @@ func init() {
|
||||
engine.OnFullMatch("渣我").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.RequestDataWith(web.NewDefaultClient(), ganhaiURL, "GET", loveliveReferer, ua)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
text := gjson.Get(helper.BytesToString(data), "returnObj.content").String()
|
||||
|
||||
@@ -8,15 +8,15 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine.OnFullMatch("讲个段子").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.RequestDataWith(web.NewDefaultClient(), yduanziURL, "POST", yduanziReferer, ua)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
text := gjson.Get(helper.BytesToString(data), "duanzi").String()
|
||||
|
||||
@@ -35,7 +35,7 @@ func handletxt(ctx *zero.Ctx) {
|
||||
// 调用接口
|
||||
txt, err := shindanmaker.Shindanmaker(ctx.State["id"].(int64), name)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text(txt))
|
||||
@@ -47,7 +47,7 @@ func handlecq(ctx *zero.Ctx) {
|
||||
// 调用接口
|
||||
txt, err := shindanmaker.Shindanmaker(ctx.State["id"].(int64), name)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.Send(txt)
|
||||
@@ -59,16 +59,16 @@ func handlepic(ctx *zero.Ctx) {
|
||||
// 调用接口
|
||||
txt, err := shindanmaker.Shindanmaker(ctx.State["id"].(int64), name)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
data, err := text.RenderToBase64(txt, text.FontFile, 400, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if id := ctx.SendChain(message.Image("base64://" + helper.BytesToString(data))); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR:可能被风控了"))
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,13 +3,13 @@ package tarot
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/binary"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
@@ -55,33 +55,32 @@ func init() {
|
||||
PublicDataFolder: "Tarot",
|
||||
}).ApplySingle(ctxext.DefaultSingle)
|
||||
|
||||
getTarot := ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
getTarot := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
data, err := engine.GetLazyData("tarots.json", true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
err = json.Unmarshal(data, &cardMap)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
for _, card := range cardMap {
|
||||
infoMap[card.Name] = card.cardInfo
|
||||
}
|
||||
for i := 0; i < 22; i++ {
|
||||
// 噢天哪,我应该把json里面序号设成int
|
||||
majorArcanaName = append(majorArcanaName, cardMap[strconv.Itoa(i)].Name)
|
||||
}
|
||||
logrus.Infof("[tarot]读取%d张塔罗牌", len(cardMap))
|
||||
formation, err := engine.GetLazyData("formation.json", true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
err = json.Unmarshal(formation, &formationMap)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
for k := range formationMap {
|
||||
@@ -94,28 +93,28 @@ func init() {
|
||||
match := ctx.State["regex_matched"].([]string)[1]
|
||||
cardType := ctx.State["regex_matched"].([]string)[2]
|
||||
n := 1
|
||||
reasons := [...]string{"您抽到的是~\n『", "锵锵锵,塔罗牌的预言是~\n『", "诶,让我看看您抽到了~\n『"}
|
||||
position := [...]string{"正位", "逆位"}
|
||||
reverse := [...]string{"", "Reverse"}
|
||||
reasons := [...]string{"您抽到的是~\n", "锵锵锵,塔罗牌的预言是~\n", "诶,让我看看您抽到了~\n"}
|
||||
position := [...]string{"『正位』", "『逆位』"}
|
||||
reverse := [...]string{"", "Reverse/"}
|
||||
start := 0
|
||||
length := 22
|
||||
if match != "" {
|
||||
var err error
|
||||
n, err = strconv.Atoi(match[:len(match)-3])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if n <= 0 {
|
||||
ctx.SendChain(message.Text("ERROR:张数必须为正"))
|
||||
ctx.SendChain(message.Text("ERROR: 张数必须为正"))
|
||||
return
|
||||
}
|
||||
if n > 1 && !zero.OnlyGroup(ctx) {
|
||||
ctx.SendChain(message.Text("ERROR:抽取多张仅支持群聊"))
|
||||
ctx.SendChain(message.Text("ERROR: 抽取多张仅支持群聊"))
|
||||
return
|
||||
}
|
||||
if n > 20 {
|
||||
ctx.SendChain(message.Text("ERROR:抽取张数过多"))
|
||||
ctx.SendChain(message.Text("ERROR: 抽取张数过多"))
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -128,10 +127,15 @@ func init() {
|
||||
p := rand.Intn(2)
|
||||
card := cardMap[strconv.Itoa(i)]
|
||||
name := card.Name
|
||||
description := card.Description
|
||||
if p == 1 {
|
||||
description = card.ReverseDescription
|
||||
}
|
||||
if id := ctx.SendChain(
|
||||
message.Text(reasons[rand.Intn(len(reasons))], position[p], "』的『", name, "』\n"),
|
||||
message.Image(fmt.Sprintf("%s/%s/%s", bed, reverse[p], card.ImgURL))); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR:可能被风控了"))
|
||||
message.Text(reasons[rand.Intn(len(reasons))], position[p], "的『", name, "』\n"),
|
||||
message.Image(bed+reverse[p]+card.ImgURL),
|
||||
message.Text("\n其释义为: ", description)); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -148,9 +152,14 @@ func init() {
|
||||
p := rand.Intn(2)
|
||||
card := cardMap[strconv.Itoa(j+start)]
|
||||
name := card.Name
|
||||
description := card.Description
|
||||
if p == 1 {
|
||||
description = card.ReverseDescription
|
||||
}
|
||||
tarotMsg := []message.MessageSegment{
|
||||
message.Text(reasons[rand.Intn(len(reasons))], position[p], "』的『", name, "』\n"),
|
||||
message.Image(fmt.Sprintf("%s/%s/%s", bed, reverse[p], card.ImgURL))}
|
||||
message.Text(position[p], "的『", name, "』\n"),
|
||||
message.Image(bed + reverse[p] + card.ImgURL),
|
||||
message.Text("\n其释义为: ", description)}
|
||||
msg[i] = ctxext.FakeSenderForwardNode(ctx, tarotMsg...)
|
||||
}
|
||||
ctx.SendGroupForwardMessage(ctx.Event.GroupID, msg)
|
||||
@@ -163,8 +172,8 @@ func init() {
|
||||
ctx.SendChain(
|
||||
message.Image(bed+info.ImgURL),
|
||||
message.Text("\n", match, "的含义是~"),
|
||||
message.Text("\n正位:", info.Description),
|
||||
message.Text("\n逆位:", info.ReverseDescription))
|
||||
message.Text("\n『正位』:", info.Description),
|
||||
message.Text("\n『逆位』:", info.ReverseDescription))
|
||||
} else {
|
||||
var build strings.Builder
|
||||
build.WriteString("塔罗牌列表\n大阿尔卡纳:\n")
|
||||
@@ -178,7 +187,7 @@ func init() {
|
||||
cardList, err := text.RenderToBase64(txt, text.FontFile, 420, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("没有找到", match, "噢~"))
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
}
|
||||
ctx.SendChain(message.Text("没有找到", match, "噢~"), message.Image("base64://"+binary.BytesToString(cardList)))
|
||||
}
|
||||
@@ -187,8 +196,8 @@ func init() {
|
||||
cardType := ctx.State["regex_matched"].([]string)[1]
|
||||
match := ctx.State["regex_matched"].([]string)[5]
|
||||
info, ok := formationMap[match]
|
||||
position := [...]string{"正位", "逆位"}
|
||||
reverse := [...]string{"", "Reverse"}
|
||||
position := [...]string{"『正位』", "『逆位』"}
|
||||
reverse := [...]string{"", "Reverse/"}
|
||||
start, length := 0, 22
|
||||
if strings.Contains(cardType, "小") {
|
||||
start = 22
|
||||
@@ -221,11 +230,11 @@ func init() {
|
||||
if p == 1 {
|
||||
description = card.ReverseDescription
|
||||
}
|
||||
tarotMsg := []message.MessageSegment{message.Image(fmt.Sprintf("%s/%s/%s", bed, reverse[p], card.ImgURL))}
|
||||
tarotMsg := []message.MessageSegment{message.Image(bed + reverse[p] + card.ImgURL)}
|
||||
build.WriteString(info.Represent[0][i])
|
||||
build.WriteString(":『")
|
||||
build.WriteString(":")
|
||||
build.WriteString(position[p])
|
||||
build.WriteString("』的『")
|
||||
build.WriteString("的『")
|
||||
build.WriteString(name)
|
||||
build.WriteString("』\n其释义为: \n")
|
||||
build.WriteString(description)
|
||||
@@ -235,7 +244,7 @@ func init() {
|
||||
txt := build.String()
|
||||
formation, err := text.RenderToBase64(txt, text.FontFile, 400, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
msg[info.CardsNum] = ctxext.FakeSenderForwardNode(ctx, []message.MessageSegment{message.Image("base64://" + binary.BytesToString(formation))}...)
|
||||
|
||||
@@ -4,6 +4,7 @@ package tiangou
|
||||
import (
|
||||
"time"
|
||||
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
sql "github.com/FloatTech/sqlite"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
@@ -28,27 +29,27 @@ func init() {
|
||||
PublicDataFolder: "Tiangou",
|
||||
})
|
||||
|
||||
en.OnFullMatch("舔狗日记", ctxext.DoOnceOnSuccess(
|
||||
en.OnFullMatch("舔狗日记", fcext.DoOnceOnSuccess(
|
||||
func(ctx *zero.Ctx) bool {
|
||||
db.DBPath = en.DataFolder() + "tiangou.db"
|
||||
_, err := en.GetLazyData("tiangou.db", true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
err = db.Open(time.Hour * 24)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
err = db.Create("tiangou", &tiangou{})
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
c, err := db.Count("tiangou")
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
logrus.Infoln("[tiangou]加载", c, "条舔狗日记")
|
||||
@@ -58,7 +59,7 @@ func init() {
|
||||
var t tiangou
|
||||
err := db.Pick("tiangou", &t)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text(t.Text))
|
||||
|
||||
@@ -25,7 +25,7 @@ func init() { // 插件主体
|
||||
ctx.SendChain(message.Text("少女祈祷中......"))
|
||||
for _, pic := range ctx.State["image_url"].([]string) {
|
||||
if result, err := moe.Search(pic, true, true); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
} else if len(result.Result) > 0 {
|
||||
r := result.Result[0]
|
||||
hint := "我有把握是这个!"
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
_ "github.com/fumiama/sqlite3" // import sql
|
||||
"github.com/jinzhu/gorm"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
@@ -18,12 +18,12 @@ import (
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"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"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/plugin/vtb_quotation/model"
|
||||
)
|
||||
@@ -38,15 +38,15 @@ func init() {
|
||||
})
|
||||
dbfile := engine.DataFolder() + "vtb.db"
|
||||
storePath := engine.DataFolder() + "store/"
|
||||
getdb := ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
err := os.MkdirAll(storePath, 0755)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
_, err = engine.GetLazyData("vtb.db", false)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
return true
|
||||
@@ -60,23 +60,23 @@ func init() {
|
||||
Repeat() // 不断监听复读
|
||||
db, err := model.Open(dbfile)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
defer db.Close()
|
||||
defer cancel()
|
||||
r, err := db.GetAllFirstCategoryMessage()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
firstStepImageBytes, err := text.RenderToBase64(r, text.FontFile, 400, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(firstStepImageBytes))); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR:可能被风控了"))
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
// 步骤0,1,2,依次选择3个类别
|
||||
step := 0
|
||||
@@ -102,33 +102,33 @@ func init() {
|
||||
indexs[0] = num
|
||||
secondStepMessage, err := db.GetAllSecondCategoryMessageByFirstIndex(indexs[0])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if secondStepMessage == "" {
|
||||
ctx.SendChain(message.Reply(c.Event.MessageID), message.Text("你选择的序号没有内容,请重新选择,三次输入错误,指令可退出重输"))
|
||||
r, err := db.GetAllFirstCategoryMessage()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
firstStepImageBytes, err := text.RenderToBase64(r, text.FontFile, 400, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(firstStepImageBytes))); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR:可能被风控了"))
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
errorCount++
|
||||
} else {
|
||||
secondStepMessageBytes, err := text.RenderToBase64(secondStepMessage, text.FontFile, 400, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(secondStepMessageBytes))); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR:可能被风控了"))
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
step++
|
||||
}
|
||||
@@ -137,33 +137,33 @@ func init() {
|
||||
indexs[1] = num
|
||||
thirdStepMessage, err := db.GetAllThirdCategoryMessageByFirstIndexAndSecondIndex(indexs[0], indexs[1])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if thirdStepMessage == "" {
|
||||
ctx.SendChain(message.Reply(c.Event.MessageID), message.Text("你选择的序号没有内容,请重新选择,三次输入错误,指令可退出重输"))
|
||||
r, err := db.GetAllSecondCategoryMessageByFirstIndex(indexs[0])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
secondStepMessageBytes, err := text.RenderToBase64(r, text.FontFile, 400, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(secondStepMessageBytes))); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR:可能被风控了"))
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
errorCount++
|
||||
} else {
|
||||
thirdStepMessageBytes, err := text.RenderToBase64(thirdStepMessage, text.FontFile, 400, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(thirdStepMessageBytes))); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR:可能被风控了"))
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
step++
|
||||
}
|
||||
@@ -175,16 +175,16 @@ func init() {
|
||||
ctx.SendChain(message.Reply(c.Event.MessageID), message.Text("没有内容请重新选择,三次输入错误,指令可退出重输"))
|
||||
r, err := db.GetAllFirstCategoryMessage()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
firstStepImageBytes, err := text.RenderToBase64(r, text.FontFile, 400, 20)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
if id := ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Image("base64://"+helper.BytesToString(firstStepImageBytes))); id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR:可能被风控了"))
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
errorCount++
|
||||
step = 1
|
||||
@@ -201,7 +201,7 @@ func init() {
|
||||
}
|
||||
err = initRecord(recordFile, recURL)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Record("file:///" + file.BOTPATH + "/" + recordFile))
|
||||
@@ -220,7 +220,7 @@ func init() {
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
db, err := model.Open(dbfile)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
defer db.Close()
|
||||
@@ -240,7 +240,7 @@ func init() {
|
||||
}
|
||||
err = initRecord(recordFile, recURL)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Record("file:///" + file.BOTPATH + "/" + recordFile))
|
||||
@@ -253,19 +253,19 @@ func init() {
|
||||
if db != nil {
|
||||
vl, err := db.GetVtbList()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
for _, v := range vl {
|
||||
err = db.StoreVtb(v)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
}
|
||||
err = db.Close()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
package wangyiyun
|
||||
|
||||
import (
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
@@ -25,7 +25,7 @@ func init() {
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.RequestDataWith(web.NewDefaultClient(), wangyiyunURL, "GET", wangyiyunReferer, ua)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text(helper.BytesToString(data)))
|
||||
|
||||
@@ -11,11 +11,12 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
"github.com/FloatTech/floatbox/file"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"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"
|
||||
@@ -40,15 +41,15 @@ func init() {
|
||||
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 {
|
||||
engine.OnRegex(`^热词\s?(\d*)\s?(\d*)$`, zero.OnlyGroup, fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
_, err := engine.GetLazyData("stopwords.txt", false)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
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))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
stopwords = strings.Split(strings.ReplaceAll(binary.BytesToString(data), "\r", ""), "\n")
|
||||
@@ -59,17 +60,17 @@ func init() {
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
_, err := file.GetLazyData(text.FontFile, true)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
b, err := os.ReadFile(text.FontFile)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
font, err := freetype.ParseFont(b)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -140,7 +141,7 @@ func init() {
|
||||
}
|
||||
// 绘图
|
||||
if len(wc) == 0 {
|
||||
ctx.SendChain(message.Text("ERROR:历史消息为空或者无法获得历史消息"))
|
||||
ctx.SendChain(message.Text("ERROR: 历史消息为空或者无法获得历史消息"))
|
||||
return
|
||||
}
|
||||
bars := make([]chart.Value, len(wc))
|
||||
@@ -164,14 +165,14 @@ func init() {
|
||||
}
|
||||
f, err := os.Create(drawedFile)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
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))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Image("file:///" + file.BOTPATH + "/" + drawedFile))
|
||||
|
||||
@@ -15,11 +15,12 @@ import (
|
||||
"github.com/FloatTech/AnimeAPI/tl"
|
||||
|
||||
"github.com/Coloured-glaze/gg"
|
||||
"github.com/FloatTech/floatbox/binary"
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
"github.com/FloatTech/floatbox/img/writer"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/binary"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/img/writer"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/extension/single"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
@@ -79,7 +80,7 @@ func init() {
|
||||
}),
|
||||
))
|
||||
|
||||
en.OnRegex(`^(个人|团队)(五阶|六阶|七阶)?猜单词$`, zero.OnlyGroup, ctxext.DoOnceOnSuccess(
|
||||
en.OnRegex(`^(个人|团队)(五阶|六阶|七阶)?猜单词$`, zero.OnlyGroup, fcext.DoOnceOnSuccess(
|
||||
func(ctx *zero.Ctx) bool {
|
||||
var errcnt uint32
|
||||
var wg sync.WaitGroup
|
||||
@@ -119,7 +120,7 @@ func init() {
|
||||
}
|
||||
wg.Wait()
|
||||
if errcnt > 0 {
|
||||
ctx.SendChain(message.Text("ERROR:下载字典时发生", errcnt, "个错误"))
|
||||
ctx.SendChain(message.Text("ERROR: 下载字典时发生", errcnt, "个错误"))
|
||||
return false
|
||||
}
|
||||
return true
|
||||
@@ -130,7 +131,7 @@ func init() {
|
||||
target := words[class].cet4[rand.Intn(len(words[class].cet4))]
|
||||
tt, err := tl.Translate(target)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
game := newWordleGame(target)
|
||||
|
||||
@@ -30,7 +30,7 @@ func init() {
|
||||
// 调用接口
|
||||
i, err := strconv.Atoi(ctx.State["regex_matched"].([]string)[1])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
w := newWtf(i)
|
||||
@@ -53,7 +53,7 @@ func init() {
|
||||
text, err = w.predict(name)
|
||||
}
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
// TODO: 可注入
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"errors"
|
||||
"net/url"
|
||||
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
"github.com/FloatTech/floatbox/web"
|
||||
)
|
||||
|
||||
/* JS path getter for https://wtf.hiigara.net/ranking
|
||||
|
||||
@@ -4,6 +4,7 @@ package ymgal
|
||||
import (
|
||||
"strings"
|
||||
|
||||
fcext "github.com/FloatTech/floatbox/ctxext"
|
||||
ctrl "github.com/FloatTech/zbpctrl"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
@@ -17,16 +18,16 @@ func init() {
|
||||
Help: "月幕galgame\n- 随机galCG\n- 随机gal表情包\n- galCG[xxx]\n- gal表情包[xxx]\n- 更新gal\n",
|
||||
PublicDataFolder: "Ymgal",
|
||||
})
|
||||
getdb := ctxext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
getdb := fcext.DoOnceOnSuccess(func(ctx *zero.Ctx) bool {
|
||||
dbfile := engine.DataFolder() + "ymgal.db"
|
||||
_, err := engine.GetLazyData("ymgal.db", false)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
gdb, err = initialize(dbfile)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return false
|
||||
}
|
||||
return true
|
||||
@@ -61,7 +62,7 @@ func init() {
|
||||
ctx.Send("少女祈祷中......")
|
||||
err := updatePic()
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
}
|
||||
ctx.Send("ymgal数据库已更新")
|
||||
@@ -83,6 +84,6 @@ func sendYmgal(y ymgal, ctx *zero.Ctx) {
|
||||
if id := ctx.SendGroupForwardMessage(
|
||||
ctx.Event.GroupID,
|
||||
m).Get("message_id").Int(); id == 0 {
|
||||
ctx.SendChain(message.Text("ERROR:可能被风控了"))
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user