Log key dcc info messages, keep dcc tab open

This commit is contained in:
Ken-Håvard Lieng 2020-05-19 10:37:20 +02:00
parent a90e8d4b2f
commit 84a10efe36
2 changed files with 13 additions and 10 deletions

View File

@ -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),

View File

@ -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 {