-
Notifications
You must be signed in to change notification settings - Fork 15
/
message.go
145 lines (115 loc) · 4.49 KB
/
message.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
package margelet
import (
"gopkg.in/redis.v3"
"gopkg.in/telegram-bot-api.v4"
)
type message struct {
bot MargeletAPI
message *tgbotapi.Message
}
// NewMessage returns message, that wraps bot and message
func NewMessage(bot MargeletAPI, msg *tgbotapi.Message) *message {
return &message{
bot: bot,
message: msg,
}
}
func (s *message) Bot() MargeletAPI {
return s.bot
}
// QuickSend send test to session chat
func (s *message) QuickSend(text string, replyMarkup interface{}) (tgbotapi.Message, error) {
return s.bot.QuickSend(s.message.Chat.ID, text, replyMarkup)
}
// QuckReply send a reply to last session message
func (s *message) QuickReply(text string, replyMarkup interface{}) (tgbotapi.Message, error) {
return s.bot.QuickReply(s.message.Chat.ID, s.message.MessageID, text, replyMarkup)
}
func (s *message) QuickForceReply(text string) (tgbotapi.Message, error) {
return s.bot.QuickForceReply(s.message.Chat.ID, s.message.MessageID, text)
}
// SendImageByURL send image by url to session chat
func (s *message) SendImageByURL(url string, caption string, replyMarkup interface{}) (tgbotapi.Message, error) {
return s.bot.SendImageByURL(s.message.Chat.ID, url, caption, replyMarkup)
}
// SendImage send image by url to session chat
func (s *message) SendImage(reader tgbotapi.FileReader, caption string, replyMarkup interface{}) (tgbotapi.Message, error) {
return s.bot.SendImage(s.message.Chat.ID, reader, caption, replyMarkup)
}
// SendTypingAction send typing action to session chat
func (s *message) SendTypingAction() error {
return s.bot.SendTypingAction(s.message.Chat.ID)
}
// SendTypingAction send upload photo action to session chat
func (s *message) SendUploadPhotoAction() error {
return s.bot.SendUploadPhotoAction(s.message.Chat.ID)
}
// SendRecordVideoAction send record video action to session chat
func (s *message) SendRecordVideoAction() error {
return s.bot.SendRecordVideoAction(s.message.Chat.ID)
}
// SendUploadVideoAction send upload video action to session chat
func (s *message) SendUploadVideoAction() error {
return s.bot.SendUploadVideoAction(s.message.Chat.ID)
}
// SendRecordAudioAction send record audio action to session chat
func (s *message) SendRecordAudioAction() error {
return s.bot.SendRecordAudioAction(s.message.Chat.ID)
}
// SendUploadAudioAction send upload audio action to session chat
func (s *message) SendUploadAudioAction() error {
return s.bot.SendUploadAudioAction(s.message.Chat.ID)
}
// SendUploadDocumentAction send upload document action to session chat
func (s *message) SendUploadDocumentAction() error {
return s.bot.SendUploadDocumentAction(s.message.Chat.ID)
}
// SendFindLocationAction send find location action to session chat
func (s *message) SendFindLocationAction() error {
return s.bot.SendFindLocationAction(s.message.Chat.ID)
}
// SendHideKeyboard send message with hidding keyboard to session chat
func (s *message) SendHideKeyboard(message string) error {
return s.bot.SendHideKeyboard(s.message.Chat.ID, message)
}
// Message returns user's message
func (s *message) Message() *tgbotapi.Message {
return s.message
}
func (s *message) GetFileDirectURL(fileID string) (string, error) {
return s.bot.GetFileDirectURL(fileID)
}
func (s *message) GetCurrentUserpic() (string, error) {
return s.bot.GetCurrentUserpic(s.message.From.ID)
}
func (s *message) GetCurrentUserpicID() (string, error) {
return s.bot.GetCurrentUserpicID(s.message.From.ID)
}
// GetConfigRepository - returns chat config repository
func (s *message) GetConfigRepository() *ChatConfigRepository {
return s.bot.GetConfigRepository()
}
// GetSessionRepository - returns session repository
func (s *message) GetSessionRepository() SessionRepository {
return s.bot.GetSessionRepository()
}
// GetRedis - returns margelet's redis client
func (s *message) GetRedis() *redis.Client {
return s.bot.GetRedis()
}
func (s *message) StartSession(command string) {
s.bot.StartSession(s.message, command)
}
func (s *message) GetChatRepository() *ChatRepository {
return s.bot.GetChatRepository()
}
// GetStatsRepository - returns stats repository
func (s *message) GetStatsRepository() StatsRepository {
return s.bot.GetStatsRepository()
}
func (s *message) SendDocument(reader tgbotapi.FileReader, replyMarkup interface{}) (tgbotapi.Message, error) {
return s.bot.SendDocument(s.Message().Chat.ID, reader, replyMarkup)
}
func (s *message) SendDocumentByURL(url string, replyMarkup interface{}) (tgbotapi.Message, error) {
return s.bot.SendDocumentByURL(s.Message().Chat.ID, url, replyMarkup)
}