summaryrefslogtreecommitdiff
path: root/logging.c
diff options
context:
space:
mode:
Diffstat (limited to 'logging.c')
-rw-r--r--logging.c37
1 files changed, 31 insertions, 6 deletions
diff --git a/logging.c b/logging.c
index c3271fe..e7a20ea 100644
--- a/logging.c
+++ b/logging.c
@@ -55,6 +55,9 @@ int logline(char *str, char *ournick, char *basedir, int type) {
char tokens[MAXTOKENS][MAXDATASIZE];
char *token;
+ // Whether or not this is a "/me" PRIVMSG so we can log it slightly differently later
+ int meprivmsg = 0;
+
// Split out the first three space-separated parts of the string, leaving the rest.
// If LOG_PRIVMSG:
// This gets us the prefix (containing the "from" nick), the PRIVMSG command (not needed),
@@ -114,6 +117,18 @@ int logline(char *str, char *ournick, char *basedir, int type) {
}
}
+ // If it was a "/me" line then strip the "\1ACTION " and the trailing "\1", plus set a flag for later
+ if (strstr(str, "\1ACTION ") == str) {
+ debugprint(DEBUG_FULL, "logline(): /me PRIVMSG detected, stripping ACTION things.\n");
+ // Skip over the first 8 characters (\1ACTION )
+ str += 8;
+ // And remove the trailing \1
+ if (str[strlen(str) - 1] == '\1') {
+ str[strlen(str) - 1] = '\0';
+ }
+ meprivmsg = 1;
+ }
+
debugprint(DEBUG_FULL, "logline(): Logging PRIVMSG from '%s' to '%s' message '%s' in filename '%s'.\n", tokens[0], tokens[2], str, filename);
break;
@@ -226,12 +241,22 @@ int logline(char *str, char *ournick, char *basedir, int type) {
timestr[strlen(timestr) - 1] = '\0';
if (type == LOG_PRIVMSG) {
- // Prepend the time string and "from" nick
- if (!snprintf(line, MAXCHAR, "%s <%s> %s", timestr, tokens[0], str)) {
- fprintf(stderr, "Error while preparing log string to write!\n");
- debugprint(DEBUG_CRIT, "Error while preparing log string to write!\n");
- fclose(fp);
- return 0;
+ // Prepend the time string and "from" nick, different formatting depending on
+ // whether or not it was a "/me" message
+ if (meprivmsg) {
+ if (!snprintf(line, MAXCHAR, "%s * %s %s", timestr, tokens[0], str)) {
+ fprintf(stderr, "Error while preparing /me log string to write!\n");
+ debugprint(DEBUG_CRIT, "Error while preparing /me log string to write!\n");
+ fclose(fp);
+ return 0;
+ }
+ } else {
+ if (!snprintf(line, MAXCHAR, "%s <%s> %s", timestr, tokens[0], str)) {
+ fprintf(stderr, "Error while preparing log string to write!\n");
+ debugprint(DEBUG_CRIT, "Error while preparing log string to write!\n");
+ fclose(fp);
+ return 0;
+ }
}
} else if (type == LOG_JOINPART || type == LOG_TOPIC) {
// Prepend the time string