This commit is contained in:
shoopea 2019-06-09 19:44:34 +08:00
parent 2d66971e17
commit 787d6a0f7b

38
bot.go
View File

@ -284,42 +284,10 @@ func botMsgLoad(m *tb.Message) {
FromChatID64: m.Chat.ID,
}
TGCmdQueue <- c
log.Printf("Getting file !\n")
r, err := b.GetFile(&f)
logOnError(err, "botMsgLoad : GetFile")
log.Printf("Reading file !\n")
buf := new(bytes.Buffer)
n, err := buf.ReadFrom(r)
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
}
if f.OnDisk() {
c = TGCommand{
Type: commandReplyMsg,
Text: "File now on disk !",
FromMsgID64: int64(m.ID),
FromChatID64: m.Chat.ID,
}
TGCmdQueue <- c
} else {
c = TGCommand{
Type: commandReplyMsg,
Text: "Still not on disk ?",
FromMsgID64: int64(m.ID),
FromChatID64: m.Chat.ID,
}
TGCmdQueue <- c
}
url := fmt.Sprintf("%s/file/bot%s/%s", b.URL, b.Token, f.FilePath)
log.Printf("Getting file from %s !\n", url)
} else {
c := TGCommand{