mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2026-02-06 23:30:20 +00:00
Compare commits
36 Commits
v1.3.0
...
v1.3.1-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bccf789714 | ||
|
|
55944dddb3 | ||
|
|
f67932cc56 | ||
|
|
6d633fac6a | ||
|
|
86fc5c51c8 | ||
|
|
156e9f07ad | ||
|
|
1ba4722fc7 | ||
|
|
54c9857219 | ||
|
|
ea56c7d0d2 | ||
|
|
0cbe43df97 | ||
|
|
1f941d883a | ||
|
|
f5b3e423fb | ||
|
|
6c7f81ca55 | ||
|
|
3911b5ed82 | ||
|
|
f38f3ab69c | ||
|
|
846db6f063 | ||
|
|
ff068a05b0 | ||
|
|
051b7dd182 | ||
|
|
11870aeed6 | ||
|
|
9bcff82d9c | ||
|
|
309efe8cd8 | ||
|
|
bf54789f0f | ||
|
|
01e527abdb | ||
|
|
db6b558c75 | ||
|
|
9a792eb144 | ||
|
|
44e99664a3 | ||
|
|
9f3dd37bf0 | ||
|
|
f5936d9cb7 | ||
|
|
27e69ef022 | ||
|
|
6262aab6bd | ||
|
|
4781bc8eb7 | ||
|
|
b233c4b638 | ||
|
|
0a0cc807dc | ||
|
|
feeeb63e52 | ||
|
|
5c620d6268 | ||
|
|
a469000d7a |
45
README.md
45
README.md
@@ -66,6 +66,42 @@ zerobot [-h] [-t token] [-u url] [-n nickname] [-p prefix] [-d|w] [-g 监听地
|
||||
- [x] /服务列表
|
||||
- [x] /服务详情
|
||||
- [x] @Bot 插件冲突检测 (会在本群发送一条消息并在约 1s 后撤回以检测其它同类 bot 中已启用的插件并禁用)
|
||||
- **定时指令触发器** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/job"`
|
||||
- [x] 记录在"cron"触发的指令
|
||||
- [x] 取消在"cron"触发的指令
|
||||
- [x] 查看所有触发指令
|
||||
- [x] 查看在"cron"触发的指令
|
||||
- [x] 注入指令结果:任意指令,可以使用形如`?::参数1提示语::1!`,`?::参数2提示语::2!`的未定参数,在注入时一一匹配
|
||||
- [x] 执行指令:任意指令,可以使用形如`?::参数1提示语::1!`,`?::参数2提示语::2!`的未定参数,在注入时一一匹配
|
||||
- 一些示例
|
||||
> 每日9:30推送摸鱼人日历
|
||||
```
|
||||
记录在"30 9 * * *"触发的指令
|
||||
run[CQ:image,file=https://api.vvhan.com/api/moyu]
|
||||
```
|
||||
> 每日12:00以1/2概率执行coser指令
|
||||
```python
|
||||
记录在"0 12 * * *"触发的指令
|
||||
注入指令结果:>runcoderaw py
|
||||
from random import random
|
||||
if random() > 0.5: print('coser')
|
||||
else: print('今天没有coser哦~')
|
||||
```
|
||||
> 每日15:00询问设置定时者否想看coser
|
||||
```python
|
||||
记录在"0 15 * * *"触发的指令
|
||||
注入指令结果:>runcoderaw py
|
||||
if '?::想看coser吗?::1!' == '想': print('coser')
|
||||
else: print('好吧')
|
||||
```
|
||||
> 自行编写简易的选择困难症助手小插件
|
||||
```python
|
||||
执行指令:>runcoderaw py
|
||||
from random import random
|
||||
if random() > 0.5: print('您最终会选?::请输入您的选择1::1!')
|
||||
else: print('您最终会选?::请输入您的选择2::2!')
|
||||
```
|
||||

|
||||
- **聊天** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/chat"`
|
||||
- [x] [BOT名字]
|
||||
- [x] [戳一戳BOT]
|
||||
@@ -115,6 +151,7 @@ zerobot [-h] [-t token] [-u url] [-n nickname] [-p prefix] [-d|w] [-g 监听地
|
||||
- **在线代码运行** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/runcode"`
|
||||
- [x] > runcode [language] help
|
||||
- [x] > runcode [language] [code block]
|
||||
- [x] > runcoderaw [language] [code block]
|
||||
- **点歌** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/music"`
|
||||
- [x] 点歌[xxx]
|
||||
- [x] 网易点歌[xxx]
|
||||
@@ -179,7 +216,7 @@ zerobot [-h] [-t token] [-u url] [-n nickname] [-p prefix] [-d|w] [-g 监听地
|
||||
- [x] 放大图片[图片]
|
||||
- **每日运势** `import _ github.com/FloatTech/ZeroBot-Plugin/plugin/fortune`
|
||||
- [x] 运势 | 抽签
|
||||
- [x] 设置底图[车万 DC4 爱因斯坦 星空列车 樱云之恋 富婆妹 李清歌 公主连结 原神 明日方舟 碧蓝航线 碧蓝幻想 战双 阴阳师 赛马娘]
|
||||
- [x] 设置底图[车万 DC4 爱因斯坦 星空列车 樱云之恋 富婆妹 李清歌 公主连结 原神 明日方舟 碧蓝航线 碧蓝幻想 战双 阴阳师 赛马娘 东方归言录]
|
||||
- **睡眠管理** `import _ github.com/FloatTech/ZeroBot-Plugin/plugin/sleep_manage`
|
||||
- [x] 早安 | 晚安
|
||||
- **浅草寺求签** `import _ github.com/FloatTech/ZeroBot-Plugin/plugin/omikuji`
|
||||
@@ -287,6 +324,12 @@ zerobot [-h] [-t token] [-u url] [-n nickname] [-p prefix] [-d|w] [-g 监听地
|
||||
- **煎蛋网无聊图** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/jandan"`
|
||||
- [x] 来份屌图
|
||||
- [x] 更新屌图
|
||||
- **月幕galgame图** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin/ymgal"`
|
||||
- [x] 随机galCG
|
||||
- [x] 随机gal表情包
|
||||
- [x] galCG[xxx]
|
||||
- [x] gal表情包[xxx]
|
||||
- [x] 更新gal
|
||||
- **TODO...**
|
||||
|
||||
## 使用方法
|
||||
|
||||
2
data
2
data
Submodule data updated: f8067d8790...e084d72e9d
30
go.mod
30
go.mod
@@ -3,26 +3,26 @@ module github.com/FloatTech/ZeroBot-Plugin
|
||||
go 1.17
|
||||
|
||||
require (
|
||||
github.com/FloatTech/AnimeAPI v1.3.0-beta8.0.20220227060429-ae266747b1df
|
||||
github.com/FloatTech/sqlite v0.2.0
|
||||
github.com/FloatTech/zbputils v1.3.0-beta8.0.20220227042832-376a84a3ea87
|
||||
github.com/FloatTech/AnimeAPI v1.3.1-0.20220307053346-aa76aec4b635
|
||||
github.com/FloatTech/sqlite v0.2.1
|
||||
github.com/FloatTech/zbputils v1.3.1-0.20220307143543-1139754cacdf
|
||||
github.com/antchfx/htmlquery v1.2.4
|
||||
github.com/corona10/goimagehash v1.0.3
|
||||
github.com/fogleman/gg v1.3.0
|
||||
github.com/fumiama/cron v1.3.0
|
||||
github.com/fumiama/go-base16384 v1.3.0
|
||||
github.com/fumiama/go-registry v0.1.0
|
||||
github.com/fumiama/go-registry v0.1.1
|
||||
github.com/fumiama/gofastTEA v0.0.9
|
||||
github.com/fumiama/gotracemoe v0.0.3
|
||||
github.com/fumiama/sqlite3 v1.14.6
|
||||
github.com/jinzhu/gorm v1.9.16
|
||||
github.com/mroth/weightedrand v0.4.1
|
||||
github.com/pkumza/numcn v1.0.0
|
||||
github.com/shirou/gopsutil/v3 v3.21.12
|
||||
github.com/shirou/gopsutil/v3 v3.22.2
|
||||
github.com/sirupsen/logrus v1.8.1
|
||||
github.com/tidwall/gjson v1.13.0
|
||||
github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220223090418-8c5d8eccaf3a
|
||||
golang.org/x/image v0.0.0-20211028202545-6944b10bf410
|
||||
github.com/tidwall/gjson v1.14.0
|
||||
github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220307142419-a1b34e6da007
|
||||
golang.org/x/image v0.0.0-20220302094943-723b81ca9867
|
||||
)
|
||||
|
||||
require (
|
||||
@@ -37,19 +37,19 @@ require (
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||
github.com/mattn/go-sqlite3 v1.14.10 // indirect
|
||||
github.com/mattn/go-sqlite3 v1.14.12 // indirect
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
|
||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
|
||||
github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c // indirect
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.0 // indirect
|
||||
github.com/tklauser/go-sysconf v0.3.9 // indirect
|
||||
github.com/tklauser/numcpus v0.3.0 // indirect
|
||||
github.com/tklauser/go-sysconf v0.3.10 // indirect
|
||||
github.com/tklauser/numcpus v0.4.0 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.2 // indirect
|
||||
golang.org/x/net v0.0.0-20220111093109-d55c255bac03 // indirect
|
||||
golang.org/x/sys v0.0.0-20220209214540-3681064d5158 // indirect
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
|
||||
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9 // indirect
|
||||
golang.org/x/text v0.3.7 // indirect
|
||||
modernc.org/libc v1.14.5 // indirect
|
||||
modernc.org/libc v1.14.6 // indirect
|
||||
modernc.org/mathutil v1.4.1 // indirect
|
||||
modernc.org/memory v1.0.5 // indirect
|
||||
)
|
||||
|
||||
67
go.sum
67
go.sum
@@ -1,10 +1,11 @@
|
||||
github.com/FloatTech/AnimeAPI v1.3.0-beta8.0.20220227060429-ae266747b1df h1:pz6mcz4pC8hEbyygM/QX/mX7pgvQOIpYF8H940/4Z8Q=
|
||||
github.com/FloatTech/AnimeAPI v1.3.0-beta8.0.20220227060429-ae266747b1df/go.mod h1:uMe7TzdyGnyRn6AzMmkvDXp+GfTTWV/vBlv6mhhP8kg=
|
||||
github.com/FloatTech/AnimeAPI v1.3.1-0.20220307053346-aa76aec4b635 h1:T7J1wLvSqn8PvkM7X98dgbafW+zG1l0LdX664HbrG0U=
|
||||
github.com/FloatTech/AnimeAPI v1.3.1-0.20220307053346-aa76aec4b635/go.mod h1:ZNhcnGEchvEjd09WbpLMlmxlmYy4trtLYEAJHRAoKaw=
|
||||
github.com/FloatTech/bot-manager v1.0.0/go.mod h1:8YYRJ16oroGHQGD2En0oVnmcKJkxR9O/jd5BPSfWfOQ=
|
||||
github.com/FloatTech/sqlite v0.2.0 h1:x3uls/hExXH1+bbaNLkvilce6ATtWlDx4IqoxBW/bv8=
|
||||
github.com/FloatTech/sqlite v0.2.0/go.mod h1:xIDWIvpOFl8AXmZm0FC8t3PZjiR6ZutytCpBv2EWCns=
|
||||
github.com/FloatTech/zbputils v1.3.0-beta8.0.20220227042832-376a84a3ea87 h1:nyUTZLGUAJP/kLXx48j2qdxQBPVqaZgypjjIqpIRqwk=
|
||||
github.com/FloatTech/zbputils v1.3.0-beta8.0.20220227042832-376a84a3ea87/go.mod h1:Jn5LmnwqYivr64qQJBdhDwm2gRut8Hhq5gPBydV0Gvg=
|
||||
github.com/FloatTech/sqlite v0.2.1 h1:9t6Me48XJJCIoPy4nLRvcdhcVKfT0c2lilp7SEKROG8=
|
||||
github.com/FloatTech/sqlite v0.2.1/go.mod h1:6NfHRzqOo9RWeMJEoAQVuo51Omd5LFNxCNQhMF02/9U=
|
||||
github.com/FloatTech/zbputils v1.3.1-0.20220307053255-29a0c0203693/go.mod h1:1nzt5KFkggpZaqkW0faY3y0X/qeMKTodqWc8wbVYhoY=
|
||||
github.com/FloatTech/zbputils v1.3.1-0.20220307143543-1139754cacdf h1:891FSWb/olANthyZpmsqLWc8Xqr9yKxNOlRjZeHF/c8=
|
||||
github.com/FloatTech/zbputils v1.3.1-0.20220307143543-1139754cacdf/go.mod h1:u+PiX1khNvtAgfRVTVP4hkA2oUnn5q5dTZSk1Cgp0Gw=
|
||||
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
|
||||
github.com/RomiChan/websocket v1.4.3-0.20220123145318-307a86b127bc h1:AAx50/fb/xS4lvsdQg+bFbGvqSDhyV1MF+p2PLCamZ0=
|
||||
github.com/RomiChan/websocket v1.4.3-0.20220123145318-307a86b127bc/go.mod h1:OMmITAib6POA37xCichWM0aRnoVpSMZO1rB/G01wrr0=
|
||||
@@ -35,8 +36,9 @@ 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.3.0 h1:J5Xtwh/3alGJt/z/0IFralo5UQA89iFWQqbxj5ZQZi8=
|
||||
github.com/fumiama/go-base16384 v1.3.0/go.mod h1:RGA715p34BiLoZvPRtaxuo2q25Kq9jFsgUsJb8dwy14=
|
||||
github.com/fumiama/go-registry v0.1.0 h1:CIzQN9wOZKIokALyYkNIpPQ7bpzmirDua77S2BicdVE=
|
||||
github.com/fumiama/go-registry v0.1.0/go.mod h1:iJT3DVgH7KXpJZs6waXEjnWtJPUBBGhF+ByJIMRfngk=
|
||||
github.com/fumiama/go-registry v0.1.1 h1:cmCRizjXHFW2ApwUHCXi8wKLJ6Gtt4GrShJlamGPbVI=
|
||||
github.com/fumiama/go-registry v0.1.1/go.mod h1:iJT3DVgH7KXpJZs6waXEjnWtJPUBBGhF+ByJIMRfngk=
|
||||
github.com/fumiama/gofastTEA v0.0.9 h1:adaWz+014vMShnLUNWIHLBs0Yv6JNUohcaXZNtct5J0=
|
||||
github.com/fumiama/gofastTEA v0.0.9/go.mod h1:RIdbYZyB4MbH6ZBlPymRaXn3cD6SedlCu5W/HHfMPBk=
|
||||
github.com/fumiama/gotracemoe v0.0.3 h1:iI5EbE9A3UUbfukG6+/soYPjp1S31eCNYf4tw7s6/Jc=
|
||||
@@ -103,8 +105,8 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky
|
||||
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-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
|
||||
github.com/mattn/go-sqlite3 v1.14.10 h1:MLn+5bFRlWMGoSRmJour3CL1w/qL96mvipqpwQW/Sfk=
|
||||
github.com/mattn/go-sqlite3 v1.14.10/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||
github.com/mattn/go-sqlite3 v1.14.12 h1:TJ1bhYJPV44phC+IMu1u2K/i5RriLTPe+yc68XDJ1Z0=
|
||||
github.com/mattn/go-sqlite3 v1.14.12/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
@@ -121,14 +123,15 @@ 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=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=
|
||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
|
||||
github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c h1:NRoLoZvkBTKvR5gQLgA3e0hqjkY9u1wm+iOL45VN/qI=
|
||||
github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
|
||||
github.com/shirou/gopsutil/v3 v3.21.12 h1:VoGxEW2hpmz0Vt3wUvHIl9fquzYLNpVpgNNB7pGJimA=
|
||||
github.com/shirou/gopsutil/v3 v3.21.12/go.mod h1:BToYZVTlSVlfazpDDYFnsVZLaoRG+g8ufT6fPQLdJzA=
|
||||
github.com/shirou/gopsutil/v3 v3.22.2 h1:wCrArWFkHYIdDxx/FSfF5RB4dpJYW6t7rcp3+zL8uks=
|
||||
github.com/shirou/gopsutil/v3 v3.22.2/go.mod h1:WapW1AOOPlHyXr+yOyw3uYx36enocrtSoSBy0L5vUHY=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
|
||||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
@@ -142,22 +145,26 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
|
||||
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816/go.mod h1:tzym/CEb5jnFI+Q0k4Qq3+LvRF4gO3E2pxS8fHP8jcA=
|
||||
github.com/tidwall/gjson v1.13.0 h1:3TFY9yxOQShrvmjdM76K+jc66zJeT6D3/VFFYCGQf7M=
|
||||
github.com/tidwall/gjson v1.13.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/gjson v1.14.0 h1:6aeJ0bzojgWLa82gDQHcx3S0Lr/O51I9bJ5nv6JFx5w=
|
||||
github.com/tidwall/gjson v1.14.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
||||
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
|
||||
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||
github.com/tklauser/go-sysconf v0.3.9 h1:JeUVdAOWhhxVcU6Eqr/ATFHgXk/mmiItdKeJPev3vTo=
|
||||
github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs=
|
||||
github.com/tklauser/numcpus v0.3.0 h1:ILuRUQBtssgnxw0XXIjKUC56fgnOrFoQQ/4+DeU2biQ=
|
||||
github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw=
|
||||
github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk=
|
||||
github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8=
|
||||
github.com/tklauser/numcpus v0.4.0 h1:E53Dm1HjH1/R2/aoCtXtPgzmElmn51aOkhCFSuZq//o=
|
||||
github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ=
|
||||
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
||||
github.com/ugorji/go v1.2.6/go.mod h1:anCg0y61KIhDlPZmnH+so+RQbysYVyDko0IMgJv0Nn0=
|
||||
github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M=
|
||||
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
|
||||
github.com/ugorji/go/codec v1.2.6/go.mod h1:V6TCNZ4PHqoHGFZuSG1W8nrCzzdgA2DozYxWFFpvxTw=
|
||||
github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220223090418-8c5d8eccaf3a h1:Mw7850zyEgIr8VO9e8iofo78maed53FclPzRiMa7aeY=
|
||||
github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220223090418-8c5d8eccaf3a/go.mod h1:NwXIp7PgjV+kUALMXJ4v4/3QcsRSOodtjhLekuPXFog=
|
||||
github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
|
||||
github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220304040741-8e53f210618c/go.mod h1:NwXIp7PgjV+kUALMXJ4v4/3QcsRSOodtjhLekuPXFog=
|
||||
github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220307142419-a1b34e6da007 h1:yHCJCj8u3Y0JDgTlrUqPHxIO6KU0WK9+voECZ2im5lo=
|
||||
github.com/wdvxdr1123/ZeroBot v1.4.2-0.20220307142419-a1b34e6da007/go.mod h1:NwXIp7PgjV+kUALMXJ4v4/3QcsRSOodtjhLekuPXFog=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg=
|
||||
github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
|
||||
@@ -167,11 +174,11 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
|
||||
golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20220126234351-aa10faf2a1f8 h1:kACShD3qhmr/3rLmg1yXyt+N4HcwutKyPRB93s54TIU=
|
||||
golang.org/x/crypto v0.0.0-20220126234351-aa10faf2a1f8/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.0.0-20220214200702-86341886e292 h1:f+lwQ+GtmgoY+A2YaQxlSOnDjXcQ7ZRLWOHbC6HtRqE=
|
||||
golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.0.0-20211028202545-6944b10bf410 h1:hTftEOvwiOq2+O8k2D5/Q7COC7k5Qcrgc2TFURJYnvQ=
|
||||
golang.org/x/image v0.0.0-20211028202545-6944b10bf410/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
|
||||
golang.org/x/image v0.0.0-20220302094943-723b81ca9867 h1:TcHcE0vrmgzNH1v3ppjcMGbhG5+9fMuvOmUYwNEF4q4=
|
||||
golang.org/x/image v0.0.0-20220302094943-723b81ca9867/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@@ -183,8 +190,8 @@ golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220111093109-d55c255bac03 h1:0FB83qp0AzVJm+0wcIlauAjJ+tNdh7jLuacRYCIVv7s=
|
||||
golang.org/x/net v0.0.0-20220111093109-d55c255bac03/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc=
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@@ -207,11 +214,14 @@ golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210902050250-f475640dd07b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211013075003-97ac67df715c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220111092808-5a964db01320/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220209214540-3681064d5158 h1:rm+CHSpPEEW2IsXUib1ThaHIjuBVZjxNgSKmBLFfD4c=
|
||||
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9 h1:nhht2DYV/Sn3qOayu8lM+cU1ii9sTLUeBQwQQfUHtrs=
|
||||
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
@@ -343,8 +353,9 @@ modernc.org/libc v1.12.0/go.mod h1:2MH3DaF/gCU8i/UBiVE1VFRos4o523M7zipmwH8SIgQ=
|
||||
modernc.org/libc v1.14.1/go.mod h1:npFeGWjmZTjFeWALQLrvklVmAxv4m80jnG3+xI8FdJk=
|
||||
modernc.org/libc v1.14.2/go.mod h1:MX1GBLnRLNdvmK9azU9LCxZ5lMyhrbEMK8rG3X/Fe34=
|
||||
modernc.org/libc v1.14.3/go.mod h1:GPIvQVOVPizzlqyRX3l756/3ppsAgg1QgPxjr5Q4agQ=
|
||||
modernc.org/libc v1.14.5 h1:DAHvwGoVRDZs5iJXnX9RJrgXSsorupCWmJ2ac964Owk=
|
||||
modernc.org/libc v1.14.5/go.mod h1:2PJHINagVxO4QW/5OQdRrvMYo+bm5ClpUFfyXCYl9ak=
|
||||
modernc.org/libc v1.14.6 h1:SSiZiE5199iYsGM9gtkDj90xqcXVwubWG8CtoYE+Mnk=
|
||||
modernc.org/libc v1.14.6/go.mod h1:2PJHINagVxO4QW/5OQdRrvMYo+bm5ClpUFfyXCYl9ak=
|
||||
modernc.org/mathutil v1.1.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
|
||||
modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
|
||||
modernc.org/mathutil v1.4.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
|
||||
|
||||
45
kanban/banner.go
Normal file
45
kanban/banner.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package kanban
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/fumiama/go-registry"
|
||||
)
|
||||
|
||||
var (
|
||||
info = [...]string{
|
||||
"* OneBot + ZeroBot + Golang",
|
||||
"* Version 1.3.1 - 2022-03-07 13:40:58 +0800 CST",
|
||||
"* Copyright © 2020 - 2022 FloatTech. All Rights Reserved.",
|
||||
"* Project: https://github.com/FloatTech/ZeroBot-Plugin",
|
||||
}
|
||||
// Banner ...
|
||||
Banner = strings.Join(info[:], "\n")
|
||||
reg = registry.NewRegReader("reilia.westeurope.cloudapp.azure.com:32664", "fumiama")
|
||||
)
|
||||
|
||||
// PrintBanner ...
|
||||
func PrintBanner() {
|
||||
fmt.Print(
|
||||
"\n======================[ZeroBot-Plugin]======================",
|
||||
"\n", Banner, "\n",
|
||||
"----------------------[ZeroBot-公告栏]----------------------",
|
||||
"\n", Kanban(), "\n",
|
||||
"============================================================\n\n",
|
||||
)
|
||||
}
|
||||
|
||||
// Kanban ...
|
||||
func Kanban() string {
|
||||
err := reg.Connect()
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
}
|
||||
defer reg.Close()
|
||||
text, err := reg.Get("ZeroBot-Plugin/kanban")
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
}
|
||||
return text
|
||||
}
|
||||
6
kanban/init.go
Normal file
6
kanban/init.go
Normal file
@@ -0,0 +1,6 @@
|
||||
// Package kanban 打印版本信息
|
||||
package kanban
|
||||
|
||||
func init() {
|
||||
PrintBanner()
|
||||
}
|
||||
51
main.go
51
main.go
@@ -5,9 +5,10 @@ import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/kanban" // 在最前打印 banner
|
||||
|
||||
// ---------以下插件均可通过前面加 // 注释,注释后停用并不加载插件--------- //
|
||||
// ----------------------插件优先级按顺序从高到低---------------------- //
|
||||
// //
|
||||
@@ -76,6 +77,7 @@ import (
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/hs" // 炉石
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/image_finder" // 关键字搜图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/jandan" // 煎蛋网无聊图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/job" // 定时指令触发器
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/juejuezi" // 绝绝子生成器
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/lolicon" // lolicon 随机图片
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/moyu" // 摸鱼
|
||||
@@ -100,6 +102,7 @@ import (
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/vtb_quotation" // vtb语录
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wangyiyun" // 网易云音乐热评
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/wordle" // 猜单词
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin/ymgal" // 月幕galgame
|
||||
|
||||
// _ "github.com/FloatTech/ZeroBot-Plugin/plugin/wtf" // 鬼东西
|
||||
// _ "github.com/FloatTech/ZeroBot-Plugin/plugin/bilibili_push" // b站推送
|
||||
@@ -138,8 +141,7 @@ import (
|
||||
// //
|
||||
// //
|
||||
// -----------------------以下为内置依赖,勿动------------------------ //
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
"github.com/fumiama/go-registry"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
"github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/driver"
|
||||
@@ -148,19 +150,11 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
contents = []string{
|
||||
"* OneBot + ZeroBot + Golang",
|
||||
"* Version 1.3.0 - 2022-02-09 14:31:34 +0800 CST",
|
||||
"* Copyright © 2020 - 2021 FloatTech. All Rights Reserved.",
|
||||
"* Project: https://github.com/FloatTech/ZeroBot-Plugin",
|
||||
}
|
||||
nicks = []string{"ATRI", "atri", "亚托莉", "アトリ"}
|
||||
banner = strings.Join(contents, "\n")
|
||||
token *string
|
||||
url *string
|
||||
adana *string
|
||||
prefix *string
|
||||
reg = registry.NewRegReader("reilia.fumiama.top:32664", "fumiama")
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -181,7 +175,7 @@ func init() {
|
||||
|
||||
flag.Parse()
|
||||
if *h {
|
||||
printBanner()
|
||||
kanban.PrintBanner()
|
||||
fmt.Println("Usage:")
|
||||
flag.PrintDefaults()
|
||||
os.Exit(0)
|
||||
@@ -198,43 +192,18 @@ func init() {
|
||||
// webctrl.InitGui(*g)
|
||||
}
|
||||
|
||||
func printBanner() {
|
||||
fmt.Print(
|
||||
"\n======================[ZeroBot-Plugin]======================",
|
||||
"\n", banner, "\n",
|
||||
"----------------------[ZeroBot-公告栏]----------------------",
|
||||
"\n", getKanban(), "\n",
|
||||
"============================================================\n",
|
||||
)
|
||||
}
|
||||
|
||||
func getKanban() string {
|
||||
err := reg.Connect()
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
}
|
||||
defer reg.Close()
|
||||
text, err := reg.Get("ZeroBot-Plugin/kanban")
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
}
|
||||
return text
|
||||
}
|
||||
|
||||
func main() {
|
||||
order.Wait()
|
||||
printBanner()
|
||||
rand.Seed(time.Now().UnixNano()) // 全局 seed,其他插件无需再 seed
|
||||
// 帮助
|
||||
zero.OnFullMatchGroup([]string{"/help", ".help", "菜单"}, zero.OnlyToMe).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SendChain(message.Text(banner, "\n可发送\"/服务列表\"查看 bot 功能"))
|
||||
ctx.SendChain(message.Text(kanban.Banner, "\n可发送\"/服务列表\"查看 bot 功能"))
|
||||
})
|
||||
zero.OnFullMatch("查看zbp公告", zero.OnlyToMe, zero.AdminPermission).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SendChain(message.Text(getKanban()))
|
||||
ctx.SendChain(message.Text(kanban.Kanban()))
|
||||
})
|
||||
zero.RunAndBlock(
|
||||
zero.Run(
|
||||
zero.Config{
|
||||
NickName: append([]string{*adana}, nicks...),
|
||||
CommandPrefix: *prefix,
|
||||
@@ -244,4 +213,6 @@ func main() {
|
||||
Driver: []zero.Driver{driver.NewWebSocketClient(*url, *token)},
|
||||
},
|
||||
)
|
||||
process.GlobalInitMutex.Unlock()
|
||||
select {}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,13 @@ func init() { // 插件主体
|
||||
} else {
|
||||
url = randapi
|
||||
}
|
||||
setLastMsg(ctx.Event.GroupID, ctx.SendChain(message.Image(url).Add("cache", "0")))
|
||||
setLastMsg(ctx.Event.GroupID, message.NewMessageID(
|
||||
ctx.SendGroupForwardMessage(ctx.Event.GroupID,
|
||||
message.Message{
|
||||
ctxext.FakeSenderForwardNode(ctx,
|
||||
message.Image(url).Add("cache", "0"),
|
||||
),
|
||||
}).Get("message_id").String()))
|
||||
block = false
|
||||
}
|
||||
})
|
||||
@@ -149,9 +155,19 @@ func reply(ctx *zero.Ctx, class int, dhash string, comment string) error {
|
||||
}
|
||||
} else {
|
||||
send = func(msg interface{}) int64 {
|
||||
return ctx.Send(append(msg.(message.Message), message.Text(comment))).ID()
|
||||
return ctx.SendGroupForwardMessage(ctx.Event.GroupID, message.Message{
|
||||
ctxext.FakeSenderForwardNode(ctx, append(
|
||||
msg.(message.Message),
|
||||
message.Text(comment))...,
|
||||
),
|
||||
}).Get("message_id").Int()
|
||||
}
|
||||
}
|
||||
|
||||
return pool.SendRemoteImageFromPool(b14, u, send, ctxext.GetMessage(ctx))
|
||||
return pool.SendRemoteImageFromPool(b14, u, send, func(i int64) zero.Message {
|
||||
if class > 5 {
|
||||
return ctxext.GetMessage(ctx)(i)
|
||||
}
|
||||
return ctxext.GetFirstMessageInForward(ctx)(i)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"sync"
|
||||
|
||||
"github.com/pkumza/numcn"
|
||||
log "github.com/sirupsen/logrus"
|
||||
@@ -38,18 +39,26 @@ var (
|
||||
)
|
||||
|
||||
type ttsInstances struct {
|
||||
sync.RWMutex
|
||||
m map[string]tts.TTS
|
||||
l []string
|
||||
}
|
||||
|
||||
func (t *ttsInstances) List() []string {
|
||||
return t.l
|
||||
t.RLock()
|
||||
cl := make([]string, len(t.l))
|
||||
_ = copy(cl, t.l)
|
||||
t.RUnlock()
|
||||
return cl
|
||||
}
|
||||
|
||||
func init() {
|
||||
engine := control.Register(ttsServiceName, order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "语音回复(包括拟声鸟和百度)\n- @Bot 任意文本(任意一句话回复)\n- 设置语音模式拟声鸟阿梓 | 设置语音模式拟声鸟药水哥 | 设置语音模式百度女声 | 设置语音模式百度男声| 设置语音模式百度度逍遥 | 设置语音模式百度度丫丫",
|
||||
DisableOnDefault: true,
|
||||
Help: "语音回复(包括拟声鸟和百度)\n" +
|
||||
"- @Bot 任意文本(任意一句话回复)\n" +
|
||||
"- 设置语音模式[拟声鸟阿梓 | 拟声鸟药水哥 | 百度女声 | 百度男声| 百度度逍遥 | 百度度丫丫]\n" +
|
||||
"- 设置默认语音模式[拟声鸟阿梓 | 拟声鸟药水哥 | 百度女声 | 百度男声| 百度度逍遥 | 百度度丫丫]\n",
|
||||
})
|
||||
engine.OnMessage(zero.OnlyToMe).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
@@ -78,7 +87,13 @@ func init() {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text(err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("成功"))
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("设置成功,当前模式为", param))
|
||||
})
|
||||
engine.OnRegex(`^设置默认语音模式(.*)$`, ctxext.FirstValueInList(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))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -93,12 +108,14 @@ func (t *ttsInstances) setSoundMode(ctx *zero.Ctx, name string) error {
|
||||
gid = -ctx.Event.UserID
|
||||
}
|
||||
var index int64
|
||||
t.RLock()
|
||||
for i, s := range t.l {
|
||||
if s == name {
|
||||
index = int64(i)
|
||||
break
|
||||
}
|
||||
}
|
||||
t.RUnlock()
|
||||
m, ok := control.Lookup(ttsServiceName)
|
||||
if !ok {
|
||||
return errors.New("no such plugin")
|
||||
@@ -113,6 +130,8 @@ func (t *ttsInstances) getSoundMode(ctx *zero.Ctx) (name string) {
|
||||
}
|
||||
m, ok := control.Lookup(ttsServiceName)
|
||||
if ok {
|
||||
t.RLock()
|
||||
defer t.RUnlock()
|
||||
index := m.GetData(gid)
|
||||
if int(index) < len(t.l) {
|
||||
return t.l[index]
|
||||
@@ -120,3 +139,18 @@ func (t *ttsInstances) getSoundMode(ctx *zero.Ctx) (name string) {
|
||||
}
|
||||
return "拟声鸟阿梓"
|
||||
}
|
||||
|
||||
func (t *ttsInstances) setDefaultSoundMode(name string) {
|
||||
var index int
|
||||
t.RLock()
|
||||
for _, s := range t.l {
|
||||
if s == name {
|
||||
break
|
||||
}
|
||||
index++
|
||||
}
|
||||
t.RUnlock()
|
||||
t.Lock()
|
||||
t.l[0], t.l[index] = t.l[index], t.l[0]
|
||||
t.Unlock()
|
||||
}
|
||||
@@ -75,7 +75,6 @@ func init() {
|
||||
go func() {
|
||||
dbpath := en.DataFolder()
|
||||
dbfile := dbpath + "push.db"
|
||||
defer order.DoneOnExit()()
|
||||
bdb = initialize(dbfile)
|
||||
log.Println("[bilibilipush]加载bilibilipush数据库")
|
||||
}()
|
||||
@@ -232,7 +231,7 @@ func bilibiliPushDaily() {
|
||||
}
|
||||
|
||||
func checkBuid(buid int64) (status int, name string) {
|
||||
data, err := web.ReqWith(fmt.Sprintf(infoURL, buid), "GET", referer, ua)
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), fmt.Sprintf(infoURL, buid), "GET", referer, ua)
|
||||
if err != nil {
|
||||
log.Errorln("[bilibilipush]:", err)
|
||||
}
|
||||
@@ -290,7 +289,7 @@ func unsubscribeLive(buid, groupid int64) (err error) {
|
||||
}
|
||||
|
||||
func getUserDynamicCard(buid int64) (cardList []gjson.Result) {
|
||||
data, err := web.ReqWith(fmt.Sprintf(userDynamicURL, buid), "GET", referer, ua)
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), fmt.Sprintf(userDynamicURL, buid), "GET", referer, ua)
|
||||
if err != nil {
|
||||
log.Errorln("[bilibilipush]:", err)
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ func init() {
|
||||
go func() {
|
||||
dbpath := engine.DataFolder()
|
||||
db.DBPath = dbpath + "bookreview.db"
|
||||
defer order.DoneOnExit()()
|
||||
// os.RemoveAll(dbpath)
|
||||
_, _ = file.GetLazyData(db.DBPath, false, true)
|
||||
err := db.Create("bookreview", &book{})
|
||||
|
||||
@@ -21,7 +21,6 @@ func init() {
|
||||
go func() {
|
||||
dbpath := en.DataFolder()
|
||||
db.DBPath = dbpath + "cxh.db"
|
||||
defer order.DoneOnExit()()
|
||||
// os.RemoveAll(dbpath)
|
||||
_, _ = file.GetLazyData(db.DBPath, false, true)
|
||||
err := db.Create("pinyin", &pinyin{})
|
||||
|
||||
@@ -28,27 +28,15 @@ func init() {
|
||||
}).ApplySingle(ctxext.DefaultSingle).OnFullMatch("coser", zero.OnlyGroup).SetBlock(true).Limit(ctxext.LimitByGroup).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.SendChain(message.Text("少女祈祷中......"))
|
||||
data, err := web.ReqWith(coserURL, "GET", "", ua)
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), coserURL, "GET", "", ua)
|
||||
if err != nil {
|
||||
log.Println("err为:", err)
|
||||
}
|
||||
var m message.Message
|
||||
|
||||
text := gjson.Get(helper.BytesToString(data), "data.Title").String()
|
||||
m = append(m,
|
||||
message.CustomNode(
|
||||
ctx.Event.Sender.NickName,
|
||||
ctx.Event.UserID,
|
||||
text,
|
||||
))
|
||||
m := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Text(text))}
|
||||
gjson.Get(helper.BytesToString(data), "data.data").ForEach(func(_, value gjson.Result) bool {
|
||||
m = append(m,
|
||||
message.CustomNode(
|
||||
ctx.Event.Sender.NickName,
|
||||
ctx.Event.UserID,
|
||||
[]message.MessageSegment{
|
||||
message.Image(value.String()),
|
||||
}),
|
||||
)
|
||||
m = append(m, ctxext.FakeSenderForwardNode(ctx, message.Image(value.String())))
|
||||
return true
|
||||
})
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ func init() {
|
||||
go func() {
|
||||
dbpath := engine.DataFolder()
|
||||
db.DBPath = dbpath + "cp.db"
|
||||
defer order.DoneOnExit()()
|
||||
// os.RemoveAll(dbpath)
|
||||
_, _ = file.GetLazyData(db.DBPath, false, true)
|
||||
err := db.Create("cp_story", &cpstory{})
|
||||
|
||||
@@ -29,7 +29,6 @@ func init() {
|
||||
go func() {
|
||||
dbpath := engine.DataFolder()
|
||||
db.DBPath = dbpath + "curse.db"
|
||||
defer order.DoneOnExit()()
|
||||
_, err := file.GetLazyData(db.DBPath, false, true)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
@@ -26,7 +26,6 @@ func init() {
|
||||
go func() {
|
||||
datapath := engine.DataFolder()
|
||||
dbfile := datapath + "text.db"
|
||||
defer order.DoneOnExit()()
|
||||
data.LoadText(dbfile)
|
||||
}()
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ const (
|
||||
|
||||
var (
|
||||
// 底图类型列表
|
||||
table = [...]string{"车万", "DC4", "爱因斯坦", "星空列车", "樱云之恋", "富婆妹", "李清歌", "公主连结", "原神", "明日方舟", "碧蓝航线", "碧蓝幻想", "战双", "阴阳师", "赛马娘"}
|
||||
table = [...]string{"车万", "DC4", "爱因斯坦", "星空列车", "樱云之恋", "富婆妹", "李清歌", "公主连结", "原神", "明日方舟", "碧蓝航线", "碧蓝幻想", "战双", "阴阳师", "赛马娘", "东方归言录"}
|
||||
// 映射底图与 index
|
||||
index = make(map[string]uint8)
|
||||
// 签文
|
||||
@@ -55,11 +55,10 @@ func init() {
|
||||
DisableOnDefault: false,
|
||||
Help: "每日运势: \n" +
|
||||
"- 运势 | 抽签\n" +
|
||||
"- 设置底图[车万 | DC4 | 爱因斯坦 | 星空列车 | 樱云之恋 | 富婆妹 | 李清歌 | 公主连结 | 原神 | 明日方舟 | 碧蓝航线 | 碧蓝幻想 | 战双 | 阴阳师 | 赛马娘]",
|
||||
"- 设置底图[车万 | DC4 | 爱因斯坦 | 星空列车 | 樱云之恋 | 富婆妹 | 李清歌 | 公主连结 | 原神 | 明日方舟 | 碧蓝航线 | 碧蓝幻想 | 战双 | 阴阳师 | 赛马娘 | 东方归言录]",
|
||||
PublicDataFolder: "Fortune",
|
||||
})
|
||||
go func() {
|
||||
defer order.DoneOnExit()()
|
||||
for i, s := range table {
|
||||
index[s] = uint8(i)
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ func init() {
|
||||
go func() {
|
||||
dbpath := en.DataFolder()
|
||||
db.DBPath = dbpath + "jokes.db"
|
||||
defer order.DoneOnExit()()
|
||||
_, err := file.GetLazyData(db.DBPath, false, true)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
@@ -66,7 +66,7 @@ func init() {
|
||||
cid := gjson.Get(g, `list.`+strconv.Itoa(i)+`.CardID`).String()
|
||||
cachefile := cachedir + cid
|
||||
if file.IsNotExist(cachefile) {
|
||||
data, err := web.ReqWith(
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(),
|
||||
`https://res.fbigame.com/hs/v13/`+cid+`.png?auth_key=`+
|
||||
gjson.Get(g, `list.`+strconv.Itoa(i)+`.auth_key`).String(),
|
||||
reqconf[0], reqconf[1], reqconf[2])
|
||||
@@ -77,14 +77,7 @@ func init() {
|
||||
continue
|
||||
}
|
||||
}
|
||||
sk = append(
|
||||
sk,
|
||||
message.CustomNode(
|
||||
zero.BotConfig.NickName[0],
|
||||
ctx.Event.SelfID,
|
||||
[]message.MessageSegment{message.Image("file:///" + cachefile)}, // 图片
|
||||
),
|
||||
)
|
||||
sk = append(sk, ctxext.FakeSenderForwardNode(ctx, message.Image("file:///"+cachefile)))
|
||||
}
|
||||
if id := ctx.SendGroupForwardMessage(
|
||||
ctx.Event.GroupID,
|
||||
@@ -105,10 +98,10 @@ func init() {
|
||||
}
|
||||
|
||||
func sh(s string) string {
|
||||
data, err := web.ReqWith("https://hs.fbigame.com", reqconf[0], reqconf[1], reqconf[2])
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), "https://hs.fbigame.com", reqconf[0], reqconf[1], reqconf[2])
|
||||
if err == nil {
|
||||
url := hs + para + "&hash=" + strings.SplitN(strings.SplitN(helper.BytesToString(data), `var hash = "`, 2)[1], `"`, 2)[0] + "&search=" + s
|
||||
r, err := web.ReqWith(url, reqconf[0], reqconf[1], reqconf[2])
|
||||
r, err := web.GetDataWith(web.NewDefaultClient(), url, reqconf[0], reqconf[1], reqconf[2])
|
||||
if err == nil {
|
||||
return helper.BytesToString(r)
|
||||
}
|
||||
@@ -117,10 +110,10 @@ func sh(s string) string {
|
||||
}
|
||||
|
||||
func kz(s string) string {
|
||||
data, err := web.ReqWith("https://hs.fbigame.com", reqconf[0], reqconf[1], reqconf[2])
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), "https://hs.fbigame.com", reqconf[0], reqconf[1], reqconf[2])
|
||||
if err == nil {
|
||||
url := hs + para + "mod=general_deck_image&deck_code=" + s + "&deck_text=&hash=" + strings.SplitN(strings.SplitN(helper.BytesToString(data), `var hash = "`, 2)[1], `"`, 2)[0] + "&search=" + s
|
||||
r, err := web.ReqWith(url, reqconf[0], reqconf[1], reqconf[2])
|
||||
r, err := web.GetDataWith(web.NewDefaultClient(), url, reqconf[0], reqconf[1], reqconf[2])
|
||||
if err == nil {
|
||||
return "base64://" + gjson.Get(helper.BytesToString(r), "img").String()
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"math/rand"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
@@ -59,7 +60,7 @@ func init() {
|
||||
err = pool.SendImageFromPool(n, f, func() error {
|
||||
// 下载图片
|
||||
return illust.DownloadToCache(0)
|
||||
}, ctxext.Send(ctx), ctxext.GetMessage(ctx))
|
||||
}, ctxext.SendFakeForwardToGroup(ctx), ctxext.GetFirstMessageInForward(ctx))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
return
|
||||
@@ -69,8 +70,7 @@ func init() {
|
||||
|
||||
// soutuapi 请求api
|
||||
func soutuapi(keyword string) (r resultjson, err error) {
|
||||
url := "https://api.pixivel.moe/v2/pixiv/illust/search/" + keyword + "?page=0"
|
||||
data, err := web.ReqWith(url, "GET", "https://pixivel.moe/", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36")
|
||||
data, err := web.GetData("https://copymanga.azurewebsites.net/api/pixivel?" + url.QueryEscape(keyword) + "?page=0")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ func init() {
|
||||
go func() {
|
||||
dbpath := engine.DataFolder()
|
||||
db.DBPath = dbpath + "pics.db"
|
||||
defer order.DoneOnExit()()
|
||||
_, _ = file.GetLazyData(db.DBPath, false, false)
|
||||
err := db.Create("picture", &picture{})
|
||||
if err != nil {
|
||||
|
||||
282
plugin/job/main.go
Normal file
282
plugin/job/main.go
Normal file
@@ -0,0 +1,282 @@
|
||||
// Package job 定时指令触发器
|
||||
package job
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"hash/crc64"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/zbputils/binary"
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/process"
|
||||
"github.com/FloatTech/zbputils/vevent"
|
||||
"github.com/fumiama/cron"
|
||||
"github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/extension/rate"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
var (
|
||||
lo map[int64]vevent.Loop
|
||||
entries map[int64]cron.EntryID // id entryid
|
||||
mu sync.Mutex
|
||||
limit = rate.NewLimiter(time.Second*2, 1)
|
||||
)
|
||||
|
||||
func init() {
|
||||
en := control.Register("job", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "定时指令触发器\n- 记录在\"cron\"触发的指令\n- 取消在\"cron\"触发的指令\n- 查看所有触发指令\n- 查看在\"cron\"触发的指令\n- 注入指令结果:任意指令\n- 执行指令:任意指令",
|
||||
PrivateDataFolder: "job",
|
||||
})
|
||||
db.DBPath = en.DataFolder() + "job.db"
|
||||
err := db.Open()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
go func() {
|
||||
process.GlobalInitMutex.Lock()
|
||||
process.SleepAbout1sTo2s()
|
||||
lo = make(map[int64]vevent.Loop, len(zero.BotConfig.Driver))
|
||||
entries = map[int64]cron.EntryID{}
|
||||
for _, drv := range zero.BotConfig.Driver {
|
||||
id := drv.SelfID()
|
||||
ids := strconv.FormatInt(id, 36)
|
||||
c := &cmd{}
|
||||
lo[id] = vevent.NewLoop(id)
|
||||
err := db.Create(ids, c)
|
||||
logrus.Infoln("[job]创建表", ids)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
_ = db.FindFor(ids, c, "", func() error {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
eid, err := process.CronTab.AddFunc(c.Cron, inject(id, []byte(c.Cmd)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
entries[c.ID] = eid
|
||||
return nil
|
||||
})
|
||||
}
|
||||
logrus.Infoln("[job]本地环回初始化完成")
|
||||
process.GlobalInitMutex.Unlock()
|
||||
}()
|
||||
en.OnRegex(`^记录在"(.*)"触发的指令$`, ctxext.UserOrGrpAdmin, islonotnil, func(ctx *zero.Ctx) bool {
|
||||
ctx.SendChain(message.Text("您的下一条指令将被记录,在", ctx.State["regex_matched"].([]string)[1], "时触发"))
|
||||
select {
|
||||
case <-time.After(time.Second * 120):
|
||||
ctx.SendChain(message.Text("指令记录超时"))
|
||||
return false
|
||||
case e := <-zero.NewFutureEvent("message", 0, false, zero.CheckUser(ctx.Event.UserID)).Next():
|
||||
ctx.State["job_raw_event"] = e.RawEvent.Raw
|
||||
return true
|
||||
}
|
||||
}).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
cron := ctx.State["regex_matched"].([]string)[1]
|
||||
command := ctx.State["job_raw_event"].(string)
|
||||
c := &cmd{
|
||||
ID: idof(cron, command),
|
||||
Cron: cron,
|
||||
Cmd: command,
|
||||
}
|
||||
err := addcmd(ctx.Event.SelfID, c)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("成功!"))
|
||||
})
|
||||
en.OnRegex(`^取消在"(.*)"触发的指令$`, ctxext.UserOrGrpAdmin, islonotnil).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
cron := ctx.State["regex_matched"].([]string)[1]
|
||||
err := rmcmd(ctx.Event.SelfID, cron)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("成功!"))
|
||||
})
|
||||
en.OnFullMatch("查看所有触发指令", zero.SuperUserPermission, islonotnil).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
c := &cmd{}
|
||||
ids := strconv.FormatInt(ctx.Event.SelfID, 36)
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
n, err := db.Count(ids)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
lst := make([]string, 0, n)
|
||||
err = db.FindFor(ids, c, "GROUP BY cron", func() error {
|
||||
lst = append(lst, c.Cron+"\n")
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text(lst))
|
||||
})
|
||||
en.OnRegex(`^查看在"(.*)"触发的指令$`, zero.SuperUserPermission, islonotnil).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
c := &cmd{}
|
||||
ids := strconv.FormatInt(ctx.Event.SelfID, 36)
|
||||
cron := ctx.State["regex_matched"].([]string)[1]
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
n, err := db.Count(ids)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
lst := make([]string, 0, n)
|
||||
err = db.FindFor(ids, c, "WHERE cron='"+cron+"'", func() error {
|
||||
lst = append(lst, c.Cmd+"\n")
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text(lst))
|
||||
})
|
||||
en.OnPrefix("执行指令:", ctxext.UserOrGrpAdmin, islonotnil, func(ctx *zero.Ctx) bool {
|
||||
return ctx.State["args"].(string) != ""
|
||||
}, parseArgs).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
inject(ctx.Event.SelfID, binary.StringToBytes(strings.ReplaceAll(ctx.Event.RawEvent.Raw, "执行指令:", "")))()
|
||||
})
|
||||
en.OnPrefix("注入指令结果:", ctxext.UserOrGrpAdmin, islonotnil, func(ctx *zero.Ctx) bool {
|
||||
return ctx.State["args"].(string) != ""
|
||||
}, parseArgs).SetBlock(true).Handle(func(ctx *zero.Ctx) {
|
||||
vevent.NewLoopOf(vevent.NewAPICallerHook(ctx, func(rsp zero.APIResponse, err error) {
|
||||
if err == nil {
|
||||
logrus.Debugln("[job] CallerHook returned")
|
||||
id := message.NewMessageID(rsp.Data.Get("message_id").String())
|
||||
if id.ID() == 0 {
|
||||
ctx.SendChain(message.Text("ERROR:未获取到返回结果"))
|
||||
return
|
||||
}
|
||||
msg := ctx.GetMessage(id)
|
||||
ctx.Event.NativeMessage = json.RawMessage("\"" + msg.Elements.String() + "\"")
|
||||
ctx.Event.RawMessageID = json.RawMessage(msg.MessageId.String())
|
||||
ctx.Event.RawMessage = msg.Elements.String()
|
||||
time.Sleep(time.Second * 5) // 防止风控
|
||||
ctx.Event.Time = time.Now().Unix()
|
||||
ctx.DeleteMessage(id)
|
||||
vev, cl := binary.OpenWriterF(func(w *binary.Writer) {
|
||||
err = json.NewEncoder(w).Encode(ctx.Event)
|
||||
})
|
||||
if err != nil {
|
||||
cl()
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
}
|
||||
logrus.Debugln("[job] inject:", binary.BytesToString(vev))
|
||||
inject(ctx.Event.SelfID, vev)()
|
||||
cl()
|
||||
}
|
||||
})).Echo(binary.StringToBytes(strings.ReplaceAll(ctx.Event.RawEvent.Raw, "注入指令结果:", "")))
|
||||
})
|
||||
}
|
||||
|
||||
func islonotnil(ctx *zero.Ctx) bool {
|
||||
return len(lo) > 0
|
||||
}
|
||||
|
||||
func inject(bot int64, response []byte) func() {
|
||||
return func() {
|
||||
if limit.Acquire() {
|
||||
lo[bot].Echo(response)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func idof(cron, cmd string) int64 {
|
||||
return int64(crc64.Checksum(binary.StringToBytes(cron+cmd), crc64.MakeTable(crc64.ISO)))
|
||||
}
|
||||
|
||||
func addcmd(bot int64, c *cmd) error {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
eid, err := process.CronTab.AddFunc(c.Cron, inject(bot, []byte(c.Cmd)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
entries[c.ID] = eid
|
||||
return db.Insert(strconv.FormatInt(bot, 36), c)
|
||||
}
|
||||
|
||||
func rmcmd(bot int64, cron string) error {
|
||||
c := &cmd{}
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
bots := strconv.FormatInt(bot, 36)
|
||||
err := db.FindFor(bots, c, "WHERE cron='"+cron+"'", func() error {
|
||||
eid, ok := entries[c.ID]
|
||||
if ok {
|
||||
process.CronTab.Remove(eid)
|
||||
delete(entries, c.ID)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return db.Del(bots, "WHERE cron='"+cron+"'")
|
||||
}
|
||||
|
||||
func parseArgs(ctx *zero.Ctx) bool {
|
||||
if !strings.Contains(ctx.State["args"].(string), "?::") {
|
||||
return true
|
||||
}
|
||||
args := make(map[int]string)
|
||||
for strings.Contains(ctx.Event.RawEvent.Raw, "?::") {
|
||||
start := strings.Index(ctx.Event.RawEvent.Raw, "?::")
|
||||
msgend := strings.Index(ctx.Event.RawEvent.Raw[start+3:], "::")
|
||||
if msgend < 0 {
|
||||
ctx.SendChain(message.Text("ERROR:找不到结束的::"))
|
||||
return false
|
||||
}
|
||||
msgend += start + 3
|
||||
numend := strings.Index(ctx.Event.RawEvent.Raw[msgend+2:], "!")
|
||||
if numend <= 0 {
|
||||
ctx.SendChain(message.Text("ERROR:找不到结束的!"))
|
||||
return false
|
||||
}
|
||||
numend += msgend + 2
|
||||
logrus.Debugln("[job]", start, msgend, numend)
|
||||
msg := ctx.Event.RawEvent.Raw[start+3 : msgend]
|
||||
arg, err := strconv.Atoi(ctx.Event.RawEvent.Raw[msgend+2 : numend])
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return false
|
||||
}
|
||||
arr, ok := args[arg]
|
||||
if !ok {
|
||||
if msg == "" {
|
||||
ctx.SendChain(message.At(ctx.Event.UserID), message.Text("请输入参数", arg))
|
||||
} else {
|
||||
ctx.SendChain(message.At(ctx.Event.UserID), message.Text("[", arg, "] ", msg))
|
||||
}
|
||||
select {
|
||||
case <-time.After(time.Second * 120):
|
||||
ctx.SendChain(message.Text("参数读取超时"))
|
||||
return false
|
||||
case e := <-zero.NewFutureEvent("message", 0, true, zero.CheckUser(ctx.Event.UserID)).Next():
|
||||
args[arg] = e.Message.String()
|
||||
arr = args[arg]
|
||||
process.SleepAbout1sTo2s()
|
||||
ctx.SendChain(message.Reply(e.MessageID), message.Text("已记录"))
|
||||
process.SleepAbout1sTo2s()
|
||||
}
|
||||
}
|
||||
ctx.Event.RawEvent.Raw = ctx.Event.RawEvent.Raw[:start] + arr + ctx.Event.RawEvent.Raw[numend+1:]
|
||||
}
|
||||
return true
|
||||
}
|
||||
11
plugin/job/model.go
Normal file
11
plugin/job/model.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package job
|
||||
|
||||
import sql "github.com/FloatTech/sqlite"
|
||||
|
||||
type cmd struct {
|
||||
ID int64 `db:"id"`
|
||||
Cron string `db:"cron"`
|
||||
Cmd string `db:"cmd"`
|
||||
}
|
||||
|
||||
var db = &sql.Sqlite{}
|
||||
@@ -66,7 +66,6 @@ func init() { // 插件主体
|
||||
})
|
||||
|
||||
go func() {
|
||||
defer order.DoneOnExit()()
|
||||
db.DBPath = engine.DataFolder() + "config.db"
|
||||
clock = timer.NewClock(db)
|
||||
err := db.Create("welcome", &welcome{})
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
reg "github.com/fumiama/go-registry"
|
||||
)
|
||||
|
||||
var sr = reg.NewRegedit("reilia.fumiama.top:32664", "fumiama", "--")
|
||||
var sr = reg.NewRegedit("reilia.westeurope.cloudapp.azure.com:32664", "fumiama", "--")
|
||||
|
||||
func TestGetHoliday(t *testing.T) {
|
||||
registry.Connect()
|
||||
|
||||
@@ -21,7 +21,7 @@ func NewHoliday(name string, dur, year int, month time.Month, day int) *Holiday
|
||||
return &Holiday{name: name, date: time.Date(year, month, day, 0, 0, 0, 0, time.Local), dur: time.Duration(dur) * time.Hour * 24}
|
||||
}
|
||||
|
||||
var registry = reg.NewRegReader("reilia.fumiama.top:32664", "fumiama")
|
||||
var registry = reg.NewRegReader("reilia.westeurope.cloudapp.azure.com:32664", "fumiama")
|
||||
|
||||
// GetHoliday 从 reg 服务器获取节日
|
||||
func GetHoliday(name string) *Holiday {
|
||||
|
||||
@@ -54,6 +54,13 @@ func init() {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
} else {
|
||||
p := "file:///" + setupath + "/" + sc.Path
|
||||
if ctx.Event.GroupID != 0 {
|
||||
ctx.SendGroupForwardMessage(ctx.Event.GroupID, message.Message{
|
||||
ctxext.FakeSenderForwardNode(ctx,
|
||||
message.Text(imgtype, ": ", sc.Name, "\n"), message.Image(p),
|
||||
)})
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text(imgtype, ": ", sc.Name, "\n"), message.Image(p))
|
||||
}
|
||||
})
|
||||
|
||||
@@ -33,7 +33,6 @@ func init() { // 插件主体
|
||||
go func() {
|
||||
dbpath := engine.DataFolder()
|
||||
db.DBPath = dbpath + "kuji.db"
|
||||
defer order.DoneOnExit()()
|
||||
_, _ = file.GetLazyData(db.DBPath, false, true)
|
||||
err := db.Create("kuji", &kuji{})
|
||||
if err != nil {
|
||||
|
||||
@@ -23,7 +23,6 @@ func init() {
|
||||
go func() {
|
||||
datapath := en.DataFolder()
|
||||
jsonfile := datapath + "rate.json"
|
||||
defer order.DoneOnExit()()
|
||||
area := make(rate, 226)
|
||||
err := load(&area, jsonfile)
|
||||
if err != nil {
|
||||
|
||||
@@ -104,9 +104,10 @@ func init() {
|
||||
"JavaScript || TypeScript || PHP || Shell \n" +
|
||||
"Kotlin || Rust || Erlang || Ruby || Swift \n" +
|
||||
"R || VB || Py2 || Perl || Pascal || Scala",
|
||||
}).ApplySingle(ctxext.DefaultSingle).OnRegex(`^>runcode\s(.+?)\s([\s\S]+)$`).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
}).ApplySingle(ctxext.DefaultSingle).OnRegex(`^>runcode(raw)?\s(.+?)\s([\s\S]+)$`).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
language := ctx.State["regex_matched"].([]string)[1]
|
||||
israw := ctx.State["regex_matched"].([]string)[1] != ""
|
||||
language := ctx.State["regex_matched"].([]string)[2]
|
||||
language = strings.ToLower(language)
|
||||
if runType, exist := table[language]; !exist {
|
||||
// 不支持语言
|
||||
@@ -116,10 +117,9 @@ func init() {
|
||||
)
|
||||
} else {
|
||||
// 执行运行
|
||||
block := ctx.State["regex_matched"].([]string)[2]
|
||||
block = message.UnescapeCQCodeText(block)
|
||||
if block == "help" {
|
||||
// 输出模板
|
||||
block := message.UnescapeCQCodeText(ctx.State["regex_matched"].([]string)[3])
|
||||
switch block {
|
||||
case "help":
|
||||
ctx.SendChain(
|
||||
message.Text("> ", ctx.Event.Sender.NickName, " ", language, "-template:\n"),
|
||||
message.Text(
|
||||
@@ -127,7 +127,7 @@ func init() {
|
||||
templates[language],
|
||||
),
|
||||
)
|
||||
} else {
|
||||
default:
|
||||
if output, err := runCode(block, runType); err != nil {
|
||||
// 运行失败
|
||||
ctx.SendChain(
|
||||
@@ -136,10 +136,14 @@ func init() {
|
||||
)
|
||||
} else {
|
||||
// 运行成功
|
||||
ctx.SendChain(
|
||||
message.Text("> ", ctx.Event.Sender.NickName, "\n"),
|
||||
message.Text(output),
|
||||
)
|
||||
if israw {
|
||||
ctx.SendChain(message.Text(output))
|
||||
} else {
|
||||
ctx.SendChain(
|
||||
message.Text("> ", ctx.Event.Sender.NickName, "\n"),
|
||||
message.Text(output),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,9 +111,8 @@ func init() { // 插件主体
|
||||
if result, err := yandex.Yandex(pic); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
} else {
|
||||
// 返回SauceNAO的结果
|
||||
ctx.SendChain(
|
||||
message.Text("我有把握是这个!"),
|
||||
message.Text("也许是这个?"),
|
||||
message.Text(
|
||||
"\n",
|
||||
"标题:", result.Title, "\n",
|
||||
@@ -123,36 +122,24 @@ func init() { // 插件主体
|
||||
"直链:", "https://pixivel.moe/detail?id=", result.Pid,
|
||||
),
|
||||
)
|
||||
continue
|
||||
}
|
||||
// 不论结果如何都执行 ascii2d 搜索
|
||||
if result, err := ascii2d.Ascii2d(pic); err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
continue
|
||||
} else {
|
||||
var msg message.Message = []message.MessageSegment{
|
||||
message.CustomNode(
|
||||
ctx.Event.Sender.Name(),
|
||||
ctx.Event.UserID,
|
||||
"ascii2d搜图结果",
|
||||
)}
|
||||
msg := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Text("ascii2d搜图结果"))}
|
||||
for i := 0; i < len(result) && i < 5; i++ {
|
||||
msg = append(
|
||||
msg,
|
||||
message.CustomNode(
|
||||
ctx.Event.Sender.Name(),
|
||||
ctx.Event.UserID,
|
||||
[]message.MessageSegment{
|
||||
message.Image(result[i].Thumb),
|
||||
message.Text(fmt.Sprintf(
|
||||
"标题:%s\n图源:%s\n画师:%s\n画师链接:%s\n图片链接:%s",
|
||||
result[i].Name,
|
||||
result[i].Type,
|
||||
result[i].AuthNm,
|
||||
result[i].Author,
|
||||
result[i].Link,
|
||||
)),
|
||||
},
|
||||
),
|
||||
msg = append(msg, ctxext.FakeSenderForwardNode(ctx,
|
||||
message.Image(result[i].Thumb),
|
||||
message.Text(fmt.Sprintf(
|
||||
"标题:%s\n图源:%s\n画师:%s\n画师链接:%s\n图片链接:%s",
|
||||
result[i].Name,
|
||||
result[i].Type,
|
||||
result[i].AuthNm,
|
||||
result[i].Author,
|
||||
result[i].Link,
|
||||
))),
|
||||
)
|
||||
}
|
||||
if id := ctx.SendGroupForwardMessage(
|
||||
|
||||
@@ -43,7 +43,6 @@ func init() {
|
||||
})
|
||||
cachePath := engine.DataFolder() + "cache/"
|
||||
go func() {
|
||||
defer order.DoneOnExit()()
|
||||
os.RemoveAll(cachePath)
|
||||
err := os.MkdirAll(cachePath, 0755)
|
||||
if err != nil {
|
||||
@@ -204,12 +203,12 @@ func getLevel(count int) int {
|
||||
|
||||
func initPic(picFile string) {
|
||||
if file.IsNotExist(picFile) {
|
||||
data, err := web.ReqWith(backgroundURL, "GET", referer, ua)
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), backgroundURL, "GET", referer, ua)
|
||||
if err != nil {
|
||||
log.Errorln("[score]", err)
|
||||
}
|
||||
picURL := gjson.Get(string(data), "pic").String()
|
||||
data, err = web.ReqWith(picURL, "GET", "", ua)
|
||||
data, err = web.GetDataWith(web.NewDefaultClient(), picURL, "GET", "", ua)
|
||||
if err != nil {
|
||||
log.Errorln("[score]", err)
|
||||
}
|
||||
|
||||
@@ -62,7 +62,6 @@ func init() { // 插件主体
|
||||
})
|
||||
|
||||
go func() {
|
||||
defer order.DoneOnExit()()
|
||||
// 如果数据库不存在则下载
|
||||
pool.db.DBPath = engine.DataFolder() + "SetuTime.db"
|
||||
_, _ = fileutil.GetLazyData(pool.db.DBPath, false, false)
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
func init() {
|
||||
engine.OnFullMatch("哄我").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.ReqWith(chpURL, "GET", chpReferer, ua)
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), chpURL, "GET", chpReferer, ua)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
func init() {
|
||||
engine.OnFullMatch("来碗毒鸡汤").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.ReqWith(duURL, "GET", duReferer, ua)
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), duURL, "GET", duReferer, ua)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
func init() {
|
||||
engine.OnFullMatch("发个朋友圈").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.ReqWith(pyqURL, "GET", pyqReferer, ua)
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), pyqURL, "GET", pyqReferer, ua)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
|
||||
func init() {
|
||||
engine.OnFullMatch("来碗绿茶").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.ReqWith(chayiURL, "GET", loveliveReferer, ua)
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), chayiURL, "GET", loveliveReferer, ua)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
@@ -22,7 +22,7 @@ func init() {
|
||||
})
|
||||
|
||||
engine.OnFullMatch("渣我").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.ReqWith(ganhaiURL, "GET", loveliveReferer, ua)
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), ganhaiURL, "GET", loveliveReferer, ua)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
|
||||
func init() {
|
||||
engine.OnFullMatch("讲个段子").SetBlock(true).Limit(ctxext.LimitByUser).Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.ReqWith(yduanziURL, "POST", yduanziReferer, ua)
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), yduanziURL, "POST", yduanziReferer, ua)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
|
||||
@@ -23,7 +23,6 @@ func init() {
|
||||
PublicDataFolder: "Chat",
|
||||
})
|
||||
go func() {
|
||||
defer order.DoneOnExit()()
|
||||
data, err := file.GetLazyData(engine.DataFolder()+"kimoi.json", true, true)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
package vtbquotation
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
@@ -22,6 +21,7 @@ import (
|
||||
control "github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
"github.com/FloatTech/zbputils/img/text"
|
||||
"github.com/FloatTech/zbputils/web"
|
||||
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
|
||||
@@ -44,7 +44,6 @@ func init() {
|
||||
dbfile := engine.DataFolder() + "vtb.db"
|
||||
storePath := engine.DataFolder() + "store/"
|
||||
go func() {
|
||||
defer order.DoneOnExit()()
|
||||
err := os.MkdirAll(storePath, 0755)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -255,14 +254,7 @@ func init() {
|
||||
|
||||
func initRecord(recordFile, recordURL string) {
|
||||
if file.IsNotExist(recordFile) {
|
||||
transport := http.Transport{
|
||||
TLSClientConfig: &tls.Config{
|
||||
MaxVersion: tls.VersionTLS12,
|
||||
},
|
||||
}
|
||||
client := &http.Client{
|
||||
Transport: &transport,
|
||||
}
|
||||
client := web.NewTLS12Client()
|
||||
req, _ := http.NewRequest("GET", recordURL, nil)
|
||||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20100101 Firefox/6.0")
|
||||
|
||||
@@ -24,7 +24,7 @@ func init() {
|
||||
Help: "wangyiyun \n- 来份网易云热评",
|
||||
}).OnFullMatch("来份网易云热评").SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
data, err := web.ReqWith(wangyiyunURL, "GET", wangyiyunReferer, ua)
|
||||
data, err := web.GetDataWith(web.NewDefaultClient(), wangyiyunURL, "GET", wangyiyunReferer, ua)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR:", err))
|
||||
return
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
package wordle
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"unsafe"
|
||||
|
||||
goBinary "encoding/binary"
|
||||
|
||||
"github.com/FloatTech/zbputils/binary"
|
||||
)
|
||||
|
||||
type wordpack [3]byte
|
||||
|
||||
/*
|
||||
func pack(word string) (w wordpack) {
|
||||
if len(word) != 5 {
|
||||
panic("word must be 5 letters")
|
||||
}
|
||||
r := []rune(word)
|
||||
for i := range r {
|
||||
if r[i] < 'k' { // 0-9
|
||||
r[i] -= 'a' - '0'
|
||||
} else {
|
||||
r[i] -= 10
|
||||
}
|
||||
}
|
||||
word = string(r)
|
||||
n, err := strconv.ParseUint(word, 26, 32)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
wt := binary.SelectWriter()
|
||||
wt.WriteUInt32LE(uint32(n))
|
||||
copy(w[:], wt.Bytes())
|
||||
binary.PutWriter(wt)
|
||||
return
|
||||
}
|
||||
*/
|
||||
|
||||
func (w wordpack) String() (word string) {
|
||||
wt := binary.SelectWriter()
|
||||
_, _ = wt.Write(w[:])
|
||||
_ = wt.WriteByte(0)
|
||||
n := goBinary.LittleEndian.Uint32(wt.Bytes())
|
||||
binary.PutWriter(wt)
|
||||
word = strconv.FormatUint(uint64(n), 26)
|
||||
for len(word) < 5 {
|
||||
word = "0" + word
|
||||
}
|
||||
r := []rune(word)
|
||||
for i := range r {
|
||||
if r[i] < 'a' { // 0-9
|
||||
r[i] += 'a' - '0'
|
||||
} else {
|
||||
r[i] += 10
|
||||
}
|
||||
}
|
||||
word = string(r)
|
||||
return
|
||||
}
|
||||
|
||||
func loadwords(data []byte) (wordpacks []wordpack) {
|
||||
(*slice)(unsafe.Pointer(&wordpacks)).data = (*slice)(unsafe.Pointer(&data)).data
|
||||
(*slice)(unsafe.Pointer(&wordpacks)).len = len(data) / 3
|
||||
(*slice)(unsafe.Pointer(&wordpacks)).cap = (*slice)(unsafe.Pointer(&data)).cap / 3
|
||||
return
|
||||
}
|
||||
|
||||
// slice is the runtime representation of a slice.
|
||||
// It cannot be used safely or portably and its representation may
|
||||
// change in a later release.
|
||||
//
|
||||
// Unlike reflect.SliceHeader, its Data field is sufficient to guarantee the
|
||||
// data it references will not be garbage collected.
|
||||
type slice struct {
|
||||
data unsafe.Pointer
|
||||
len int
|
||||
cap int
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package wordle
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"image/color"
|
||||
"math/rand"
|
||||
"sort"
|
||||
@@ -40,8 +41,19 @@ var colors = [...]color.RGBA{
|
||||
{219, 219, 219, 255},
|
||||
}
|
||||
|
||||
var words []string
|
||||
var questions []string
|
||||
var classdict = map[string]int{
|
||||
"": 5,
|
||||
"五阶": 5,
|
||||
"六阶": 6,
|
||||
"七阶": 7,
|
||||
}
|
||||
|
||||
type dictionary map[int]struct {
|
||||
dict []string
|
||||
cet4 []string
|
||||
}
|
||||
|
||||
var words = make(dictionary)
|
||||
|
||||
func init() {
|
||||
en := control.Register("wordle", order.AcquirePrio(), &control.Options{
|
||||
@@ -61,47 +73,50 @@ func init() {
|
||||
}),
|
||||
))
|
||||
go func() {
|
||||
questionsdata, err := file.GetLazyData(en.DataFolder()+"questions.bin", true, true)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
for i := 5; i <= 7; i++ {
|
||||
dc, err := file.GetLazyData(fmt.Sprintf("%scet-4_%d.txt", en.DataFolder(), i), true, true)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
c := strings.Split(string(dc), "\n")
|
||||
sort.Strings(c)
|
||||
dd, err := file.GetLazyData(fmt.Sprintf("%sdict_%d.txt", en.DataFolder(), i), true, true)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
d := strings.Split(string(dd), "\n")
|
||||
sort.Strings(d)
|
||||
words[i] = struct {
|
||||
dict []string
|
||||
cet4 []string
|
||||
}{d, c}
|
||||
}
|
||||
questionspacks := loadwords(questionsdata)
|
||||
questions = make([]string, len(questionspacks))
|
||||
for i := range questionspacks {
|
||||
questions[i] = questionspacks[i].String()
|
||||
}
|
||||
wordsdata, err := file.GetLazyData(en.DataFolder()+"words.bin", true, true)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
wordpacks := loadwords(wordsdata)
|
||||
words = make([]string, len(wordpacks))
|
||||
for i := range wordpacks {
|
||||
words[i] = wordpacks[i].String()
|
||||
}
|
||||
sort.Strings(words)
|
||||
}()
|
||||
en.OnRegex(`(个人|团队)猜单词`, zero.OnlyGroup).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
en.OnRegex(`(个人|团队)(五阶|六阶|七阶)?猜单词`, zero.OnlyGroup).SetBlock(true).Limit(ctxext.LimitByUser).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
target := questions[rand.Intn(len(questions))]
|
||||
class := classdict[ctx.State["regex_matched"].([]string)[2]]
|
||||
target := words[class].cet4[rand.Intn(len(words[class].cet4))]
|
||||
game := newWordleGame(target)
|
||||
_, img, cl, _ := game("")
|
||||
typ := ctx.State["regex_matched"].([]string)[1]
|
||||
ctx.Send(
|
||||
message.ReplyWithMessage(ctx.Event.MessageID,
|
||||
message.ImageBytes(img),
|
||||
message.Text("你有6次机会猜出单词,单词长度为5,请发送单词"),
|
||||
message.Text("你有", class+1, "次机会猜出单词,单词长度为", class, ",请发送单词"),
|
||||
),
|
||||
)
|
||||
cl()
|
||||
var next *zero.FutureEvent
|
||||
if typ == "个人" {
|
||||
next = zero.NewFutureEvent("message", 999, false, zero.RegexRule(`^[A-Z]{5}$|^[a-z]{5}$`), zero.OnlyGroup, zero.CheckUser(ctx.Event.UserID))
|
||||
if ctx.State["regex_matched"].([]string)[1] == "个人" {
|
||||
next = zero.NewFutureEvent("message", 999, false, zero.RegexRule(fmt.Sprintf(`^([A-Z]|[a-z]){%d}$`, class)),
|
||||
zero.OnlyGroup, zero.CheckUser(ctx.Event.UserID))
|
||||
} else {
|
||||
next = zero.NewFutureEvent("message", 999, false, zero.RegexRule(`^[A-Z]{5}$|^[a-z]{5}$`), zero.OnlyGroup, zero.CheckGroup(ctx.Event.GroupID))
|
||||
next = zero.NewFutureEvent("message", 999, false, zero.RegexRule(fmt.Sprintf(`^([A-Z]|[a-z]){%d}$`, class)),
|
||||
zero.OnlyGroup, zero.CheckGroup(ctx.Event.GroupID))
|
||||
}
|
||||
var win bool
|
||||
var err error
|
||||
recv, cancel := next.Repeat()
|
||||
defer cancel()
|
||||
for {
|
||||
select {
|
||||
case <-time.After(time.Second * 120):
|
||||
@@ -111,7 +126,7 @@ func init() {
|
||||
),
|
||||
)
|
||||
return
|
||||
case e := <-next.Next():
|
||||
case e := <-recv:
|
||||
win, img, cl, err = game(e.Message.String())
|
||||
switch {
|
||||
case win:
|
||||
@@ -158,6 +173,7 @@ func init() {
|
||||
}
|
||||
|
||||
func newWordleGame(target string) func(string) (bool, []byte, func(), error) {
|
||||
var class = len(target)
|
||||
record := make([]string, 0, len(target)+1)
|
||||
return func(s string) (win bool, data []byte, cl func(), err error) {
|
||||
if s != "" {
|
||||
@@ -169,8 +185,8 @@ func newWordleGame(target string) func(string) (bool, []byte, func(), error) {
|
||||
err = errLengthNotEnough
|
||||
return
|
||||
}
|
||||
i := sort.SearchStrings(words, s)
|
||||
if i >= len(words) || words[i] != s {
|
||||
i := sort.SearchStrings(words[class].dict, s)
|
||||
if i >= len(words[class].dict) || words[class].dict[i] != s {
|
||||
err = errUnknownWord
|
||||
return
|
||||
}
|
||||
@@ -181,13 +197,14 @@ func newWordleGame(target string) func(string) (bool, []byte, func(), error) {
|
||||
}
|
||||
}
|
||||
var side = 20
|
||||
ctx := gg.NewContext((side+2)*5+26, (side+2)*6+26)
|
||||
var space = 10
|
||||
ctx := gg.NewContext((side+4)*class+space*2-4, (side+4)*(class+1)+space*2-4)
|
||||
ctx.SetColor(color.RGBA{255, 255, 255, 255})
|
||||
ctx.Clear()
|
||||
for i := 0; i < len(target)+1; i++ {
|
||||
for j := 0; j < len(target); j++ {
|
||||
for i := 0; i < class+1; i++ {
|
||||
for j := 0; j < class; j++ {
|
||||
if len(record) > i {
|
||||
ctx.DrawRectangle(float64(10+j*(side+4)), float64(10+i*(side+4)), float64(side), float64(side))
|
||||
ctx.DrawRectangle(float64(space+j*(side+4)), float64(space+i*(side+4)), float64(side), float64(side))
|
||||
switch {
|
||||
case record[i][j] == target[j]:
|
||||
ctx.SetColor(colors[match])
|
||||
|
||||
275
plugin/ymgal/model.go
Normal file
275
plugin/ymgal/model.go
Normal file
@@ -0,0 +1,275 @@
|
||||
package ymgal
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"net/url"
|
||||
"os"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/antchfx/htmlquery"
|
||||
_ "github.com/fumiama/sqlite3" // import sql
|
||||
"github.com/jinzhu/gorm"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// gdb 得分数据库
|
||||
var gdb *ymgaldb
|
||||
|
||||
// ymgaldb galgame图片数据库
|
||||
type ymgaldb gorm.DB
|
||||
|
||||
var mu sync.RWMutex
|
||||
|
||||
// ymgal gal图片储存结构体
|
||||
type ymgal struct {
|
||||
ID int64 `gorm:"column:id" `
|
||||
Title string `gorm:"column:title" `
|
||||
PictureType string `gorm:"column:picture_type" `
|
||||
PictureDescription string `gorm:"column:picture_description;type:varchar(1024)" `
|
||||
PictureList string `gorm:"column:picture_list;type:varchar(20000)" `
|
||||
}
|
||||
|
||||
// TableName ...
|
||||
func (ymgal) TableName() string {
|
||||
return "ymgal"
|
||||
}
|
||||
|
||||
// initialize 初始化ymgaldb数据库
|
||||
func initialize(dbpath string) *ymgaldb {
|
||||
var err error
|
||||
if _, err = os.Stat(dbpath); err != nil || os.IsNotExist(err) {
|
||||
// 生成文件
|
||||
f, err := os.Create(dbpath)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
defer f.Close()
|
||||
}
|
||||
gdb, err := gorm.Open("sqlite3", dbpath)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
gdb.AutoMigrate(&ymgal{})
|
||||
return (*ymgaldb)(gdb)
|
||||
}
|
||||
|
||||
func (gdb *ymgaldb) insertOrUpdateYmgalByID(id int64, title, pictureType, pictureDescription, pictureList string) (err error) {
|
||||
db := (*gorm.DB)(gdb)
|
||||
y := ymgal{
|
||||
ID: id,
|
||||
Title: title,
|
||||
PictureType: pictureType,
|
||||
PictureDescription: pictureDescription,
|
||||
PictureList: pictureList,
|
||||
}
|
||||
if err = db.Debug().Model(&ymgal{}).First(&y, "id = ? ", id).Error; err != nil {
|
||||
if gorm.IsRecordNotFoundError(err) {
|
||||
err = db.Debug().Model(&ymgal{}).Create(&y).Error // newUser not user
|
||||
}
|
||||
} else {
|
||||
err = db.Debug().Model(&ymgal{}).Where("id = ? ", id).Update(map[string]interface{}{
|
||||
"title": title,
|
||||
"picture_type": pictureType,
|
||||
"picture_description": pictureDescription,
|
||||
"picture_list": pictureList,
|
||||
}).Error
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (gdb *ymgaldb) getYmgalByID(id string) (y ymgal) {
|
||||
db := (*gorm.DB)(gdb)
|
||||
db.Debug().Model(&ymgal{}).Where("id = ?", id).Take(&y)
|
||||
return
|
||||
}
|
||||
|
||||
func (gdb *ymgaldb) randomYmgal(pictureType string) (y ymgal) {
|
||||
db := (*gorm.DB)(gdb)
|
||||
var count int
|
||||
s := db.Debug().Model(&ymgal{}).Where("picture_type = ?", pictureType).Count(&count)
|
||||
if count == 0 {
|
||||
return
|
||||
}
|
||||
s.Offset(rand.Intn(count)).Take(&y)
|
||||
return
|
||||
}
|
||||
|
||||
func (gdb *ymgaldb) getYmgalByKey(pictureType, key string) (y ymgal) {
|
||||
db := (*gorm.DB)(gdb)
|
||||
var count int
|
||||
s := db.Debug().Model(&ymgal{}).Where("picture_type = ? and (picture_description like ? or title like ?) ", pictureType, "%"+key+"%", "%"+key+"%").Count(&count)
|
||||
if count == 0 {
|
||||
return
|
||||
}
|
||||
s.Offset(rand.Intn(count)).Take(&y)
|
||||
return
|
||||
}
|
||||
|
||||
const (
|
||||
webURL = "https://www.ymgal.com"
|
||||
cgType = "Gal CG"
|
||||
emoticonType = "其他"
|
||||
webPicURL = webURL + "/co/picset/"
|
||||
reNumber = `\d+`
|
||||
)
|
||||
|
||||
var (
|
||||
cgURL = webURL + "/search?type=picset&sort=default&category=" + url.QueryEscape(cgType) + "&page="
|
||||
emoticonURL = webURL + "/search?type=picset&sort=default&category=" + url.QueryEscape(emoticonType) + "&page="
|
||||
commonPageNumberExpr = "//*[@id='pager-box']/div/a[@class='icon item pager-next']/preceding-sibling::a[1]/text()"
|
||||
cgIDList []string
|
||||
emoticonIDList []string
|
||||
)
|
||||
|
||||
func initPageNumber() (maxCgPageNumber, maxEmoticonPageNumber int) {
|
||||
doc, err := htmlquery.LoadURL(cgURL + "1")
|
||||
if err != nil {
|
||||
log.Errorln("[ymgal]:", err)
|
||||
}
|
||||
maxCgPageNumber, err = strconv.Atoi(htmlquery.FindOne(doc, commonPageNumberExpr).Data)
|
||||
if err != nil {
|
||||
log.Errorln("[ymgal]:", err)
|
||||
}
|
||||
doc, err = htmlquery.LoadURL(emoticonURL + "1")
|
||||
if err != nil {
|
||||
log.Errorln("[ymgal]:", err)
|
||||
}
|
||||
maxEmoticonPageNumber, err = strconv.Atoi(htmlquery.FindOne(doc, commonPageNumberExpr).Data)
|
||||
if err != nil {
|
||||
log.Errorln("[ymgal]:", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func getPicID(pageNumber int, pictureType string) {
|
||||
var picURL string
|
||||
if pictureType == cgType {
|
||||
picURL = cgURL + strconv.Itoa(pageNumber)
|
||||
} else if pictureType == emoticonType {
|
||||
picURL = emoticonURL + strconv.Itoa(pageNumber)
|
||||
}
|
||||
doc, err := htmlquery.LoadURL(picURL)
|
||||
if err != nil {
|
||||
log.Errorln("[ymgal]:", err)
|
||||
}
|
||||
list := htmlquery.Find(doc, "//*[@id='picset-result-list']/ul/div/div[1]/a")
|
||||
for i := 0; i < len(list); i++ {
|
||||
re := regexp.MustCompile(reNumber)
|
||||
picID := re.FindString(list[i].Attr[0].Val)
|
||||
if pictureType == cgType {
|
||||
cgIDList = append(cgIDList, picID)
|
||||
} else if pictureType == emoticonType {
|
||||
emoticonIDList = append(emoticonIDList, picID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func updatePic() {
|
||||
maxCgPageNumber, maxEmoticonPageNumber := initPageNumber()
|
||||
for i := 1; i <= maxCgPageNumber; i++ {
|
||||
getPicID(i, cgType)
|
||||
time.Sleep(time.Millisecond * 500)
|
||||
}
|
||||
for i := 1; i <= maxEmoticonPageNumber; i++ {
|
||||
getPicID(i, emoticonType)
|
||||
time.Sleep(time.Millisecond * 500)
|
||||
}
|
||||
CGLOOP:
|
||||
for i := len(cgIDList) - 1; i >= 0; i-- {
|
||||
mu.RLock()
|
||||
y := gdb.getYmgalByID(cgIDList[i])
|
||||
mu.RUnlock()
|
||||
if y.PictureList == "" {
|
||||
mu.Lock()
|
||||
storeCgPic(cgIDList[i])
|
||||
mu.Unlock()
|
||||
} else {
|
||||
break CGLOOP
|
||||
}
|
||||
time.Sleep(time.Millisecond * 500)
|
||||
}
|
||||
EMOTICONLOOP:
|
||||
for i := len(emoticonIDList) - 1; i >= 0; i-- {
|
||||
mu.RLock()
|
||||
y := gdb.getYmgalByID(emoticonIDList[i])
|
||||
mu.RUnlock()
|
||||
if y.PictureList == "" {
|
||||
mu.Lock()
|
||||
storeEmoticonPic(emoticonIDList[i])
|
||||
mu.Unlock()
|
||||
} else {
|
||||
break EMOTICONLOOP
|
||||
}
|
||||
time.Sleep(time.Millisecond * 500)
|
||||
}
|
||||
}
|
||||
|
||||
func storeCgPic(picIDStr string) {
|
||||
picID, err := strconv.ParseInt(picIDStr, 10, 64)
|
||||
if err != nil {
|
||||
log.Errorln("[ymgal]:", err)
|
||||
}
|
||||
pictureType := cgType
|
||||
doc, err := htmlquery.LoadURL(webPicURL + picIDStr)
|
||||
if err != nil {
|
||||
log.Errorln("[ymgal]:", err)
|
||||
}
|
||||
title := htmlquery.FindOne(doc, "//meta[@name='name']").Attr[1].Val
|
||||
pictureDescription := htmlquery.FindOne(doc, "//meta[@name='description']").Attr[1].Val
|
||||
pictureNumberStr := htmlquery.FindOne(doc, "//div[@class='meta-info']/div[@class='meta-right']/span[2]/text()").Data
|
||||
re := regexp.MustCompile(reNumber)
|
||||
pictureNumber, err := strconv.Atoi(re.FindString(pictureNumberStr))
|
||||
if err != nil {
|
||||
log.Errorln("[ymgal]:", err)
|
||||
}
|
||||
pictureList := ""
|
||||
for i := 1; i <= pictureNumber; i++ {
|
||||
picURL := htmlquery.FindOne(doc, fmt.Sprintf("//*[@id='main-picset-warp']/div/div[2]/div/div[@class='swiper-wrapper']/div[%d]", i)).Attr[1].Val
|
||||
if i == 1 {
|
||||
pictureList += picURL
|
||||
} else {
|
||||
pictureList += "," + picURL
|
||||
}
|
||||
}
|
||||
err = gdb.insertOrUpdateYmgalByID(picID, title, pictureType, pictureDescription, pictureList)
|
||||
if err != nil {
|
||||
log.Errorln("[ymgal]:", err)
|
||||
}
|
||||
}
|
||||
|
||||
func storeEmoticonPic(picIDStr string) {
|
||||
picID, err := strconv.ParseInt(picIDStr, 10, 64)
|
||||
if err != nil {
|
||||
log.Errorln("[ymgal]:", err)
|
||||
}
|
||||
pictureType := emoticonType
|
||||
doc, err := htmlquery.LoadURL(webPicURL + picIDStr)
|
||||
if err != nil {
|
||||
log.Errorln("[ymgal]:", err)
|
||||
}
|
||||
title := htmlquery.FindOne(doc, "//meta[@name='name']").Attr[1].Val
|
||||
pictureDescription := htmlquery.FindOne(doc, "//meta[@name='description']").Attr[1].Val
|
||||
pictureNumberStr := htmlquery.FindOne(doc, "//div[@class='meta-info']/div[@class='meta-right']/span[2]/text()").Data
|
||||
re := regexp.MustCompile(reNumber)
|
||||
pictureNumber, err := strconv.Atoi(re.FindString(pictureNumberStr))
|
||||
if err != nil {
|
||||
log.Errorln("[ymgal]:", err)
|
||||
}
|
||||
pictureList := ""
|
||||
for i := 1; i <= pictureNumber; i++ {
|
||||
picURL := htmlquery.FindOne(doc, fmt.Sprintf("//*[@id='main-picset-warp']/div/div[@class='stream-list']/div[%d]/img", i)).Attr[1].Val
|
||||
if i == 1 {
|
||||
pictureList += picURL
|
||||
} else {
|
||||
pictureList += "," + picURL
|
||||
}
|
||||
}
|
||||
err = gdb.insertOrUpdateYmgalByID(picID, title, pictureType, pictureDescription, pictureList)
|
||||
if err != nil {
|
||||
log.Errorln("[ymgal]:", err)
|
||||
}
|
||||
}
|
||||
76
plugin/ymgal/ymgal.go
Normal file
76
plugin/ymgal/ymgal.go
Normal file
@@ -0,0 +1,76 @@
|
||||
// Package ymgal 月幕galgame
|
||||
package ymgal
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/FloatTech/zbputils/control"
|
||||
"github.com/FloatTech/zbputils/control/order"
|
||||
"github.com/FloatTech/zbputils/ctxext"
|
||||
"github.com/FloatTech/zbputils/file"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("ymgal", order.AcquirePrio(), &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "月幕galgame\n- 随机galCG\n- 随机gal表情包\n- galCG[xxx]\n- gal表情包[xxx]\n- 更新gal\n",
|
||||
PublicDataFolder: "Ymgal",
|
||||
})
|
||||
dbfile := engine.DataFolder() + "ymgal.db"
|
||||
go func() {
|
||||
_, _ = file.GetLazyData(dbfile, false, false)
|
||||
gdb = initialize(dbfile)
|
||||
}()
|
||||
engine.OnRegex("^随机gal(CG|表情包)$").Limit(ctxext.LimitByUser).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.Send("少女祈祷中......")
|
||||
pictureType := ctx.State["regex_matched"].([]string)[1]
|
||||
var y ymgal
|
||||
if pictureType == "表情包" {
|
||||
y = gdb.randomYmgal(emoticonType)
|
||||
} else {
|
||||
y = gdb.randomYmgal(cgType)
|
||||
}
|
||||
sendYmgal(y, ctx)
|
||||
})
|
||||
engine.OnRegex("^gal(CG|表情包)([一-龥ぁ-んァ-ヶA-Za-z0-9]{1,25})$").Limit(ctxext.LimitByUser).SetBlock(true).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
ctx.Send("少女祈祷中......")
|
||||
pictureType := ctx.State["regex_matched"].([]string)[1]
|
||||
key := ctx.State["regex_matched"].([]string)[2]
|
||||
var y ymgal
|
||||
if pictureType == "CG" {
|
||||
y = gdb.getYmgalByKey(cgType, key)
|
||||
} else {
|
||||
y = gdb.getYmgalByKey(emoticonType, key)
|
||||
}
|
||||
sendYmgal(y, ctx)
|
||||
})
|
||||
engine.OnFullMatch("更新gal", zero.SuperUserPermission).SetBlock(true).Handle(
|
||||
func(ctx *zero.Ctx) {
|
||||
ctx.Send("少女祈祷中......")
|
||||
updatePic()
|
||||
ctx.Send("ymgal数据库已更新")
|
||||
})
|
||||
}
|
||||
|
||||
func sendYmgal(y ymgal, ctx *zero.Ctx) {
|
||||
if y.PictureList == "" {
|
||||
ctx.SendChain(message.Text(zero.BotConfig.NickName[0] + "暂时没有这样的图呢"))
|
||||
return
|
||||
}
|
||||
m := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Text(y.Title))}
|
||||
if y.PictureDescription != "" {
|
||||
m = append(m, ctxext.FakeSenderForwardNode(ctx, message.Text(y.PictureDescription)))
|
||||
}
|
||||
for _, v := range strings.Split(y.PictureList, ",") {
|
||||
m = append(m, ctxext.FakeSenderForwardNode(ctx, message.Image(v)))
|
||||
}
|
||||
if id := ctx.SendGroupForwardMessage(
|
||||
ctx.Event.GroupID,
|
||||
m).Get("message_id").Int(); id == 0 {
|
||||
ctx.SendChain(message.Text("ERROR: 可能被风控了"))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user