-
-
Notifications
You must be signed in to change notification settings - Fork 135
/
request.go
63 lines (50 loc) · 1.53 KB
/
request.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package message
import (
"context"
"github.com/go-faster/errors"
"github.com/gotd/td/tg"
)
// RequestBuilder is an intermediate builder to make different RPC calls using Sender.
type RequestBuilder struct {
Builder
}
// Reaction sends reaction for given message.
func (b *RequestBuilder) Reaction(ctx context.Context, msgID int, reaction ...tg.ReactionClass) (tg.UpdatesClass, error) {
p, err := b.peer(ctx)
if err != nil {
return nil, errors.Wrap(err, "peer")
}
upd, err := b.sender.sendReaction(ctx, p, msgID, reaction...)
if err != nil {
return nil, errors.Wrap(err, "send reaction")
}
return upd, nil
}
// ScreenshotNotify sends notification about screenshot.
// Parameter msgID is an ID of message that was screenshotted, can be 0.
func (b *RequestBuilder) ScreenshotNotify(ctx context.Context, msgID int) (tg.UpdatesClass, error) {
p, err := b.peer(ctx)
if err != nil {
return nil, errors.Wrap(err, "peer")
}
upd, err := b.sender.sendScreenshotNotification(ctx, &tg.MessagesSendScreenshotNotificationRequest{
Peer: p,
ReplyTo: &tg.InputReplyToMessage{ReplyToMsgID: msgID},
})
if err != nil {
return nil, errors.Wrap(err, "send screenshot notify")
}
return upd, nil
}
// PeerSettings returns peer settings.
func (b *RequestBuilder) PeerSettings(ctx context.Context) (*tg.PeerSettings, error) {
p, err := b.peer(ctx)
if err != nil {
return nil, errors.Wrap(err, "peer")
}
r, err := b.sender.getPeerSettings(ctx, p)
if err != nil {
return nil, errors.Wrap(err, "get peer settings")
}
return &r.Settings, nil
}