diff --git a/bot.go b/bot.go index f5674c7..88ff3e0 100644 --- a/bot.go +++ b/bot.go @@ -224,10 +224,9 @@ func botMsgExportAll(m *tb.Message) { d.FileName = `backup.zip` c = TGCommand{ - Type: commandReplyDocument, - Document: d, - FromMsgID64: int64(m.ID), - FromChatID64: m.Chat.ID, + Type: commandSendDocument, + Document: d, + ToChatID64: m.Chat.ID, } TGCmdQueue <- c diff --git a/def.go b/def.go index a253ff0..218912a 100644 --- a/def.go +++ b/def.go @@ -239,13 +239,12 @@ type JobPayloadMsgClient struct { const ( userID64ChtWrsBot = 408101137 - commandForwardMsg = 1 - commandReplyMsg = 2 - commandSendMsg = 3 - commandDeleteMsg = 4 - commandRefreshMsg = 5 - commandSendDocument = 6 - commandReplyDocument = 7 + commandForwardMsg = 1 + commandReplyMsg = 2 + commandSendMsg = 3 + commandDeleteMsg = 4 + commandRefreshMsg = 5 + commandSendDocument = 6 objTypeUser = 1 objTypeGuild = 2 diff --git a/workers.go b/workers.go index a4af0e0..2e4471c 100644 --- a/workers.go +++ b/workers.go @@ -247,27 +247,6 @@ func TGCmdWorker(id int, b *tb.Bot, cmds <-chan TGCommand) { logOnError(err, "TGCmdWorker["+strconv.Itoa(id)+"] : Marshal(c)") log.Printf("TGCmdWorker["+strconv.Itoa(id)+"] : new command.\n%s\n", string(j)) switch c.Type { - case commandReplyMsg: - ch := tb.Chat{ - ID: c.FromChatID64, - } - m := tb.Message{ - ID: int(c.FromMsgID64), - Chat: &ch, - } - _, err := b.Reply(&m, c.Text) - logOnError(err, "TGCmdWorker["+strconv.Itoa(id)+"] : ReplyMsg") - case commandReplyDocument: - ch := tb.Chat{ - ID: c.FromChatID64, - } - m := tb.Message{ - ID: int(c.FromMsgID64), - Chat: &ch, - } - _, err := b.Reply(&m, c.Document) - //_, err := c.Document.Send(b, m, nil) - logOnError(err, "TGCmdWorker["+strconv.Itoa(id)+"] : ReplyDocument") case commandSendMsg: if c.ToChatID64 != 0 { ch := tb.Chat{ @@ -282,23 +261,32 @@ func TGCmdWorker(id int, b *tb.Bot, cmds <-chan TGCommand) { _, err := b.Send(&ch, c.Text) logOnError(err, "TGCmdWorker["+strconv.Itoa(id)+"] : SendMsg User") } + case commandReplyMsg: + ch := tb.Chat{ + ID: c.FromChatID64, + } + m := tb.Message{ + ID: int(c.FromMsgID64), + Chat: &ch, + } + _, err := b.Reply(&m, c.Text) + logOnError(err, "TGCmdWorker["+strconv.Itoa(id)+"] : ReplyMsg") case commandSendDocument: if c.ToChatID64 != 0 { ch := tb.Chat{ ID: c.ToUserID64, } - _, err := b.Send(&ch, c.Document) - // _, err := c.Document.Send(b, ch, nil) + //_, err := b.Send(&ch, c.Document) + _, err := c.Document.Send(b, ch, nil) 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, &ch, nil) + //_, err := b.Send(&ch, c.Document) + _, err := c.Document.Send(b, &ch, nil) logOnError(err, "TGCmdWorker["+strconv.Itoa(id)+"] : SendDocument Chat") } - default: }