-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
MoYoez
committed
Mar 11, 2024
1 parent
8cb13fd
commit e2a086e
Showing
12 changed files
with
115 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "telegram-bot-api"] | ||
path = telegram-bot-api | ||
url = [email protected]:OvyFlash/telegram-bot-api.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package blocker | ||
|
||
import ( | ||
ctrl "github.com/FloatTech/zbpctrl" | ||
rei "github.com/fumiama/ReiBot" | ||
) | ||
|
||
var ( | ||
engine = rei.Register("blocker", &ctrl.Options[*rei.Ctx]{ | ||
DisableOnDefault: true, | ||
Help: "block", | ||
}) | ||
) | ||
|
||
func init() { | ||
engine.OnMessage().SetBlock(true).Handle(func(ctx *rei.Ctx) { | ||
|
||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,72 @@ | ||
// Package tracemoe 搜番 | ||
package tracemoe | ||
|
||
import ( | ||
"fmt" | ||
"strconv" | ||
|
||
rei "github.com/fumiama/ReiBot" | ||
tgba "github.com/go-telegram-bot-api/telegram-bot-api/v5" | ||
|
||
trmoe "github.com/fumiama/gotracemoe" | ||
|
||
"github.com/FloatTech/floatbox/binary" | ||
ctrl "github.com/FloatTech/zbpctrl" | ||
) | ||
|
||
var ( | ||
moe = trmoe.NewMoe("") | ||
) | ||
|
||
func init() { // 插件主体 | ||
engine := rei.Register("tracemoe", &ctrl.Options[*rei.Ctx]{ | ||
DisableOnDefault: false, | ||
Help: "tracemoe\n- 搜番 | 搜索番剧[图片]", | ||
}) | ||
// 以图搜图 | ||
engine.OnMessageCommand("tracemoe", rei.MustProvidePhoto("请发送一张图片", "获取图片失败!")).SetBlock(true). | ||
Handle(func(ctx *rei.Ctx) { | ||
// 开始搜索图片 | ||
_, _ = ctx.SendPlainMessage(false, "少女祈祷中...") | ||
ps := ctx.State["photos"].([]tgba.PhotoSize) | ||
pic := ps[len(ps)-1] | ||
picu, err := ctx.Caller.GetFileDirectURL(pic.FileID) | ||
if err != nil { | ||
_, _ = ctx.SendPlainMessage(false, "ERROR: ", err) | ||
return | ||
} | ||
if result, err := moe.Search(picu, true, true); err != nil { | ||
_, _ = ctx.SendPlainMessage(false, "ERROR: ", err) | ||
} else if len(result.Result) > 0 { | ||
r := result.Result[0] | ||
hint := "我有把握是这个!" | ||
if r.Similarity < 80 { | ||
hint = "大概是这个?" | ||
} | ||
mf := int(r.From / 60) | ||
mt := int(r.To / 60) | ||
sf := r.From - float32(mf*60) | ||
st := r.To - float32(mt*60) | ||
_, _ = ctx.Caller.Send(&tgba.PhotoConfig{ | ||
BaseFile: tgba.BaseFile{ | ||
BaseChat: tgba.BaseChat{ | ||
ChatID: ctx.Message.Chat.ID, | ||
ReplyToMessageID: ctx.Event.Value.(*tgba.Message).MessageID, | ||
}, | ||
File: tgba.FileURL(r.Image), | ||
}, | ||
Caption: binary.BytesToString(binary.NewWriterF(func(m *binary.Writer) { | ||
m.WriteString(hint) | ||
_ = m.WriteByte('\n') | ||
m.WriteString("番剧名: ") | ||
m.WriteString(r.Anilist.Title.Native) | ||
_ = m.WriteByte('\n') | ||
m.WriteString("话数: ") | ||
m.WriteString(strconv.Itoa(r.Episode)) | ||
_ = m.WriteByte('\n') | ||
m.WriteString(fmt.Sprint("时间:", mf, ":", sf, "-", mt, ":", st)) | ||
})), | ||
}) | ||
} | ||
}) | ||
} | ||
// Package tracemoe 搜番 | ||
package tracemoe | ||
|
||
import ( | ||
"fmt" | ||
"strconv" | ||
|
||
rei "github.com/fumiama/ReiBot" | ||
tgba "github.com/go-telegram-bot-api/telegram-bot-api/v5" | ||
|
||
trmoe "github.com/fumiama/gotracemoe" | ||
|
||
"github.com/FloatTech/floatbox/binary" | ||
ctrl "github.com/FloatTech/zbpctrl" | ||
) | ||
|
||
var ( | ||
moe = trmoe.NewMoe("") | ||
) | ||
|
||
func init() { // 插件主体 | ||
engine := rei.Register("tracemoe", &ctrl.Options[*rei.Ctx]{ | ||
DisableOnDefault: false, | ||
Help: "tracemoe\n- 搜番 | 搜索番剧[图片]", | ||
}) | ||
// 以图搜图 | ||
engine.OnMessageCommand("tracemoe", rei.MustProvidePhoto("请发送一张图片", "获取图片失败!")).SetBlock(true). | ||
Handle(func(ctx *rei.Ctx) { | ||
// 开始搜索图片 | ||
_, _ = ctx.SendPlainMessage(false, "少女祈祷中...") | ||
ps := ctx.State["photos"].([]tgba.PhotoSize) | ||
pic := ps[len(ps)-1] | ||
picu, err := ctx.Caller.GetFileDirectURL(pic.FileID) | ||
if err != nil { | ||
_, _ = ctx.SendPlainMessage(false, "ERROR: ", err) | ||
return | ||
} | ||
if result, err := moe.Search(picu, true, true); err != nil { | ||
_, _ = ctx.SendPlainMessage(false, "ERROR: ", err) | ||
} else if len(result.Result) > 0 { | ||
r := result.Result[0] | ||
hint := "我有把握是这个!" | ||
if r.Similarity < 80 { | ||
hint = "大概是这个?" | ||
} | ||
mf := int(r.From / 60) | ||
mt := int(r.To / 60) | ||
sf := r.From - float32(mf*60) | ||
st := r.To - float32(mt*60) | ||
_, _ = ctx.Caller.Send(&tgba.PhotoConfig{ | ||
BaseFile: tgba.BaseFile{ | ||
BaseChat: tgba.BaseChat{ | ||
ChatConfig: tgba.ChatConfig{ChatID: ctx.Message.Chat.ID}, | ||
ReplyParameters: tgba.ReplyParameters{MessageID: ctx.Event.Value.(*tgba.Message).MessageID}, | ||
}, | ||
File: tgba.FileURL(r.Image), | ||
}, | ||
Caption: binary.BytesToString(binary.NewWriterF(func(m *binary.Writer) { | ||
m.WriteString(hint) | ||
_ = m.WriteByte('\n') | ||
m.WriteString("番剧名: ") | ||
m.WriteString(r.Anilist.Title.Native) | ||
_ = m.WriteByte('\n') | ||
m.WriteString("话数: ") | ||
m.WriteString(strconv.Itoa(r.Episode)) | ||
_ = m.WriteByte('\n') | ||
m.WriteString(fmt.Sprint("时间:", mf, ":", sf, "-", mt, ":", st)) | ||
})), | ||
}) | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule telegram-bot-api
added at
eced2e
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters