Skip to content

Commit

Permalink
fix: refactor after schema update
Browse files Browse the repository at this point in the history
  • Loading branch information
ernado committed Oct 30, 2023
1 parent 5d31d2b commit 04fed8f
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 15 deletions.
4 changes: 2 additions & 2 deletions examples/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require (
github.com/golang/snappy v0.0.4 // indirect
github.com/gotd/ige v0.2.2 // indirect
github.com/gotd/neo v0.1.5 // indirect
github.com/klauspost/compress v1.17.0 // indirect
github.com/klauspost/compress v1.17.2 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
Expand All @@ -44,7 +44,7 @@ require (
golang.org/x/exp v0.0.0-20230116083435-1de6713980de // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
nhooyr.io/websocket v1.8.7 // indirect
nhooyr.io/websocket v1.8.10 // indirect
rsc.io/qr v0.2.0 // indirect
)

Expand Down
2 changes: 2 additions & 0 deletions examples/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYs
github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/klauspost/compress v1.17.0 h1:Rnbp4K9EjcDuVuHtd0dgA4qNuv9yKDYKK1ulpJwgrqM=
github.com/klauspost/compress v1.17.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/klauspost/compress v1.17.2/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
Expand Down Expand Up @@ -404,5 +405,6 @@ honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
nhooyr.io/websocket v1.8.7 h1:usjR2uOr/zjjkVMy0lW+PPohFok7PCow5sDjLgX4P4g=
nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0=
nhooyr.io/websocket v1.8.10/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c=
rsc.io/qr v0.2.0 h1:6vBLea5/NRMVTz8V66gipeLycZMl/+UlFmk8DvqQ6WY=
rsc.io/qr v0.2.0/go.mod h1:IF+uZjkb9fqyeF/4tlBoynqmQxUoPfWEKh921coOuXs=
8 changes: 5 additions & 3 deletions telegram/message/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ type Builder struct {
// noForwards whether that sent message cannot be forwarded.
noForwards bool

// The message ID to which this message will reply to.
replyToMsgID int
// The reply target.
replyTo tg.InputReplyToClass
// Reply markup for sending bot buttons.
replyMarkup tg.ReplyMarkupClass
// Scheduled message date for scheduled messages.
Expand Down Expand Up @@ -73,7 +73,9 @@ func (b *Builder) Clear() *Builder {

// Reply sets message ID to reply.
func (b *Builder) Reply(id int) *Builder {
b.replyToMsgID = id
b.replyTo = &tg.InputReplyToMessage{
ReplyToMsgID: id,
}
return b
}

Expand Down
2 changes: 1 addition & 1 deletion telegram/message/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestBuilder(t *testing.T) {
a.True(b.noWebpage)

b = b.ReplyMsg(&tg.Message{ID: 10})
a.Equal(10, b.replyToMsgID)
a.Equal(10, b.replyTo.(*tg.InputReplyToMessage).ReplyToMsgID)

date := time.Now()
b = b.Schedule(date)
Expand Down
10 changes: 5 additions & 5 deletions telegram/message/draft.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ func (b *Builder) saveDraftRequest(
entities []tg.MessageEntityClass,
) *tg.MessagesSaveDraftRequest {
return &tg.MessagesSaveDraftRequest{
NoWebpage: b.noWebpage,
Peer: peer,
ReplyToMsgID: b.replyToMsgID,
Message: msg,
Entities: entities,
NoWebpage: b.noWebpage,
Peer: peer,
ReplyTo: b.replyTo,
Message: msg,
Entities: entities,
}
}

Expand Down
2 changes: 1 addition & 1 deletion telegram/message/inline.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (b *Builder) InlineResult(ctx context.Context, id string, queryID int64, hi
ClearDraft: b.clearDraft,
HideVia: hideVia,
Peer: p,
ReplyTo: &tg.InputReplyToMessage{ReplyToMsgID: b.replyToMsgID},
ReplyTo: b.replyTo,
QueryID: queryID,
ID: id,
ScheduleDate: b.scheduleDate,
Expand Down
4 changes: 2 additions & 2 deletions telegram/message/media.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (b *Builder) Album(ctx context.Context, media MultiMediaOption, album ...Mu
Background: b.background,
ClearDraft: b.clearDraft,
Peer: p,
ReplyTo: &tg.InputReplyToMessage{ReplyToMsgID: b.replyToMsgID},
ReplyTo: b.replyTo,
MultiMedia: mb,
ScheduleDate: b.scheduleDate,
})
Expand Down Expand Up @@ -112,7 +112,7 @@ func (b *Builder) Media(ctx context.Context, media MediaOption) (tg.UpdatesClass
Background: b.background,
ClearDraft: b.clearDraft,
Peer: p,
ReplyTo: &tg.InputReplyToMessage{ReplyToMsgID: b.replyToMsgID},
ReplyTo: b.replyTo,
Media: attachment.Media,
Message: attachment.Message,
ReplyMarkup: b.replyMarkup,
Expand Down
2 changes: 1 addition & 1 deletion telegram/message/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (b *Builder) sendRequest(
ClearDraft: b.clearDraft,
Noforwards: b.noForwards,
Peer: p,
ReplyTo: &tg.InputReplyToMessage{ReplyToMsgID: b.replyToMsgID},
ReplyTo: b.replyTo,
Message: msg,
RandomID: 0,
ReplyMarkup: b.replyMarkup,
Expand Down

0 comments on commit 04fed8f

Please sign in to comment.