mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-19 22:00:11 +08:00
替换CustomNode为ctxext的封装
This commit is contained in:
parent
4781bc8eb7
commit
6262aab6bd
2
data
2
data
@ -1 +1 @@
|
||||
Subproject commit 7ba7dfb0f39c9c8bedfd494d2014bdb937e7509d
|
||||
Subproject commit 58c61018e84eebd7626b09d252f540346ffb68ae
|
||||
4
go.mod
4
go.mod
@ -3,9 +3,9 @@ module github.com/FloatTech/ZeroBot-Plugin
|
||||
go 1.17
|
||||
|
||||
require (
|
||||
github.com/FloatTech/AnimeAPI v1.3.1-0.20220227112758-da30b39dd7a7
|
||||
github.com/FloatTech/AnimeAPI v1.3.1-0.20220301092207-292c2a0d9971
|
||||
github.com/FloatTech/sqlite v0.2.0
|
||||
github.com/FloatTech/zbputils v1.3.1-0.20220227112438-2ccf42cc85d3
|
||||
github.com/FloatTech/zbputils v1.3.1-0.20220301091616-3ace908b3d25
|
||||
github.com/antchfx/htmlquery v1.2.4
|
||||
github.com/corona10/goimagehash v1.0.3
|
||||
github.com/fogleman/gg v1.3.0
|
||||
|
||||
8
go.sum
8
go.sum
@ -1,10 +1,10 @@
|
||||
github.com/FloatTech/AnimeAPI v1.3.1-0.20220227112758-da30b39dd7a7 h1:JOmelUrxBef/Sg/15PgkBC3IV4BpORQwiSWfqV1nCD0=
|
||||
github.com/FloatTech/AnimeAPI v1.3.1-0.20220227112758-da30b39dd7a7/go.mod h1:AuFa+9NWdJujJc2PvCoO2NqLOwwwFXKy69X0zexsZS0=
|
||||
github.com/FloatTech/AnimeAPI v1.3.1-0.20220301092207-292c2a0d9971 h1:IVYw7zzffBYPSLGcSf7kv0P4OOfFRYrl6+Fyiv3ZQRY=
|
||||
github.com/FloatTech/AnimeAPI v1.3.1-0.20220301092207-292c2a0d9971/go.mod h1:yAmOcbDWxEZYQyLY919C5A/YJ4KX+aaQkpDaVQDVtlQ=
|
||||
github.com/FloatTech/bot-manager v1.0.0/go.mod h1:8YYRJ16oroGHQGD2En0oVnmcKJkxR9O/jd5BPSfWfOQ=
|
||||
github.com/FloatTech/sqlite v0.2.0 h1:x3uls/hExXH1+bbaNLkvilce6ATtWlDx4IqoxBW/bv8=
|
||||
github.com/FloatTech/sqlite v0.2.0/go.mod h1:xIDWIvpOFl8AXmZm0FC8t3PZjiR6ZutytCpBv2EWCns=
|
||||
github.com/FloatTech/zbputils v1.3.1-0.20220227112438-2ccf42cc85d3 h1:BA9mbIE2D2hhZnGaFjgIbiUrwG4h6VjVYf4UoDnBVn8=
|
||||
github.com/FloatTech/zbputils v1.3.1-0.20220227112438-2ccf42cc85d3/go.mod h1:NXv73hWyC4Q4S4wg01DEwLzznSHSmde0o03PnsS1DtY=
|
||||
github.com/FloatTech/zbputils v1.3.1-0.20220301091616-3ace908b3d25 h1:n88oTj/5QpJuA0NkUCbYvYlka7vwtke+FvaU3VrEtjg=
|
||||
github.com/FloatTech/zbputils v1.3.1-0.20220301091616-3ace908b3d25/go.mod h1:NXv73hWyC4Q4S4wg01DEwLzznSHSmde0o03PnsS1DtY=
|
||||
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
|
||||
github.com/RomiChan/websocket v1.4.3-0.20220123145318-307a86b127bc h1:AAx50/fb/xS4lvsdQg+bFbGvqSDhyV1MF+p2PLCamZ0=
|
||||
github.com/RomiChan/websocket v1.4.3-0.20220123145318-307a86b127bc/go.mod h1:OMmITAib6POA37xCichWM0aRnoVpSMZO1rB/G01wrr0=
|
||||
|
||||
2
main.go
2
main.go
@ -161,7 +161,7 @@ var (
|
||||
url *string
|
||||
adana *string
|
||||
prefix *string
|
||||
reg = registry.NewRegReader("reilia.fumiama.top:32664", "fumiama")
|
||||
reg = registry.NewRegReader("reilia.westeurope.cloudapp.azure.com:32664", "fumiama")
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@ -32,23 +32,11 @@ func init() {
|
||||
if err != nil {
|
||||
log.Println("err为:", err)
|
||||
}
|
||||
var m message.Message
|
||||
|
||||
text := gjson.Get(helper.BytesToString(data), "data.Title").String()
|
||||
m = append(m,
|
||||
message.CustomNode(
|
||||
ctx.Event.Sender.NickName,
|
||||
ctx.Event.UserID,
|
||||
text,
|
||||
))
|
||||
m := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Text(text))}
|
||||
gjson.Get(helper.BytesToString(data), "data.data").ForEach(func(_, value gjson.Result) bool {
|
||||
m = append(m,
|
||||
message.CustomNode(
|
||||
ctx.Event.Sender.NickName,
|
||||
ctx.Event.UserID,
|
||||
[]message.MessageSegment{
|
||||
message.Image(value.String()),
|
||||
}),
|
||||
)
|
||||
m = append(m, ctxext.FakeSenderForwardNode(ctx, message.Image(value.String())))
|
||||
return true
|
||||
})
|
||||
|
||||
|
||||
@ -77,14 +77,7 @@ func init() {
|
||||
continue
|
||||
}
|
||||
}
|
||||
sk = append(
|
||||
sk,
|
||||
message.CustomNode(
|
||||
zero.BotConfig.NickName[0],
|
||||
ctx.Event.SelfID,
|
||||
[]message.MessageSegment{message.Image("file:///" + cachefile)}, // 图片
|
||||
),
|
||||
)
|
||||
sk = append(sk, ctxext.FakeSenderForwardNode(ctx, message.Image("file:///"+cachefile)))
|
||||
}
|
||||
if id := ctx.SendGroupForwardMessage(
|
||||
ctx.Event.GroupID,
|
||||
|
||||
@ -8,7 +8,7 @@ import (
|
||||
reg "github.com/fumiama/go-registry"
|
||||
)
|
||||
|
||||
var sr = reg.NewRegedit("reilia.fumiama.top:32664", "fumiama", "--")
|
||||
var sr = reg.NewRegedit("reilia.westeurope.cloudapp.azure.com:32664", "fumiama", "--")
|
||||
|
||||
func TestGetHoliday(t *testing.T) {
|
||||
registry.Connect()
|
||||
|
||||
@ -21,7 +21,7 @@ func NewHoliday(name string, dur, year int, month time.Month, day int) *Holiday
|
||||
return &Holiday{name: name, date: time.Date(year, month, day, 0, 0, 0, 0, time.Local), dur: time.Duration(dur) * time.Hour * 24}
|
||||
}
|
||||
|
||||
var registry = reg.NewRegReader("reilia.fumiama.top:32664", "fumiama")
|
||||
var registry = reg.NewRegReader("reilia.westeurope.cloudapp.azure.com:32664", "fumiama")
|
||||
|
||||
// GetHoliday 从 reg 服务器获取节日
|
||||
func GetHoliday(name string) *Holiday {
|
||||
|
||||
@ -129,19 +129,9 @@ func init() { // 插件主体
|
||||
ctx.SendChain(message.Text("ERROR: ", err))
|
||||
continue
|
||||
} else {
|
||||
var msg message.Message = []message.MessageSegment{
|
||||
message.CustomNode(
|
||||
ctx.Event.Sender.Name(),
|
||||
ctx.Event.UserID,
|
||||
"ascii2d搜图结果",
|
||||
)}
|
||||
msg := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Text("ascii2d搜图结果"))}
|
||||
for i := 0; i < len(result) && i < 5; i++ {
|
||||
msg = append(
|
||||
msg,
|
||||
message.CustomNode(
|
||||
ctx.Event.Sender.Name(),
|
||||
ctx.Event.UserID,
|
||||
[]message.MessageSegment{
|
||||
msg = append(msg, ctxext.FakeSenderForwardNode(ctx,
|
||||
message.Image(result[i].Thumb),
|
||||
message.Text(fmt.Sprintf(
|
||||
"标题:%s\n图源:%s\n画师:%s\n画师链接:%s\n图片链接:%s",
|
||||
@ -150,9 +140,7 @@ func init() { // 插件主体
|
||||
result[i].AuthNm,
|
||||
result[i].Author,
|
||||
result[i].Link,
|
||||
)),
|
||||
},
|
||||
),
|
||||
))),
|
||||
)
|
||||
}
|
||||
if id := ctx.SendGroupForwardMessage(
|
||||
|
||||
@ -64,29 +64,12 @@ func sendYmgal(y ymgal, ctx *zero.Ctx) {
|
||||
ctx.SendChain(message.Text(zero.BotConfig.NickName[0] + "暂时没有这样的图呢"))
|
||||
return
|
||||
}
|
||||
m := message.Message{
|
||||
message.CustomNode(
|
||||
ctx.Event.Sender.NickName,
|
||||
ctx.Event.UserID,
|
||||
y.Title,
|
||||
)}
|
||||
m := message.Message{ctxext.FakeSenderForwardNode(ctx, message.Text(y.Title))}
|
||||
if y.PictureDescription != "" {
|
||||
m = append(m,
|
||||
message.CustomNode(
|
||||
ctx.Event.Sender.NickName,
|
||||
ctx.Event.UserID,
|
||||
y.PictureDescription,
|
||||
))
|
||||
m = append(m, ctxext.FakeSenderForwardNode(ctx, message.Text(y.PictureDescription)))
|
||||
}
|
||||
for _, v := range strings.Split(y.PictureList, ",") {
|
||||
m = append(m,
|
||||
message.CustomNode(
|
||||
ctx.Event.Sender.NickName,
|
||||
ctx.Event.UserID,
|
||||
[]message.MessageSegment{
|
||||
message.Image(v),
|
||||
}),
|
||||
)
|
||||
m = append(m, ctxext.FakeSenderForwardNode(ctx, message.Image(v)))
|
||||
}
|
||||
if id := ctx.SendGroupForwardMessage(
|
||||
ctx.Event.GroupID,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user