This commit is contained in:
shoopea 2019-06-09 18:20:08 +08:00
parent 71c28649cc
commit b2c5eaa754

25
bot.go
View File

@ -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,
}