Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
c08afc2
:bookmark: Update to 1.0.6
kanrichan Dec 9, 2020
ae18269
:bookmark: Update to 1.0.6
kanrichan Dec 9, 2020
d30cf1f
:green_heart: Satrt actions
kanrichan Dec 9, 2020
15023dd
:green_heart: Start action
kanrichan Dec 9, 2020
d6ecacc
:green_heart: Start action
kanrichan Dec 9, 2020
7a1ef9a
:green_heart: Start action
kanrichan Dec 9, 2020
2d50f1b
:bug: Fix Title ask
kanrichan Dec 12, 2020
e85eea8
:memo: Update README.md
kanrichan Jan 9, 2021
061d848
:memo: Update README.md
kanrichan Jan 9, 2021
6cce89a
:bug: Fix manage permission
kanrichan Jan 15, 2021
4151acd
:art: improve code
kanrichan Feb 13, 2021
1eb924d
:sparkles: Add plugin setutime
kanrichan Feb 14, 2021
b67b5bc
:sparkles: Add plugin manager
kanrichan Feb 14, 2021
8cb64a6
:heavy_plus_sign: Add some mods
kanrichan Feb 14, 2021
d9698ba
:see_no_evil: Add gitignore
kanrichan Feb 14, 2021
b25957f
:sparkles: Add music selector
kanrichan Feb 14, 2021
4e491da
:sparkles: Add some plugins
kanrichan Feb 14, 2021
f8a6f35
:bug: Fix 进群欢迎&退群提醒
kanrichan Feb 15, 2021
ca8ab82
🚸 增加了涩图触发的频率限制
kanrichan Feb 16, 2021
9c533da
📝 更新README
kanrichan Feb 16, 2021
3be1eb3
:bug: 修复禁言时长超出上限无效的问题
kanrichan Feb 19, 2021
3a683ba
✨ 增加禁言(分钟/小时/天)的选择
kanrichan Feb 19, 2021
7ec2213
:bug: 修复网易云点歌失效问题
kanrichan Feb 19, 2021
cc7d3ef
✏️ 修复个别碧油鸡
kanrichan Mar 13, 2021
631cca5
🚧 测试action
kanrichan Mar 13, 2021
9d59524
🚧 测试 action
kanrichan Mar 13, 2021
c712b4b
🎨 改进代码结构
kanrichan Mar 18, 2021
54ba7cf
🚧 测试 action
kanrichan Mar 18, 2021
7d3c7d8
💚 更新 action
kanrichan Mar 18, 2021
778a85f
📄 使用 AGPL v3
kanrichan Mar 18, 2021
025581f
Merge pull request #5 from Yiwen-Chan/add-license-1
kanrichan Mar 18, 2021
be66413
📦 更新使用方法
kanrichan Mar 18, 2021
8d847f4
:bug: 修复添加图片无法正常发出图片
kanrichan Mar 19, 2021
2897b6e
📝 更新 README
kanrichan Mar 19, 2021
9cdc06a
:bug: 修复缓存图片重复
kanrichan Mar 19, 2021
e1ac125
✏️ 减少指令误触发
kanrichan Mar 22, 2021
e631731
✨ 添加run功能
kanrichan Mar 22, 2021
bc958d0
📝 更新 README
kanrichan Mar 22, 2021
044599a
📝 更新 README
kanrichan Mar 22, 2021
201f659
🐛 修复转发问题
kanrichan Mar 22, 2021
26ef5b9
🎨 改进代码
kanrichan Mar 22, 2021
f90487e
➖ 去除不必要依赖
kanrichan Mar 24, 2021
1ca1840
✏️ 修改错别字
kanrichan Mar 28, 2021
3aaef12
✨ 添加 GitHub 仓库搜索
kanrichan Mar 28, 2021
c6d55fc
✏️ 修复 github repo 搜索中文的问题
kanrichan Apr 1, 2021
93b0046
🎨 调整代码结构
kanrichan Apr 1, 2021
d88f505
📝 更新 README
kanrichan Apr 1, 2021
564c84d
📝 更新 README
kanrichan Apr 1, 2021
9bee242
✨ 添加戳一戳回戳
kanrichan Apr 5, 2021
bff667f
📝 更新 README
kanrichan Apr 5, 2021
dbaf45b
⚡️ 使用 pximg 下载图片
kanrichan Apr 7, 2021
17bed53
🎨 戳一戳独立到闲聊插件
kanrichan Apr 7, 2021
866b752
➕ 更新依赖
kanrichan Apr 7, 2021
8702815
Update music_selecter.go
DawnNights Apr 9, 2021
f7dfb27
Update music_selecter.go
DawnNights Apr 9, 2021
f399887
Create learn.go
DawnNights Apr 12, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Compile ZeroBot-Plugin-linux
on:
push:
branches:
- master

env:
GITHUB_TOKEN: ${{ github.token }}

jobs:
my-job:
name: Build ZeroBot-Plugin-linux 🚀
runs-on: ubuntu-latest
steps:

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15

- 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
run: go build -ldflags="-s -w" -o artifacts/ZeroBot-Plugin-linux

- name: Upload Build Artifact
uses: actions/upload-artifact@v2
with:
name: ZeroBot-Plugin-linux
path: ./artifacts
41 changes: 41 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Compile ZeroBot-Plugin-windows
on:
push:
branches:
- master

env:
GITHUB_TOKEN: ${{ github.token }}

jobs:
my-job:
name: Build ZeroBot-Plugin-windows 🚀
runs-on: windows-latest
steps:

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Cache Go
id: cache
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-build-${{ hashFiles('**/go.sum') }}

- name: Tidy Go modules
run: go mod tidy

- name: Build
run: go build -ldflags="-s -w" -o artifacts/ZeroBot-Plugin-windows.exe

- name: Upload Build Artifact
uses: actions/upload-artifact@v2
with:
name: ZeroBot-Plugin-windows.exe
path: ./artifacts
Binary file added .github/yaya.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
data/*
main.exe
661 changes: 661 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

77 changes: 77 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<div align="center">
<img src=".github/yaya.jpg" width = "150" height = "150" alt="OneBot-YaYa"><br>
<h2>ZeroBot-Plugin</h2>
ZeroBot-Plugin 是 ZeroBot 的 实用插件合集<br><br>

[![YAYA](https://img.shields.io/badge/OneBot-YaYa-green.svg?style=social&logo=appveyor)](https://github.com/Yiwen-Chan/OneBot-YaYa)
[![GOCQ](https://img.shields.io/badge/OneBot-MiraiGo-green.svg?style=social&logo=appveyor)](https://github.com/Mrs4s/go-cqhttp)
[![OICQ](https://img.shields.io/badge/OneBot-OICQ-green.svg?style=social&logo=appveyor)](https://github.com/takayama-lily/node-onebot)
[![MIRAI](https://img.shields.io/badge/OneBot-Mirai-green.svg?style=social&logo=appveyor)](https://github.com/yyuueexxiinngg/onebot-kotlin)

[![Go Report Card](https://goreportcard.com/badge/github.com/Yiwen-Chan/ZeroBot-Plugin?style=flat-square&logo=go)](https://goreportcard.com/report/github.com/github.com/Yiwen-Chan/ZeroBot-Plugin)
[![Badge](https://img.shields.io/badge/onebot-v11-black?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHAAAABwCAMAAADxPgR5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAxQTFRF////29vbr6+vAAAAk1hCcwAAAAR0Uk5T////AEAqqfQAAAKcSURBVHja7NrbctswDATQXfD//zlpO7FlmwAWIOnOtNaTM5JwDMa8E+PNFz7g3waJ24fviyDPgfhz8fHP39cBcBL9KoJbQUxjA2iYqHL3FAnvzhL4GtVNUcoSZe6eSHizBcK5LL7dBr2AUZlev1ARRHCljzRALIEog6H3U6bCIyqIZdAT0eBuJYaGiJaHSjmkYIZd+qSGWAQnIaz2OArVnX6vrItQvbhZJtVGB5qX9wKqCMkb9W7aexfCO/rwQRBzsDIsYx4AOz0nhAtWu7bqkEQBO0Pr+Ftjt5fFCUEbm0Sbgdu8WSgJ5NgH2iu46R/o1UcBXJsFusWF/QUaz3RwJMEgngfaGGdSxJkE/Yg4lOBryBiMwvAhZrVMUUvwqU7F05b5WLaUIN4M4hRocQQRnEedgsn7TZB3UCpRrIJwQfqvGwsg18EnI2uSVNC8t+0QmMXogvbPg/xk+Mnw/6kW/rraUlvqgmFreAA09xW5t0AFlHrQZ3CsgvZm0FbHNKyBmheBKIF2cCA8A600aHPmFtRB1XvMsJAiza7LpPog0UJwccKdzw8rdf8MyN2ePYF896LC5hTzdZqxb6VNXInaupARLDNBWgI8spq4T0Qb5H4vWfPmHo8OyB1ito+AysNNz0oglj1U955sjUN9d41LnrX2D/u7eRwxyOaOpfyevCWbTgDEoilsOnu7zsKhjRCsnD/QzhdkYLBLXjiK4f3UWmcx2M7PO21CKVTH84638NTplt6JIQH0ZwCNuiWAfvuLhdrcOYPVO9eW3A67l7hZtgaY9GZo9AFc6cryjoeFBIWeU+npnk/nLE0OxCHL1eQsc1IciehjpJv5mqCsjeopaH6r15/MrxNnVhu7tmcslay2gO2Z1QfcfX0JMACG41/u0RrI9QAAAABJRU5ErkJggg==)](https://github.com/howmanybots/onebot)
[![Badge](https://img.shields.io/badge/zerobot-v1.0.1-black?style=flat-square&logo=go)](https://github.com/wdvxdr1123/ZeroBot)
[![License](https://img.shields.io/github/license/Yiwen-Chan/OneBot-YaYa.svg?style=flat-square&logo=gnu)](https://raw.githubusercontent.com/Yiwen-Chan/ZeroBot-Plugin/master/LICENSE)
[![qq group](https://img.shields.io/badge/group-1048452984-red?style=flat-square&logo=tencent-qq)](https://jq.qq.com/?_wv=1027&k=QMb7x1mM)

</div>


### 功能
- 群管
- [x] 禁言[@xxx][分钟]
- [x] 解除禁言[@xxx]
- [x] 我要自闭 [分钟]
- [x] 开启全员禁言
- [x] 解除全员禁言
- [x] 升为管理[@xxx]
- [x] 取消管理[@xxx]
- [x] 修改名片[@xxx][xxx]
- [x] 修改头衔[@xxx][xxx]
- [x] 申请头衔[xxx]
- [x] 踢出群聊[@xxx]
- [x] 退出群聊[群号]
- [x] *入群欢迎
- [x] *退群通知
- [ ] 同意入群请求
- [ ] 同意好友请求
- [ ] 撤回[@xxx] [xxx]
- [ ] 警告[@xxx]
- [x] run[xxx]
- 涩图
- [x] 来份[涩图/二次元/风景]
- [x] 添加[涩图/二次元/风景][P站图片ID]
- [x] 删除[涩图/二次元/风景][P站图片ID]
- [x] setu -s
- [x] setu -x
- [x] setu -p
- 点歌
- [x] 点歌[xxx]
- TODO...

### 使用方法

本项目符合 [OneBot](https://github.com/howmanybots/onebot) 标准,可基于以下项目与机器人框架/平台进行交互
| 项目地址 | 平台 | 核心作者 | 备注 |
| --- | --- | --- | --- |
| [Yiwen-Chan/OneBot-YaYa](https://github.com/Yiwen-Chan/OneBot-YaYa) | [先驱](https://www.xianqubot.com/) | kanri | |
| [richardchien/coolq-http-api](https://github.com/richardchien/coolq-http-api) | CKYU | richardchien | 可在 Mirai 平台使用 [mirai-native](https://github.com/iTXTech/mirai-native) 加载 |
| [Mrs4s/go-cqhttp](https://github.com/Mrs4s/go-cqhttp) | [MiraiGo](https://github.com/Mrs4s/MiraiGo) | Mrs4s | |
| [yyuueexxiinngg/cqhttp-mirai](https://github.com/yyuueexxiinngg/cqhttp-mirai) | [Mirai](https://github.com/mamoe/mirai) | yyuueexxiinngg | |
| [takayama-lily/onebot](https://github.com/takayama-lily/onebot) | [OICQ](https://github.com/takayama-lily/oicq) | takayama | |

#### 本地编译
1. 下载安装 [Go](https://studygolang.com/dl/golang/go1.16.2.windows-amd64.msi) 环境
2. 下载安装 [TDM-GCC](https://github.com/jmeubank/tdm-gcc/releases),并添加到环境变量
3. [clone](https://github.com/Yiwen-Chan/ZeroBot-Plugin/archive/master.zip) 本项目,本地解压
4. 编辑 main.go 文件,内容按需修改
5. 双击点击 build.bat 文件
6. 运行框架,并同时运行本插件

#### 利用 Actions 编译 (推荐)
1. 点击右上角 Fork 本项目,并转跳到自己 Fork 的仓库
2. 点击仓库上方的 Actions 按钮,确认使用 Actions
3. 编辑 main.go 文件,内容按需修改,返回仓库
4. 点击 Actions 按钮,等待编译完成,在 Actions 里下载编译好的文件
5. 运行框架,并同时运行本插件

37 changes: 0 additions & 37 deletions app.go

This file was deleted.

6 changes: 6 additions & 0 deletions build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
go version
gcc -v
go env -w GOPROXY=https://goproxy.cn,direct
go env -w GO111MODULE=auto
go build -ldflags="-s -w" -o ZeroBot-Plugin-windows.exe
pause
17 changes: 17 additions & 0 deletions chat/chat.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package chat

import (
"time"

zero "github.com/wdvxdr1123/ZeroBot"
)

func init() { // 插件主体
// 戳一戳
zero.On("notice/notify/poke", zero.OnlyToMe).SetBlock(false).SetPriority(0).
Handle(func(ctx *zero.Ctx) {
time.Sleep(time.Second * 1)
ctx.Send("请不要戳我 >_<")
return
})
}
56 changes: 56 additions & 0 deletions chat/learn.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package chat

import (
zero "github.com/wdvxdr1123/ZeroBot"
yaml "gopkg.in/yaml.v2"
"io/ioutil"
"math/rand"
"os"
"strings"
"time"
)

func init() {
botName := "小沫" //填写机器人的名称
myData := map[string][]string{}
yaml.Unmarshal(FileRead("chat\\myData.yaml"),&myData)

zero.OnRegex("^(.+?)$").Handle(func(ctx *zero.Ctx) {

text := ctx.State["regex_matched"].([]string)[1]
if strings.Index(text,botName+"跟我学")==0{
kv := strings.Split(text[len(botName+"跟我学 "):len(text)]," ")
if len(kv)>1 && kv[1]!=""{
myData[kv[0]] = kv[1:len(kv)]
content,_ := yaml.Marshal(myData)
FileWrite("chat\\myData.yaml",content)
ctx.Send(botName + "学会了奇怪的新知识["+kv[0]+"]:\n- "+strings.Join(kv[1:len(kv)],"\n- "))
}else {
ctx.Send("你想让"+botName+"学些什么呀?")
}
return
}

for k,vs := range myData{
if strings.Index(text,k) != -1{
rand.Seed(time.Now().Unix())
ctx.Send(vs[rand.Intn(len(vs))])
return
}
}
})
}

func FileRead(path string) []byte {
//读取文件数据
file,_ := os.Open(path)
defer file.Close()
data,_ := ioutil.ReadAll(file)
return data
}

func FileWrite(path string,content []byte) int {
//写入文件数据
ioutil.WriteFile(path,content,0644)
return len(content)
}
78 changes: 78 additions & 0 deletions github/repo_searcher.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package github

import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strings"

"github.com/tidwall/gjson"
zero "github.com/wdvxdr1123/ZeroBot"
)

func init() { // 插件主体
zero.OnRegex(`>G\s(.*)`).SetBlock(true).SetPriority(0).
Handle(func(ctx *zero.Ctx) {
api, _ := url.Parse("https://api.github.com/search/repositories")
params := url.Values{}
params.Set("q", ctx.State["regex_matched"].([]string)[1])
api.RawQuery = params.Encode()
link := api.String()

client := &http.Client{}

req, err := http.NewRequest("GET", link, nil)
if err != nil {
ctx.Send(fmt.Sprintf("ERROR: %v", err))
return
}
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36")
resp, err := client.Do(req)
if err != nil {
ctx.Send(fmt.Sprintf("ERROR: %v", err))
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
ctx.Send(fmt.Sprintf("ERROR: %v", err))
return
}

if code := resp.StatusCode; code != 200 {
// 如果返回不是200则立刻抛出错误
ctx.Send(fmt.Sprintf("ERROR: code %d", code))
return
}
count := gjson.ParseBytes(body).Get("total_count").Int()
if count == 0 {
ctx.Send("没有找到这样的仓库")
return
}
repo := gjson.ParseBytes(body).Get("items.0")
language := repo.Get("language").Str
if language == "" {
language = "None"
}
license := strings.ToUpper(repo.Get("license.key").Str)
if license == "" {
license = "None"
}
id := ctx.Send(fmt.Sprintf(
"%s: \nDescription: %s\nStar/Fork/Issue: %d/%d/%d\nLanguage: %s\nLicense: %s\nLast pushed: %s\nJump: %s",
repo.Get("full_name").Str,
repo.Get("description").Str,
repo.Get("watchers").Int(),
repo.Get("forks").Int(),
repo.Get("open_issues").Int(),
language,
license,
repo.Get("updated_at").Str,
repo.Get("html_url").Str,
))
if id == 0 {
ctx.Send("ERROR: 可能被风控,发送失败")
}
})
}
13 changes: 8 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
module gm
module github.com/Yiwen-Chan/ZeroBot-Plugin

go 1.14
go 1.15

require (
github.com/wdvxdr1123/ZeroBot v0.0.0-20201129064504-07d9e1b5400f
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776
github.com/antchfx/htmlquery v1.2.3
github.com/mattn/go-sqlite3 v1.14.6
github.com/sirupsen/logrus v1.8.0
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816
github.com/tidwall/gjson v1.7.4
github.com/wdvxdr1123/ZeroBot v1.0.3-0.20210407015205-7cb1b23c5417
)
Loading