File tree Expand file tree Collapse file tree 5 files changed +20
-8
lines changed Expand file tree Collapse file tree 5 files changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ func (b *Bot) NewChat(id string) *Chat {
126126// SendMessage sends a message, passed as an argument.
127127// This method fills the argument with ID of sent message and returns an error if any.
128128func (b * Bot ) SendMessage (message * Message ) error {
129- return b .client .SendMessage (message )
129+ return b .client .SendTextMessage (message )
130130}
131131
132132// EditMessage edit a message passed as an argument.
Original file line number Diff line number Diff line change @@ -227,7 +227,7 @@ func (c *Client) DeleteMessage(message *Message) error {
227227 return nil
228228}
229229
230- func (c * Client ) SendFile (message * Message ) error {
230+ func (c * Client ) SendFileMessage (message * Message ) error {
231231 params := url.Values {
232232 "chatId" : {message .Chat .ID },
233233 "caption" : {message .Text },
@@ -246,7 +246,7 @@ func (c *Client) SendFile(message *Message) error {
246246 return nil
247247}
248248
249- func (c * Client ) SendVoice (message * Message ) error {
249+ func (c * Client ) SendVoiceMessage (message * Message ) error {
250250 params := url.Values {
251251 "chatId" : {message .Chat .ID },
252252 "caption" : {message .Text },
Original file line number Diff line number Diff line change @@ -34,6 +34,18 @@ func main() {
3434 }
3535
3636 fileMessage .Delete ()
37+ file .Close ()
38+
39+ file , err = os .Open ("./voice.aac" )
40+ if err != nil {
41+ log .Fatalf ("cannot open file: %s" , err )
42+ }
43+ defer file .Close ()
44+
45+ voiceMessage := bot .
NewVoiceMessage (
"[email protected] " ,
file )
46+ if err := voiceMessage .Send (); err != nil {
47+ log .Println (err )
48+ }
3749
3850 // Simple 30-seconds echo bot
3951 ctx , _ := context .WithTimeout (context .Background (), 30 * time .Second )
Original file line number Diff line number Diff line change @@ -85,22 +85,22 @@ func (m *Message) Send() error {
8585 switch m .ContentType {
8686 case Voice :
8787 if m .FileID != "" {
88- return m .client .SendVoice (m )
88+ return m .client .SendVoiceMessage (m )
8989 }
9090
9191 if m .File != nil {
9292 return m .client .UploadVoice (m )
9393 }
9494 case OtherFile :
9595 if m .FileID != "" {
96- return m .client .SendFile (m )
96+ return m .client .SendFileMessage (m )
9797 }
9898
9999 if m .File != nil {
100100 return m .client .UploadFile (m )
101101 }
102102 case Text :
103- return m .client .SendMessage (m )
103+ return m .client .SendTextMessage (m )
104104 }
105105
106106 return fmt .Errorf ("cannot send message or file without data" )
@@ -135,7 +135,7 @@ func (m *Message) Reply(text string) error {
135135 m .ReplyMsgID = m .ID
136136 m .Text = text
137137
138- return m .client .SendMessage (m )
138+ return m .client .SendTextMessage (m )
139139}
140140
141141// Forward method forwards your message to chat.
@@ -149,5 +149,5 @@ func (m *Message) Forward(chatID string) error {
149149 m .ForwardMsgID = m .ID
150150 m .Chat .ID = chatID
151151
152- return m .client .SendMessage (m )
152+ return m .client .SendTextMessage (m )
153153}
You can’t perform that action at this time.
0 commit comments