[mw-devel] [Git][milliways/mw][master] Put timestamps on onoff messages

Andrew Price welshbyte at sucs.org
Mon Apr 8 21:32:36 BST 2019


Andrew Price pushed to branch master at milliways / mw


Commits:
661fd23e by Andrew Price at 2019-04-08T20:29:53Z
Put timestamps on onoff messages

Fixes #41

- - - - -


1 changed file:

- src/client/incoming.c


Changes:

=====================================
src/client/incoming.c
=====================================
@@ -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:



View it on GitLab: https://projects.sucs.org/milliways/mw/commit/661fd23eb4169f8b886eacdcb370e878d356807d

-- 
View it on GitLab: https://projects.sucs.org/milliways/mw/commit/661fd23eb4169f8b886eacdcb370e878d356807d
You're receiving this email because of your account on projects.sucs.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sucs.org/pipermail/mw-devel/attachments/20190408/76e05729/attachment-0001.html>


More information about the mw-devel mailing list