mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 13:59:39 +08:00
Merge pull request #30 from fumiama/master
群管增加翻牌,修复计时器空指针错误,简易随机增加分类识别
This commit is contained in:
commit
16901e33a6
@ -49,6 +49,7 @@
|
|||||||
- [x] 在[月份]月[每周or周几]的[小时]点[分钟]分时(用[url])提醒大家[消息]
|
- [x] 在[月份]月[每周or周几]的[小时]点[分钟]分时(用[url])提醒大家[消息]
|
||||||
- [x] 取消在[月份]月[日期]日的[小时]点[分钟]分的提醒
|
- [x] 取消在[月份]月[日期]日的[小时]点[分钟]分的提醒
|
||||||
- [x] 取消在[月份]月[每周or周几]的[小时]点[分钟]分的提醒
|
- [x] 取消在[月份]月[每周or周几]的[小时]点[分钟]分的提醒
|
||||||
|
- [x] 翻牌
|
||||||
- [ ] 同意入群请求
|
- [ ] 同意入群请求
|
||||||
- [ ] 同意好友请求
|
- [ ] 同意好友请求
|
||||||
- [ ] 撤回[@xxx] [xxx]
|
- [ ] 撤回[@xxx] [xxx]
|
||||||
@ -67,6 +68,7 @@
|
|||||||
- 简易随机图片(调用url) `import _ "github.com/Yiwen-Chan/ZeroBot-Plugin/randimg"`
|
- 简易随机图片(调用url) `import _ "github.com/Yiwen-Chan/ZeroBot-Plugin/randimg"`
|
||||||
- [x] 随机图片
|
- [x] 随机图片
|
||||||
- [x] 设置随机图片网址[url]
|
- [x] 设置随机图片网址[url]
|
||||||
|
- [x] 太涩了(撤回最近发的图)
|
||||||
- 点歌 `import _ "github.com/Yiwen-Chan/ZeroBot-Plugin/music"`
|
- 点歌 `import _ "github.com/Yiwen-Chan/ZeroBot-Plugin/music"`
|
||||||
- [x] 点歌[xxx]
|
- [x] 点歌[xxx]
|
||||||
- [x] 网易点歌[xxx]
|
- [x] 网易点歌[xxx]
|
||||||
|
|||||||
5
build_arm.sh
Executable file
5
build_arm.sh
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
go version
|
||||||
|
go env -w GOPROXY=https://goproxy.cn,direct
|
||||||
|
go env -w GO111MODULE=auto
|
||||||
|
go mod tidy
|
||||||
|
GOOS=linux GOARCH=arm GOARM=6 CGO_ENABLED=0 CC=${CCBIN} CXX=${CXXBIN} go build -ldflags "-s -w" -o zerobot
|
||||||
2
go.mod
2
go.mod
@ -4,7 +4,7 @@ go 1.15
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/antchfx/htmlquery v1.2.3
|
github.com/antchfx/htmlquery v1.2.3
|
||||||
github.com/fumiama/ZeroBot-Plugin-Timer v0.0.0-20210609104507-70d574d5761d
|
github.com/fumiama/ZeroBot-Plugin-Timer v0.0.0-20210609110318-3c8ef99e3c6c
|
||||||
github.com/mattn/go-sqlite3 v1.14.7
|
github.com/mattn/go-sqlite3 v1.14.7
|
||||||
github.com/sirupsen/logrus v1.8.1
|
github.com/sirupsen/logrus v1.8.1
|
||||||
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816
|
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816
|
||||||
|
|||||||
6
go.sum
6
go.sum
@ -1,4 +1,5 @@
|
|||||||
github.com/Yiwen-Chan/ZeroBot-Plugin v0.0.0-20210606065432-ce326ce97753/go.mod h1:54LOXRTKW0iR0BcKwRSUK46KfLPz7hiLcGMD5GGtL0k=
|
github.com/Yiwen-Chan/ZeroBot-Plugin v0.0.0-20210606065432-ce326ce97753/go.mod h1:54LOXRTKW0iR0BcKwRSUK46KfLPz7hiLcGMD5GGtL0k=
|
||||||
|
github.com/Yiwen-Chan/ZeroBot-Plugin v0.0.0-20210606082630-29be1bd5eca6/go.mod h1:UfFAgNpRzp1N9HFmYoUlBJ4nvJOMJC9fMBBHQoaHmf8=
|
||||||
github.com/antchfx/htmlquery v1.2.3 h1:sP3NFDneHx2stfNXCKbhHFo8XgNjCACnU/4AO5gWz6M=
|
github.com/antchfx/htmlquery v1.2.3 h1:sP3NFDneHx2stfNXCKbhHFo8XgNjCACnU/4AO5gWz6M=
|
||||||
github.com/antchfx/htmlquery v1.2.3/go.mod h1:B0ABL+F5irhhMWg54ymEZinzMSi0Kt3I2if0BLYa3V0=
|
github.com/antchfx/htmlquery v1.2.3/go.mod h1:B0ABL+F5irhhMWg54ymEZinzMSi0Kt3I2if0BLYa3V0=
|
||||||
github.com/antchfx/xpath v1.1.6/go.mod h1:Yee4kTMuNiPYJ7nSNorELQMr1J33uOpXDMByNYhvtNk=
|
github.com/antchfx/xpath v1.1.6/go.mod h1:Yee4kTMuNiPYJ7nSNorELQMr1J33uOpXDMByNYhvtNk=
|
||||||
@ -9,8 +10,9 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
|
|||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||||
github.com/fumiama/ZeroBot-Plugin-Timer v0.0.0-20210606064339-d55b94d71eee/go.mod h1:RN0gCtafWRu2d7lMg9/5UfZDhtsPgdeUovsyuSwl+oQ=
|
github.com/fumiama/ZeroBot-Plugin-Timer v0.0.0-20210606064339-d55b94d71eee/go.mod h1:RN0gCtafWRu2d7lMg9/5UfZDhtsPgdeUovsyuSwl+oQ=
|
||||||
github.com/fumiama/ZeroBot-Plugin-Timer v0.0.0-20210609104507-70d574d5761d h1:p67VMUDiZUhwKjUD6Xsur6FJc96hsikoXI0cm90IGSQ=
|
github.com/fumiama/ZeroBot-Plugin-Timer v0.0.0-20210606075146-09f50acdb4de/go.mod h1:vG2ODqgJYFQobphBnhhmNv3TO+j/ZNYvN6FjUP/zkmA=
|
||||||
github.com/fumiama/ZeroBot-Plugin-Timer v0.0.0-20210609104507-70d574d5761d/go.mod h1:vG2ODqgJYFQobphBnhhmNv3TO+j/ZNYvN6FjUP/zkmA=
|
github.com/fumiama/ZeroBot-Plugin-Timer v0.0.0-20210609110318-3c8ef99e3c6c h1:M98iR1Em9EzfaduyhaO/I9Az3CVC0YS3pVbUihoPlM8=
|
||||||
|
github.com/fumiama/ZeroBot-Plugin-Timer v0.0.0-20210609110318-3c8ef99e3c6c/go.mod h1:/Tv1kgOdp76gvr1VoVmMG2Xu4c76vXngy6P8NFE4pA0=
|
||||||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
|
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
|
||||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
package manager
|
package manager
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"math/rand"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
timer "github.com/fumiama/ZeroBot-Plugin-Timer"
|
timer "github.com/fumiama/ZeroBot-Plugin-Timer"
|
||||||
zero "github.com/wdvxdr1123/ZeroBot"
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
@ -262,6 +265,20 @@ func init() { // 插件主体
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
|
// 随机点名
|
||||||
|
zero.OnFullMatchGroup([]string{"翻牌"}).SetBlock(true).SetPriority(40).
|
||||||
|
Handle(func(ctx *zero.Ctx) {
|
||||||
|
if ctx.Event.GroupID > 0 {
|
||||||
|
list := ctx.GetGroupMemberList(ctx.Event.GroupID)
|
||||||
|
rand.Seed(time.Now().UnixNano())
|
||||||
|
rand_index := fmt.Sprint(rand.Intn(int(list.Get("#").Int())))
|
||||||
|
random_card := list.Get(rand_index + ".card").String()
|
||||||
|
if random_card == "" {
|
||||||
|
random_card = list.Get(rand_index + ".nickname").String()
|
||||||
|
}
|
||||||
|
ctx.Send(random_card + ",就是你啦!")
|
||||||
|
}
|
||||||
|
})
|
||||||
// 入群欢迎
|
// 入群欢迎
|
||||||
zero.OnNotice().SetBlock(false).SetPriority(40).
|
zero.OnNotice().SetBlock(false).SetPriority(40).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
|
|||||||
@ -1,14 +1,29 @@
|
|||||||
package randimg
|
package randimg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/Yiwen-Chan/ZeroBot-Plugin/api/msgext"
|
"github.com/Yiwen-Chan/ZeroBot-Plugin/api/msgext"
|
||||||
zero "github.com/wdvxdr1123/ZeroBot"
|
zero "github.com/wdvxdr1123/ZeroBot"
|
||||||
)
|
)
|
||||||
|
|
||||||
var RANDOM_API_URL = "https://api.pixivweb.com/anime18r.php?return=img"
|
var (
|
||||||
var BLOCK_REQUEST = false
|
RANDOM_API_URL = "https://api.pixivweb.com/anime18r.php?return=img"
|
||||||
|
CLASSIFY_RANDOM_API_URL = "http://127.0.0.1:62002/dice?url=" + RANDOM_API_URL
|
||||||
|
VOTE_API_URL = "http://saki.fumiama.top/vote?uuid=零号&img=%s&class=%d"
|
||||||
|
BLOCK_REQUEST_CLASS = false
|
||||||
|
BLOCK_REQUEST = false
|
||||||
|
CACHE_IMG_FILE = "/tmp/setugt"
|
||||||
|
CACHE_URI = "file:///" + CACHE_IMG_FILE
|
||||||
|
msgofgrp = make(map[int64]int64)
|
||||||
|
dhashofmsg = make(map[int64]string)
|
||||||
|
)
|
||||||
|
|
||||||
func init() { // 插件主体
|
func init() { // 插件主体
|
||||||
zero.OnRegex(`^设置随机图片网址(.*)$`, zero.SuperUserPermission).SetBlock(true).SetPriority(20).
|
zero.OnRegex(`^设置随机图片网址(.*)$`, zero.SuperUserPermission).SetBlock(true).SetPriority(20).
|
||||||
@ -21,16 +36,101 @@ func init() { // 插件主体
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
// 随机图片
|
zero.OnRegex(`^设置评价图片网址(.*)$`, zero.SuperUserPermission).SetBlock(true).SetPriority(20).
|
||||||
zero.OnFullMatchGroup([]string{"随机图片"}).SetBlock(true).SetPriority(24).
|
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if BLOCK_REQUEST {
|
url := ctx.State["regex_matched"].([]string)[1]
|
||||||
ctx.Send("请稍后再试哦")
|
if !strings.HasPrefix(url, "http") {
|
||||||
|
ctx.Send("URL非法!")
|
||||||
} else {
|
} else {
|
||||||
BLOCK_REQUEST = true
|
CLASSIFY_RANDOM_API_URL = url + RANDOM_API_URL
|
||||||
ctx.Send(msgext.ImageNoCache(RANDOM_API_URL))
|
}
|
||||||
BLOCK_REQUEST = false
|
return
|
||||||
|
})
|
||||||
|
// 有保护的随机图片
|
||||||
|
if CLASSIFY_RANDOM_API_URL != "" {
|
||||||
|
zero.OnFullMatch("评价图片").SetBlock(true).SetPriority(24).
|
||||||
|
Handle(func(ctx *zero.Ctx) {
|
||||||
|
if ctx.Event.GroupID > 0 {
|
||||||
|
if BLOCK_REQUEST_CLASS {
|
||||||
|
ctx.Send("请稍后再试哦")
|
||||||
|
} else {
|
||||||
|
BLOCK_REQUEST_CLASS = true
|
||||||
|
resp, err := http.Get(CLASSIFY_RANDOM_API_URL)
|
||||||
|
if err != nil {
|
||||||
|
ctx.Send(fmt.Sprintf("ERROR: %v", err))
|
||||||
|
} else {
|
||||||
|
class, err1 := strconv.Atoi(resp.Header.Get("Class"))
|
||||||
|
dhash := resp.Header.Get("DHash")
|
||||||
|
if err1 != nil {
|
||||||
|
ctx.Send(fmt.Sprintf("ERROR: %v", err1))
|
||||||
|
} else {
|
||||||
|
defer resp.Body.Close()
|
||||||
|
// 写入文件
|
||||||
|
data, _ := ioutil.ReadAll(resp.Body)
|
||||||
|
f, _ := os.OpenFile(CACHE_IMG_FILE, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, 0644)
|
||||||
|
defer f.Close()
|
||||||
|
f.Write(data)
|
||||||
|
if class > 4 {
|
||||||
|
ctx.Send("太涩啦,不发了!")
|
||||||
|
if dhash != "" {
|
||||||
|
b14, err3 := url.QueryUnescape(dhash)
|
||||||
|
if err3 == nil {
|
||||||
|
ctx.Send("给你点提示哦:" + b14)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
last_message_id := ctx.Send(msgext.ImageNoCache(CACHE_URI))
|
||||||
|
last_group_id := ctx.Event.GroupID
|
||||||
|
msgofgrp[last_group_id] = last_message_id
|
||||||
|
dhashofmsg[last_message_id] = dhash
|
||||||
|
if class > 2 {
|
||||||
|
ctx.Send("我好啦!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BLOCK_REQUEST_CLASS = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
zero.OnFullMatch("不许好").SetBlock(true).SetPriority(24).
|
||||||
|
Handle(func(ctx *zero.Ctx) {
|
||||||
|
vote(ctx, 5)
|
||||||
|
})
|
||||||
|
zero.OnFullMatch("太涩了").SetBlock(true).SetPriority(24).
|
||||||
|
Handle(func(ctx *zero.Ctx) {
|
||||||
|
vote(ctx, 6)
|
||||||
|
})
|
||||||
|
// 直接随机图片
|
||||||
|
zero.OnFullMatch("随机图片").SetBlock(true).SetPriority(24).
|
||||||
|
Handle(func(ctx *zero.Ctx) {
|
||||||
|
if ctx.Event.GroupID > 0 {
|
||||||
|
if BLOCK_REQUEST {
|
||||||
|
ctx.Send("请稍后再试哦")
|
||||||
|
} else {
|
||||||
|
BLOCK_REQUEST = true
|
||||||
|
last_message_id := ctx.Send(msgext.ImageNoCache(RANDOM_API_URL))
|
||||||
|
last_group_id := ctx.Event.GroupID
|
||||||
|
msgofgrp[last_group_id] = last_message_id
|
||||||
|
BLOCK_REQUEST = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func vote(ctx *zero.Ctx, class int) {
|
||||||
|
msg, ok := msgofgrp[ctx.Event.GroupID]
|
||||||
|
if ok {
|
||||||
|
ctx.DeleteMessage(msg)
|
||||||
|
delete(msgofgrp, ctx.Event.GroupID)
|
||||||
|
dhash, ok2 := dhashofmsg[msg]
|
||||||
|
if ok2 {
|
||||||
|
http.Get(fmt.Sprintf(VOTE_API_URL, dhash, class))
|
||||||
|
delete(dhashofmsg, msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user