mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2026-02-06 23:30:20 +00:00
Compare commits
30 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
820daa7b1e | ||
|
|
529345da9c | ||
|
|
c251a7bf53 | ||
|
|
06d7804fe7 | ||
|
|
d31dc14271 | ||
|
|
adceba0d86 | ||
|
|
fb8ba1d66b | ||
|
|
e61ecd683c | ||
|
|
77bc391f6e | ||
|
|
ebeac37f21 | ||
|
|
ac4d8429d4 | ||
|
|
ceb9455250 | ||
|
|
736f645e9d | ||
|
|
5c8aa92792 | ||
|
|
7ac9d34cc4 | ||
|
|
5b8fd14d09 | ||
|
|
4776da4584 | ||
|
|
c10cb49c30 | ||
|
|
9f0d93bca2 | ||
|
|
59c6fe593a | ||
|
|
63f3b3861e | ||
|
|
433b0ae4c1 | ||
|
|
452b39075b | ||
|
|
1001a52a53 | ||
|
|
10c79456a5 | ||
|
|
d0b55bb9dd | ||
|
|
bf4aa59467 | ||
|
|
a402d91367 | ||
|
|
928719f5a1 | ||
|
|
33b00f369f |
52
.github/workflows/latest.yml
vendored
52
.github/workflows/latest.yml
vendored
@@ -1,52 +0,0 @@
|
||||
name: 最新版
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
|
||||
jobs:
|
||||
my-job:
|
||||
name: Build ZeroBot-Plugin on Push 🚀
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.16
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Cache Go
|
||||
id: cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
# A list of files, directories, and wildcard patterns to cache and restore
|
||||
path: ~/go/pkg/mod
|
||||
key: ${{ runner.os }}-build-${{ hashFiles('**/go.sum') }}
|
||||
|
||||
- name: Tidy Go modules
|
||||
run: go mod tidy
|
||||
|
||||
- name: Build linux-x64
|
||||
run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o artifacts/zerobot-plugin-linux-x64
|
||||
- name: Build linux-x86
|
||||
run: CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags="-s -w" -o artifacts/zerobot-plugin-linux-x86
|
||||
- name: Build windows-x64
|
||||
run: CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o artifacts/zerobot-plugin-windows-x64.exe
|
||||
- name: Build windows-x86
|
||||
run: CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags="-s -w" -o artifacts/zerobot-plugin-windows-x86.exe
|
||||
- name: Build arm64
|
||||
run: CGO_ENABLED=0 GOOS=linux GOARCH=arm64 GOARM=7 go build -ldflags="-s -w" -o artifacts/zerobot-plugin-linux-arm64
|
||||
- name: Build armv6
|
||||
run: CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -ldflags="-s -w" -o artifacts/zerobot-plugin-linux-armv6
|
||||
|
||||
- name: Upload Build Artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: zerobot-plugin-all.zip
|
||||
path: ./artifacts/zerobot-plugin-*
|
||||
2
.github/workflows/prerelease.yml
vendored
2
.github/workflows/prerelease.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.16
|
||||
go-version: 1.17
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
|
||||
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.16
|
||||
go-version: 1.17
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,6 +1,7 @@
|
||||
data/SetuTime/cache
|
||||
data/SetuTime/search
|
||||
data/manager
|
||||
data/acgimage
|
||||
.idea/
|
||||
.DS_Store
|
||||
.vscode
|
||||
|
||||
16
README.md
16
README.md
@@ -48,8 +48,8 @@
|
||||
- [x] 设置欢迎语[欢迎~]
|
||||
- [x] 在MM月dd日的hh点mm分时(用http://url)提醒大家xxx
|
||||
- [x] 在MM月[每周|周几]的hh点mm分时(用http://url)提醒大家xxx
|
||||
- [x] 取消在MM月dd日的hh点mm分的提醒
|
||||
- [x] 取消在MM月[每周|周几]的hh点mm分的提醒
|
||||
- [x] 取消在MM月dd日的hh点mm分的提醒
|
||||
- [x] 取消在MM月[每周|周几]的hh点mm分的提醒
|
||||
- [x] 列出所有提醒
|
||||
- [x] 翻牌
|
||||
- [x] [开启|关闭]入群验证
|
||||
@@ -74,6 +74,9 @@
|
||||
- [x] 今天是什么少女[@xxx]
|
||||
- [x] 异世界转生[@xxx]
|
||||
- [x] 卖萌[@xxx]
|
||||
- [x] 抽老婆[@xxx]
|
||||
- **AIWife** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_aiwife"`
|
||||
- [x] waifu|随机waifu(从[100000个AI生成的waifu](https://www.thiswaifudoesnotexist.net/)中随机一位)
|
||||
- **gif** `import _ "github.com/tdf1939/ZeroBot-Plugin-Gif/plugin_gif"`
|
||||
- [x] 爬[@xxx]
|
||||
- [x] 摸[@xxx]
|
||||
@@ -95,6 +98,9 @@
|
||||
- [x] 设置随机图片网址[url]
|
||||
- [x] 太涩了(撤回最近发的图)
|
||||
- [x] 评价图片(发送一张图片让bot评分)
|
||||
- **浅草寺求签** `github.com/FloatTech/ZeroBot-Plugin/plugin_omikuji`
|
||||
- 本插件要求`Go`版本大于等于`1.17`
|
||||
- [x] @BOT 求签|运势|占卜
|
||||
- **bilibili** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_bilibili"`
|
||||
- [x] >bili info [名字]
|
||||
- **嘉然** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_diana"`
|
||||
@@ -108,6 +114,10 @@
|
||||
- **minecraft** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_minecraft"`
|
||||
- [x] 具体指令看代码
|
||||
- 注:此功能实现依赖[MCSManager](https://github.com/Suwings/MCSManager)项目对服务器的管理api,mc服务器如果没有在该管理平台部署此功能无效
|
||||
- **炉石** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_hs"`
|
||||
- [x] 搜卡[xxxx]
|
||||
- [x] [卡组代码xxx]
|
||||
- 注:更多搜卡指令参数:https://hs.fbigame.com/misc/searchhelp
|
||||
- **TODO...**
|
||||
|
||||
## 使用方法
|
||||
@@ -122,7 +132,6 @@
|
||||
| [takayama-lily/onebot](https://github.com/takayama-lily/onebot) | [OICQ](https://github.com/takayama-lily/oicq) | takayama | |
|
||||
|
||||
### 使用稳定版/测试版
|
||||
> 需要将`data`目录放置到与编译好的可执行文件相同目录下才可正常执行。
|
||||
可以前往[Release](https://github.com/FloatTech/ZeroBot-Plugin/releases)页面下载对应系统版本可执行文件,编译时开启了全部插件。
|
||||
|
||||
### 本地运行
|
||||
@@ -133,7 +142,6 @@
|
||||
5. 运行 OneBot 框架,并同时运行本插件
|
||||
|
||||
### 编译运行
|
||||
> 需要将`data`目录放置到与编译好的可执行文件相同目录下才可正常执行。
|
||||
|
||||
#### 利用 Actions 在线编译 (推荐)
|
||||
1. 点击右上角 Fork 本项目,并转跳到自己 Fork 的仓库
|
||||
|
||||
3
go.mod
3
go.mod
@@ -3,7 +3,7 @@ module github.com/FloatTech/ZeroBot-Plugin
|
||||
go 1.16
|
||||
|
||||
require (
|
||||
github.com/FloatTech/AnimeAPI v1.1.6
|
||||
github.com/FloatTech/AnimeAPI v1.1.9
|
||||
github.com/FloatTech/ZeroBot-Plugin-Timer v1.4.3
|
||||
github.com/StackExchange/wmi v1.2.1 // indirect
|
||||
github.com/golang/protobuf v1.5.2
|
||||
@@ -12,6 +12,7 @@ require (
|
||||
github.com/sirupsen/logrus v1.8.1
|
||||
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816
|
||||
github.com/tidwall/gjson v1.8.1
|
||||
github.com/tidwall/pretty v1.2.0 // indirect
|
||||
github.com/tklauser/go-sysconf v0.3.7 // indirect
|
||||
github.com/wdvxdr1123/ZeroBot v1.2.2
|
||||
modernc.org/sqlite v1.12.0
|
||||
|
||||
7
go.sum
7
go.sum
@@ -1,5 +1,5 @@
|
||||
github.com/FloatTech/AnimeAPI v1.1.6 h1:M+970Vfi0ax0ElcS3fQXNKKlB+TiKWnL9gEePj/z0oo=
|
||||
github.com/FloatTech/AnimeAPI v1.1.6/go.mod h1:CC+vF30UGBlcIUxwFOcXIEHoJ4r7c5x2iLQsnUCVdDI=
|
||||
github.com/FloatTech/AnimeAPI v1.1.9 h1:H1hZmgwZPNHdx39K9JvY3awT8TTsCl9kKA1uVMyCjRg=
|
||||
github.com/FloatTech/AnimeAPI v1.1.9/go.mod h1:CC+vF30UGBlcIUxwFOcXIEHoJ4r7c5x2iLQsnUCVdDI=
|
||||
github.com/FloatTech/ZeroBot-Plugin-Timer v1.4.3 h1:jn/dH+OwPSRozkmeCeQQPrAGJRBudcm3OK5tXhGItRk=
|
||||
github.com/FloatTech/ZeroBot-Plugin-Timer v1.4.3/go.mod h1:MVOQQ4e6AVGFm993blXXU4Sd6bAsLY2+Zb+/HMrEeEc=
|
||||
github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA=
|
||||
@@ -72,8 +72,9 @@ github.com/tidwall/gjson v1.8.1 h1:8j5EE9Hrh3l9Od1OIEDAb7IpezNA20UdRngNAj5N0WU=
|
||||
github.com/tidwall/gjson v1.8.1/go.mod h1:5/xDoumyyDNerp2U36lyolv46b3uF/9Bu6OfyQ9GImk=
|
||||
github.com/tidwall/match v1.0.3 h1:FQUVvBImDutD8wJLN6c5eMzWtjgONK9MwIBCOrUJKeE=
|
||||
github.com/tidwall/match v1.0.3/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||
github.com/tidwall/pretty v1.1.0 h1:K3hMW5epkdAVwibsQEfR/7Zj0Qgt4DxtNumTq/VloO8=
|
||||
github.com/tidwall/pretty v1.1.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||
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.7 h1:HT7h4+536gjqeq1ZIJPgOl1rg1XFatQGVZWp7Py53eg=
|
||||
github.com/tklauser/go-sysconf v0.3.7/go.mod h1:JZIdXh4RmBvZDBZ41ld2bGxRV3n4daiiqA3skYhAoQ4=
|
||||
github.com/tklauser/numcpus v0.2.3 h1:nQ0QYpiritP6ViFhrKYsiv6VVxOpum2Gks5GhnJbS/8=
|
||||
|
||||
3
main.go
3
main.go
@@ -20,7 +20,9 @@ import (
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_ai_false" // 服务器监控
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_minecraft" // MCSManager
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_music" // 点歌
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_omikuji" // 浅草寺求签
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_shindan" // 测定
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_hs" // 炉石
|
||||
|
||||
// b站相关
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_bilibili" // 查询b站用户信息
|
||||
@@ -28,6 +30,7 @@ import (
|
||||
|
||||
// 二次元图片
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_acgimage" // 随机图片与AI点评
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_aiwife" // 随机老婆
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_image_finder" // 关键字搜图
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_lolicon" // lolicon 随机图片
|
||||
_ "github.com/FloatTech/ZeroBot-Plugin/plugin_saucenao" // 以图搜图
|
||||
|
||||
24
plugin_aiwife/non-existent.go
Normal file
24
plugin_aiwife/non-existent.go
Normal file
@@ -0,0 +1,24 @@
|
||||
// Package aiwife 随机老婆
|
||||
package aiwife
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
const (
|
||||
bed = "https://www.thiswaifudoesnotexist.net/example-%d.jpg"
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
rand.Seed(time.Now().UnixMicro())
|
||||
zero.OnFullMatchGroup([]string{"waifu", "随机waifu"}).SetPriority(10).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
miku := rand.Intn(100000) + 1
|
||||
ctx.SendChain(message.At(ctx.Event.UserID), message.Image(fmt.Sprintf(bed, miku)))
|
||||
})
|
||||
}
|
||||
@@ -16,8 +16,8 @@ import (
|
||||
var (
|
||||
// ATRI 所有命令的优先级
|
||||
prio = -1
|
||||
// ATRI 表情的 GitHub 镜像位置
|
||||
res = "https://raw.dihe.moe/Yiwen-Chan/ZeroBot-Plugin/master/plugin_atri/"
|
||||
// ATRI 表情的 codechina 镜像
|
||||
res = "https://codechina.csdn.net/u011570312/ZeroBot-Plugin/-/raw/master/plugin_atri/"
|
||||
// ATRI 的总开关
|
||||
enable = true
|
||||
)
|
||||
|
||||
@@ -3,6 +3,7 @@ package data
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
@@ -12,6 +13,7 @@ import (
|
||||
const (
|
||||
datapath = "data/Diana"
|
||||
pbfile = datapath + "/text.pb"
|
||||
pburl = "https://codechina.csdn.net/u011570312/ZeroBot-Plugin/-/raw/master/data/Diana/text.pb"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -41,6 +43,7 @@ func LoadText() error {
|
||||
if _, err := os.Stat(pbfile); err == nil || os.IsExist(err) {
|
||||
f, err := os.Open(pbfile)
|
||||
if err == nil {
|
||||
defer f.Close()
|
||||
data, err1 := io.ReadAll(f)
|
||||
if err1 == nil {
|
||||
if len(data) > 0 {
|
||||
@@ -49,6 +52,26 @@ func LoadText() error {
|
||||
}
|
||||
return err1
|
||||
}
|
||||
} else { // 如果没有小作文,则从 url 下载
|
||||
f, err := os.Create(pbfile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
resp, err := http.Get(pburl)
|
||||
if err == nil {
|
||||
defer resp.Body.Close()
|
||||
if resp.ContentLength > 0 {
|
||||
log.Printf("[Diana]从镜像下载小作文%d字节...", resp.ContentLength)
|
||||
data, err := io.ReadAll(resp.Body)
|
||||
if err == nil && len(data) > 0 {
|
||||
f.Write(data)
|
||||
return compo.Unmarshal(data)
|
||||
}
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
101
plugin_hs/run.go
Normal file
101
plugin_hs/run.go
Normal file
@@ -0,0 +1,101 @@
|
||||
package hs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/imroc/req"
|
||||
"github.com/tidwall/gjson"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
var header = req.Header{
|
||||
"user-agent": `Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Mobile Safari/537.36`,
|
||||
"referer": `https://hs.fbigame.com`,
|
||||
}
|
||||
|
||||
func init() {
|
||||
zero.OnRegex(`^搜卡(.+)$`).
|
||||
SetBlock(true).SetPriority(20).Handle(func(ctx *zero.Ctx) {
|
||||
List := ctx.State["regex_matched"].([]string)[1]
|
||||
g := sh(List)
|
||||
im, _ := req.Get(`https://res.fbigame.com/hs/v13/`+
|
||||
gjson.Get(g, `list.0.CardID`).String()+
|
||||
`.png?auth_key=`+
|
||||
gjson.Get(g, `list.0.auth_key`).String(), header)
|
||||
im.ToFile("data/image/1.png")
|
||||
file, _ := os.Open("data/image/1.png")
|
||||
sg, _ := req.Post("https://pic.sogou.com/pic/upload_pic.jsp", req.FileUpload{
|
||||
File: file,
|
||||
FieldName: "image", // FieldName 是表单字段名
|
||||
FileName: "avatar.png", // Filename 是要上传的文件的名称,我们使用它来猜测mimetype,并将其上传到服务器上
|
||||
})
|
||||
var tx string
|
||||
t := int(gjson.Get(g, `list.#`).Int())
|
||||
if t == 0 {
|
||||
ctx.SendChain(message.Text("查询为空!"))
|
||||
return
|
||||
}
|
||||
for i := 0; i < t && i < 10; i++ {
|
||||
tx += strconv.Itoa(i+1) + ". 法力:" +
|
||||
gjson.Get(g, `list.`+strconv.Itoa(i)+`.COST`).String() +
|
||||
" " +
|
||||
gjson.Get(g, `list.`+strconv.Itoa(i)+`.CARDNAME`).String() +
|
||||
"\n"
|
||||
}
|
||||
ctx.SendChain(
|
||||
message.Image(sg.String()),
|
||||
message.Text(tx),
|
||||
)
|
||||
})
|
||||
//卡组
|
||||
zero.OnRegex(`^[\s\S]*?(AAE[a-zA-Z0-9/\+=]{70,})[\s\S]*$`).
|
||||
SetBlock(true).SetPriority(20).Handle(func(ctx *zero.Ctx) {
|
||||
fmt.Print("成功")
|
||||
List := ctx.State["regex_matched"].([]string)[1]
|
||||
ctx.SendChain(
|
||||
message.Image(kz(List)),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
func sh(s string) string {
|
||||
var hs = `https://hs.fbigame.com/ajax.php`
|
||||
h, _ := req.Get("https://hs.fbigame.com", header)
|
||||
var param = req.Param{
|
||||
"mod": `get_cards_list`,
|
||||
"mode": `-1`,
|
||||
"extend": `-1`,
|
||||
"mutil_extend": ``,
|
||||
"hero": `-1`,
|
||||
"rarity": `-1`,
|
||||
"cost": `-1`,
|
||||
"mutil_cost": ``,
|
||||
"techlevel": `-1`,
|
||||
"type": `-1`,
|
||||
"collectible": `-1`,
|
||||
"isbacon": `-1`,
|
||||
"page": `1`,
|
||||
"search_type": `1`,
|
||||
"deckmode": "normal",
|
||||
"hash": strings.SplitN(strings.SplitN(h.String(), `var hash = "`, 2)[1], `"`, 2)[0],
|
||||
}
|
||||
r, _ := req.Get(hs, header, param, req.Param{"search": s})
|
||||
return r.String()
|
||||
}
|
||||
|
||||
func kz(s string) string {
|
||||
h, _ := req.Get("https://hs.fbigame.com")
|
||||
param := req.Param{
|
||||
"mod": `general_deck_image`,
|
||||
"deck_code": s,
|
||||
"deck_text": ``,
|
||||
"hash": strings.SplitN(strings.SplitN(h.String(), `var hash = "`, 2)[1], `"`, 2)[0],
|
||||
}
|
||||
r, _ := req.Get(`https://hs.fbigame.com/ajax.php`, param, h.Request().Header)
|
||||
im := gjson.Get(r.String(), "img").String()
|
||||
return `base64://` + im
|
||||
}
|
||||
@@ -177,9 +177,9 @@ func qqmusic(keyword string) message.MessageSegment {
|
||||
}.Encode()
|
||||
audio := gjson.ParseBytes(netGet(music.String(), h2))
|
||||
// 获得音乐封面
|
||||
image := "https://y.gtimg.cn/music/photo_new" +
|
||||
image := "https://y.gtimg.cn/music/photo_new/" +
|
||||
find(
|
||||
"src=\"//y.gtimg.cn/music/photo_new",
|
||||
`photo_new\u002F`,
|
||||
"?max_age",
|
||||
string(
|
||||
netGet("https://y.qq.com/n/yqq/song/"+info.Get("songmid").Str+".html", nil),
|
||||
|
||||
24
plugin_omikuji/sensou.go
Normal file
24
plugin_omikuji/sensou.go
Normal file
@@ -0,0 +1,24 @@
|
||||
// Package omikuji 浅草寺求签
|
||||
package omikuji
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
)
|
||||
|
||||
const (
|
||||
bed = "https://codechina.csdn.net/u011570312/senso-ji-omikuji/-/raw/main/%d_%d.jpg"
|
||||
)
|
||||
|
||||
func init() { // 插件主体
|
||||
rand.Seed(time.Now().UnixMicro())
|
||||
zero.OnFullMatchGroup([]string{"求签", "运势", "占卜"}, zero.OnlyToMe).SetPriority(10).
|
||||
Handle(func(ctx *zero.Ctx) {
|
||||
miku := rand.Intn(100) + 1
|
||||
ctx.SendChain(message.At(ctx.Event.UserID), message.Image(fmt.Sprintf(bed, miku, 0)), message.Image(fmt.Sprintf(bed, miku, 1)))
|
||||
})
|
||||
}
|
||||
@@ -3,6 +3,9 @@ package setutime
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -28,6 +31,10 @@ type imgpool struct {
|
||||
Form int64
|
||||
}
|
||||
|
||||
const (
|
||||
dburl = "https://codechina.csdn.net/u011570312/ZeroBot-Plugin/-/raw/master/data/SetuTime/SetuTime.db"
|
||||
)
|
||||
|
||||
// NewPoolsCache 返回一个缓冲池对象
|
||||
func newPools() *imgpool {
|
||||
cache := &imgpool{
|
||||
@@ -43,6 +50,24 @@ func newPools() *imgpool {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
// 如果数据库不存在则下载
|
||||
if _, err := os.Stat(cache.DB.DBPath); err != nil || os.IsNotExist(err) {
|
||||
f, err := os.Create(cache.DB.DBPath)
|
||||
if err == nil {
|
||||
resp, err := http.Get(dburl)
|
||||
if err == nil {
|
||||
defer resp.Body.Close()
|
||||
if resp.ContentLength > 0 {
|
||||
log.Printf("[Setu]从镜像下载数据库%d字节...", resp.ContentLength)
|
||||
data, err := io.ReadAll(resp.Body)
|
||||
if err == nil && len(data) > 0 {
|
||||
f.Write(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
f.Close()
|
||||
}
|
||||
}
|
||||
for i := range cache.List {
|
||||
if err := cache.DB.create(cache.List[i], &pixiv.Illust{}); err != nil {
|
||||
panic(err)
|
||||
|
||||
@@ -5,11 +5,10 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/shindanmaker"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/extension/rate"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
|
||||
"github.com/FloatTech/AnimeAPI/shindanmaker"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -21,10 +20,11 @@ func init() {
|
||||
zero.OnPrefix("异世界转生", number(587874)).SetBlock(true).FirstPriority().Handle(handle)
|
||||
zero.OnPrefix("今天是什么少女", number(162207)).SetBlock(true).FirstPriority().Handle(handle)
|
||||
zero.OnPrefix("卖萌", number(360578)).SetBlock(true).FirstPriority().Handle(handle)
|
||||
zero.OnPrefix("抽老婆", number(1075116)).SetBlock(true).FirstPriority().Handle(handle)
|
||||
}
|
||||
|
||||
// shindanmaker 处理函数
|
||||
var handle = func(ctx *zero.Ctx) {
|
||||
func handle(ctx *zero.Ctx) {
|
||||
if !limit.Load(ctx.Event.UserID).Acquire() {
|
||||
ctx.SendChain(message.Text("请稍后重试0x0..."))
|
||||
return
|
||||
@@ -42,11 +42,11 @@ var handle = func(ctx *zero.Ctx) {
|
||||
if err != nil {
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
}
|
||||
ctx.SendChain(message.Text(text))
|
||||
ctx.Send(text)
|
||||
}
|
||||
|
||||
// 传入 shindanmaker id
|
||||
var number = func(id int64) func(ctx *zero.Ctx) bool {
|
||||
func number(id int64) func(ctx *zero.Ctx) bool {
|
||||
return func(ctx *zero.Ctx) bool {
|
||||
ctx.State["id"] = id
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user