test
This commit is contained in:
parent
0304c06ca0
commit
8ae650fb41
5
bot.go
5
bot.go
@ -224,10 +224,9 @@ func botMsgExportAll(m *tb.Message) {
|
|||||||
d.FileName = `backup.zip`
|
d.FileName = `backup.zip`
|
||||||
|
|
||||||
c = TGCommand{
|
c = TGCommand{
|
||||||
Type: commandReplyDocument,
|
Type: commandSendDocument,
|
||||||
Document: d,
|
Document: d,
|
||||||
FromMsgID64: int64(m.ID),
|
ToChatID64: m.Chat.ID,
|
||||||
FromChatID64: m.Chat.ID,
|
|
||||||
}
|
}
|
||||||
TGCmdQueue <- c
|
TGCmdQueue <- c
|
||||||
|
|
||||||
|
1
def.go
1
def.go
@ -245,7 +245,6 @@ const (
|
|||||||
commandDeleteMsg = 4
|
commandDeleteMsg = 4
|
||||||
commandRefreshMsg = 5
|
commandRefreshMsg = 5
|
||||||
commandSendDocument = 6
|
commandSendDocument = 6
|
||||||
commandReplyDocument = 7
|
|
||||||
|
|
||||||
objTypeUser = 1
|
objTypeUser = 1
|
||||||
objTypeGuild = 2
|
objTypeGuild = 2
|
||||||
|
40
workers.go
40
workers.go
@ -247,27 +247,6 @@ func TGCmdWorker(id int, b *tb.Bot, cmds <-chan TGCommand) {
|
|||||||
logOnError(err, "TGCmdWorker["+strconv.Itoa(id)+"] : Marshal(c)")
|
logOnError(err, "TGCmdWorker["+strconv.Itoa(id)+"] : Marshal(c)")
|
||||||
log.Printf("TGCmdWorker["+strconv.Itoa(id)+"] : new command.\n%s\n", string(j))
|
log.Printf("TGCmdWorker["+strconv.Itoa(id)+"] : new command.\n%s\n", string(j))
|
||||||
switch c.Type {
|
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:
|
case commandSendMsg:
|
||||||
if c.ToChatID64 != 0 {
|
if c.ToChatID64 != 0 {
|
||||||
ch := tb.Chat{
|
ch := tb.Chat{
|
||||||
@ -282,23 +261,32 @@ func TGCmdWorker(id int, b *tb.Bot, cmds <-chan TGCommand) {
|
|||||||
_, err := b.Send(&ch, c.Text)
|
_, err := b.Send(&ch, c.Text)
|
||||||
logOnError(err, "TGCmdWorker["+strconv.Itoa(id)+"] : SendMsg User")
|
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:
|
case commandSendDocument:
|
||||||
if c.ToChatID64 != 0 {
|
if c.ToChatID64 != 0 {
|
||||||
ch := tb.Chat{
|
ch := tb.Chat{
|
||||||
ID: c.ToUserID64,
|
ID: c.ToUserID64,
|
||||||
}
|
}
|
||||||
_, err := b.Send(&ch, c.Document)
|
//_, err := b.Send(&ch, c.Document)
|
||||||
// _, err := c.Document.Send(b, ch, nil)
|
_, err := c.Document.Send(b, ch, nil)
|
||||||
logOnError(err, "TGCmdWorker["+strconv.Itoa(id)+"] : SendDocument Chat")
|
logOnError(err, "TGCmdWorker["+strconv.Itoa(id)+"] : SendDocument Chat")
|
||||||
} else if c.ToUserID64 != 0 {
|
} else if c.ToUserID64 != 0 {
|
||||||
ch := tb.Chat{
|
ch := tb.Chat{
|
||||||
ID: c.ToUserID64,
|
ID: c.ToUserID64,
|
||||||
}
|
}
|
||||||
_, err := b.Send(&ch, c.Document)
|
//_, err := b.Send(&ch, c.Document)
|
||||||
// _, err := c.Document.Send(b, &ch, nil)
|
_, err := c.Document.Send(b, &ch, nil)
|
||||||
logOnError(err, "TGCmdWorker["+strconv.Itoa(id)+"] : SendDocument Chat")
|
logOnError(err, "TGCmdWorker["+strconv.Itoa(id)+"] : SendDocument Chat")
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user