- // FIXME: This needs converted to 64-bit time.
- // For legacy protocol, keep the 32-bit signed int time. For modern protocol, just send
- // the actual QDateTime() instead, don't bother converting it.
- int now = QDateTime::currentDateTime().toTime_t();
- // FIXME: Convert to millisecond comparison, comment the constant value as needed
- const int silenceTime = 60;
- if (ircuser->lastAwayMessage() + silenceTime >= now)
+ QDateTime now = QDateTime::currentDateTime();
+ now.setTimeSpec(Qt::UTC);
+ // Don't print "user is away" messages more often than this
+ // 1 hour = 60 min * 60 sec
+ const int silenceTime = 60 * 60;
+ // Check if away state has NOT changed and silence time hasn't yet elapsed
+ if (!ircuser->hasAwayChanged() && ircuser->lastAwayMessageTime().addSecs(silenceTime) >= now) {
+ // Away message hasn't changed and we're still within the period of silence; don't
+ // repeat the message