mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-20 06:20:08 +08:00
增加撤回
This commit is contained in:
parent
d9221585e1
commit
5d490be15b
@ -8,17 +8,22 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"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 (
|
var (
|
||||||
RANDOM_API_URL = "https://api.pixivweb.com/anime18r.php?return=img"
|
RANDOM_API_URL = "https://api.pixivweb.com/anime18r.php?return=img"
|
||||||
CLASSIFY_RANDOM_API_URL string = "http://saki.fumiama.top:62002/dice?url=" + RANDOM_API_URL
|
CLASSIFY_RANDOM_API_URL = "http://saki.fumiama.top:62002/dice?url=" + RANDOM_API_URL
|
||||||
BLOCK_REQUEST = false
|
VOTE_API_URL = "http://saki.fumiama.top/vote?uuid=零号&img=%s&class=%d"
|
||||||
CACHE_IMG_FILE = "/tmp/setugt"
|
BLOCK_REQUEST = false
|
||||||
CACHE_URI = "file:///" + CACHE_IMG_FILE
|
CACHE_IMG_FILE = "/tmp/setugt"
|
||||||
|
CACHE_URI = "file:///" + CACHE_IMG_FILE
|
||||||
|
last_message_id int64
|
||||||
|
last_dhash string
|
||||||
|
last_visit = 0
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() { // 插件主体
|
func init() { // 插件主体
|
||||||
@ -36,9 +41,10 @@ func init() { // 插件主体
|
|||||||
zero.OnFullMatch("随机图片").SetBlock(true).SetPriority(24).
|
zero.OnFullMatch("随机图片").SetBlock(true).SetPriority(24).
|
||||||
Handle(func(ctx *zero.Ctx) {
|
Handle(func(ctx *zero.Ctx) {
|
||||||
if ctx.Event.GroupID > 0 {
|
if ctx.Event.GroupID > 0 {
|
||||||
if BLOCK_REQUEST {
|
if BLOCK_REQUEST && time.Now().Unix()-last_message_id < 30 {
|
||||||
ctx.Send("请稍后再试哦")
|
ctx.Send("请稍后再试哦")
|
||||||
} else {
|
} else {
|
||||||
|
last_message_id = time.Now().Unix()
|
||||||
BLOCK_REQUEST = true
|
BLOCK_REQUEST = true
|
||||||
if CLASSIFY_RANDOM_API_URL != "" {
|
if CLASSIFY_RANDOM_API_URL != "" {
|
||||||
resp, err := http.Get(CLASSIFY_RANDOM_API_URL)
|
resp, err := http.Get(CLASSIFY_RANDOM_API_URL)
|
||||||
@ -46,6 +52,7 @@ func init() { // 插件主体
|
|||||||
ctx.Send(fmt.Sprintf("ERROR: %v", err))
|
ctx.Send(fmt.Sprintf("ERROR: %v", err))
|
||||||
} else {
|
} else {
|
||||||
class, err1 := strconv.Atoi(resp.Header.Get("Class"))
|
class, err1 := strconv.Atoi(resp.Header.Get("Class"))
|
||||||
|
dhash := resp.Header.Get("DHash")
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
ctx.Send(fmt.Sprintf("ERROR: %v", err1))
|
ctx.Send(fmt.Sprintf("ERROR: %v", err1))
|
||||||
} else {
|
} else {
|
||||||
@ -57,7 +64,6 @@ func init() { // 插件主体
|
|||||||
f.Write(data)
|
f.Write(data)
|
||||||
if class > 4 {
|
if class > 4 {
|
||||||
ctx.Send("太涩啦,不发了!")
|
ctx.Send("太涩啦,不发了!")
|
||||||
dhash := resp.Header.Get("DHash")
|
|
||||||
if dhash != "" {
|
if dhash != "" {
|
||||||
b14, err3 := url.QueryUnescape(dhash)
|
b14, err3 := url.QueryUnescape(dhash)
|
||||||
if err3 == nil {
|
if err3 == nil {
|
||||||
@ -65,7 +71,8 @@ func init() { // 插件主体
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ctx.Send(msgext.ImageNoCache(CACHE_URI))
|
last_message_id = ctx.Send(msgext.ImageNoCache(CACHE_URI))
|
||||||
|
last_dhash = dhash
|
||||||
if class > 2 {
|
if class > 2 {
|
||||||
ctx.Send("我好啦!")
|
ctx.Send("我好啦!")
|
||||||
}
|
}
|
||||||
@ -80,4 +87,24 @@ func init() { // 插件主体
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
|
zero.OnFullMatch("不许好").SetBlock(true).SetPriority(24).
|
||||||
|
Handle(func(ctx *zero.Ctx) {
|
||||||
|
if last_message_id != 0 {
|
||||||
|
ctx.DeleteMessage(last_message_id)
|
||||||
|
last_message_id = 0
|
||||||
|
vote(5)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
zero.OnFullMatch("太涩了").SetBlock(true).SetPriority(24).
|
||||||
|
Handle(func(ctx *zero.Ctx) {
|
||||||
|
if last_message_id != 0 {
|
||||||
|
ctx.DeleteMessage(last_message_id)
|
||||||
|
last_message_id = 0
|
||||||
|
vote(6)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func vote(class int) {
|
||||||
|
http.Get(fmt.Sprintf(VOTE_API_URL, last_dhash, class))
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user