Compare commits
14 Commits
v1.2.2-bet
...
v1.2.2-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
58e075e6ff | ||
|
|
ef081714d7 | ||
|
|
96802efa45 | ||
|
|
0a95f3198b | ||
|
|
cb44758036 | ||
|
|
1682c321d3 | ||
|
|
eeba8a5de7 | ||
|
|
2ea0f58e03 | ||
|
|
05235473c1 | ||
|
|
f0c083f4e6 | ||
|
|
6997c9a5c0 | ||
|
|
eebfa23509 | ||
|
|
59fe8a021f | ||
|
|
16672d9b89 |
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
[submodule "data"]
|
||||
path = data
|
||||
url = https://github.com/FloatTech/zbpdata
|
||||
@@ -11,7 +11,6 @@ builds:
|
||||
- GO111MODULE=on
|
||||
goos:
|
||||
- linux
|
||||
- darwin
|
||||
goarch:
|
||||
- 386
|
||||
- amd64
|
||||
@@ -20,11 +19,6 @@ builds:
|
||||
goarm:
|
||||
- 6
|
||||
- 7
|
||||
ignore:
|
||||
- goos: darwin
|
||||
goarch: arm
|
||||
- goos: darwin
|
||||
goarch: 386
|
||||
mod_timestamp: "{{ .CommitTimestamp }}"
|
||||
flags:
|
||||
- -trimpath
|
||||
|
||||
@@ -231,6 +231,13 @@ zerobot -h -t token -u url [-d|w] [-g 监听地址:端口] qq1 qq2 qq3 ...
|
||||
- [x] 讲个段子
|
||||
- **笑话** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_funny"`
|
||||
- [x] 讲个笑话[@xxx]|讲个笑话[qq号]
|
||||
- **抽象话** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_chouxianghua"`
|
||||
- [x] 抽象翻译[xxx]
|
||||
- **绝绝子** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_juejuezi"`
|
||||
- [x] 喝奶茶绝绝子|绝绝子吃饭
|
||||
- **藏头诗** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_cangtoushi"`
|
||||
- [x] 藏头诗[xxx]
|
||||
- [x] 藏尾诗[xxx]
|
||||
- **TODO...**
|
||||
|
||||
## 使用方法
|
||||
|
||||
1
data
Submodule
1607
data/Chat/kimoi.json
@@ -1,906 +0,0 @@
|
||||
[
|
||||
{
|
||||
"name": "印度",
|
||||
"weight": 0.179369185
|
||||
},
|
||||
{
|
||||
"weight": 0.116660088,
|
||||
"name": "中华人民共和国"
|
||||
},
|
||||
{
|
||||
"name": "尼日利亚",
|
||||
"weight": 0.052104876
|
||||
},
|
||||
{
|
||||
"weight": 0.04490831,
|
||||
"name": "巴基斯坦"
|
||||
},
|
||||
{
|
||||
"weight": 0.029767875,
|
||||
"name": "印尼"
|
||||
},
|
||||
{
|
||||
"weight": 0.02917347,
|
||||
"name": "美国"
|
||||
},
|
||||
{
|
||||
"name": "刚果民主共和国",
|
||||
"weight": 0.026980482
|
||||
},
|
||||
{
|
||||
"weight": 0.02653533,
|
||||
"name": "埃塞俄比亚"
|
||||
},
|
||||
{
|
||||
"name": "孟加拉国",
|
||||
"weight": 0.022001723
|
||||
},
|
||||
{
|
||||
"name": "巴西",
|
||||
"weight": 0.020641351
|
||||
},
|
||||
{
|
||||
"name": "埃及",
|
||||
"weight": 0.019722924
|
||||
},
|
||||
{
|
||||
"name": "菲律宾",
|
||||
"weight": 0.017944256
|
||||
},
|
||||
{
|
||||
"name": "墨西哥",
|
||||
"weight": 0.015798468
|
||||
},
|
||||
{
|
||||
"weight": 0.015156998,
|
||||
"name": "坦桑尼亚"
|
||||
},
|
||||
{
|
||||
"weight": 0.013686862,
|
||||
"name": "乌干达"
|
||||
},
|
||||
{
|
||||
"weight": 0.010405389,
|
||||
"name": "俄罗斯"
|
||||
},
|
||||
{
|
||||
"weight": 0.010217107,
|
||||
"name": "苏丹"
|
||||
},
|
||||
{
|
||||
"weight": 0.010079201,
|
||||
"name": "越南"
|
||||
},
|
||||
{
|
||||
"name": "阿富汗",
|
||||
"weight": 0.009796745
|
||||
},
|
||||
{
|
||||
"name": "伊朗",
|
||||
"weight": 0.009789926
|
||||
},
|
||||
{
|
||||
"name": "肯尼亚",
|
||||
"weight": 0.009216044
|
||||
},
|
||||
{
|
||||
"weight": 0.008870993,
|
||||
"name": "安哥拉"
|
||||
},
|
||||
{
|
||||
"name": "土耳其",
|
||||
"weight": 0.008815318
|
||||
},
|
||||
{
|
||||
"weight": 0.008267509,
|
||||
"name": "莫桑比克"
|
||||
},
|
||||
{
|
||||
"name": "南非",
|
||||
"weight": 0.007826801
|
||||
},
|
||||
{
|
||||
"weight": 0.00755071,
|
||||
"name": "尼日尔"
|
||||
},
|
||||
{
|
||||
"name": "伊拉克",
|
||||
"weight": 0.007350484
|
||||
},
|
||||
{
|
||||
"name": "喀麦隆",
|
||||
"weight": 0.006786572
|
||||
},
|
||||
{
|
||||
"weight": 0.006782117,
|
||||
"name": "缅甸"
|
||||
},
|
||||
{
|
||||
"name": "日本",
|
||||
"weight": 0.006518972
|
||||
},
|
||||
{
|
||||
"weight": 0.006384764,
|
||||
"name": "加纳"
|
||||
},
|
||||
{
|
||||
"weight": 0.006183538,
|
||||
"name": "阿尔及利亚"
|
||||
},
|
||||
{
|
||||
"weight": 0.006075416,
|
||||
"name": "马里"
|
||||
},
|
||||
{
|
||||
"name": "法国",
|
||||
"weight": 0.00571344
|
||||
},
|
||||
{
|
||||
"name": "英国",
|
||||
"weight": 0.005662409
|
||||
},
|
||||
{
|
||||
"name": "马达加斯加",
|
||||
"weight": 0.00559132
|
||||
},
|
||||
{
|
||||
"weight": 0.005562893,
|
||||
"name": "也门"
|
||||
},
|
||||
{
|
||||
"name": "哥伦比亚",
|
||||
"weight": 0.005525953
|
||||
},
|
||||
{
|
||||
"name": "布基纳法索",
|
||||
"weight": 0.005378297
|
||||
},
|
||||
{
|
||||
"name": "科特迪瓦",
|
||||
"weight": 0.005352997
|
||||
},
|
||||
{
|
||||
"name": "阿根廷",
|
||||
"weight": 0.005171935
|
||||
},
|
||||
{
|
||||
"name": "赞比亚",
|
||||
"weight": 0.005147159
|
||||
},
|
||||
{
|
||||
"name": "德国",
|
||||
"weight": 0.005096501
|
||||
},
|
||||
{
|
||||
"weight": 0.005067552,
|
||||
"name": "泰国"
|
||||
},
|
||||
{
|
||||
"name": "马拉维",
|
||||
"weight": 0.005017242
|
||||
},
|
||||
{
|
||||
"name": "乍得",
|
||||
"weight": 0.004825619
|
||||
},
|
||||
{
|
||||
"name": "摩洛哥",
|
||||
"weight": 0.004571552
|
||||
},
|
||||
{
|
||||
"weight": 0.004266592,
|
||||
"name": "马来西亚"
|
||||
},
|
||||
{
|
||||
"weight": 0.004130712,
|
||||
"name": "南苏丹"
|
||||
},
|
||||
{
|
||||
"name": "委内瑞拉",
|
||||
"weight": 0.00410843
|
||||
},
|
||||
{
|
||||
"weight": 0.003903682,
|
||||
"name": "乌兹别克斯坦"
|
||||
},
|
||||
{
|
||||
"weight": 0.003891083,
|
||||
"name": "秘鲁"
|
||||
},
|
||||
{
|
||||
"weight": 0.003854943,
|
||||
"name": "尼泊尔"
|
||||
},
|
||||
{
|
||||
"name": "沙特阿拉伯",
|
||||
"weight": 0.003683713
|
||||
},
|
||||
{
|
||||
"name": "塞内加尔",
|
||||
"weight": 0.003671814
|
||||
},
|
||||
{
|
||||
"name": "津巴布韦",
|
||||
"weight": 0.003628572
|
||||
},
|
||||
{
|
||||
"name": "意大利",
|
||||
"weight": 0.003591173
|
||||
},
|
||||
{
|
||||
"weight": 0.003564036,
|
||||
"name": "贝宁"
|
||||
},
|
||||
{
|
||||
"weight": 0.003318383,
|
||||
"name": "索马里"
|
||||
},
|
||||
{
|
||||
"name": "几内亚",
|
||||
"weight": 0.003229938
|
||||
},
|
||||
{
|
||||
"name": "韩国",
|
||||
"weight": 0.00302709
|
||||
},
|
||||
{
|
||||
"name": "危地马拉",
|
||||
"weight": 0.002989448
|
||||
},
|
||||
{
|
||||
"weight": 0.002933277,
|
||||
"name": "西班牙"
|
||||
},
|
||||
{
|
||||
"name": "布隆迪",
|
||||
"weight": 0.002916273
|
||||
},
|
||||
{
|
||||
"name": "乌克兰",
|
||||
"weight": 0.002865519
|
||||
},
|
||||
{
|
||||
"name": "叙利亚",
|
||||
"weight": 0.002803866
|
||||
},
|
||||
{
|
||||
"name": "加拿大",
|
||||
"weight": 0.002769376
|
||||
},
|
||||
{
|
||||
"name": "朝鲜",
|
||||
"weight": 0.002663995
|
||||
},
|
||||
{
|
||||
"name": "柬埔寨",
|
||||
"weight": 0.002507218
|
||||
},
|
||||
{
|
||||
"weight": 0.002459301,
|
||||
"name": "卢旺达"
|
||||
},
|
||||
{
|
||||
"weight": 0.002433661,
|
||||
"name": "波兰"
|
||||
},
|
||||
{
|
||||
"weight": 0.002264484,
|
||||
"name": "澳大利亚"
|
||||
},
|
||||
{
|
||||
"name": "斯里兰卡",
|
||||
"weight": 0.002205474
|
||||
},
|
||||
{
|
||||
"weight": 0.00217928,
|
||||
"name": "哈萨克斯坦"
|
||||
},
|
||||
{
|
||||
"name": "厄瓜多尔",
|
||||
"weight": 0.002114416
|
||||
},
|
||||
{
|
||||
"name": "塞拉利昂",
|
||||
"weight": 0.002042686
|
||||
},
|
||||
{
|
||||
"name": "海地",
|
||||
"weight": 0.001815248
|
||||
},
|
||||
{
|
||||
"name": "智利",
|
||||
"weight": 0.001761297
|
||||
},
|
||||
{
|
||||
"name": "多哥",
|
||||
"weight": 0.001756614
|
||||
},
|
||||
{
|
||||
"name": "约旦",
|
||||
"weight": 0.001738363
|
||||
},
|
||||
{
|
||||
"weight": 0.001716995,
|
||||
"name": "玻利维亚"
|
||||
},
|
||||
{
|
||||
"weight": 0.001432103,
|
||||
"name": "巴布亚新几内亚"
|
||||
},
|
||||
{
|
||||
"weight": 0.001424043,
|
||||
"name": "塔吉克斯坦"
|
||||
},
|
||||
{
|
||||
"name": "多米尼加",
|
||||
"weight": 0.001376899
|
||||
},
|
||||
{
|
||||
"name": "荷兰",
|
||||
"weight": 0.001365722
|
||||
},
|
||||
{
|
||||
"name": "罗马尼亚",
|
||||
"weight": 0.001342703
|
||||
},
|
||||
{
|
||||
"weight": 0.001340039,
|
||||
"name": "台湾"
|
||||
},
|
||||
{
|
||||
"name": "突尼斯",
|
||||
"weight": 0.001327688
|
||||
},
|
||||
{
|
||||
"name": "中非",
|
||||
"weight": 0.001269639
|
||||
},
|
||||
{
|
||||
"name": "洪都拉斯",
|
||||
"weight": 0.001219191
|
||||
},
|
||||
{
|
||||
"name": "刚果共和国",
|
||||
"weight": 0.001209073
|
||||
},
|
||||
{
|
||||
"weight": 0.001189154,
|
||||
"name": "利比里亚"
|
||||
},
|
||||
{
|
||||
"weight": 0.001150376,
|
||||
"name": "以色列"
|
||||
},
|
||||
{
|
||||
"weight": 0.001149654,
|
||||
"name": "厄立特里亚"
|
||||
},
|
||||
{
|
||||
"weight": 0.001119049,
|
||||
"name": "老挝"
|
||||
},
|
||||
{
|
||||
"name": "阿塞拜疆",
|
||||
"weight": 0.001039837
|
||||
},
|
||||
{
|
||||
"name": "利比亚",
|
||||
"weight": 0.001029222
|
||||
},
|
||||
{
|
||||
"name": "巴勒斯坦",
|
||||
"weight": 0.000992651
|
||||
},
|
||||
{
|
||||
"name": "吉尔吉斯斯坦",
|
||||
"weight": 0.000957294
|
||||
},
|
||||
{
|
||||
"weight": 0.000907425,
|
||||
"name": "比利时"
|
||||
},
|
||||
{
|
||||
"name": "瑞典",
|
||||
"weight": 0.000890654
|
||||
},
|
||||
{
|
||||
"name": "巴拉圭",
|
||||
"weight": 0.00085764
|
||||
},
|
||||
{
|
||||
"name": "毛里塔尼亚",
|
||||
"weight": 0.000842302
|
||||
},
|
||||
{
|
||||
"weight": 0.000830493,
|
||||
"name": "古巴"
|
||||
},
|
||||
{
|
||||
"name": "萨尔瓦多",
|
||||
"weight": 0.000822881
|
||||
},
|
||||
{
|
||||
"name": "尼加拉瓜",
|
||||
"weight": 0.000782782
|
||||
},
|
||||
{
|
||||
"weight": 0.000764766,
|
||||
"name": "阿曼"
|
||||
},
|
||||
{
|
||||
"name": "黎巴嫩",
|
||||
"weight": 0.000751395
|
||||
},
|
||||
{
|
||||
"name": "土库曼斯坦",
|
||||
"weight": 0.000743841
|
||||
},
|
||||
{
|
||||
"weight": 0.000680867,
|
||||
"name": "阿联酋"
|
||||
},
|
||||
{
|
||||
"weight": 0.000677997,
|
||||
"name": "捷克"
|
||||
},
|
||||
{
|
||||
"weight": 0.000643037,
|
||||
"name": "白俄罗斯"
|
||||
},
|
||||
{
|
||||
"weight": 0.000642255,
|
||||
"name": "瑞士"
|
||||
},
|
||||
{
|
||||
"name": "匈牙利",
|
||||
"weight": 0.000612393
|
||||
},
|
||||
{
|
||||
"name": "奥地利",
|
||||
"weight": 0.000602473
|
||||
},
|
||||
{
|
||||
"name": "希腊",
|
||||
"weight": 0.000595922
|
||||
},
|
||||
{
|
||||
"weight": 0.000592992,
|
||||
"name": "葡萄牙"
|
||||
},
|
||||
{
|
||||
"weight": 0.000566764,
|
||||
"name": "科威特"
|
||||
},
|
||||
{
|
||||
"weight": 0.000538867,
|
||||
"name": "哥斯达黎加"
|
||||
},
|
||||
{
|
||||
"name": "巴拿马",
|
||||
"weight": 0.000513904
|
||||
},
|
||||
{
|
||||
"name": "挪威",
|
||||
"weight": 0.000466485
|
||||
},
|
||||
{
|
||||
"name": "丹麦",
|
||||
"weight": 0.000460789
|
||||
},
|
||||
{
|
||||
"name": "爱尔兰",
|
||||
"weight": 0.000455762
|
||||
},
|
||||
{
|
||||
"name": "新西兰",
|
||||
"weight": 0.000451486
|
||||
},
|
||||
{
|
||||
"name": "纳米比亚",
|
||||
"weight": 0.000450165
|
||||
},
|
||||
{
|
||||
"name": "香港",
|
||||
"weight": 0.000448826
|
||||
},
|
||||
{
|
||||
"weight": 0.000441931,
|
||||
"name": "冈比亚"
|
||||
},
|
||||
{
|
||||
"weight": 0.000436542,
|
||||
"name": "塞尔维亚"
|
||||
},
|
||||
{
|
||||
"name": "芬兰",
|
||||
"weight": 0.000417327
|
||||
},
|
||||
{
|
||||
"weight": 0.00041658,
|
||||
"name": "几内亚比绍"
|
||||
},
|
||||
{
|
||||
"weight": 0.000410456,
|
||||
"name": "保加利亚"
|
||||
},
|
||||
{
|
||||
"weight": 0.000382945,
|
||||
"name": "蒙古"
|
||||
},
|
||||
{
|
||||
"name": "莱索托",
|
||||
"weight": 0.00037228
|
||||
},
|
||||
{
|
||||
"weight": 0.000361607,
|
||||
"name": "新加坡"
|
||||
},
|
||||
{
|
||||
"name": "斯洛伐克",
|
||||
"weight": 0.000361482
|
||||
},
|
||||
{
|
||||
"weight": 0.00035722,
|
||||
"name": "加蓬"
|
||||
},
|
||||
{
|
||||
"name": "博茨瓦纳",
|
||||
"weight": 0.000348221
|
||||
},
|
||||
{
|
||||
"weight": 0.000323338,
|
||||
"name": "乌拉圭"
|
||||
},
|
||||
{
|
||||
"name": "赤道几内亚",
|
||||
"weight": 0.000318155
|
||||
},
|
||||
{
|
||||
"name": "东帝汶",
|
||||
"weight": 0.000316195
|
||||
},
|
||||
{
|
||||
"name": "牙买加",
|
||||
"weight": 0.000312724
|
||||
},
|
||||
{
|
||||
"name": "格鲁吉亚",
|
||||
"weight": 0.000307685
|
||||
},
|
||||
{
|
||||
"weight": 0.000265076,
|
||||
"name": "阿尔巴尼亚"
|
||||
},
|
||||
{
|
||||
"weight": 0.000252622,
|
||||
"name": "克罗地亚"
|
||||
},
|
||||
{
|
||||
"weight": 0.000250708,
|
||||
"name": "亚美尼亚"
|
||||
},
|
||||
{
|
||||
"name": "波黑",
|
||||
"weight": 0.000232069
|
||||
},
|
||||
{
|
||||
"name": "摩尔多瓦",
|
||||
"weight": 0.000204405
|
||||
},
|
||||
{
|
||||
"name": "科索沃",
|
||||
"weight": 0.000196993
|
||||
},
|
||||
{
|
||||
"weight": 0.000189047,
|
||||
"name": "立陶宛"
|
||||
},
|
||||
{
|
||||
"weight": 0.000182006,
|
||||
"name": "卡塔尔"
|
||||
},
|
||||
{
|
||||
"name": "波多黎各",
|
||||
"weight": 0.000182004
|
||||
},
|
||||
{
|
||||
"name": "吉布提",
|
||||
"weight": 0.000174383
|
||||
},
|
||||
{
|
||||
"name": "北马其顿",
|
||||
"weight": 0.000158321
|
||||
},
|
||||
{
|
||||
"weight": 0.000146886,
|
||||
"name": "科摩罗"
|
||||
},
|
||||
{
|
||||
"weight": 0.000144027,
|
||||
"name": "巴林"
|
||||
},
|
||||
{
|
||||
"weight": 0.000129782,
|
||||
"name": "斯洛文尼亚"
|
||||
},
|
||||
{
|
||||
"weight": 0.000126232,
|
||||
"name": "西撒哈拉"
|
||||
},
|
||||
{
|
||||
"name": "拉脱维亚",
|
||||
"weight": 0.000124966
|
||||
},
|
||||
{
|
||||
"name": "所罗门群岛",
|
||||
"weight": 0.000120169
|
||||
},
|
||||
{
|
||||
"name": "斐济",
|
||||
"weight": 0.000110985
|
||||
},
|
||||
{
|
||||
"weight": 0.000110769,
|
||||
"name": "特立尼达和多巴哥"
|
||||
},
|
||||
{
|
||||
"weight": 0.000109656,
|
||||
"name": "毛里求斯"
|
||||
},
|
||||
{
|
||||
"weight": 8.8e-5,
|
||||
"name": "爱沙尼亚"
|
||||
},
|
||||
{
|
||||
"weight": 8.61e-5,
|
||||
"name": "圭亚那"
|
||||
},
|
||||
{
|
||||
"name": "不丹",
|
||||
"weight": 8.61e-5
|
||||
},
|
||||
{
|
||||
"weight": 7.49e-5,
|
||||
"name": "佛得角"
|
||||
},
|
||||
{
|
||||
"name": "塞浦路斯",
|
||||
"weight": 6.8e-5
|
||||
},
|
||||
{
|
||||
"name": "伯利兹",
|
||||
"weight": 6.4e-5
|
||||
},
|
||||
{
|
||||
"weight": 6.01e-5,
|
||||
"name": "苏里南"
|
||||
},
|
||||
{
|
||||
"name": "文莱",
|
||||
"weight": 5.2e-5
|
||||
},
|
||||
{
|
||||
"weight": 5.1e-5,
|
||||
"name": "黑山"
|
||||
},
|
||||
{
|
||||
"name": "瓦努阿图",
|
||||
"weight": 5.1e-5
|
||||
},
|
||||
{
|
||||
"name": "卢森堡",
|
||||
"weight": 5.07e-5
|
||||
},
|
||||
{
|
||||
"name": "马尔代夫",
|
||||
"weight": 4.27e-5
|
||||
},
|
||||
{
|
||||
"name": "巴哈马",
|
||||
"weight": 4.06e-5
|
||||
},
|
||||
{
|
||||
"weight": 3.82e-5,
|
||||
"name": "澳门"
|
||||
},
|
||||
{
|
||||
"weight": 3.48e-5,
|
||||
"name": "马耳他"
|
||||
},
|
||||
{
|
||||
"name": "冰岛",
|
||||
"weight": 3.45e-5
|
||||
},
|
||||
{
|
||||
"weight": 3.03e-5,
|
||||
"name": "新喀里多尼亚"
|
||||
},
|
||||
{
|
||||
"name": "萨摩亚",
|
||||
"weight": 2.83e-5
|
||||
},
|
||||
{
|
||||
"weight": 2.8e-5,
|
||||
"name": "法属波利尼西亚"
|
||||
},
|
||||
{
|
||||
"name": "关岛",
|
||||
"weight": 2.36e-5
|
||||
},
|
||||
{
|
||||
"weight": 2.32e-5,
|
||||
"name": "巴巴多斯"
|
||||
},
|
||||
{
|
||||
"name": "基里巴斯",
|
||||
"weight": 1.83e-5
|
||||
},
|
||||
{
|
||||
"weight": 1.71e-5,
|
||||
"name": "圣卢西亚"
|
||||
},
|
||||
{
|
||||
"name": "库拉索",
|
||||
"weight": 1.51e-5
|
||||
},
|
||||
{
|
||||
"weight": 1.5e-5,
|
||||
"name": "汤加"
|
||||
},
|
||||
{
|
||||
"weight": 1.42e-5,
|
||||
"name": "密克罗尼西亚联邦"
|
||||
},
|
||||
{
|
||||
"weight": 1.13e-5,
|
||||
"name": "格林纳达"
|
||||
},
|
||||
{
|
||||
"name": "安提瓜和巴布达",
|
||||
"weight": 1.05e-5
|
||||
},
|
||||
{
|
||||
"weight": 9.93e-6,
|
||||
"name": "圣文森特和格林纳丁斯"
|
||||
},
|
||||
{
|
||||
"name": "泽西",
|
||||
"weight": 9.66e-6
|
||||
},
|
||||
{
|
||||
"weight": 9.64e-6,
|
||||
"name": "阿鲁巴"
|
||||
},
|
||||
{
|
||||
"weight": 9.15e-6,
|
||||
"name": "美属维尔京群岛"
|
||||
},
|
||||
{
|
||||
"weight": 9.08e-6,
|
||||
"name": "马绍尔群岛"
|
||||
},
|
||||
{
|
||||
"weight": 8.9e-6,
|
||||
"name": "塞舌尔"
|
||||
},
|
||||
{
|
||||
"name": "美属萨摩亚",
|
||||
"weight": 7.97e-6
|
||||
},
|
||||
{
|
||||
"name": "多米尼克",
|
||||
"weight": 7.57e-6
|
||||
},
|
||||
{
|
||||
"weight": 6.41e-6,
|
||||
"name": "马恩岛"
|
||||
},
|
||||
{
|
||||
"weight": 6.09e-6,
|
||||
"name": "北马里亚纳群岛"
|
||||
},
|
||||
{
|
||||
"name": "开曼群岛",
|
||||
"weight": 5.77e-6
|
||||
},
|
||||
{
|
||||
"name": "格陵兰",
|
||||
"weight": 5.63e-6
|
||||
},
|
||||
{
|
||||
"weight": 5.54e-6,
|
||||
"name": "法罗群岛"
|
||||
},
|
||||
{
|
||||
"weight": 5.17e-6,
|
||||
"name": "圣基茨和尼维斯"
|
||||
},
|
||||
{
|
||||
"weight": 5.11e-6,
|
||||
"name": "百慕大"
|
||||
},
|
||||
{
|
||||
"weight": 4.38e-6,
|
||||
"name": "根西"
|
||||
},
|
||||
{
|
||||
"weight": 4.31e-6,
|
||||
"name": "特克斯和凯科斯群岛"
|
||||
},
|
||||
{
|
||||
"name": "荷属圣马丁",
|
||||
"weight": 4.14e-6
|
||||
},
|
||||
{
|
||||
"weight": 3.87e-6,
|
||||
"name": "安道尔"
|
||||
},
|
||||
{
|
||||
"name": "法国(法属圣马丁)",
|
||||
"weight": 3.6e-6
|
||||
},
|
||||
{
|
||||
"name": "直布罗陀",
|
||||
"weight": 3.2e-6
|
||||
},
|
||||
{
|
||||
"weight": 2.87e-6,
|
||||
"name": "列支敦士登"
|
||||
},
|
||||
{
|
||||
"name": "英属维尔京群岛",
|
||||
"weight": 2.57e-6
|
||||
},
|
||||
{
|
||||
"weight": 2.1e-6,
|
||||
"name": "圣马力诺"
|
||||
},
|
||||
{
|
||||
"weight": 1.75e-6,
|
||||
"name": "瑙鲁"
|
||||
},
|
||||
{
|
||||
"name": "摩纳哥",
|
||||
"weight": 1.75e-6
|
||||
},
|
||||
{
|
||||
"name": "图瓦卢",
|
||||
"weight": 1.72e-6
|
||||
},
|
||||
{
|
||||
"name": "库克群岛",
|
||||
"weight": 1.44e-6
|
||||
},
|
||||
{
|
||||
"name": "帕劳",
|
||||
"weight": 1.44e-6
|
||||
},
|
||||
{
|
||||
"weight": 1.41e-6,
|
||||
"name": "安圭拉"
|
||||
},
|
||||
{
|
||||
"weight": 1.05e-6,
|
||||
"name": "法国(瓦利斯和富图纳)"
|
||||
},
|
||||
{
|
||||
"weight": 6.6e-7,
|
||||
"name": "法国(圣巴泰勒米)"
|
||||
},
|
||||
{
|
||||
"name": "蒙特塞拉特",
|
||||
"weight": 4.35e-7
|
||||
},
|
||||
{
|
||||
"weight": 3.77e-7,
|
||||
"name": "圣赫勒拿、阿森松和特里斯坦-达库尼亚"
|
||||
},
|
||||
{
|
||||
"name": "法国(圣皮埃尔和密克隆)",
|
||||
"weight": 2.86e-7
|
||||
},
|
||||
{
|
||||
"name": "福克兰群岛",
|
||||
"weight": 2.48e-7
|
||||
}
|
||||
]
|
||||
52
go.mod
@@ -1,6 +1,6 @@
|
||||
module github.com/FloatTech/ZeroBot-Plugin
|
||||
|
||||
go 1.16
|
||||
go 1.17
|
||||
|
||||
require (
|
||||
github.com/FloatTech/AnimeAPI v1.1.11
|
||||
@@ -27,3 +27,53 @@ require (
|
||||
golang.org/x/image v0.0.0-20211028202545-6944b10bf410
|
||||
golang.org/x/text v0.3.6
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/FloatTech/imgfactory v0.1.1 // indirect
|
||||
github.com/antchfx/xpath v1.1.6 // indirect
|
||||
github.com/disintegration/imaging v1.6.2 // indirect
|
||||
github.com/ericpauley/go-quantize v0.0.0-20200331213906-ae555eb2afa4 // indirect
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
github.com/go-ole/go-ole v1.2.6 // indirect
|
||||
github.com/go-playground/locales v0.13.0 // indirect
|
||||
github.com/go-playground/universal-translator v0.17.0 // indirect
|
||||
github.com/go-playground/validator/v10 v10.4.1 // indirect
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/json-iterator/go v1.1.11 // indirect
|
||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
|
||||
github.com/leodido/go-urn v1.2.0 // indirect
|
||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.12 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2-0.20210109003243-333559e1834b // indirect
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
|
||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // 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/ugorji/go/codec v1.1.7 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.2 // indirect
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect
|
||||
golang.org/x/mod v0.3.0 // indirect
|
||||
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f // indirect
|
||||
golang.org/x/sys v0.0.0-20211013075003-97ac67df715c // indirect
|
||||
golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
|
||||
google.golang.org/protobuf v1.27.1 // indirect
|
||||
gopkg.in/yaml.v2 v2.2.8 // indirect
|
||||
lukechampine.com/uint128 v1.1.1 // indirect
|
||||
modernc.org/cc/v3 v3.34.0 // indirect
|
||||
modernc.org/ccgo/v3 v3.11.2 // indirect
|
||||
modernc.org/libc v1.11.3 // indirect
|
||||
modernc.org/mathutil v1.4.1 // indirect
|
||||
modernc.org/memory v1.0.5 // indirect
|
||||
modernc.org/opt v0.1.1 // indirect
|
||||
modernc.org/sqlite v1.13.0 // indirect
|
||||
modernc.org/strutil v1.1.1 // indirect
|
||||
modernc.org/token v1.0.0 // indirect
|
||||
)
|
||||
|
||||
35
main.go
@@ -28,22 +28,25 @@ import (
|
||||
|
||||
// 娱乐类
|
||||
// _ "github.com/FloatTech/ZeroBot-Plugin/plugin_wtf" // 鬼东西
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin-Gif" // 制图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_ai_false" // 服务器监控
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_book_review" // 哀伤雪刃吧推书记录
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_choose" // 选择困难症帮手
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_coser" // 三次元小姐姐
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_fortune" // 运势
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_funny" // 笑话
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_hs" // 炉石
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_minecraft" // MCSManager
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_moyu" // 摸鱼
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_music" // 点歌
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_novel" // 铅笔小说网搜索
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_omikuji" // 浅草寺求签
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_reborn" // 投胎
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_shadiao" // 沙雕app
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_shindan" // 测定
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin-Gif" // 制图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_ai_false" // 服务器监控
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_book_review" // 哀伤雪刃吧推书记录
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_cangtoushi" // 藏头诗
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_choose" // 选择困难症帮手
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_chouxianghua" // 说抽象话
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_coser" // 三次元小姐姐
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_fortune" // 运势
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_funny" // 笑话
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_hs" // 炉石
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_juejuezi" // 绝绝子生成器
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_minecraft" // MCSManager
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_moyu" // 摸鱼
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_music" // 点歌
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_novel" // 铅笔小说网搜索
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_omikuji" // 浅草寺求签
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_reborn" // 投胎
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_shadiao" // 沙雕app
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_shindan" // 测定
|
||||
|
||||
// b站相关
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_bilibili" // 查询b站用户信息
|
||||
|
||||
|
Before Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 60 KiB |
|
Before Width: | Height: | Size: 79 KiB |
|
Before Width: | Height: | Size: 149 KiB |
|
Before Width: | Height: | Size: 693 KiB |
|
Before Width: | Height: | Size: 91 KiB |
|
Before Width: | Height: | Size: 58 KiB |
|
Before Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 60 KiB |
|
Before Width: | Height: | Size: 121 KiB |
|
Before Width: | Height: | Size: 125 KiB |
@@ -22,7 +22,7 @@ const (
|
||||
// ATRI 所有命令的优先级
|
||||
prio = 15
|
||||
// ATRI 表情的 codechina 镜像
|
||||
res = "https://gitcode.net/u011570312/ZeroBot-Plugin/-/raw/master/plugin_atri/"
|
||||
res = "https://gitcode.net/u011570312/zbpdata/-/raw/main/Atri/"
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package plugin_book_review
|
||||
// Package bookreview 书评
|
||||
package bookreview
|
||||
|
||||
import (
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package plugin_book_review
|
||||
package bookreview
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
package plugin_book_review
|
||||
package bookreview
|
||||
|
||||
type book struct {
|
||||
Id uint64 `db:"id"`
|
||||
ID uint64 `db:"id"`
|
||||
BookReview string `db:"bookreview"`
|
||||
}
|
||||
|
||||
// 暂时随机选择一个书评
|
||||
func getBookReviewByKeyword(keyword string) (b book) {
|
||||
db.Find("bookreview", &b, "where bookreview LIKE '%"+keyword+"%'")
|
||||
_ = db.Find("bookreview", &b, "where bookreview LIKE '%"+keyword+"%'")
|
||||
return
|
||||
}
|
||||
|
||||
func getRandomBookReview() (b book) {
|
||||
db.Pick("bookreview", &b)
|
||||
_ = db.Pick("bookreview", &b)
|
||||
return
|
||||
}
|
||||
|
||||
123
plugin_cangtoushi/cangtoushi.go
Normal file
@@ -0,0 +1,123 @@
|
||||
// Package cangtoushi 藏头诗
|
||||
package cangtoushi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/cookiejar"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/antchfx/htmlquery"
|
||||
log "github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/control"
|
||||
)
|
||||
|
||||
const (
|
||||
loginURL = "https://www.shicimingju.com/cangtoushi/"
|
||||
searchURL = "https://www.shicimingju.com/cangtoushi/index.html"
|
||||
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"
|
||||
referer = "https://www.shicimingju.com/cangtoushi/index.html"
|
||||
prio = 20
|
||||
)
|
||||
|
||||
var (
|
||||
gCurCookieJar *cookiejar.Jar
|
||||
csrf string
|
||||
)
|
||||
|
||||
func init() {
|
||||
engine := control.Register("cangtoushi", &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "藏头诗\n" +
|
||||
"- 藏头诗[xxx]\n- 藏尾诗[xxx]",
|
||||
})
|
||||
engine.OnRegex("藏头诗([\u4E00-\u9FA5]{3,10})").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) {
|
||||
kw := ctx.State["regex_matched"].([]string)[1]
|
||||
login()
|
||||
data, err := search(kw, "7", "0")
|
||||
if err != nil {
|
||||
log.Errorln("[cangtoushi]:", err)
|
||||
}
|
||||
text := dealHTML(helper.BytesToString(data))
|
||||
ctx.SendChain(message.Text(text))
|
||||
})
|
||||
|
||||
engine.OnRegex("藏尾诗([\u4E00-\u9FA5]{3,10})").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) {
|
||||
kw := ctx.State["regex_matched"].([]string)[1]
|
||||
login()
|
||||
data, err := search(kw, "7", "2")
|
||||
if err != nil {
|
||||
log.Errorln("[cangtoushi]:", err)
|
||||
}
|
||||
text := dealHTML(helper.BytesToString(data))
|
||||
ctx.SendChain(message.Text(text))
|
||||
})
|
||||
}
|
||||
|
||||
func login() {
|
||||
gCurCookieJar, _ = cookiejar.New(nil)
|
||||
client := &http.Client{
|
||||
Jar: gCurCookieJar,
|
||||
}
|
||||
request, err := http.NewRequest("GET", loginURL, nil)
|
||||
if err != nil {
|
||||
log.Errorln("[cangtoushi]:", err)
|
||||
}
|
||||
request.Header.Add("User-Agent", ua)
|
||||
response, err := client.Do(request)
|
||||
if err != nil {
|
||||
log.Errorln("[cangtoushi]:", err)
|
||||
}
|
||||
data, err := io.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
log.Errorln("[cangtoushi]:", err)
|
||||
}
|
||||
response.Body.Close()
|
||||
doc, err := htmlquery.Parse(strings.NewReader(helper.BytesToString(data)))
|
||||
if err != nil {
|
||||
log.Errorln("[cangtoushi]:", err)
|
||||
}
|
||||
csrf = htmlquery.SelectAttr(htmlquery.FindOne(doc, "//input[@name='_csrf']"), "value")
|
||||
}
|
||||
|
||||
func search(kw, zishu, position string) (data []byte, err error) {
|
||||
postStr := fmt.Sprintf("_csrf=%s&kw=%s&zishu=%s&position=%s", url.QueryEscape(csrf), url.QueryEscape(kw), zishu, position)
|
||||
log.Println("postStr:", postStr)
|
||||
client := &http.Client{
|
||||
Jar: gCurCookieJar,
|
||||
}
|
||||
request, err := http.NewRequest("POST", searchURL, strings.NewReader(postStr))
|
||||
if err != nil {
|
||||
log.Errorln("[cangtoushi]:", err)
|
||||
}
|
||||
request.Header.Add("Referer", referer)
|
||||
request.Header.Add("User-Agent", ua)
|
||||
request.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
||||
response, err := client.Do(request)
|
||||
if err != nil {
|
||||
log.Errorln("[cangtoushi]:", err)
|
||||
}
|
||||
data, err = io.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
log.Errorln("[cangtoushi]:", err)
|
||||
}
|
||||
response.Body.Close()
|
||||
return
|
||||
}
|
||||
|
||||
func dealHTML(data string) (text string) {
|
||||
doc, err := htmlquery.Parse(strings.NewReader(data))
|
||||
if err != nil {
|
||||
log.Errorln("[cangtoushi]:", err)
|
||||
}
|
||||
text = htmlquery.InnerText(htmlquery.FindOne(doc, "//div[@class='card']/div[@class='card']"))
|
||||
text = strings.ReplaceAll(text, " ", "")
|
||||
text = strings.Replace(text, "\n", "", 1)
|
||||
return text
|
||||
}
|
||||
@@ -20,7 +20,10 @@ func initChatList(postinit func()) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
json.Unmarshal(data, &kimomap)
|
||||
err = json.Unmarshal(data, &kimomap)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
for k := range kimomap {
|
||||
chatList = append(chatList, k)
|
||||
}
|
||||
|
||||
42
plugin_chouxianghua/chouxianghua.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package chouxianghua
|
||||
|
||||
import (
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/control"
|
||||
)
|
||||
|
||||
const prio = 10
|
||||
|
||||
func init() {
|
||||
control.Register("chouxianghua", &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "抽象话\n- 抽象翻译xxx\n",
|
||||
}).OnRegex("^抽象翻译((\\s|[\\r\\n]|[\u4E00-\u9FA5A-Za-z0-9“”,;、。《》=?\\x22])+)$").SetBlock(true).SetPriority(prio).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
r := cx(ctx.State["regex_matched"].([]string)[1])
|
||||
ctx.SendChain(message.Text(r))
|
||||
})
|
||||
}
|
||||
|
||||
func cx(s string) (r string) {
|
||||
h := []rune(s)
|
||||
for i := 0; i < len(h); i++ {
|
||||
if i < len(h)-1 {
|
||||
e := getEmojiByPronun(getPronunByDWord(h[i], h[i+1]))
|
||||
if e != "" {
|
||||
r += e
|
||||
i++
|
||||
continue
|
||||
}
|
||||
}
|
||||
e := getEmojiByPronun(getPinyinByWord(string(h[i])))
|
||||
if e != "" {
|
||||
r += e
|
||||
continue
|
||||
}
|
||||
r += string(h[i])
|
||||
}
|
||||
return
|
||||
}
|
||||
37
plugin_chouxianghua/data.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package chouxianghua
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/utils/file"
|
||||
"github.com/FloatTech/ZeroBot-Plugin/utils/process"
|
||||
"github.com/FloatTech/ZeroBot-Plugin/utils/sql"
|
||||
)
|
||||
|
||||
const (
|
||||
dbpath = "data/ChouXiangHua/"
|
||||
dbfile = dbpath + "cxh.db"
|
||||
)
|
||||
|
||||
var db = &sql.Sqlite{DBPath: dbfile}
|
||||
|
||||
// 加载数据库
|
||||
func init() {
|
||||
go func() {
|
||||
process.SleepAbout1sTo2s()
|
||||
// os.RemoveAll(dbpath)
|
||||
_ = os.MkdirAll(dbpath, 0755)
|
||||
_, _ = file.GetLazyData(dbfile, false, true)
|
||||
err := db.Create("pinyin", &pinyin{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
n, err := db.Count("pinyin")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
log.Printf("[chouxianghua]读取%d条拼音", n)
|
||||
}()
|
||||
}
|
||||
26
plugin_chouxianghua/model.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package chouxianghua
|
||||
|
||||
type pinyin struct {
|
||||
Word string `db:"word"`
|
||||
Pronun string `db:"pronunciation"`
|
||||
}
|
||||
type emoji struct {
|
||||
Pronun string `db:"pronunciation"`
|
||||
Emoji string `db:"emoji"`
|
||||
}
|
||||
|
||||
func getPinyinByWord(word string) string {
|
||||
var p pinyin
|
||||
db.Find("pinyin", &p, "where word = '"+word+"'")
|
||||
return p.Pronun
|
||||
}
|
||||
|
||||
func getPronunByDWord(w0, w1 rune) string {
|
||||
return getPinyinByWord(string(w0)) + getPinyinByWord(string(w1))
|
||||
}
|
||||
|
||||
func getEmojiByPronun(pronun string) string {
|
||||
var e emoji
|
||||
db.Find("emoji", &e, "where pronunciation = '"+pronun+"'")
|
||||
return e.Emoji
|
||||
}
|
||||
@@ -21,8 +21,8 @@ const (
|
||||
|
||||
var db = sql.Sqlite{DBPath: dbfile}
|
||||
|
||||
type Text struct {
|
||||
Id int64 `db:"id"`
|
||||
type text struct {
|
||||
ID int64 `db:"id"`
|
||||
Data string `db:"data"`
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ func init() {
|
||||
}
|
||||
err = LoadText()
|
||||
if err == nil {
|
||||
err = db.Create("text", &Text{})
|
||||
err = db.Create("text", &text{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -57,12 +57,12 @@ func LoadText() error {
|
||||
func AddText(txt string) error {
|
||||
s := md5.Sum(helper.StringToBytes(txt))
|
||||
i := binary.LittleEndian.Uint64(s[:8])
|
||||
return db.Insert("text", &Text{Id: int64(i), Data: txt})
|
||||
return db.Insert("text", &text{ID: int64(i), Data: txt})
|
||||
}
|
||||
|
||||
// RandText 随机小作文
|
||||
func RandText() string {
|
||||
var t Text
|
||||
var t text
|
||||
err := db.Pick("text", &t)
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
@@ -72,7 +72,7 @@ func RandText() string {
|
||||
|
||||
// HentaiText 发大病
|
||||
func HentaiText() string {
|
||||
var t Text
|
||||
var t text
|
||||
err := db.Find("text", &t, "where id = -3802576048116006195")
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
|
||||
@@ -66,11 +66,15 @@ func init() {
|
||||
if ok {
|
||||
c, ok := control.Lookup("fortune")
|
||||
if ok {
|
||||
c.SetData(gid, int64(i)&0xff)
|
||||
err = c.SetData(gid, int64(i)&0xff)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("设置失败:", err))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("设置成功~"))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("设置失败!"))
|
||||
ctx.SendChain(message.Text("设置失败: 找不到插件"))
|
||||
return
|
||||
}
|
||||
ctx.SendChain(message.Text("没有这个底图哦~"))
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
engine = control.Register("curse", &control.Options{
|
||||
engine = control.Register("funny", &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "讲个笑话\n" +
|
||||
"- 讲个笑话[@xxx]|讲个笑话[qq号]\n",
|
||||
@@ -32,9 +32,15 @@ func init() {
|
||||
name := ctx.State["args"].(string)
|
||||
if len(ctx.Event.Message) > 1 && ctx.Event.Message[1].Type == "at" {
|
||||
qq, _ := strconv.ParseInt(ctx.Event.Message[1].Data["qq"], 10, 64)
|
||||
name = ctx.GetGroupMemberInfo(ctx.Event.GroupID, qq, false).Get("nickname").Str
|
||||
name = ctx.GetGroupMemberInfo(ctx.Event.GroupID, qq, false).Get("card").String()
|
||||
if name == "" {
|
||||
name = ctx.GetGroupMemberInfo(ctx.Event.GroupID, qq, false).Get("nickname").String()
|
||||
}
|
||||
} else if name == "" {
|
||||
name = ctx.Event.Sender.NickName
|
||||
name = ctx.GetGroupMemberInfo(ctx.Event.GroupID, ctx.Event.UserID, false).Get("card").String()
|
||||
if name == "" {
|
||||
name = ctx.GetGroupMemberInfo(ctx.Event.GroupID, ctx.Event.UserID, false).Get("nickname").String()
|
||||
}
|
||||
}
|
||||
var j joke
|
||||
err := db.Pick("jokes", &j)
|
||||
|
||||
@@ -96,6 +96,7 @@ func init() { // 插件主体
|
||||
}
|
||||
|
||||
// notnull 如果传入文本为空,则返回默认值
|
||||
//nolint: unparam
|
||||
func notnull(text, defstr string) string {
|
||||
if text == "" {
|
||||
return defstr
|
||||
|
||||
79
plugin_juejuezi/jiejiezi.go
Normal file
@@ -0,0 +1,79 @@
|
||||
// Package juejuezi 绝绝子
|
||||
package juejuezi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/tidwall/gjson"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/extension/rate"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/control"
|
||||
)
|
||||
|
||||
const (
|
||||
juejueziURL = "https://www.offjuan.com/api/juejuezi/text"
|
||||
prio = 15
|
||||
referer = "https://juejuezi.offjuan.com/"
|
||||
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"
|
||||
)
|
||||
|
||||
var (
|
||||
limit = rate.NewManager(time.Minute, 20)
|
||||
)
|
||||
|
||||
func init() {
|
||||
control.Register("juejuezi", &control.Options{
|
||||
DisableOnDefault: false,
|
||||
Help: "绝绝子生成器\n" +
|
||||
"- 喝奶茶绝绝子|绝绝子吃饭",
|
||||
}).OnRegex("[\u4E00-\u9FA5]{0,10}绝绝子[\u4E00-\u9FA5]{0,10}").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) {
|
||||
if !limit.Load(ctx.Event.GroupID).Acquire() {
|
||||
return
|
||||
}
|
||||
toDealStr := []rune(strings.ReplaceAll(ctx.ExtractPlainText(), "绝绝子", ""))
|
||||
switch len(toDealStr) {
|
||||
case 0, 1:
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("不要只输入绝绝子"))
|
||||
case 2:
|
||||
data, err := juejuezi(string(toDealStr[0]), string(toDealStr[1]))
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(err))
|
||||
}
|
||||
ctx.SendChain(message.Text(gjson.Get(helper.BytesToString(data), "text").String()))
|
||||
default:
|
||||
params := ctx.GetWordSlices(string(toDealStr)).Get("slices").Array()
|
||||
data, err := juejuezi(params[0].String(), params[1].String())
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text(err))
|
||||
}
|
||||
ctx.SendChain(message.Text(gjson.Get(helper.BytesToString(data), "text").String()))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func juejuezi(verb, noun string) (data []byte, err error) {
|
||||
juejueziStr := fmt.Sprintf("{\"verb\":\"%s\",\"noun\":\"%s\"}", verb, noun)
|
||||
client := &http.Client{}
|
||||
// 提交请求
|
||||
request, err := http.NewRequest("POST", juejueziURL, strings.NewReader(juejueziStr))
|
||||
if err != nil {
|
||||
log.Errorln("[juejuezi]:", err)
|
||||
}
|
||||
request.Header.Add("Referer", referer)
|
||||
request.Header.Add("User-Agent", ua)
|
||||
response, err := client.Do(request)
|
||||
if err != nil {
|
||||
log.Errorln("[juejuezi]:", err)
|
||||
}
|
||||
data, err = io.ReadAll(response.Body)
|
||||
response.Body.Close()
|
||||
return
|
||||
}
|
||||
@@ -314,7 +314,7 @@ func init() { // 插件主体
|
||||
engine.OnRegex(`^取消在"(.*)"的提醒`, zero.AdminPermission, zero.OnlyGroup).SetBlock(true).SetPriority(40).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
dateStrs := ctx.State["regex_matched"].([]string)
|
||||
ts := timer.Timer{Cron: dateStrs[1], GrpId: ctx.Event.GroupID}
|
||||
ts := timer.Timer{Cron: dateStrs[1], GrpID: ctx.Event.GroupID}
|
||||
ti := ts.GetTimerID()
|
||||
ok := clock.CancelTimer(ti)
|
||||
if ok {
|
||||
@@ -423,7 +423,10 @@ func init() { // 插件主体
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
if ctx.Event.NoticeType == "group_decrease" {
|
||||
userid := ctx.Event.UserID
|
||||
nickname := ctx.GetStrangerInfo(userid, false).Get("nickname").String()
|
||||
nickname := ctx.GetGroupMemberInfo(ctx.Event.GroupID, userid, false).Get("card").String()
|
||||
if nickname == "" {
|
||||
nickname = ctx.GetGroupMemberInfo(ctx.Event.GroupID, userid, false).Get("nickname").String()
|
||||
}
|
||||
ctx.SendChain(message.Text(nickname, "(", userid, ")", "离开了我们..."))
|
||||
}
|
||||
})
|
||||
|
||||
@@ -8,9 +8,9 @@ import (
|
||||
func (ts *Timer) sendmsg(grp int64, ctx *zero.Ctx) {
|
||||
ctx.Event = new(zero.Event)
|
||||
ctx.Event.GroupID = grp
|
||||
if ts.Url == "" {
|
||||
if ts.URL == "" {
|
||||
ctx.SendChain(atall, message.Text(ts.Alert))
|
||||
} else {
|
||||
ctx.SendChain(atall, message.Text(ts.Alert), message.Image(ts.Url).Add("cache", "0"))
|
||||
ctx.SendChain(atall, message.Text(ts.Alert), message.Image(ts.URL).Add("cache", "0"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,12 +16,12 @@ import (
|
||||
// GetTimerInfo 获得标准化定时字符串
|
||||
func (ts *Timer) GetTimerInfo() string {
|
||||
if ts.Cron != "" {
|
||||
return fmt.Sprintf("[%d]%s", ts.GrpId, ts.Cron)
|
||||
return fmt.Sprintf("[%d]%s", ts.GrpID, ts.Cron)
|
||||
}
|
||||
return fmt.Sprintf("[%d]%d月%d日%d周%d:%d", ts.GrpId, ts.Month(), ts.Day(), ts.Week(), ts.Hour(), ts.Minute())
|
||||
return fmt.Sprintf("[%d]%d月%d日%d周%d:%d", ts.GrpID, ts.Month(), ts.Day(), ts.Week(), ts.Hour(), ts.Minute())
|
||||
}
|
||||
|
||||
// GetTimerInfo 获得标准化 ID
|
||||
// GetTimerID 获得标准化 ID
|
||||
func (ts *Timer) GetTimerID() uint32 {
|
||||
key := ts.GetTimerInfo()
|
||||
m := md5.Sum(helper.StringToBytes(key))
|
||||
@@ -33,9 +33,9 @@ func GetFilledCronTimer(croncmd string, alert string, img string, botqq, gid int
|
||||
var ts Timer
|
||||
ts.Alert = alert
|
||||
ts.Cron = croncmd
|
||||
ts.Url = img
|
||||
ts.Selfid = botqq
|
||||
ts.GrpId = gid
|
||||
ts.URL = img
|
||||
ts.SelfID = botqq
|
||||
ts.GrpID = gid
|
||||
return &ts
|
||||
}
|
||||
|
||||
@@ -105,10 +105,10 @@ func GetFilledTimer(dateStrs []string, botqq, grp int64, matchDateOnly bool) *Ti
|
||||
if !matchDateOnly {
|
||||
urlStr := dateStrs[5]
|
||||
if urlStr != "" { // 是图片url
|
||||
ts.Url = urlStr[3:] // utf-8下用为3字节
|
||||
logrus.Println("[群管]" + ts.Url)
|
||||
if !strings.HasPrefix(ts.Url, "http") {
|
||||
ts.Url = "illegal"
|
||||
ts.URL = urlStr[3:] // utf-8下用为3字节
|
||||
logrus.Println("[群管]" + ts.URL)
|
||||
if !strings.HasPrefix(ts.URL, "http") {
|
||||
ts.URL = "illegal"
|
||||
logrus.Println("[群管]url非法!")
|
||||
return &ts
|
||||
}
|
||||
@@ -116,8 +116,8 @@ func GetFilledTimer(dateStrs []string, botqq, grp int64, matchDateOnly bool) *Ti
|
||||
ts.Alert = dateStrs[6]
|
||||
ts.SetEn(true)
|
||||
}
|
||||
ts.Selfid = botqq
|
||||
ts.GrpId = grp
|
||||
ts.SelfID = botqq
|
||||
ts.GrpID = grp
|
||||
return &ts
|
||||
}
|
||||
|
||||
@@ -155,13 +155,12 @@ func chineseNum2Int(rs []rune) int {
|
||||
func chineseChar2Int(c rune) int {
|
||||
if c == rune('日') || c == rune('天') { // 周日/周天
|
||||
return 7
|
||||
} else {
|
||||
match := []rune("零一二三四五六七八九十")
|
||||
for i, m := range match {
|
||||
if c == m {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
match := []rune("零一二三四五六七八九十")
|
||||
for i, m := range match {
|
||||
if c == m {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -152,11 +152,11 @@ func (ts *Timer) nextWakeTime() (date time.Time) {
|
||||
func (ts *Timer) judgeHM() {
|
||||
if ts.Hour() < 0 || ts.Hour() == time.Now().Hour() {
|
||||
if ts.Minute() < 0 || ts.Minute() == time.Now().Minute() {
|
||||
if ts.Selfid != 0 {
|
||||
ts.sendmsg(ts.GrpId, zero.GetBot(ts.Selfid))
|
||||
if ts.SelfID != 0 {
|
||||
ts.sendmsg(ts.GrpID, zero.GetBot(ts.SelfID))
|
||||
} else {
|
||||
zero.RangeBot(func(id int64, ctx *zero.Ctx) (_ bool) {
|
||||
ts.sendmsg(ts.GrpId, ctx)
|
||||
ts.sendmsg(ts.GrpID, ctx)
|
||||
return
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,26 +1,28 @@
|
||||
package timer
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/utils/sql"
|
||||
)
|
||||
|
||||
// Timer 计时器
|
||||
type Timer struct {
|
||||
Id uint32 `db:"id"`
|
||||
ID uint32 `db:"id"`
|
||||
En1Month4Day5Week3Hour5Min6 int32 `db:"emdwhm"`
|
||||
Selfid int64 `db:"sid"`
|
||||
GrpId int64 `db:"gid"`
|
||||
SelfID int64 `db:"sid"`
|
||||
GrpID int64 `db:"gid"`
|
||||
Alert string `db:"alert"`
|
||||
Cron string `db:"cron"`
|
||||
Url string `db:"url"`
|
||||
URL string `db:"url"`
|
||||
}
|
||||
|
||||
// InsertInto 插入自身
|
||||
func (t *Timer) InsertInto(db *sql.Sqlite) error {
|
||||
return db.Insert("timer", t)
|
||||
}
|
||||
|
||||
/*
|
||||
func getTimerFrom(db *sql.Sqlite, id uint32) (t Timer, err error) {
|
||||
err = db.Find("timer", &t, "where id = "+strconv.Itoa(int(id)))
|
||||
return
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -12,10 +12,10 @@ import (
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/utils/file"
|
||||
"github.com/FloatTech/ZeroBot-Plugin/utils/sql"
|
||||
)
|
||||
|
||||
// Clock 时钟
|
||||
type Clock struct {
|
||||
db *sql.Sqlite
|
||||
timers *(map[uint32]*Timer)
|
||||
@@ -37,10 +37,12 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
// NewClock 添加一个新时钟
|
||||
func NewClock(db *sql.Sqlite) (c Clock) {
|
||||
c.loadTimers(db)
|
||||
c.cron = cron.New()
|
||||
c.entries = make(map[uint32]cron.EntryID)
|
||||
c.timers = &map[uint32]*Timer{}
|
||||
c.cron.Start()
|
||||
return
|
||||
}
|
||||
@@ -50,9 +52,9 @@ func (c *Clock) RegisterTimer(ts *Timer, save bool) bool {
|
||||
var key uint32
|
||||
if save {
|
||||
key = ts.GetTimerID()
|
||||
ts.Id = key
|
||||
ts.ID = key
|
||||
} else {
|
||||
key = ts.Id
|
||||
key = ts.ID
|
||||
}
|
||||
t, ok := c.GetTimer(key)
|
||||
if t != ts && ok { // 避免重复注册定时器
|
||||
@@ -61,16 +63,16 @@ func (c *Clock) RegisterTimer(ts *Timer, save bool) bool {
|
||||
logrus.Println("[群管]注册计时器", key)
|
||||
if ts.Cron != "" {
|
||||
var ctx *zero.Ctx
|
||||
if ts.Selfid != 0 {
|
||||
ctx = zero.GetBot(ts.Selfid)
|
||||
if ts.SelfID != 0 {
|
||||
ctx = zero.GetBot(ts.SelfID)
|
||||
} else {
|
||||
zero.RangeBot(func(id int64, c *zero.Ctx) bool {
|
||||
ctx = c
|
||||
ts.Selfid = id
|
||||
ts.SelfID = id
|
||||
return false
|
||||
})
|
||||
}
|
||||
eid, err := c.cron.AddFunc(ts.Cron, func() { ts.sendmsg(ts.GrpId, ctx) })
|
||||
eid, err := c.cron.AddFunc(ts.Cron, func() { ts.sendmsg(ts.GrpID, ctx) })
|
||||
if err == nil {
|
||||
c.entmu.Lock()
|
||||
c.entries[key] = eid
|
||||
@@ -135,7 +137,7 @@ func (c *Clock) ListTimers(grpID int64) []string {
|
||||
c.timersmu.RLock()
|
||||
keys := make([]string, 0, len(*c.timers))
|
||||
for _, v := range *c.timers {
|
||||
if v.GrpId == grpID {
|
||||
if v.GrpID == grpID {
|
||||
k := v.GetTimerInfo()
|
||||
start := strings.Index(k, "]")
|
||||
msg := strings.ReplaceAll(k[start+1:]+"\n", "-1", "每")
|
||||
@@ -147,11 +149,11 @@ func (c *Clock) ListTimers(grpID int64) []string {
|
||||
}
|
||||
c.timersmu.RUnlock()
|
||||
return keys
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetTimer 获得定时器
|
||||
func (c *Clock) GetTimer(key uint32) (t *Timer, ok bool) {
|
||||
c.timersmu.RLock()
|
||||
t, ok = (*c.timers)[key]
|
||||
@@ -159,25 +161,24 @@ func (c *Clock) GetTimer(key uint32) (t *Timer, ok bool) {
|
||||
return
|
||||
}
|
||||
|
||||
// AddTimer 添加定时器
|
||||
func (c *Clock) AddTimer(t *Timer) (err error) {
|
||||
c.timersmu.Lock()
|
||||
(*c.timers)[t.Id] = t
|
||||
(*c.timers)[t.ID] = t
|
||||
err = c.db.Insert("timer", t)
|
||||
c.timersmu.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
func (c *Clock) loadTimers(db *sql.Sqlite) {
|
||||
if file.IsExist(db.DBPath) {
|
||||
c.db = db
|
||||
err := c.db.Create("timer", &Timer{})
|
||||
if err == nil {
|
||||
var t Timer
|
||||
c.db.FindFor("timer", &t, "", func() error {
|
||||
tescape := t
|
||||
go c.RegisterTimer(&tescape, false)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
c.db = db
|
||||
err := c.db.Create("timer", &Timer{})
|
||||
if err == nil {
|
||||
var t Timer
|
||||
_ = c.db.FindFor("timer", &t, "", func() error {
|
||||
tescape := t
|
||||
go c.RegisterTimer(&tescape, false)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/utils/sql"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@@ -22,3 +23,11 @@ func TestNextWakeTime(t *testing.T) {
|
||||
t.Log(t1)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
func TestClock(t *testing.T) {
|
||||
db := &sql.Sqlite{DBPath: "test.db"}
|
||||
c := NewClock(db)
|
||||
c.AddTimer(GetFilledTimer([]string{"", "12", "-1", "12", "0", "", "test"}, 0, 0, false))
|
||||
t.Log(c.ListTimers(0))
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
@@ -81,7 +81,11 @@ func init() {
|
||||
url := ctx.State["image_url"].([]string)[0]
|
||||
grpfolder := base + "/" + strconv.FormatInt(ctx.Event.GroupID, 36)
|
||||
if file.IsNotExist(grpfolder) {
|
||||
os.Mkdir(grpfolder, 0755)
|
||||
err = os.Mkdir(grpfolder, 0755)
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("错误:", err.Error()))
|
||||
return
|
||||
}
|
||||
}
|
||||
err = file.DownloadTo(url, grpfolder+"/"+name, true)
|
||||
if err == nil {
|
||||
|
||||
@@ -54,14 +54,15 @@ func init() {
|
||||
ctx.SendChain(message.Text("少女祈祷中......"))
|
||||
login(username, password)
|
||||
searchKey := ctx.State["regex_matched"].([]string)[1]
|
||||
searchHtml := search(searchKey)
|
||||
searchHTML := search(searchKey)
|
||||
var m message.Message
|
||||
doc, err := htmlquery.Parse(strings.NewReader(searchHtml))
|
||||
doc, err := htmlquery.Parse(strings.NewReader(searchHTML))
|
||||
if err != nil {
|
||||
log.Errorln("[novel]", err)
|
||||
}
|
||||
htmlTitle := htmlquery.InnerText(htmlquery.FindOne(doc, "/html/head/title"))
|
||||
if htmlTitle == websiteTitle {
|
||||
switch htmlTitle {
|
||||
case websiteTitle:
|
||||
list, err := htmlquery.QueryAll(doc, "//dl[@id='nr']")
|
||||
if err != nil {
|
||||
log.Errorln("[novel]", err)
|
||||
@@ -97,16 +98,16 @@ func init() {
|
||||
}
|
||||
} else {
|
||||
text := htmlquery.InnerText(htmlquery.FindOne(doc, "//div[@id='tipss']"))
|
||||
text = strings.Replace(text, " ", "", -1)
|
||||
text = strings.Replace(text, "本站", websiteURL, -1)
|
||||
text = strings.ReplaceAll(text, " ", "")
|
||||
text = strings.ReplaceAll(text, "本站", websiteURL)
|
||||
ctx.SendChain(message.Text(text))
|
||||
}
|
||||
} else if htmlTitle == errorTitle {
|
||||
case errorTitle:
|
||||
ctx.SendChain(message.Text(errorTitle))
|
||||
text := htmlquery.InnerText(htmlquery.FindOne(doc, "//div[@style='text-align: center;padding:10px']"))
|
||||
text = strings.Replace(text, " ", "", -1)
|
||||
text = strings.ReplaceAll(text, " ", "")
|
||||
ctx.SendChain(message.Text(text))
|
||||
} else {
|
||||
default:
|
||||
bookName := htmlquery.SelectAttr(htmlquery.FindOne(doc, "//meta[@property='og:novel:book_name']"), "content")
|
||||
category := htmlquery.SelectAttr(htmlquery.FindOne(doc, "//meta[@property='og:novel:category']"), "content")
|
||||
author := htmlquery.SelectAttr(htmlquery.FindOne(doc, "//meta[@property='og:novel:author']"), "content")
|
||||
@@ -153,7 +154,7 @@ func login(username, password string) {
|
||||
defer loginResp.Body.Close()
|
||||
}
|
||||
|
||||
func search(searchKey string) (searchHtml string) {
|
||||
func search(searchKey string) (searchHTML string) {
|
||||
searchKeyData, err := ub.UTF82GBK(helper.StringToBytes(searchKey))
|
||||
if err != nil {
|
||||
log.Errorln("[novel]", err)
|
||||
@@ -181,6 +182,6 @@ func search(searchKey string) (searchHtml string) {
|
||||
if err != nil {
|
||||
log.Errorln("[novel]", err)
|
||||
}
|
||||
searchHtml = helper.BytesToString(searchData)
|
||||
return searchHtml
|
||||
searchHTML = helper.BytesToString(searchData)
|
||||
return searchHTML
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package omikuji
|
||||
import "strconv"
|
||||
|
||||
type kuji struct {
|
||||
Id uint8 `db:"id"`
|
||||
ID uint8 `db:"id"`
|
||||
Text string `db:"text"`
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package shadiao
|
||||
|
||||
/*
|
||||
func init() {
|
||||
/*
|
||||
engine.OnFullMatch("骂我").SetBlock(true).SetPriority(prio).Handle(func(ctx *zero.Ctx) {
|
||||
if !limit.Load(ctx.Event.GroupID).Acquire() {
|
||||
return
|
||||
@@ -25,5 +25,5 @@ func init() {
|
||||
}
|
||||
ctx.SendChain(message.At(math.Str2Int64(ctx.State["regex_matched"].([]string)[1])), message.Text(helper.BytesToString(data)))
|
||||
})
|
||||
*/
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
/*
|
||||
* @Author: Kanri
|
||||
* @Date: 2021-10-15 21:23:14
|
||||
* @LastEditors: Kanri
|
||||
* @LastEditTime: 2021-10-15 21:42:51
|
||||
* @Description:
|
||||
*/
|
||||
// Package shindan 基于 https://shindanmaker.com 的测定小功能
|
||||
package shindan
|
||||
|
||||
|
||||
@@ -6,12 +6,14 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/jinzhu/gorm"
|
||||
_ "github.com/logoove/sqlite"
|
||||
_ "github.com/logoove/sqlite" // use sql
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// SleepDB 睡眠数据库
|
||||
type SleepDB gorm.DB
|
||||
|
||||
// Initialize 初始化
|
||||
func Initialize(dbpath string) *SleepDB {
|
||||
var err error
|
||||
if _, err = os.Stat(dbpath); err != nil || os.IsNotExist(err) {
|
||||
@@ -30,6 +32,7 @@ func Initialize(dbpath string) *SleepDB {
|
||||
return (*SleepDB)(gdb)
|
||||
}
|
||||
|
||||
// Open 打开
|
||||
func Open(dbpath string) (*SleepDB, error) {
|
||||
db, err := gorm.Open("sqlite3", dbpath)
|
||||
if err != nil {
|
||||
@@ -39,24 +42,27 @@ func Open(dbpath string) (*SleepDB, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// Close 关闭
|
||||
func (sdb *SleepDB) Close() error {
|
||||
db := (*gorm.DB)(sdb)
|
||||
return db.Close()
|
||||
}
|
||||
|
||||
// SleepManage 睡眠信息
|
||||
type SleepManage struct {
|
||||
gorm.Model
|
||||
GroupId int64 `gorm:"column:group_id"`
|
||||
UserId int64 `gorm:"column:user_id"`
|
||||
GroupID int64 `gorm:"column:group_id"`
|
||||
UserID int64 `gorm:"column:user_id"`
|
||||
SleepTime time.Time `gorm:"column:sleep_time"`
|
||||
}
|
||||
|
||||
// TableName 表名
|
||||
func (SleepManage) TableName() string {
|
||||
return "sleep_manage"
|
||||
}
|
||||
|
||||
// 更新睡眠时间
|
||||
func (sdb *SleepDB) Sleep(groupId, userId int64) (position int, awakeTime time.Duration) {
|
||||
// Sleep 更新睡眠时间
|
||||
func (sdb *SleepDB) Sleep(gid, uid int64) (position int, awakeTime time.Duration) {
|
||||
db := (*gorm.DB)(sdb)
|
||||
now := time.Now()
|
||||
var today time.Time
|
||||
@@ -66,11 +72,11 @@ func (sdb *SleepDB) Sleep(groupId, userId int64) (position int, awakeTime time.D
|
||||
today = now.Add(-time.Hour*time.Duration(3+now.Hour()) - time.Minute*time.Duration(now.Minute()) - time.Second*time.Duration(now.Second()))
|
||||
}
|
||||
st := SleepManage{
|
||||
GroupId: groupId,
|
||||
UserId: userId,
|
||||
GroupID: gid,
|
||||
UserID: uid,
|
||||
SleepTime: now,
|
||||
}
|
||||
if err := db.Debug().Model(&SleepManage{}).Where("group_id = ? and user_id = ?", groupId, userId).First(&st).Error; err != nil {
|
||||
if err := db.Debug().Model(&SleepManage{}).Where("group_id = ? and user_id = ?", gid, uid).First(&st).Error; err != nil {
|
||||
// error handling...
|
||||
if gorm.IsRecordNotFoundError(err) {
|
||||
db.Debug().Model(&SleepManage{}).Create(&st) // newUser not user
|
||||
@@ -78,26 +84,26 @@ func (sdb *SleepDB) Sleep(groupId, userId int64) (position int, awakeTime time.D
|
||||
} else {
|
||||
log.Println("sleeptime为", st)
|
||||
awakeTime = now.Sub(st.SleepTime)
|
||||
db.Debug().Model(&SleepManage{}).Where("group_id = ? and user_id = ?", groupId, userId).Update(
|
||||
db.Debug().Model(&SleepManage{}).Where("group_id = ? and user_id = ?", gid, uid).Update(
|
||||
map[string]interface{}{
|
||||
"sleep_time": now,
|
||||
})
|
||||
}
|
||||
db.Debug().Model(&SleepManage{}).Where("group_id = ? and sleep_time <= ? and sleep_time >= ?", groupId, now, today).Count(&position)
|
||||
db.Debug().Model(&SleepManage{}).Where("group_id = ? and sleep_time <= ? and sleep_time >= ?", gid, now, today).Count(&position)
|
||||
return position, awakeTime
|
||||
}
|
||||
|
||||
// 更新起床时间
|
||||
func (sdb *SleepDB) GetUp(groupId, userId int64) (position int, sleepTime time.Duration) {
|
||||
// GetUp 更新起床时间
|
||||
func (sdb *SleepDB) GetUp(gid, uid int64) (position int, sleepTime time.Duration) {
|
||||
db := (*gorm.DB)(sdb)
|
||||
now := time.Now()
|
||||
today := now.Add(-time.Hour*time.Duration(-6+now.Hour()) - time.Minute*time.Duration(now.Minute()) - time.Second*time.Duration(now.Second()))
|
||||
st := SleepManage{
|
||||
GroupId: groupId,
|
||||
UserId: userId,
|
||||
GroupID: gid,
|
||||
UserID: uid,
|
||||
SleepTime: now,
|
||||
}
|
||||
if err := db.Debug().Model(&SleepManage{}).Where("group_id = ? and user_id = ?", groupId, userId).First(&st).Error; err != nil {
|
||||
if err := db.Debug().Model(&SleepManage{}).Where("group_id = ? and user_id = ?", gid, uid).First(&st).Error; err != nil {
|
||||
// error handling...
|
||||
if gorm.IsRecordNotFoundError(err) {
|
||||
db.Debug().Model(&SleepManage{}).Create(&st) // newUser not user
|
||||
@@ -105,11 +111,11 @@ func (sdb *SleepDB) GetUp(groupId, userId int64) (position int, sleepTime time.D
|
||||
} else {
|
||||
log.Println("sleeptime为", st)
|
||||
sleepTime = now.Sub(st.SleepTime)
|
||||
db.Debug().Model(&SleepManage{}).Where("group_id = ? and user_id = ?", groupId, userId).Update(
|
||||
db.Debug().Model(&SleepManage{}).Where("group_id = ? and user_id = ?", gid, uid).Update(
|
||||
map[string]interface{}{
|
||||
"sleep_time": now,
|
||||
})
|
||||
}
|
||||
db.Debug().Model(&SleepManage{}).Where("group_id = ? and sleep_time <= ? and sleep_time >= ?", groupId, now, today).Count(&position)
|
||||
db.Debug().Model(&SleepManage{}).Where("group_id = ? and sleep_time <= ? and sleep_time >= ?", gid, now, today).Count(&position)
|
||||
return position, sleepTime
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Package tracemoe 搜番
|
||||
package tracemoe
|
||||
|
||||
import (
|
||||
|
||||
@@ -96,12 +96,18 @@ func (vdb *VtbDB) GetAllFirstCategoryMessage() string {
|
||||
rows, err := db.Model(&FirstCategory{}).Rows()
|
||||
if err != nil {
|
||||
logrus.Errorln("[vtb/model]数据库读取错误", err)
|
||||
return ""
|
||||
}
|
||||
if rows == nil {
|
||||
return ""
|
||||
}
|
||||
defer rows.Close()
|
||||
for rows.Next() {
|
||||
db.ScanRows(rows, &fc)
|
||||
err = db.ScanRows(rows, &fc)
|
||||
if err != nil {
|
||||
logrus.Errorln("[vtb/model]数据库读取错误", err)
|
||||
return ""
|
||||
}
|
||||
// logrus.Println(fc)
|
||||
firstStepMessage = firstStepMessage + strconv.FormatInt(fc.FirstCategoryIndex, 10) + ". " + fc.FirstCategoryName + "\n"
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
_ "github.com/logoove/sqlite"
|
||||
_ "github.com/logoove/sqlite" // use sql
|
||||
"github.com/sirupsen/logrus"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
@@ -106,22 +106,22 @@ func init() {
|
||||
} else {
|
||||
tc := db.GetThirdCategory(firstIndex, secondIndex, thirdIndex)
|
||||
reg := regexp.MustCompile(regStr)
|
||||
recordUrl := tc.ThirdCategoryPath
|
||||
if recordUrl == "" {
|
||||
recURL := tc.ThirdCategoryPath
|
||||
if recURL == "" {
|
||||
ctx.SendChain(message.Reply(e.MessageID), message.Text("没有内容请重新选择,三次输入错误,指令可退出重输"))
|
||||
ctx.SendChain(message.Reply(e.MessageID), message.Text(db.GetAllFirstCategoryMessage()))
|
||||
errorCount++
|
||||
step = 1
|
||||
} else {
|
||||
if reg.MatchString(recordUrl) {
|
||||
if reg.MatchString(recURL) {
|
||||
// log.Println(reg.FindStringSubmatch(recordUrl)[1])
|
||||
// log.Println(url.QueryEscape(reg.FindStringSubmatch(recordUrl)[1]))
|
||||
recordUrl = strings.ReplaceAll(recordUrl, reg.FindStringSubmatch(recordUrl)[1], url.QueryEscape(reg.FindStringSubmatch(recordUrl)[1]))
|
||||
recordUrl = strings.ReplaceAll(recordUrl, "+", "%20")
|
||||
recURL = strings.ReplaceAll(recURL, reg.FindStringSubmatch(recURL)[1], url.QueryEscape(reg.FindStringSubmatch(recURL)[1]))
|
||||
recURL = strings.ReplaceAll(recURL, "+", "%20")
|
||||
// log.Println(recordUrl)
|
||||
}
|
||||
ctx.SendChain(message.Reply(e.MessageID), message.Text("请欣赏《"+tc.ThirdCategoryName+"》"))
|
||||
ctx.SendChain(message.Record(recordUrl))
|
||||
ctx.SendChain(message.Record(recURL))
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -145,16 +145,16 @@ func init() {
|
||||
fc := db.GetFirstCategoryByFirstUid(tc.FirstCategoryUid)
|
||||
if (tc != model.ThirdCategory{}) && (fc != model.FirstCategory{}) {
|
||||
reg := regexp.MustCompile(regStr)
|
||||
recordUrl := tc.ThirdCategoryPath
|
||||
if reg.MatchString(recordUrl) {
|
||||
recURL := tc.ThirdCategoryPath
|
||||
if reg.MatchString(recURL) {
|
||||
// log.Println(reg.FindStringSubmatch(recordUrl)[1])
|
||||
// log.Println(url.QueryEscape(reg.FindStringSubmatch(recordUrl)[1]))
|
||||
recordUrl = strings.ReplaceAll(recordUrl, reg.FindStringSubmatch(recordUrl)[1], url.QueryEscape(reg.FindStringSubmatch(recordUrl)[1]))
|
||||
recordUrl = strings.ReplaceAll(recordUrl, "+", "%20")
|
||||
recURL = strings.ReplaceAll(recURL, reg.FindStringSubmatch(recURL)[1], url.QueryEscape(reg.FindStringSubmatch(recURL)[1]))
|
||||
recURL = strings.ReplaceAll(recURL, "+", "%20")
|
||||
// log.Println(recordUrl)
|
||||
}
|
||||
ctx.SendChain(message.Reply(ctx.Event.MessageID), message.Text("请欣赏"+fc.FirstCategoryName+"的《"+tc.ThirdCategoryName+"》"))
|
||||
ctx.SendChain(message.Record(recordUrl))
|
||||
ctx.SendChain(message.Record(recURL))
|
||||
}
|
||||
db.Close()
|
||||
})
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Package binary 数据处理
|
||||
package binary
|
||||
|
||||
import (
|
||||
|
||||
@@ -16,6 +16,7 @@ var (
|
||||
)
|
||||
|
||||
// DownloadTo 下载到路径
|
||||
//nolint: bodyclose
|
||||
func DownloadTo(url, file string, chkcrt bool) error {
|
||||
var resp *http.Response
|
||||
var err error
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
dataurl = "https://gitcode.net/u011570312/ZeroBot-Plugin/-/raw/master/"
|
||||
dataurl = "https://gitcode.net/u011570312/zbpdata/-/raw/main/"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -24,13 +24,16 @@ var (
|
||||
)
|
||||
|
||||
// GetLazyData 获取懒加载数据
|
||||
// 传入的 path 的前缀 data/
|
||||
// 在验证完 md5 后将被删去
|
||||
// 以便进行下载
|
||||
func GetLazyData(path string, isReturnDataBytes, isDataMustEqual bool) ([]byte, error) {
|
||||
var data []byte
|
||||
var resp *http.Response
|
||||
var filemd5 *[16]byte
|
||||
var ms string
|
||||
|
||||
u := dataurl + path
|
||||
u := dataurl + path[5:]
|
||||
lzmu.Lock()
|
||||
logrus.Infoln("[file]检查懒加载文件:", path)
|
||||
err := registry.Connect()
|
||||
|
||||
@@ -11,14 +11,14 @@ import (
|
||||
func ReqWith(url string, method string, referer string, ua string) (data []byte, err error) {
|
||||
client := &http.Client{}
|
||||
// 提交请求
|
||||
var reqest *http.Request
|
||||
reqest, err = http.NewRequest(method, url, nil)
|
||||
var request *http.Request
|
||||
request, err = http.NewRequest(method, url, nil)
|
||||
if err == nil {
|
||||
// 增加header选项
|
||||
reqest.Header.Add("Referer", referer)
|
||||
reqest.Header.Add("User-Agent", ua)
|
||||
request.Header.Add("Referer", referer)
|
||||
request.Header.Add("User-Agent", ua)
|
||||
var response *http.Response
|
||||
response, err = client.Do(reqest)
|
||||
response, err = client.Do(request)
|
||||
if err == nil {
|
||||
data, err = io.ReadAll(response.Body)
|
||||
response.Body.Close()
|
||||
|
||||