summary refs log tree commit diff stats
path: root/plugins/checksum
diff options
context:
space:
mode:
authorberkeviktor@aol.com <berkeviktor@aol.com>2010-10-21 02:51:18 +0200
committerberkeviktor@aol.com <berkeviktor@aol.com>2010-10-21 02:51:18 +0200
commit2fd336f1569abbb4b6de85c6def2c5b8f4b1ee07 (patch)
tree0e38aa5cc5b8f8848b216e3c78936f49d574e7f3 /plugins/checksum
parent6263278707993a43770ca0bcc2c6ee58b2f862d8 (diff)
send checksum in privmsg, print local sum in the same tab
Diffstat (limited to 'plugins/checksum')
-rw-r--r--plugins/checksum/checksum.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/plugins/checksum/checksum.c b/plugins/checksum/checksum.c
index 14e6ea24..d5301ce3 100644
--- a/plugins/checksum/checksum.c
+++ b/plugins/checksum/checksum.c
@@ -106,20 +106,24 @@ int
 dccrecv_cb(char *word[], void *userdata)
 {
 	unsigned char sum[65];
+
 	sha256_file (word[2], sum);
-	xchat_printf (ph, "DCC RECV %s from %s complete [%s cps]\n", word[1], word[3], word[4]);
-	xchat_printf (ph, "SHA256 checksum for %s:\n%s\n", word[1], sum);
-	return XCHAT_EAT_XCHAT;
+	/* try to print the checksum in the privmsg tab of the sender */
+	xchat_set_context (ph, xchat_find_context (ph, NULL, word[3]));
+	xchat_printf (ph, "SHA-256 checksum for %s (local):  %s\n", word[1], sum);
+
+	return XCHAT_EAT_NONE;
 }
 
 int
 dccoffer_cb(char *word[], void *userdata)
 {
 	unsigned char sum[65];
+
 	sha256_file (word[3], sum);
-	xchat_printf (ph, "Offering %s to %s\n", word[1], word[2]);
-	xchat_printf (ph, "SHA256 checksum for %s:\n%s\n", word[1], sum);
-	return XCHAT_EAT_XCHAT;
+	xchat_commandf (ph, "raw PRIVMSG %s :SHA-256 checksum for %s (remote): %s", word[2], word[1], sum);
+
+	return XCHAT_EAT_NONE;
 }
 
 int
@@ -129,7 +133,7 @@ xchat_plugin_init (xchat_plugin *plugin_handle, char **plugin_name, char **plugi
 
 	*plugin_name = "Checksum";
 	*plugin_desc = "Calculate checksum for DCC file transfers";
-	*plugin_version = "1.0";
+	*plugin_version = "1.1";
 	
 	xchat_hook_print(ph, "DCC RECV Complete", XCHAT_PRI_NORM, dccrecv_cb, NULL);
 	xchat_hook_print(ph, "DCC Offer", XCHAT_PRI_NORM, dccoffer_cb, NULL);