-
-
Notifications
You must be signed in to change notification settings - Fork 126
/
types.go
50 lines (39 loc) · 1.2 KB
/
types.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
package message
import (
"context"
"github.com/gotd/td/tg"
)
type multiMediaBuilder struct {
sender *Sender
peer tg.InputPeerClass
// Attached media.
media []tg.InputSingleMedia
}
// MediaOption is an option for sending media attachments.
type MediaOption interface {
apply(ctx context.Context, b *multiMediaBuilder) error
}
var _ MediaOption = mediaOptionFunc(nil)
// mediaOptionFunc is a function adapter for MediaOption.
type mediaOptionFunc func(ctx context.Context, b *multiMediaBuilder) error
// apply implements MediaOption.
func (m mediaOptionFunc) apply(ctx context.Context, b *multiMediaBuilder) error {
return m(ctx, b)
}
// MultiMediaOption is an option for sending albums.
type MultiMediaOption interface {
MediaOption
applyMulti(ctx context.Context, b *multiMediaBuilder) error
}
type multiMediaWrapper struct {
MediaOption
}
// applyMulti implements MultiMediaOption.
func (m multiMediaWrapper) applyMulti(ctx context.Context, b *multiMediaBuilder) error {
return m.apply(ctx, b)
}
// ForceMulti converts MediaOption to MultiMediaOption.
// It can produce unexpected RPC errors. Use carefully.
func ForceMulti(opt MediaOption) MultiMediaOption {
return multiMediaWrapper{MediaOption: opt}
}