• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

bots-go-framework / bots-fw / 15793400695

21 Jun 2025 07:19AM UTC coverage: 5.376% (-0.09%) from 5.461%
15793400695

push

github

trakhimenok
fix(deps): latest dalgo v0.21.1

279 of 5190 relevant lines covered (5.38%)

0.06 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/botinput/webhook_interfaces.go
1
package botinput
2

3
import (
4
        "fmt"
5
        "strconv"
6
        "time"
7
)
8

9
// WebhookEntry represents a single message from a messenger user
10
type WebhookEntry interface {
11
        GetID() interface{}
12
        GetTime() time.Time
13
}
14

15
func GetWebhookInputTypeIdNameString(whInputType WebhookInputType) string {
×
16
        name, ok := webhookInputTypeNames[whInputType]
×
17
        if ok {
×
18
                return fmt.Sprintf("%d:%s", whInputType, name)
×
19
        }
×
20
        return strconv.Itoa(int(whInputType))
×
21
}
22

23
// WebhookInput represent a single message
24
// '/entry/messaging' for Facebook Messenger
25
type WebhookInput interface {
26
        GetSender() WebhookUser
27
        GetRecipient() WebhookRecipient
28
        GetTime() time.Time
29
        InputType() WebhookInputType
30
        BotChatID() (string, error)
31
        Chat() WebhookChat
32
        LogRequest() // TODO: should not be part of Input? If should - specify why
33
}
34

35
// WebhookActor represents sender
36
type WebhookActor interface {
37
        Platform() string // TODO: Consider removing this?
38
        GetID() any
39
        IsBotUser() bool
40
        GetFirstName() string
41
        GetLastName() string
42
        GetUserName() string
43
        GetLanguage() string
44
}
45

46
// WebhookSender represents sender with avatar
47
type WebhookSender interface {
48
        GetAvatar() string // Extension to support avatar (Viber)
49
        WebhookActor
50
}
51

52
// WebhookUser represents sender with country
53
type WebhookUser interface {
54
        WebhookSender
55

56
        // GetCountry is an extension to support language & country (Viber)
57
        GetCountry() string
58
}
59

60
// WebhookRecipient represents receiver
61
type WebhookRecipient interface {
62
        WebhookActor
63
}
64

65
// WebhookMessage represents a single message
66
type WebhookMessage interface {
67
        WebhookInput
68
        IntID() int64
69
        StringID() string
70
        Chat() WebhookChat
71
        //Sequence() int // 'seq' for Facebook, '???' for Telegram
72
}
73

74
// WebhookTextMessage represents a single text message
75
type WebhookTextMessage interface {
76
        WebhookMessage
77
        Text() string
78
        IsEdited() bool
79
}
80

81
// WebhookStickerMessage represents single sticker message
82
type WebhookStickerMessage interface {
83
        WebhookMessage
84
        // TODO: Define sticker message interface
85
}
86

87
// WebhookVoiceMessage represents a single voice message
88
type WebhookVoiceMessage interface {
89
        WebhookMessage
90
        // TODO: Define voice message interface
91
}
92

93
// WebhookPhotoMessage represents a single photo message
94
type WebhookPhotoMessage interface {
95
        WebhookMessage
96
        // TODO: Define photo message interface
97
}
98

99
// WebhookAudioMessage represents a single audio message
100
type WebhookAudioMessage interface {
101
        WebhookMessage
102
        // TODO: Define audio message interface
103
}
104

105
// WebhookReferralMessage represents a single referral message
106
// https://developers.facebook.com/docs/messenger-platform/webhook-reference/referral
107
type WebhookReferralMessage interface {
108
        Type() string
109
        Source() string
110
        RefData() string
111
}
112

113
// WebhookContactMessage represents a single contact message
114
type WebhookContactMessage interface {
115
        GetPhoneNumber() string
116
        GetFirstName() string
117
        GetLastName() string
118
        GetBotUserID() string
119
        GetVCard() string
120
}
121

122
// WebhookNewChatMembersMessage represents a single message about a new member of a botChat
123
type WebhookNewChatMembersMessage interface {
124
        BotChatID() (string, error)
125
        NewChatMembers() []WebhookActor
126
}
127

128
// WebhookLeftChatMembersMessage represents a single message about a member leaving a botChat
129
type WebhookLeftChatMembersMessage interface {
130
        BotChatID() (string, error)
131
        LeftChatMembers() []WebhookActor
132
}
133

134
// WebhookChat represents botChat of a messenger
135
type WebhookChat interface {
136
        GetID() string
137
        GetType() string
138
        IsGroupChat() bool
139
}
140

141
// WebhookPostback represents a single postback message
142
type WebhookPostback interface {
143
        PostbackMessage() interface{}
144
        Payload() string
145
}
146

147
// WebhookSubscribed represents a subscription message
148
type WebhookSubscribed interface {
149
        SubscribedMessage() interface{}
150
}
151

152
// WebhookUnsubscribed represents a message when user unsubscribe
153
type WebhookUnsubscribed interface {
154
        UnsubscribedMessage() interface{}
155
}
156

157
// WebhookConversationStarted represents a single message about new conversation
158
type WebhookConversationStarted interface {
159
        ConversationStartedMessage() interface{}
160
}
161

162
// WebhookInlineQuery represents a single inline message
163
type WebhookInlineQuery interface {
164
        GetID() interface{}
165
        GetInlineQueryID() string
166
        GetFrom() WebhookSender
167
        GetQuery() string
168
        GetOffset() string
169
        //GetLocation() - TODO: Not implemented yet
170
}
171

172
// WebhookDelivery represents a single delivery report message
173
type WebhookDelivery interface {
174
        Payload() string
175
}
176

177
// WebhookChosenInlineResult represents a single report message on chosen inline result
178
type WebhookChosenInlineResult interface {
179
        GetResultID() string
180
        GetInlineMessageID() string // Telegram only?
181
        GetFrom() WebhookSender
182
        GetQuery() string
183
        //GetLocation() - TODO: Not implemented yet
184
}
185

186
// WebhookCallbackQuery represents a single callback query message
187
type WebhookCallbackQuery interface {
188
        GetID() string
189
        //GetInlineMessageID() string // Telegram only?
190
        //GetChatInstanceID() string  // Telegram only?
191
        GetFrom() WebhookSender
192
        GetMessage() WebhookMessage
193
        GetData() string
194
        Chat() WebhookChat
195
}
196

197
//type SuccessfulPayment struct {
198
//        Currency                string
199
//        TotalAmount             int
200
//        Payload                 string
201
//        IsRecurring             bool
202
//        IsFirstRecurring        bool
203
//        MessengerChargeID       string
204
//        PaymentProviderChargeID string
205
//        //
206
//        SubscriptionExpirationDate *time.Time
207
//}
208

209
type webhookPayment interface {
210
        GetCurrency() string
211
        GetTotalAmount() int
212
        GetInvoicePayload() string
213
        GetMessengerChargeID() string
214
        GetPaymentProviderChargeID() string
215
}
216
type WebhookSuccessfulPayment interface {
217
        webhookPayment
218
        GetSubscriptionExpirationDate() time.Time
219
        GetIsRecurring() bool
220
        GetIsFirstRecurring() bool
221
        GetShippingOptionID() string
222
        GetOrderInfo() OrderInfo
223
}
224

225
type WebhookRefundedPayment interface {
226
        webhookPayment
227
}
228

229
type WebhookPreCheckoutQuery interface {
230
        GetPreCheckoutQueryID() string
231
        GetCurrency() string
232
        GetTotalAmount() int
233
        GetInvoicePayload() string
234
        GetFrom() WebhookSender
235
        GetShippingOptionID() string
236
        GetOrderInfo() OrderInfo
237
}
238

239
type OrderInfo interface {
240
        GetUserName() string //
241
        GetPhoneNumber() string
242
        GetEmailAddress() string
243
        GetShippingAddress() ShippingAddress
244
}
245

246
type ShippingAddress interface {
247
        GetCountryCode() string // Two-letter ISO 3166-1 alpha-2 country code
248
        GetState() string       // if applicable
249
        GetCity() string
250
        GetStreetLine1() string // First line for the address
251
        GetStreetLine2() string // Second line for the address
252
        GetPostCode() string
253
}
254

255
// WebhookAttachment represents attachment to a message
256
type WebhookAttachment interface {
257
        Type() string       // Enum(image, video, audio) for Facebook
258
        PayloadUrl() string // 'payload.url' for Facebook
259
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc