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

bots-go-framework / bots-fw / 16259694296

14 Jul 2025 06:30AM UTC coverage: 3.415% (-3.9%) from 7.271%
16259694296

push

github

trakhimenok
feat(refactoring): restructuring packages and renaming types

25 of 301 new or added lines in 26 files covered. (8.31%)

152 existing lines in 7 files now uncovered.

133 of 3895 relevant lines covered (3.41%)

0.04 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
// Entry represents a single message from a messenger user
10
type Entry interface {
11
        GetID() any
12
        GetTime() time.Time
13
}
14

NEW
15
func GetBotInputTypeIdNameString(whInputType Type) 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
// InputMessage represent a single message
24
// '/entry/messaging' for Facebook Messenger
25
type InputMessage interface {
26
        GetSender() User
27
        GetRecipient() Recipient
28
        GetTime() time.Time
29
        InputType() Type
30
        BotChatID() (string, error)
31
        Chat() Chat
32
        LogRequest() // TODO: should not be part of Input? If should - specify why
33
}
34

35
// Actor represents sender
36
type Actor 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
// Sender represents sender with avatar
47
type Sender interface {
48
        GetAvatar() string // Extension to support avatar (Viber)
49
        Actor
50
}
51

52
// User represents sender with country
53
type User interface {
54
        Sender
55

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

60
// Recipient represents receiver
61
type Recipient interface {
62
        Actor
63
}
64

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

186
// CallbackQuery represents a single callback query message
187
type CallbackQuery interface {
188
        GetID() string
189
        //GetInlineMessageID() string // Telegram only?
190
        //GetChatInstanceID() string  // Telegram only?
191
        GetFrom() Sender
192
        GetMessage() Message
193
        GetData() string
194
        Chat() Chat
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 SuccessfulPayment 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() Sender
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