-
Notifications
You must be signed in to change notification settings - Fork 21
/
sendable.go
166 lines (136 loc) · 4.55 KB
/
sendable.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
// Copyright 2015-2016 mrd0ll4r and contributors. All rights reserved.
// Use of this source code is governed by the MIT license, which can be found in
// the LICENSE file.
package tbotapi
type sendable interface {
Send() (*MessageResponse, error)
}
// Send sends the message.
// On success, the sent message is returned as a MessageResponse.
func (om *OutgoingMessage) Send() (*MessageResponse, error) {
return om.api.send(om)
}
// Send sends the location.
// On success, the sent message is returned as a MessageResponse.
func (ol *OutgoingLocation) Send() (*MessageResponse, error) {
return ol.api.send(ol)
}
// Send sends the venue.
// On success, the sent message is returned as a MessageResponse.
func (ol *OutgoingVenue) Send() (*MessageResponse, error) {
return ol.api.send(ol)
}
// Send sends the forward.
// On success, the sent message is returned as a MessageResponse.
func (of *OutgoingForward) Send() (*MessageResponse, error) {
return of.api.send(of)
}
// Send sends the video.
// Note that the Telegram servers may check the fileName for its extension.
// For current limitations on what bots can send, please check the API
// documentation.
// On success, the sent message is returned as a MessageResponse.
func (ov *OutgoingVideo) Send() (*MessageResponse, error) {
return ov.api.send(ov)
}
// Send sends the photo.
// Note that the Telegram servers may check the fileName for its extension.
// For current limitations on what bots can send, please check the API
// documentation.
// On success, the sent message is returned as a MessageResponse.
func (op *OutgoingPhoto) Send() (*MessageResponse, error) {
return op.api.send(op)
}
// Send sends the sticker.
// Note that the Telegram servers may check the fileName for its extension.
// For current limitations on what bots can send, please check the API
// documentation.
// On success, the sent message is returned as a MessageResponse.
func (os *OutgoingSticker) Send() (*MessageResponse, error) {
return os.api.send(os)
}
// Send sends the audio.
// Note that the Telegram servers may check the fileName for its extension.
// For current limitations on what bots can send, please check the API
// documentation.
// On success, the sent message is returned as a MessageResponse.
func (oa *OutgoingAudio) Send() (*MessageResponse, error) {
return oa.api.send(oa)
}
// Send sends the voice message.
// Note that the Telegram servers may check the fileName for its extension.
// For current limitations on what bots can send, please check the API
// documentation.
// On success, the sent message is returned as a MessageResponse.
func (ov *OutgoingVoice) Send() (*MessageResponse, error) {
return ov.api.send(ov)
}
// Send sends the document.
// Note that the Telegram servers may check the fileName for its extension.
// For current limitations on what bots can send, please check the API
// documentation.
// On success, the sent message is returned as a MessageResponse.
func (od *OutgoingDocument) Send() (*MessageResponse, error) {
return od.api.send(od)
}
// Send sends the request.
// On success, the photos are returned as a UserProfilePhotosResponse.
func (op *OutgoingUserProfilePhotosRequest) Send() (*UserProfilePhotosResponse, error) {
resp := &UserProfilePhotosResponse{}
_, err := op.api.c.postJSON(getUserProfilePhotos, resp, op)
if err != nil {
return nil, err
}
err = check(&resp.baseResponse)
if err != nil {
return nil, err
}
return resp, nil
}
// Send sends the chat action.
// On success, nil is returned.
func (oc *OutgoingChatAction) Send() error {
resp := &baseResponse{}
_, err := oc.api.c.postJSON(sendChatAction, resp, oc)
if err != nil {
return err
}
return check(resp)
}
// Send sends the inline query answer.
// On success, nil is returned.
func (ia *InlineQueryAnswer) Send() error {
resp := &baseResponse{}
_, err := ia.api.c.postJSON(answerInlineQuery, resp, ia)
if err != nil {
return err
}
return check(resp)
}
// Send sends the kick request.
func (kr *OutgoingKickChatMember) Send() error {
resp := &baseResponse{}
_, err := kr.api.c.postJSON(kickChatMember, resp, kr)
if err != nil {
return err
}
return check(resp)
}
// Send sends the unban request.
func (ub *OutgoingUnbanChatMember) Send() error {
resp := &baseResponse{}
_, err := ub.api.c.postJSON(unbanChatMember, resp, ub)
if err != nil {
return err
}
return check(resp)
}
// Send sends the callback response.
func (cbr *OutgoingCallbackQueryResponse) Send() error {
resp := &baseResponse{}
_, err := cbr.api.c.postJSON(answerCallbackQuery, resp, cbr)
if err != nil {
return err
}
return check(resp)
}