Log key dcc info messages, keep dcc tab open
This commit is contained in:
parent
a90e8d4b2f
commit
84a10efe36
@ -131,9 +131,6 @@ func (c *Client) Download(pack *DCCSend) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: is this needed?
|
|
||||||
conn.Write(uint64Bytes(totalBytes))
|
|
||||||
|
|
||||||
c.Progress <- DownloadProgress{
|
c.Progress <- DownloadProgress{
|
||||||
PercCompletion: 100,
|
PercCompletion: 100,
|
||||||
BytesCompleted: humanReadableByteCount(float64(totalBytes), false),
|
BytesCompleted: humanReadableByteCount(float64(totalBytes), false),
|
||||||
|
@ -66,14 +66,14 @@ func (i *ircHandler) run() {
|
|||||||
|
|
||||||
case progress := <-i.client.Progress:
|
case progress := <-i.client.Progress:
|
||||||
if progress.Error != nil {
|
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 {
|
} 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)
|
i.state.String("scheme"), i.state.String("host"), i.state.user.Username, progress.File)
|
||||||
} else if progress.PercCompletion == 0 {
|
} else if progress.PercCompletion == 0 {
|
||||||
i.sendDCCInfo("%s: Starting download", progress.File)
|
i.sendDCCInfo("%s: Starting download", true, progress.File)
|
||||||
} else {
|
} 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)
|
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])
|
log.Println("[IRC]", i.state.user.ID, i.client.Host, s[:len(s)-1])
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *ircHandler) sendDCCInfo(message string, a ...interface{}) {
|
func (i *ircHandler) sendDCCInfo(message string, log bool, a ...interface{}) {
|
||||||
i.state.sendJSON("pm", Message{
|
msg := Message{
|
||||||
Server: i.client.Host,
|
Server: i.client.Host,
|
||||||
From: "@dcc",
|
From: "@dcc",
|
||||||
Content: fmt.Sprintf(message, a...),
|
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 {
|
func parseMode(mode string) *Mode {
|
||||||
|
Loading…
Reference in New Issue
Block a user