-
-
Notifications
You must be signed in to change notification settings - Fork 135
/
multi.go
95 lines (86 loc) · 2.44 KB
/
multi.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package message
import (
"golang.org/x/xerrors"
"github.com/gotd/td/tg"
)
func convertMessageMediaToInput(m tg.MessageMediaClass) (tg.InputMediaClass, error) {
switch v := m.(type) {
case *tg.MessageMediaPhoto: // messageMediaPhoto#695150d7
photo, ok := v.Photo.AsNotEmpty()
if !ok {
return nil, xerrors.Errorf("unexpected type %T", v.Photo)
}
return &tg.InputMediaPhoto{
ID: photo.AsInput(),
TTLSeconds: v.TTLSeconds,
}, nil
case *tg.MessageMediaGeo: // messageMediaGeo#56e0d474
geo, ok := v.Geo.AsNotEmpty()
if !ok {
return nil, xerrors.Errorf("unexpected type %T", v.Geo)
}
r := new(tg.InputGeoPoint)
r.FillFrom(geo)
return &tg.InputMediaGeoPoint{
GeoPoint: r,
}, nil
case *tg.MessageMediaContact: // messageMediaContact#cbf24940
r := new(tg.InputMediaContact)
r.FillFrom(v)
return r, nil
case *tg.MessageMediaDocument: // messageMediaDocument#9cb070d7
document, ok := v.Document.AsNotEmpty()
if !ok {
return nil, xerrors.Errorf("unexpected type %T", v.Document)
}
return &tg.InputMediaDocument{
ID: document.AsInput(),
TTLSeconds: v.TTLSeconds,
}, nil
case *tg.MessageMediaVenue: // messageMediaVenue#2ec0533f
geo, ok := v.Geo.AsNotEmpty()
if !ok {
return nil, xerrors.Errorf("unexpected type %T", v.Geo)
}
r := new(tg.InputGeoPoint)
r.FillFrom(geo)
return &tg.InputMediaVenue{
GeoPoint: r,
Title: v.Title,
Address: v.Address,
Provider: v.Provider,
VenueID: v.VenueID,
VenueType: v.VenueType,
}, nil
case *tg.MessageMediaGame: // messageMediaGame#fdb19008
r := new(tg.InputGameID)
r.FillFrom(&v.Game)
return &tg.InputMediaGame{
ID: r,
}, nil
case *tg.MessageMediaGeoLive: // messageMediaGeoLive#b940c666
geo, ok := v.Geo.AsNotEmpty()
if !ok {
return nil, xerrors.Errorf("unexpected type %T", v.Geo)
}
r := new(tg.InputGeoPoint)
r.FillFrom(geo)
return &tg.InputMediaGeoLive{
GeoPoint: r,
Heading: v.Heading,
Period: v.Period,
ProximityNotificationRadius: v.ProximityNotificationRadius,
}, nil
case *tg.MessageMediaDice: // messageMediaDice#3f7ee58b
r := new(tg.InputMediaDice)
r.FillFrom(v)
return r, nil
default:
// messageMediaPoll#4bd6e798
// messageMediaWebPage#a32dd600
// messageMediaEmpty#3ded6320
// messageMediaUnsupported#9f84f49e
// messageMediaInvoice#84551347
return nil, xerrors.Errorf("unexpected type %T", v)
}
}