summary refs log tree commit diff stats
path: root/plugins/fishlim/plugin_hexchat.c
diff options
context:
space:
mode:
authorTingPing <tingping@tingping.se>2014-12-12 05:43:57 -0500
committerTingPing <tingping@tingping.se>2014-12-15 15:08:00 -0500
commitaddefa9ef139af1d3a910336d471637a53d15502 (patch)
tree5b8ad9ab209ad1294863c7db2875577e38ea424d /plugins/fishlim/plugin_hexchat.c
parent7769bc99fea7139538f42e882734ab06d66426b8 (diff)
fishlim: Handle server-time
Diffstat (limited to 'plugins/fishlim/plugin_hexchat.c')
-rw-r--r--plugins/fishlim/plugin_hexchat.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/plugins/fishlim/plugin_hexchat.c b/plugins/fishlim/plugin_hexchat.c
index aa7249f2..19a0d58f 100644
--- a/plugins/fishlim/plugin_hexchat.c
+++ b/plugins/fishlim/plugin_hexchat.c
@@ -98,7 +98,7 @@ static int handle_outgoing(char *word[], char *word_eol[], void *userdata) {
 /**
  * Called when a channel message or private message is received.
  */
-static int handle_incoming(char *word[], char *word_eol[], void *userdata) {
+static int handle_incoming(char *word[], char *word_eol[], hexchat_event_attrs *attrs, void *userdata) {
     const char *prefix;
     const char *command;
     const char *recipient;
@@ -142,7 +142,17 @@ static int handle_incoming(char *word[], char *word_eol[], void *userdata) {
     // Build unecrypted message
     message = g_string_sized_new (100); /* TODO: more accurate estimation of size */
     g_string_append (message, "RECV");
-    
+
+    if (attrs->server_time_utc)
+    {
+        GTimeVal tv = { (glong)attrs->server_time_utc, 0 };
+        char *timestamp = g_time_val_to_iso8601 (&tv);
+
+       g_string_append (message, " @time=");
+       g_string_append (message, timestamp);
+       g_free (timestamp);
+    }
+
     for (uw = 1; uw < HEXCHAT_MAX_WORDS; uw++) {
         if (word[uw][0] != '\0')
             g_string_append_c (message, ' ');
@@ -272,11 +282,11 @@ int hexchat_plugin_init(hexchat_plugin *plugin_handle,
     
     /* Add handlers */
     hexchat_hook_command(ph, "", HEXCHAT_PRI_NORM, handle_outgoing, NULL, NULL);
-    hexchat_hook_server(ph, "NOTICE", HEXCHAT_PRI_NORM, handle_incoming, NULL);
-    hexchat_hook_server(ph, "PRIVMSG", HEXCHAT_PRI_NORM, handle_incoming, NULL);
+    hexchat_hook_server_attrs(ph, "NOTICE", HEXCHAT_PRI_NORM, handle_incoming, NULL);
+    hexchat_hook_server_attrs(ph, "PRIVMSG", HEXCHAT_PRI_NORM, handle_incoming, NULL);
     //hexchat_hook_server(ph, "RAW LINE", HEXCHAT_PRI_NORM, handle_debug, NULL);
-    hexchat_hook_server(ph, "TOPIC", HEXCHAT_PRI_NORM, handle_incoming, NULL);
-    hexchat_hook_server(ph, "332", HEXCHAT_PRI_NORM, handle_incoming, NULL);
+    hexchat_hook_server_attrs(ph, "TOPIC", HEXCHAT_PRI_NORM, handle_incoming, NULL);
+    hexchat_hook_server_attrs(ph, "332", HEXCHAT_PRI_NORM, handle_incoming, NULL);
     
     hexchat_printf(ph, "%s plugin loaded\n", plugin_name);
     /* Return success */