-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtelegram_model.go
More file actions
84 lines (69 loc) · 2.05 KB
/
telegram_model.go
File metadata and controls
84 lines (69 loc) · 2.05 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
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
72
73
74
75
76
77
78
79
80
81
82
83
84
package teledisq
import (
"os"
"strings"
)
const (
HTMLFormatting = "HTML"
ThemeDiscourse = "discourse"
CommandSendMessage = "sendMessage"
)
type ExternalNotification interface {
Message() string
}
type Chat struct {
ID int64 `json:"id"`
Type string `json:"type"`
Title string `json:"title"`
UserName string `json:"username"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
}
type TelegramUser struct {
ID int64 `json:"id"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
UserName string `json:"username"`
}
type MessageEntities struct {
Type string `json:"type"`
}
type Location struct {
Longitude float64 `json:"longitude"`
Latitude float64 `json:"latitude"`
}
type PhotoSize struct{}
type Message struct {
ID int64 `json:"message_id"`
From *TelegramUser `json:"from"`
Chat *Chat `json:"chat"`
Text string `json:"text"`
Entities *[]MessageEntities `json:"entities"`
NewChatMember *TelegramUser `json:"new_chat_member"`
LeftChatMember *TelegramUser `json:"left_chat_member"`
NewChatTitle string `json:"new_chat_title"`
NewChatPhoto *[]PhotoSize `json:"new_chat_photo"`
Location *Location `json:"location"`
}
func (m *Message) IsCommand() bool {
return m.Text != "" && m.Text[0] == '/'
}
func (m *Message) MentionedMe() bool {
return m.Text != "" && strings.Contains(m.Text, os.Getenv("TELEGRAM_BOT_USERNAME"))
}
func (m *Message) IsNewChatMemberMessage() bool {
return m.NewChatMember != nil
}
func (m *Message) IsNewChatTitleMessage() bool {
return m.NewChatTitle != ""
}
func (m *Message) IsNewChatPhotoMessage() bool {
return m.NewChatPhoto != nil
}
type Update struct {
ID int64 `json:"update_id"`
Message *Message `json:"message"`
EditedMessage *Message `json:"edited_message"`
ChannelPost *Message `json:"channel_post"`
EditedChannelPost *Message `json:"edited_channel_post"`
}