Fix auto-away time strangeness when server reconnection happens.

git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@94 13b04d17-f746-0410-82c6-800466cd88b0
This commit is contained in:
Kevin Easton
2010-09-05 08:37:04 +00:00
parent a72091bb0e
commit d6c105861c
3 changed files with 12 additions and 11 deletions

View File

@@ -79,7 +79,7 @@ extern LastMsg last_sent_ctcp[2];
void clear_array (NickTab **, char *);
char *BX_random_str (int, int);
int check_serverlag (void);
void auto_away (unsigned long);
void check_auto_away (time_t);
ChannelList * BX_prepare_command (int *, char *, int);
int rename_file (char *, char **);
void putlog (int, ...);

View File

@@ -328,15 +328,14 @@ char *BX_update_clock(int flag)
do_hook(TIMER_LIST, "%02d:%02d", hour, min);
if (min == 0 || new_hour)
do_hook(TIMER_HOUR_LIST, "%02d:%02d", hour, min);
idlet = (hideous - idle_time) / 60L;
idlet = hideous - idle_time;
if (from_server != -1)
is_away = get_server_away(from_server) ? 1 : 0;
if (do_hook(IDLE_LIST, "%lu", (unsigned long)idlet))
if (do_hook(IDLE_LIST, "%lu", (unsigned long)idlet / 60))
{
if (is_away && new_hour && get_int_var(TIMESTAMP_AWAYLOG_HOURLY_VAR))
logmsg(LOG_CRAP, NULL, 4, NULL);
if (!is_away && get_int_var(AUTO_AWAY_TIME_VAR) && (idlet >= get_int_var(AUTO_AWAY_TIME_VAR)/60))
auto_away(idlet);
check_auto_away(idlet);
}
check_channel_limits();
}

View File

@@ -1184,18 +1184,20 @@ char *BX_random_str(int min, int max)
}
void auto_away(unsigned long idle_mins)
void check_auto_away(time_t idlet)
{
int i;
char *msg = NULL;
int auto_away_time = get_int_var(AUTO_AWAY_TIME_VAR);
int idle_mins = auto_away_time / 60;
if (!get_int_var(AUTO_AWAY_VAR))
if (!auto_away_time || !get_int_var(AUTO_AWAY_VAR) || idlet < auto_away_time)
return;
if (awaymsg)
malloc_sprintf(&msg, "%s: [%lu mins]", convert_output_format(awaymsg, NULL), idle_mins);
malloc_sprintf(&msg, "%s: [%d mins]", convert_output_format(awaymsg, NULL), idle_mins);
else
malloc_sprintf(&msg, "Auto-Away after %lu mins", idle_mins);
malloc_sprintf(&msg, "Auto-Away after %d mins", idle_mins);
for (i = 0; i < server_list_size(); i++)
if (is_server_connected(i) && !get_server_away(i))