From: Antoine Jacquet Date: Fri, 9 Nov 2007 23:00:00 +0000 (+0100) Subject: version 0.75 X-Git-Tag: v0.75 X-Git-Url: http://royale.zerezo.com/git/?p=irssistats;a=commitdiff_plain;h=refs%2Ftags%2Fv0.75;ds=sidebyside version 0.75 * generate better/longer quotes when possible (patch by Nikolai Weh) --- diff --git a/CHANGELOG b/CHANGELOG index f69053d..1fd72f8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ Change log file for irssistats +version 0.75 (2007-11-10) + * generate better/longer quotes when possible (patch by Nikolai Weh) + version 0.74 (2007-09-20) * added CFLAGS to Makefile (patch by VMiklos) * added '&' and '~' to list of nick prefix (patch by VMiklos) diff --git a/README b/README index eb94446..156ea47 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -irssistats 0.74 +irssistats 0.75 site: http://royale.zerezo.com/irssistats/ mail: royale@zerezo.com diff --git a/irssistats.c b/irssistats.c index e287e77..ea31cee 100644 --- a/irssistats.c +++ b/irssistats.c @@ -1,5 +1,5 @@ /* - * irssistats version 0.74 + * irssistats version 0.75 * * This tool generates IRC stats based on irssi logs. * Usage: irssistats [/path/to/file.conf] @@ -49,7 +49,7 @@ #define MINWORDLENGTH 5 /* irssistats */ -#define VERSION "0.74" +#define VERSION "0.75" #define URL "http://royale.zerezo.com/irssistats/" /* Counters */ @@ -1164,7 +1164,24 @@ void parse_log(char *logfile) if (message[j-1]==')') users[i].counters[D_SMILE]++; else if (message[j-1]=='(') users[i].counters[D_FROWN]++; } - if (rand()%users[i].lines==0) strncpy(users[i].quote,message,MAXQUOTELENGTH); + // Fetch a random message, messages between 25 and 70 chars are + // preferred (pisg-style, gets "better" quotes) + // + if (rand()%users[i].lines==0) { + + int len = strlen(message); + // if we have a "good" quote, use it + if ( len > 25 && len < 70 ) + { + strncpy(users[i].quote,message,MAXQUOTELENGTH); + } else { + int len2 = strlen(users[i].quote); + if ( !(len2 > 25 && len2 < 70 )) { + strncpy(users[i].quote,message,MAXQUOTELENGTH); + } + } + } + if (strncmp("http://",message,7)==0) { users[i].counters[D_URL]++; @@ -1812,7 +1829,6 @@ void parse_config(char *configfile) int main(int argc,char *argv[]) { (void) setlocale(LC_ALL, ""); - if ((users=malloc(maxusers*sizeof(struct user)))==NULL) { fprintf(stderr,"unable to malloc memory\n"); exit(1); } srand(debut=time(NULL)); if (argc==1) parse_config(NULL); @@ -1825,3 +1841,4 @@ int main(int argc,char *argv[]) } return(0); } +