diff options
| -rw-r--r-- | sparkles.c | 16 | 
1 files changed, 15 insertions, 1 deletions
| @@ -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);     } | 
