From 968d7ae958ae35d088d3f7f7982c5fc2393f691e Mon Sep 17 00:00:00 2001 From: shoopea Date: Sun, 9 Jun 2019 00:55:34 +0800 Subject: [PATCH] test --- bot.go | 4 +++- workers.go | 12 +++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/bot.go b/bot.go index 560fdfb..f5674c7 100644 --- a/bot.go +++ b/bot.go @@ -219,7 +219,9 @@ func botMsgExportAll(m *tb.Message) { TGCmdQueue <- c } - d := tb.Document{File: tb.FromReader(bytes.NewReader(b))} + d := tb.Document{} + d.File = tb.FromReader(bytes.NewReader(b)) + d.FileName = `backup.zip` c = TGCommand{ Type: commandReplyDocument, diff --git a/workers.go b/workers.go index aa80d4e..b72d9fc 100644 --- a/workers.go +++ b/workers.go @@ -265,7 +265,7 @@ func TGCmdWorker(id int, b *tb.Bot, cmds <-chan TGCommand) { ID: int(c.FromMsgID64), Chat: &ch, } - _, err := b.Reply(&m, c.Document) + _, err := c.Document.Send(b, &m) logOnError(err, "TGCmdWorker["+strconv.Itoa(id)+"] : ReplyDocument") case commandSendMsg: if c.ToChatID64 != 0 { @@ -283,16 +283,10 @@ func TGCmdWorker(id int, b *tb.Bot, cmds <-chan TGCommand) { } case commandSendDocument: if c.ToChatID64 != 0 { - ch := tb.Chat{ - ID: c.ToChatID64, - } - _, err := b.Send(&ch, c.Document) + _, err := c.Document.Send(b, c.ToChatID64) logOnError(err, "TGCmdWorker["+strconv.Itoa(id)+"] : SendDocument Chat") } else if c.ToUserID64 != 0 { - ch := tb.Chat{ - ID: c.ToUserID64, - } - _, err := b.Send(&ch, c.Document) + _, err := c.Document.Send(b, c.ToUserID64) logOnError(err, "TGCmdWorker["+strconv.Itoa(id)+"] : SendDocument Chat") } default: