Skip to content

Commit

Permalink
✏️ drop all pb & 增加 gist 审批
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama committed Dec 16, 2021
1 parent a363623 commit e2c6033
Show file tree
Hide file tree
Showing 11 changed files with 209 additions and 196 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,12 @@ zerobot -h -t token -u url [-d|w] [-g 监听地址:端口] qq1 qq2 qq3 ...
- [x] 列出所有提醒
- [x] 翻牌
- [x] [开启|关闭]入群验证
- [ ] 同意入群请求
- [x] [开启|关闭]gist加群自动审批
- [ ] 同意好友请求
- [ ] 撤回[@xxx] [xxx]
- [ ] 警告[@xxx]
- [x] run[xxx]
- 注:使用gist加群自动审批,请在群介绍添加以下说明,同时开启`需要回答问题并由管理员审核`:加群请在github新建一个gist,其文件名为本群群号的字符串的md5,内容为一行,是当前unix时间戳。然后请将您的用户名和gist哈希按照username/gisthash的格式填写到回答即可。
- **GitHub仓库搜索** `import _ "github.com/FloatTech/ZeroBot-Plugin/plugin_github"`
- [x] >github [xxx]
- [x] >github -p [xxx]
Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ require (
github.com/FloatTech/AnimeAPI v1.1.10
github.com/FloatTech/ZeroBot-Plugin-Gif v0.2.4
github.com/FloatTech/bot-manager v1.0.1-0.20211112011524-85b9895271ed
github.com/RomiChan/protobuf v0.0.0-20211204042931-ff4f35848737
github.com/corona10/goimagehash v1.0.3
github.com/fogleman/gg v1.3.0
github.com/fumiama/cron v1.3.0
Expand All @@ -24,6 +23,5 @@ require (
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816
github.com/tidwall/gjson v1.12.1
github.com/wdvxdr1123/ZeroBot v1.4.1
github.com/yusufpapurcu/wmi v1.2.2 // indirect
golang.org/x/image v0.0.0-20211028202545-6944b10bf410
)
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ github.com/FloatTech/imgfactory v0.1.1/go.mod h1:ThDALab8aOuU6KVYESVWFqmjcqtm03e
github.com/Mrs4s/MiraiGo v0.0.0-20211120033824-43b23f4e6fcb h1:Rkj28fqIwGx/EgBzRYtpmJRfH6wqVn7cNdc7aJ0QE4M=
github.com/Mrs4s/MiraiGo v0.0.0-20211120033824-43b23f4e6fcb/go.mod h1:imVKbfKqqeit+C/eaWGb4MKQ3z3gN6pRpBU5RMtp5so=
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
github.com/RomiChan/protobuf v0.0.0-20211204042931-ff4f35848737 h1:p4o7/eSoP39jwnGZz08N1IpH/mNzg9SdCn7kPM9A9BE=
github.com/RomiChan/protobuf v0.0.0-20211204042931-ff4f35848737/go.mod h1:CKKOWC7mBxd36zxsCB1V8DTrwlTNRQvkSVbYqyUiGEE=
github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
github.com/antchfx/htmlquery v1.2.3 h1:sP3NFDneHx2stfNXCKbhHFo8XgNjCACnU/4AO5gWz6M=
Expand Down
68 changes: 0 additions & 68 deletions plugin_diana/data/migrate/text.go

This file was deleted.

43 changes: 43 additions & 0 deletions plugin_manager/gist.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package manager

import (
"crypto/md5"
"encoding/hex"
"fmt"
"strconv"
"time"

"github.com/FloatTech/ZeroBot-Plugin/utils/math"
"github.com/FloatTech/ZeroBot-Plugin/utils/web"
"github.com/sirupsen/logrus"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
)

// user hash file
const gistraw = "https://gist.githubusercontent.com/%s/%s/raw/%s"

func checkNewUser(qq, gid int64, ghun, hash string) (bool, string) {
if db.CanFind("member", "where ghun="+ghun) {
return false, "该github用户已入群"
}
gidsum := md5.Sum(helper.StringToBytes(strconv.FormatInt(gid, 10)))
gidhex := hex.EncodeToString(gidsum[:])
u := fmt.Sprintf(gistraw, ghun, hash, gidhex)
logrus.Debugln("[gist]visit url:", u)
data, err := web.GetData(u)
if err == nil {
logrus.Debugln("[gist]get data:", helper.BytesToString(data))
st, err := strconv.ParseInt(helper.BytesToString(data), 10, 64)
if err == nil {
// 600s 内验证成功
ok := math.Abs(int(time.Now().Unix()-st)) < 600
if ok {
_ = db.Insert("member", &Member{QQ: qq, Ghun: ghun})
return true, ""
}
return false, "时间戳超时"
}
return false, "时间戳格式错误: " + helper.BytesToString(data)
}
return false, "无法连接到gist: " + err.Error()
}
12 changes: 12 additions & 0 deletions plugin_manager/manager.db.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package manager

type Welcome struct {
GrpID int64 `db:"gid"`
Msg string `db:"msg"`
}

type Member struct {
QQ int64 `db:"qq"`
// github username
Ghun string `db:"ghun"`
}
Loading

0 comments on commit e2c6033

Please sign in to comment.