-irssistats 0.32
+irssistats 0.4
site: http://royale.zerezo.com/programmation/irssistats/
mail: royale@zerezo.com
cp pix/*.png /path/to/webdir/
usage:
-cat /path/to/file.log | ./irssistats channel maintainer language theme > /path/to/webdir/index.html
+cat /path/to/file.log | ./irssistats channel maintainer language theme [nickfile] > /path/to/webdir/index.html
+
+nickfile:
+Since version 0.4 of irssistats, you can use a nickfile to specify nicks to join.
+Each line of the nickfile contains the final nick and a regular expression.
+Examples :
+ royale ^[Rr]oyale : join nicks starting with "Royale" or "royale" to the final nick "royale"
+ royale ^antoine$ : also join the nick "antoine" to the final nick "royale"
+ djakette [Dd]ja : join any nick that contains "Dja" or "dja" to final nick "djakette"
+The nickfile must not contain any comments.
+You can also take a look at the "sample.nickfile.txt" in this package.
links:
http://torus.lnet.lut.fi/ircstats/
-/* Usage: cat /path/to/file.log | ./irssistats channel maintainer language theme > /path/to/file.html */
+/* Usage: cat /path/to/file.log | ./irssistats channel maintainer language theme [nickfile] > /path/to/file.html */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
+#include <regex.h>
/* Config */
#define MAXUSERS 5000
#define MINWORDLENGTH 5
/* irssistats */
-#define VERSION "0.32"
+#define VERSION "0.4"
#define URL "http://royale.zerezo.com/programmation/irssistats/"
/* Counters */
char c;
char *nick,*message;
char line[MAXLINELENGTH];
+ FILE *fic;
+ regex_t preg;
/*** INIT ***/
- if (argc!=5)
+ if ((argc<5) || (argc>6))
{
- fprintf(stderr,"Usage: cat /path/to/file.log | ./irssistats channel maintainer language theme > /path/to/file.html\n\n");
+ fprintf(stderr,"Usage: cat /path/to/file.log | ./irssistats channel maintainer language theme [nickfile] > /path/to/file.html\n\n");
fprintf(stderr,"Version :\nirssistats %s\n\n",VERSION);
fprintf(stderr,"Supported languages :\n");
for (i=0;i<NBLANGUAGES;i++) fprintf(stderr,"%s = %s\n",keys[i][0][1],keys[i][0][0]);
for (j=0;j<4;j++) lastdays[0].hours[j]=0;
days++;
}
- else if (strncmp("-!- mode/",&line[6],9)==0) /* 00:00 -!- mode/#channel [...] by Nick(, Nick2, Nick3...) */
+ else if (strncmp("-!- mode/",&line[6],9)==0) /* 00:00 -!- mode/#channel [...] by (Nick, Nick2, )Nick3 */
{
- for (i=15;(line[i]!=']')||(line[i+1]!=' ');i++);
- nick=&line[i+5];
- for (i=0;(nick[i]!='\0')&&(nick[i]!=',');i++);
- nick[i]='\0';
+ for (i=strlen(line);line[i]!=' ';i--);
+ nick=&line[i+1];
users[dichotomic(nick)].counters[D_MODE]++;
}
else if (strncmp("-!-",&line[6],3)==0) /* 00:00 -!- Nick something... */
message=&line[i+1];
}
else if (line[7]=='>') /* 00:00 <>>>?Nick<<<> the personal message */
+ /* 00:00 <>>?Nick<<> the personal message */
{
- for (i=11;line[i]!='<';i++);
- nick=&line[11];
+ for (i=10;line[i]!='<';i++);
+ nick=&line[10];
+ if (line[9]=='>') nick++;
message=&line[i+5];
}
else /* 00:00 <?Nick> the message */
bestwords(words,0);
+ /*** ALIAS ***/
+
+ if (argc==6)
+ {
+ if ((fic=fopen(argv[5],"rt"))==NULL) { fprintf(stderr,"can't open nick file\n"); exit(1); }
+ while (fscanf(fic,"%s",line)==1)
+ {
+ user=dichotomic(line);
+ fscanf(fic,"%s",line);
+ if (regcomp(&preg,line,0)!=0) { fprintf(stderr,"error in nick file"); exit(1); }
+ temp=users[user].lines;
+ for (i=0;i<nbusers;i++) if ((i!=user) && (regexec(&preg,users[i].nick,0,0,0)==0) && (users[i].lines>=0))
+ {
+ if (users[i].lines>temp) /* for nick alias, keep the random quote of the most used nick */
+ {
+ strcpy(users[user].quote,users[i].quote);
+ temp=users[i].lines;
+ }
+ users[user].lines+=users[i].lines;
+ users[user].letters+=users[i].letters;
+ for (j=0;j<4;j++) users[user].hours[j]+=users[i].hours[j];
+ for (j=0;j<NBCOUNTERS;j++) users[user].counters[j]+=users[i].counters[j];
+ /* "remove" old user */
+ users[i].lines=-1;
+ users[i].letters=-1;
+ for (j=0;j<4;j++) users[i].hours[j]=-1;
+ for (j=0;j<NBCOUNTERS;j++) users[i].counters[j]=-1;
+ }
+ regfree(&preg);
+ }
+ fclose(fic);
+ }
+
/*** HTML ***/
/* header */
for (i=1;i<=NBUSERS;i++)
{
user=-1;
- max=-1;
+ max=0;
for (j=0;j<nbusers;j++) if (users[j].lines>max) max=users[user=j].lines;
if (user!=-1)
{
}
}
printf("</table>\n");
- if (nbusers>NBUSERS)
+ temp=0;
+ for (i=0;i<=nbusers;i++) if (users[i].lines>=0) temp++;
+ if (temp>0)
{
printf("<br>");
- printf(L("OTHERS"),nbusers-50);
+ printf(L("OTHERS"),temp);
printf("<br>\n");
}
printf("<br><br>\n\n");
for (j=0;j<4;j++)
{
user=-1;
- max=-1;
+ max=0;
for (k=0;k<nbusers;k++) if (users[k].hours[j]>max) max=users[user=k].hours[j];
if (user!=-1)
{