-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
types.go
56 lines (47 loc) · 1.23 KB
/
types.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
package main
import (
"context"
"net/http"
)
// Response to Telegram
type Response struct {
ChatID int64 `json:"chat_id"`
Text string `json:"text"`
Method string `json:"method"`
ReplyToID *int64 `json:"reply_to_message_id"`
ParseMode string `json:"parse_mode,omitempty"`
DisableWebPagePreview bool `json:"disable_web_page_preview"`
}
// Chat Telegram structure
type Chat struct {
ID int64 `json:"id"`
Username *string `json:"username"`
}
// Message Telegram structure
type Message struct {
ID int64 `json:"message_id"`
Chat *Chat `json:"chat"`
From *Chat `json:"from"`
Text string `json:"text"`
ReplyTo *Message `json:"reply_to_message"`
}
// Update - outer Telegram structure
type Update struct {
Message *Message `json:"message"`
EditedMessage *Message `json:"edited_message"`
}
type requestInfo struct {
updateMessage *Message
ctx context.Context
cacheID string
writer http.ResponseWriter
}
type botCommand struct {
request *requestInfo //nolint:structcheck
}
type commandInterface interface {
Handle() error
}
func handleCommand(command commandInterface) error {
return command.Handle()
}