-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathanswer_guest.go
More file actions
43 lines (35 loc) · 1.06 KB
/
Copy pathanswer_guest.go
File metadata and controls
43 lines (35 loc) · 1.06 KB
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
package botapi
import (
"context"
"strconv"
"github.com/gotd/td/tg"
)
// AnswerGuestQuery sets the result of a guest interaction with the bot and sends
// a corresponding message to the chat from which the query originated.
// guestQueryID is the query id received in the update. It returns the sent
// inline message id.
func (b *Bot) AnswerGuestQuery(ctx context.Context, guestQueryID string, result InlineQueryResult) (*SentWebAppMessage, error) {
if result == nil {
return nil, errNilInlineResult()
}
queryID, err := strconv.ParseInt(guestQueryID, 10, 64)
if err != nil {
return nil, &Error{Code: 400, Description: "Bad Request: invalid guest_query_id"}
}
converted, err := result.toTg(ctx, b)
if err != nil {
return nil, err
}
res, err := b.raw.MessagesSetBotGuestChatResult(ctx, &tg.MessagesSetBotGuestChatResultRequest{
QueryID: queryID,
Result: converted,
})
if err != nil {
return nil, asAPIError(err)
}
enc, err := encodeInlineMessageID(res)
if err != nil {
return nil, err
}
return &SentWebAppMessage{InlineMessageID: enc}, nil
}