bot: Fixed channel handler giving negative minute count if started after log is long dead.
This commit is contained in:
@@ -50,7 +50,11 @@ func (channel *Channel) loop() {
|
||||
session, err := logs.FindOpen(channel.parentCtx, channel.name)
|
||||
if err == nil {
|
||||
minsUntilDeadline := 1 + int(((time.Hour * 2) - time.Since(session.LatestTime())).Minutes())
|
||||
channel.client.Sayf(channel.name, "Session https://aiterp.net/logs/%s will be closed in %d minutes if there are no new posts.", session.ID, minsUntilDeadline)
|
||||
if minsUntilDeadline < 1 {
|
||||
minsUntilDeadline = 1
|
||||
}
|
||||
|
||||
channel.client.Sayf(channel.name, "Session https://aiterp.net/logs/%s will be closed in %d min if there are no new posts.", session.ID, minsUntilDeadline)
|
||||
|
||||
channel.lastPostSessionID = session.ID
|
||||
channel.lastPostTime = session.LatestTime()
|
||||
@@ -215,7 +219,7 @@ func (channel *Channel) loop() {
|
||||
break
|
||||
}
|
||||
|
||||
channel.client.Sayf(channel.name, "Log session closed due to 2 hours of inactivity. See log at https://aiterp.net/logs/%s", channel.lastPostSessionID)
|
||||
channel.client.Sayf(channel.name, "Log session closed after 2+ hours of inactivity. See log at https://aiterp.net/logs/%s", channel.lastPostSessionID)
|
||||
|
||||
channel.lastPostTime = time.Time{}
|
||||
channel.lastPostSessionID = ""
|
||||
|
||||
Reference in New Issue
Block a user