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
master
cheapie 2016-02-22 14:21:22 -05:00
parent 0df279ad87
commit 71bf018c1a
1 changed files with 15 additions and 1 deletions

View File

@ -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);
}