diff --git a/pkg/irc/dcc.go b/pkg/irc/dcc.go index 62449771..bc8f7032 100644 --- a/pkg/irc/dcc.go +++ b/pkg/irc/dcc.go @@ -131,9 +131,6 @@ func (c *Client) Download(pack *DCCSend) { } } - // TODO: is this needed? - conn.Write(uint64Bytes(totalBytes)) - c.Progress <- DownloadProgress{ PercCompletion: 100, BytesCompleted: humanReadableByteCount(float64(totalBytes), false), diff --git a/server/irc_handler.go b/server/irc_handler.go index a7a00853..1875f5cb 100644 --- a/server/irc_handler.go +++ b/server/irc_handler.go @@ -66,14 +66,14 @@ func (i *ircHandler) run() { case progress := <-i.client.Progress: if progress.Error != nil { - i.sendDCCInfo("%s: Download failed (%s)", progress.File, progress.Error) + i.sendDCCInfo("%s: Download failed (%s)", true, progress.File, progress.Error) } else if progress.PercCompletion == 100 { - i.sendDCCInfo("Download finished, get it here: %s://%s/downloads/%s/%s", + i.sendDCCInfo("Download finished, get it here: %s://%s/downloads/%s/%s", true, i.state.String("scheme"), i.state.String("host"), i.state.user.Username, progress.File) } else if progress.PercCompletion == 0 { - i.sendDCCInfo("%s: Starting download", progress.File) + i.sendDCCInfo("%s: Starting download", true, progress.File) } else { - i.sendDCCInfo("%s: %.1f%%, %s, %s remaining, %.1fs left", progress.File, + i.sendDCCInfo("%s: %.1f%%, %s, %s remaining, %.1fs left", false, progress.File, progress.PercCompletion, progress.Speed, progress.BytesRemaining, progress.SecondsToGo) } } @@ -431,12 +431,18 @@ func (i *ircHandler) log(v ...interface{}) { log.Println("[IRC]", i.state.user.ID, i.client.Host, s[:len(s)-1]) } -func (i *ircHandler) sendDCCInfo(message string, a ...interface{}) { - i.state.sendJSON("pm", Message{ +func (i *ircHandler) sendDCCInfo(message string, log bool, a ...interface{}) { + msg := Message{ Server: i.client.Host, From: "@dcc", Content: fmt.Sprintf(message, a...), - }) + } + i.state.sendJSON("pm", msg) + + if log { + i.state.user.AddOpenDM(msg.Server, msg.From) + i.state.user.LogMessage(betterguid.New(), msg.Server, msg.From, msg.From, msg.Content) + } } func parseMode(mode string) *Mode {