mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 13:59:39 +08:00
fix: imgfinder format
This commit is contained in:
parent
d6e352b3b4
commit
0c62d8dd07
@ -8,6 +8,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go/http3"
|
"github.com/lucas-clemente/quic-go/http3"
|
||||||
@ -58,6 +59,8 @@ type resultjson struct {
|
|||||||
} `json:"data"`
|
} `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var hrefre = regexp.MustCompile(`<a href=".*">`)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
control.Register("imgfinder", &ctrl.Options[*zero.Ctx]{
|
control.Register("imgfinder", &ctrl.Options[*zero.Ctx]{
|
||||||
DisableOnDefault: false,
|
DisableOnDefault: false,
|
||||||
@ -93,7 +96,7 @@ func init() {
|
|||||||
"ID: ", il.ID, "\n",
|
"ID: ", il.ID, "\n",
|
||||||
"画师: ", illust.UserName, " (", illust.UserId, ")", "\n",
|
"画师: ", illust.UserName, " (", illust.UserId, ")", "\n",
|
||||||
"分级:", il.Sanity, "\n",
|
"分级:", il.Sanity, "\n",
|
||||||
strings.ReplaceAll(il.Description, "<br />", "\n"),
|
hrefre.ReplaceAllString(strings.ReplaceAll(strings.ReplaceAll(il.Description, "<br />", "\n"), "</a>", ""), ""),
|
||||||
printtags(reflect.ValueOf(&il.Tags)),
|
printtags(reflect.ValueOf(&il.Tags)),
|
||||||
),
|
),
|
||||||
), ctxext.GetFirstMessageInForward(ctx))
|
), ctxext.GetFirstMessageInForward(ctx))
|
||||||
@ -127,20 +130,16 @@ func printtags(r reflect.Value) string {
|
|||||||
tags := r.Elem()
|
tags := r.Elem()
|
||||||
s := binary.BytesToString(binary.NewWriterF(func(w *binary.Writer) {
|
s := binary.BytesToString(binary.NewWriterF(func(w *binary.Writer) {
|
||||||
for i := 0; i < tags.Len(); i++ {
|
for i := 0; i < tags.Len(); i++ {
|
||||||
|
w.WriteByte('\n')
|
||||||
tag := tags.Index(i)
|
tag := tags.Index(i)
|
||||||
_ = w.WriteByte('#')
|
_ = w.WriteByte('#')
|
||||||
w.WriteString(tag.Field(0).String())
|
w.WriteString(tag.Field(0).String())
|
||||||
if !tag.Field(1).IsZero() {
|
if !tag.Field(1).IsZero() {
|
||||||
w.WriteString(" (")
|
w.WriteString(" (")
|
||||||
w.WriteString(tag.Field(1).String())
|
w.WriteString(tag.Field(1).String())
|
||||||
w.WriteString(")\n")
|
w.WriteString(")")
|
||||||
} else {
|
|
||||||
w.WriteByte('\n')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
if len(s) > 0 {
|
|
||||||
s = s[:len(s)-1]
|
|
||||||
}
|
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user