Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lianhong2758 committed Nov 20, 2024
1 parent db1bc95 commit ea71ce2
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 24 deletions.
3 changes: 2 additions & 1 deletion adapter/ob11/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func (c *Config) process(e *Event) {
// 消息事件
case "message", "message_sent":
c.preprocessMessageEvent(e)
mess := Message(e.Message).CQString()
mess := e.Message.ExtractPlainText()
log.Debug("Message: ", mess)
switch e.MessageType {
// 私聊信息
Expand Down Expand Up @@ -148,6 +148,7 @@ func (c *Config) preprocessMessageEvent(e *Event) {
if e.Message[0].Type == "at" && tool.Int64ToString(e.SelfID) == e.Message[0].Data["id"] {
e.IsToMe = true
e.Message = e.Message[1:]
return
}
if e.Message[0].Type == "text" {
e.Message[0].Data["text"] = strings.TrimLeft(e.Message[0].Data["text"], " ") // Trim!
Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ require (
github.com/fumiama/go-simple-protobuf v0.1.0 // indirect
github.com/fumiama/gofastTEA v0.0.10 // indirect
github.com/fumiama/imgsz v0.0.2 // indirect
github.com/fumiama/jieba v0.0.0-20221203025406-36c17a10b565 // indirect
github.com/fumiama/terasu v0.0.0-20241027183601-987ab91031ce // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
Expand All @@ -45,7 +44,6 @@ require (
github.com/remyoudompheng/bigfft v0.0.0-20220927061507-ef77025ab5aa // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/wdvxdr1123/ZeroBot v1.7.5-0.20231009162356-57f71b9f5258 // indirect
golang.org/x/image v0.3.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/text v0.15.0 // indirect
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ github.com/fumiama/gofastTEA v0.0.10 h1:JJJ+brWD4kie+mmK2TkspDXKzqq0IjXm89aGYfoG
github.com/fumiama/gofastTEA v0.0.10/go.mod h1:RIdbYZyB4MbH6ZBlPymRaXn3cD6SedlCu5W/HHfMPBk=
github.com/fumiama/imgsz v0.0.2 h1:fAkC0FnIscdKOXwAxlyw3EUba5NzxZdSxGaq3Uyfxak=
github.com/fumiama/imgsz v0.0.2/go.mod h1:dR71mI3I2O5u6+PCpd47M9TZptzP+39tRBcbdIkoqM4=
github.com/fumiama/jieba v0.0.0-20221203025406-36c17a10b565 h1:sQuR2+N5HurnvsZhiKdEg+Ig354TaqgCQRxd/0KgIOQ=
github.com/fumiama/jieba v0.0.0-20221203025406-36c17a10b565/go.mod h1:UUEvyLTJ7yoOA/viKG4wEis4ERydM7+Ny6gZUWgkS80=
github.com/fumiama/sqlite3 v1.20.0-with-win386 h1:ZR1AXGBEtkfq9GAXehOVcwn+aaCG8itrkgEsz4ggx5k=
github.com/fumiama/sqlite3 v1.20.0-with-win386/go.mod h1:Os58MHwYCcYZCy2PGChBrQtBAw5/LS1ZZOkfc+C/I7s=
github.com/fumiama/terasu v0.0.0-20241027183601-987ab91031ce h1:T6iDDU16rFyxV/FwfJJR6qcgkIlXJEIFlUTSmTD1h6s=
Expand Down Expand Up @@ -104,8 +102,6 @@ github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JT
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/wdvxdr1123/ZeroBot v1.7.5-0.20231009162356-57f71b9f5258 h1:Q0dKoj9SHrR8WjjlcX+eyYBjQKqBn/x1pdJJO1IIOxQ=
github.com/wdvxdr1123/ZeroBot v1.7.5-0.20231009162356-57f71b9f5258/go.mod h1:y29UIOy0RD3P+0meDNIWRhcJF3jtWPN9xP9hgt/AJAU=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
Expand Down
16 changes: 8 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

//Bot注册
//_"github.com/lianhong2758/RosmBot-MUL/server/mys/init"
//_ "github.com/lianhong2758/RosmBot-MUL/server/qq/init"
//"github.com/lianhong2758/RosmBot-MUL/server/ob11"
//_"github.com/lianhong2758/RosmBot-MUL/adapter/mys/init"
//_ "github.com/lianhong2758/RosmBot-MUL/adapter/qq/init"
//"github.com/lianhong2758/RosmBot-MUL/adapter/ob11"
_ "github.com/lianhong2758/RosmBot-MUL/adapter/ob11/init"
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand All @@ -19,14 +19,14 @@ import (
_ "github.com/lianhong2758/RosmBot-MUL/plugins/fhl"
_ "github.com/lianhong2758/RosmBot-MUL/plugins/gscore"
_ "github.com/lianhong2758/RosmBot-MUL/plugins/lc"
// _ "github.com/lianhong2758/RosmBot-MUL/plugins/liuyao"
// _ "github.com/lianhong2758/RosmBot-MUL/plugins/phi"
_ "github.com/lianhong2758/RosmBot-MUL/plugins/score"
// _ "github.com/lianhong2758/RosmBot-MUL/plugins/tarot"
_ "github.com/lianhong2758/RosmBot-MUL/plugins/liuyao"
_ "github.com/lianhong2758/RosmBot-MUL/plugins/onplugin"
_ "github.com/lianhong2758/RosmBot-MUL/plugins/phi"
_ "github.com/lianhong2758/RosmBot-MUL/plugins/score"
_ "github.com/lianhong2758/RosmBot-MUL/plugins/tarot"
_ "github.com/lianhong2758/RosmBot-MUL/plugins/test"
_ "github.com/lianhong2758/RosmBot-MUL/plugins/time"
//_ "github.com/lianhong2758/RosmBot-MUL/plugins/wife"
_ "github.com/lianhong2758/RosmBot-MUL/plugins/wife"
_ "github.com/lianhong2758/RosmBot-MUL/plugins/yujn"
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
Expand Down
10 changes: 5 additions & 5 deletions plugins/test/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ func init() {
Name: "撤回消息",
Help: "- 撤回",
})
en.OnRex(`^\[CQ:reply,id=(-?[0-9]+)\].*`).MUL("ob11").SetRule(rosm.OnlyMaster(), rosm.KeyWords("撤回")).Handle(func(ctx *rosm.Ctx) {
ob11.DeleteMessage(ctx, ctx.Being.ResultWord[1])
en.OnWord("撤回").MUL(ob11.BotType).SetRule(rosm.OnlyMaster(), rosm.OnlyReply()).Handle(func(ctx *rosm.Ctx) {
ob11.DeleteMessage(ctx, ctx.State["reply"].(string))
ob11.DeleteMessage(ctx, ctx.Being.MsgID)
logrus.Info("[delete]撤回消息", ctx.Being.ResultWord[1], " - ", ctx.Being.MsgID[0])
logrus.Info("[delete]撤回消息", ctx.State["reply"].(string), " - ", ctx.Being.MsgID)
})
//跟随撤回
en.OnNoticeWithType(rosm.FriendRecall, rosm.GroupRecall).MUL("ob11").Handle(func(ctx *rosm.Ctx) {
id := ctx.State["event"].(*ob11.Event).MessageID
en.OnNoticeWithType(rosm.FriendRecall, rosm.GroupRecall).MUL(ob11.BotType).Handle(func(ctx *rosm.Ctx) {
id := ctx.Being.MsgID
if sids := rosm.GetMessageIDFormMapCache(id); len(sids) > 0 {
for _, sid := range sids {
tool.WaitWhile()
Expand Down
8 changes: 4 additions & 4 deletions rosm/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func (p *PluginData) On(types string) *Matcher {
priority: 5,
temp: false,
PluginNode: p,
rules: []Rule{GetBotIsOnInThis()},
}
EventMatch[types] = append(EventMatch[types], m)
p.Matchers = append(p.Matchers, m)
Expand Down Expand Up @@ -183,8 +184,7 @@ func (m *Matcher) MUL(name ...string) *Matcher {
func (m *Matcher) Handle(h Handler) {
//加载默认的rule
//全局bot启动+插件单独启用
m.rules = append([]func(ctx *Ctx) bool{GetBotIsOnInThis()}, m.rules...)
m.rules = append(m.rules, m.mulPass(), MatcherIsOn(m))
m.SetRule(m.mulRule(), MatcherIsOn(m))
//执行hander
m.handler = h
}
Expand All @@ -200,7 +200,7 @@ func (m *Matcher) SetRule(r ...Rule) *Matcher {
return m
}

func (m *Matcher) mulPass() Rule {
func (m *Matcher) mulRule() Rule {
return func(ctx *Ctx) bool {
if len(m.mul) == 0 {
return true
Expand All @@ -217,7 +217,7 @@ func (m *Matcher) mulPass() Rule {
// Limit 限速器
// postfn 当请求被拒绝时的操作
func (m *Matcher) Limit(limiterfn func(*Ctx) *rate.Limiter, postfn ...func(*Ctx)) *Matcher {
m.rules = append(m.rules, func(ctx *Ctx) bool {
m.SetRule(func(ctx *Ctx) bool {
if limiterfn(ctx).Acquire() {
return true
}
Expand Down

0 comments on commit ea71ce2

Please sign in to comment.