diff --git a/bot.go b/bot.go index 5a7e4dc..20ac864 100644 --- a/bot.go +++ b/bot.go @@ -288,18 +288,25 @@ func botMsgLoad(m *tb.Message) { TGCmdQueue <- c r, err := b.GetFile(&f) logOnError(err, "botMsgLoad : GetFile") - _, err := ioutil.ReadAll(r.Body) - c = TGCommand{ - Type: commandReplyMsg, - Text: "File downloaded ?", - FromMsgID64: int64(m.ID), - FromChatID64: m.Chat.ID, + buf := new(bytes.Buffer) + n, err := buf.ReadFrom(r.Reader) + logOnError(err, "botMsgLoad : ReadFrom") + if n > 0 { + data := buf.Bytes() + s := fmt.Sprintf("Read %d/%d bytes.", n, len(data)) + + c = TGCommand{ + Type: commandReplyMsg, + Text: s, + FromMsgID64: int64(m.ID), + FromChatID64: m.Chat.ID, + } + TGCmdQueue <- c } - TGCmdQueue <- c if f.OnDisk() { c = TGCommand{ Type: commandReplyMsg, - Text: "Yes !", + Text: "File now on disk !", FromMsgID64: int64(m.ID), FromChatID64: m.Chat.ID, } @@ -307,7 +314,7 @@ func botMsgLoad(m *tb.Message) { } else { c = TGCommand{ Type: commandReplyMsg, - Text: "No !", + Text: "Still not on disk ?", FromMsgID64: int64(m.ID), FromChatID64: m.Chat.ID, }