summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2016-02-22 14:21:22 -0500
committercheapie <no-email-for-you@example.com>2016-02-22 14:21:22 -0500
commit71bf018c1a2188a2468936133f15a5bdc2900d30 (patch)
treecff17d64730ae8f5d3d75a75dae23faec175ba86
parent0df279ad8735176f7bb3ffbac1971cd5bdc6572a (diff)
downloadsparkles-71bf018c1a2188a2468936133f15a5bdc2900d30.tar
sparkles-71bf018c1a2188a2468936133f15a5bdc2900d30.tar.gz
sparkles-71bf018c1a2188a2468936133f15a5bdc2900d30.tar.bz2
sparkles-71bf018c1a2188a2468936133f15a5bdc2900d30.tar.xz
sparkles-71bf018c1a2188a2468936133f15a5bdc2900d30.zip
Openlogs ensures the file exists
If the specified logs don't exist, Sparkles tries again with the network and channel swapped, and if THAT doesn't work, it displays an error
-rw-r--r--sparkles.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/sparkles.c b/sparkles.c
index d065944..aa7f383 100644
--- a/sparkles.c
+++ b/sparkles.c
@@ -2282,7 +2282,7 @@ static int Spark_cb(char *word[], char *word_eol[], void *userdata) {
WasValid = 1;
AsyncExec(word_eol[3]);
}
- if(!strcasecmp(word[2],"openlogs")) {
+ if(!strcasecmp(word[2],"openlogs") || !strcasecmp(word[2],"openlogs_")) {
WasValid = 1;
const char *Chan = xchat_get_info(ph, "channel");
const char *Network = xchat_get_info(ph, "network");
@@ -2300,6 +2300,20 @@ static int Spark_cb(char *word[], char *word_eol[], void *userdata) {
sprintf(Buffer, "%s/logs/%s", xchat_get_info(ph, "xchatdirfs"), LogPath);
else
sprintf(Buffer, "%s/xchatlogs/%s", xchat_get_info(ph, "xchatdirfs"), LogPath);
+
+ // does the file exist?
+ // if not, the user probably swapped the network and channel name, so try it the other way
+ FILE *Test = fopen(Buffer, "rb");
+ if(!Test) {
+ if(!strcmp(word[2], "openlogs")) { // only swap if they aren't already swapped
+ xchat_commandf(ph, "spark openlogs_ %s %s", Network, Chan);
+ } else {
+ xchat_printf(ph, "No logs for %s:%s", Network, Chan);
+ }
+ return XCHAT_EAT_ALL;
+ }
+ fclose(Test);
+
xchat_commandf(ph,"spark aexec %s %s\n", TextEditor, Buffer);
}