-
-
Notifications
You must be signed in to change notification settings - Fork 135
/
message_geo.go
71 lines (60 loc) · 2.11 KB
/
message_geo.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
package inline
import (
"time"
"github.com/gotd/td/telegram/message/markup"
"github.com/gotd/td/tg"
)
// MessageMediaGeoBuilder is a builder of inline result geo message.
type MessageMediaGeoBuilder struct {
message *tg.InputBotInlineMessageMediaGeo
}
// nolint:unparam
func (b *MessageMediaGeoBuilder) apply() (tg.InputBotInlineMessageClass, error) {
r := *b.message
return &r, nil
}
// MessageGeo creates new message geo option builder.
func MessageGeo(point tg.InputGeoPointClass) *MessageMediaGeoBuilder {
return &MessageMediaGeoBuilder{
message: &tg.InputBotInlineMessageMediaGeo{
GeoPoint: point,
},
}
}
// Heading sets for live locations¹, a direction in which the location moves, in degrees; 1-360.
//
// Links:
// 1. https://core.telegram.org/api/live-location
func (b *MessageMediaGeoBuilder) Heading(heading int) *MessageMediaGeoBuilder {
b.message.Heading = heading
return b
}
// Period sets validity period.
func (b *MessageMediaGeoBuilder) Period(dur time.Duration) *MessageMediaGeoBuilder {
return b.PeriodSeconds(int(dur.Seconds()))
}
// PeriodSeconds sets validity period in seconds.
func (b *MessageMediaGeoBuilder) PeriodSeconds(period int) *MessageMediaGeoBuilder {
b.message.Period = period
return b
}
// ProximityNotificationRadius sets for live locations¹, a maximum distance to another chat member for proximity
// alerts, in meters (0-100000)
//
// Links:
// 1. https://core.telegram.org/api/live-location
func (b *MessageMediaGeoBuilder) ProximityNotificationRadius(radius int) *MessageMediaGeoBuilder {
b.message.ProximityNotificationRadius = radius
return b
}
// Markup sets reply markup for sending bot buttons.
// NB: markup will not be used, if you send multiple media attachments.
func (b *MessageMediaGeoBuilder) Markup(m tg.ReplyMarkupClass) *MessageMediaGeoBuilder {
b.message.ReplyMarkup = m
return b
}
// Row sets single row keyboard markup for sending bot buttons.
// NB: markup will not be used, if you send multiple media attachments.
func (b *MessageMediaGeoBuilder) Row(buttons ...tg.KeyboardButtonClass) *MessageMediaGeoBuilder {
return b.Markup(markup.InlineRow(buttons...))
}