Skip to content

Commit 7dbc592

Browse files
committed
fix: 修正多个地方的拼写错误,统一MessageChain类型
1 parent 099cb47 commit 7dbc592

13 files changed

Lines changed: 46 additions & 45 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func main() {
6767
}
6868
ctx.Log.Info("Private Message", "message", text.Text)
6969
msg.Reply(ctx, text.Text)
70-
var msgchain schema.MeaasgeChain
70+
var msgchain schema.MessageChain
7171
ctx.SendPvtMsg(ctx, adminuin, msgchain.Text("收到回复了吗?").Br().Face("4"))
7272
})
7373

bot.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func (h *EventHandler[T]) consume(ctx context.Context, emitter driver.Emitter, e
5757
return
5858
}
5959
}
60-
h.log.Debug("Handled", "types", event.Types, "time", event.Time, "selfId", event.SelfId, "fillter", handlerEnd.fillers.debug())
60+
h.log.Debug("Handled", "types", event.Types, "time", event.Time, "selfId", event.SelfId, "filter", handlerEnd.fillers.debug())
6161
nsxctx := NewContext(ctx, emitter, event.Time, event.SelfId, msg, event.Replyer)
6262
nsxctx.handlers = handlerEnd.handlers
6363
nsxctx.Next()

driver/driver.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ type EmitterMux interface {
2525
}
2626

2727
type Emitter interface {
28-
SendPvtMsg(ctx context.Context, userId int64, msg schema.MeaasgeChain) (*types.SendMsgRes, error)
29-
SendGrMsg(ctx context.Context, groupId int64, msg schema.MeaasgeChain) (*types.SendMsgRes, error)
28+
SendPvtMsg(ctx context.Context, userId int64, msg schema.MessageChain) (*types.SendMsgRes, error)
29+
SendGrMsg(ctx context.Context, groupId int64, msg schema.MessageChain) (*types.SendMsgRes, error)
3030
GetMsg(ctx context.Context, msgId int) (*types.GetMsgRes, error)
3131
DelMsg(ctx context.Context, msgId int) error
3232
GetLoginInfo(ctx context.Context) (*types.LoginInfo, error)

driver/http.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,14 +257,14 @@ func (e *EmitterHttp) Raw(ctx context.Context, action Action, params any) ([]byt
257257
return body, nil
258258
}
259259

260-
func (e *EmitterHttp) SendPvtMsg(ctx context.Context, userId int64, msg schema.MeaasgeChain) (*types.SendMsgRes, error) {
260+
func (e *EmitterHttp) SendPvtMsg(ctx context.Context, userId int64, msg schema.MessageChain) (*types.SendMsgRes, error) {
261261
return httpAction[types.SendPrivateMsgReq, types.SendMsgRes](ctx, e.client, e.token, e.url, ACTION_SEND_PRIVATE_MSG, types.SendPrivateMsgReq{
262262
UserId: userId,
263263
Message: msg,
264264
})
265265
}
266266

267-
func (e *EmitterHttp) SendGrMsg(ctx context.Context, groupId int64, msg schema.MeaasgeChain) (*types.SendMsgRes, error) {
267+
func (e *EmitterHttp) SendGrMsg(ctx context.Context, groupId int64, msg schema.MessageChain) (*types.SendMsgRes, error) {
268268
return httpAction[types.SendGrMsgReq, types.SendMsgRes](ctx, e.client, e.token, e.url, ACTION_SEND_GROUP_MSG, types.SendGrMsgReq{
269269
GroupId: groupId,
270270
Message: msg,
@@ -371,7 +371,7 @@ func httpAction[P any, R any](ctx context.Context, client *http.Client, token st
371371
return nil, err
372372
}
373373
if strings.EqualFold("failed", resp.Status) {
374-
return nil, fmt.Errorf("action %s failed, rawdata: %s, plase see onebot logs", action, string(body))
374+
return nil, fmt.Errorf("action %s failed, rawdata: %s, please see onebot logs", action, string(body))
375375
}
376376
return &resp.Data, nil
377377
}

driver/ws.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ func NewEmitterWS(selfId int64, conn *websocket.Conn, echo chan Response[json.Ra
356356
}
357357
}
358358

359-
func (e *EmitterWS) SendPvtMsg(ctx context.Context, userId int64, msg schema.MeaasgeChain) (*types.SendMsgRes, error) {
359+
func (e *EmitterWS) SendPvtMsg(ctx context.Context, userId int64, msg schema.MessageChain) (*types.SendMsgRes, error) {
360360
e.mu.Lock()
361361
echoId, err := wsAction(e.conn, ACTION_SEND_PRIVATE_MSG, types.SendPrivateMsgReq{
362362
UserId: userId,
@@ -370,7 +370,7 @@ func (e *EmitterWS) SendPvtMsg(ctx context.Context, userId int64, msg schema.Mea
370370
return wsWait[types.SendMsgRes](ctx, echoId, e.echo)
371371
}
372372

373-
func (e *EmitterWS) SendGrMsg(ctx context.Context, groupId int64, msg schema.MeaasgeChain) (*types.SendMsgRes, error) {
373+
func (e *EmitterWS) SendGrMsg(ctx context.Context, groupId int64, msg schema.MessageChain) (*types.SendMsgRes, error) {
374374
e.mu.Lock()
375375
echoId, err := wsAction(e.conn, ACTION_SEND_GROUP_MSG, types.SendGrMsgReq{
376376
GroupId: groupId,
@@ -543,20 +543,20 @@ func wsAction[P any](conn *websocket.Conn, action string, params P) (string, err
543543
})
544544
}
545545

546-
func wsWait[R any](ctx context.Context, echoId string, echocChan chan Response[json.RawMessage]) (*R, error) {
546+
func wsWait[R any](ctx context.Context, echoId string, echoChan chan Response[json.RawMessage]) (*R, error) {
547547
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
548548
defer cancel()
549549
for {
550550
select {
551551
case <-ctx.Done():
552552
return nil, ctx.Err()
553-
case echo := <-echocChan:
553+
case echo := <-echoChan:
554554
if !strings.EqualFold(echoId, echo.Echo) {
555-
echocChan <- echo
555+
echoChan <- echo
556556
continue
557557
}
558558
if strings.EqualFold("failed", echo.Status) {
559-
return nil, fmt.Errorf("action failed, rawdata: %x, plase see onebot logs", echo.Status)
559+
return nil, fmt.Errorf("action failed, rawdata: %x, please see onebot logs", echo.Status)
560560
}
561561
var res R
562562
if err := json.Unmarshal(echo.Data, &res); err != nil {

event/message.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import (
44
"encoding/json"
55
"errors"
66
"fmt"
7-
"github.com/nsxdevx/nsxbot/schema"
87
"iter"
8+
9+
"github.com/nsxdevx/nsxbot/schema"
910
)
1011

1112
var (
@@ -49,7 +50,7 @@ func (cm CommonMessage) Reply(replyer Replyer, text string) error {
4950
}
5051

5152
// yield the rawMessage by type
52-
func (cm CommonMessage) FliterType(Type string) iter.Seq[json.RawMessage] {
53+
func (cm CommonMessage) FilterType(Type string) iter.Seq[json.RawMessage] {
5354
return func(yield func(json.RawMessage) bool) {
5455
for _, msg := range cm.Messages {
5556
if msg.Type == Type {

event/notice.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
package event
22

33
type Notify struct {
4-
SubType string `json:"sub_type"`
5-
TargetId int64 `json:"target_id"`
6-
UserId int64 `json:"user_id"`
7-
GroupoupId int64 `json:"group_id"`
4+
SubType string `json:"sub_type"`
5+
TargetId int64 `json:"target_id"`
6+
UserId int64 `json:"user_id"`
7+
GroupId int64 `json:"group_id"`
88
}
99

1010
func (en Notify) Type() string {
1111
return "notice:notify"
1212
}
1313

1414
type GroupRecall struct {
15-
GroupoupId int64 `json:"group_id"`
15+
GroupId int64 `json:"group_id"`
1616
UserId int64 `json:"user_id"`
1717
OperatorId int64 `json:"operator_id"`
1818
MessageId int64 `json:"message_id"`
@@ -33,7 +33,7 @@ func (en PrivateRecall) Type() string {
3333

3434
type GroupDecrease struct {
3535
SubType string `json:"sub_type"` // leave/kick/kick_me
36-
GroupoupId int64 `json:"group_id"`
36+
GroupId int64 `json:"group_id"`
3737
UserId int64 `json:"user_id"`
3838
OperatorId int64 `json:"operator_id"`
3939
}
@@ -44,7 +44,7 @@ func (en GroupDecrease) Type() string {
4444

4545
type GroupIncrease struct {
4646
SubType string `json:"sub_type"` // approve/invite
47-
GroupoupId int64 `json:"group_id"`
47+
GroupId int64 `json:"group_id"`
4848
UserId int64 `json:"user_id"`
4949
OperatorId int64 `json:"operator_id"`
5050
}
@@ -54,19 +54,19 @@ func (en GroupIncrease) Type() string {
5454
}
5555

5656
type Admin struct {
57-
SubType string `json:"sub_type"` // set/unset
58-
GroupoupId int64 `json:"group_id"`
59-
UserId int64 `json:"user_id"`
57+
SubType string `json:"sub_type"` // set/unset
58+
GroupId int64 `json:"group_id"`
59+
UserId int64 `json:"user_id"`
6060
}
6161

6262
func (en Admin) Type() string {
6363
return "notice:group_admin"
6464
}
6565

6666
type GroupFile struct {
67-
GroupoupId int64 `json:"group_id"`
68-
UserId int64 `json:"user_id"`
69-
File File `json:"file"`
67+
GroupId int64 `json:"group_id"`
68+
UserId int64 `json:"user_id"`
69+
File File `json:"file"`
7070
}
7171

7272
type File struct {
@@ -82,7 +82,7 @@ func (en GroupFile) Type() string {
8282

8383
type GroupBan struct {
8484
SubType string `json:"sub_type"` // ban/lift_ban
85-
GroupoupId int64 `json:"group_id"`
85+
GroupId int64 `json:"group_id"`
8686
UserId int64 `json:"user_id"`
8787
Duration int64 `json:"duration"` // s
8888
OperatorId int64 `json:"operator_id"`

examples/conversion/conversion.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func handler(ctx0 *nsx.Context[event.GroupMessage], sation *nsx.Sation[event.Gro
3838
msg.Reply(ctx0, "使用/set 开始设置!")
3939
return
4040
}
41-
var msgchain schema.MeaasgeChain
41+
var msgchain schema.MessageChain
4242
ctx0.SendGrMsg(ctx0, msg.GroupId, msgchain.Text("请选择:").Br().Text("1:test1").Br().Text("2:test2"))
4343
//等待下一条消息
4444
ctx1, err := sation.Await(ctx0)

examples/many/many.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func main() {
3232
return
3333
}
3434
ctx.Log.Info("ping!")
35-
var msg schema.MeaasgeChain
35+
var msg schema.MessageChain
3636
ctx.SendGrMsg(ctx, groupId, msg.Text("在!这里是:"+info.NickName))
3737
}, filter.OnlyGroups(groupId), filter.OnlyGrUsers(adminuin))
3838
// Run

examples/meta/meta.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func main() {
2727
return
2828
}
2929
slog.Info("Private Message", "message", text.Text)
30-
var msg schema.MeaasgeChain
30+
var msg schema.MessageChain
3131
ctx.SendPvtMsg(ctx, adminuin, msg.Text("收到回复了吗?").Br().Text("2333333333"))
3232
})
3333

0 commit comments

Comments
 (0)