Commit 661fd23e authored by Andrew Price's avatar Andrew Price
Browse files

Put timestamps on onoff messages

Fixes #41
parent 17fda856
Loading
Loading
Loading
Loading
Loading
+16 −6
Original line number Diff line number Diff line
@@ -114,20 +114,30 @@ void ClearStack(void) {
	MesgStacked=0;
}

static void display_onoff(int action, const char *name, int room)
static void display_onoff(int action, const char *name, int room, int64_t when)
{
	char ts[7] = {0}; /* "hh:mm " */

	if (s_timestamp(user)) {
		struct tm *tm;
		time_t t = when;

		tm = localtime(&t);
		strftime(ts, 7, "%H:%M ", tm);
		ts[6] = '\0';
	}
	switch (action) {
	case ONOFF_LEAVE:
		format_message("\03311* %s has just left the talker.", name);
		format_message("%s\03311* %s has just left the talker.", ts, name);
		break;
	case ONOFF_JOIN:
		format_message("\03310* %s has just joined talker room %d.", name, room);
		format_message("%s\03310* %s has just joined talker room %d.", ts, name, room);
		break;
	case ONOFF_LOGOFF:
		format_message("\03302* %s has just left the board.", name);
		format_message("%s\03302* %s has just left the board.", ts, name);
		break;
	case ONOFF_LOGON:
		format_message("\03301* %s has just entered the board.", name);
		format_message("%s\03301* %s has just entered the board.", ts, name);
		break;
	}
}
@@ -307,7 +317,7 @@ void DisplayStack(void)
				if (cp_test(user, CP_SCRIPT) && onoff_name != NULL)
					ExecEvent2(onoff_name, "CheckOnOff", new->from, 0, 6, aargs);
				if (script_output && !isquiet)
					display_onoff(action, uname, room);
					display_onoff(action, uname, room, new->msg->head.when);
				break;
			}
			default: