/* miscellaneous things that don't really fit anywhere else */ #include #include #include "eggdrop.h" extern int serv; extern char curchan[]; extern char notefile[]; extern int dcc_total; extern struct dcc_t dcc[]; extern char logfile[]; extern char helpbot[]; extern char helpdir[]; extern int helpsock; /* retrieve info for a user */ /*void UNUSED_getinfo(who,get) char *who,*get; { FILE *f; char s[81],nick[20]; get[0]=0; if (!infofile[0]) return; f=fopen(infofile,"r"); if (f==NULL) return; while (!feof(f)) { fgets(s,80,f); if (!feof(f)) { if (s[strlen(s)-1]=='\n') s[strlen(s)-1]=0; split(nick,s); if ((nick[0]!='#') && (nick[0]!=';') && (strcasecmp(nick,who)==0)) strcpy(get,s); } } fclose(f); } */ /* find info for a user and display it if there is one */ void showinfo(who,nick) char *who,*nick; { char s[121],s1[81],mtch[21]; get_handle_info(who,s1); strcpy(s,s1); if (s[0]) { sprintf(mtch,"*%s*",nick); if (!wild_match(mtch,s1)) sprintf(s,"[%s] %s",who,s1); mprintf(serv,"PRIVMSG %s :%s\n",curchan,s); } } /* set an infofile record for a user */ /*void UNUSED_change_userinfo(who,s) char *who,*s; { FILE *f,*g; char fn[120],nick[20]; if (strlen(s)>65) s[65]=0; if (!infofile[0]) return; sprintf(fn,"%s~new",infofile); f=fopen(infofile,"r"); g=fopen(fn,"w"); if (g==NULL) { fclose(f); return; } if (f!=NULL) while (!feof(f)) { fgets(fn,80,f); if (!feof(f)) { if (fn[strlen(fn)-1]=='\n') fn[strlen(fn)-1]=0; if ((fn[0]=='#') || (fn[0]==';') || (fn[0]==0)) fprintf(g,"%s\n",fn); else { split(nick,fn); if (strcasecmp(nick,who)!=0) fprintf(g,"%s %s\n",nick,fn); } } } fprintf(g,"%s %s\n",who,s); if (f!=NULL) fclose(f); fclose(g); unlink(infofile); sprintf(fn,"mv %s~new %s",infofile,infofile); system(fn); } */ /* show all notes for 'user' to z */ /* (delete them in the process) */ void tell_notes(z,user) int z; char *user; { FILE *f,*g; char s[513],from[15],to[15],timestr[81]; time_t t; if (!notefile[0]) return; f=fopen(notefile,"r"); if (f==NULL) return; sprintf(s,"%s~new",notefile); g=fopen(s,"w"); if (g==NULL) { fclose(f); return; } while (!feof(f)) { fgets(s,512,f); if (s[strlen(s)-1]=='\n') s[strlen(s)-1]=0; if (!feof(f)) { rmspace(s); if ((s[0]) && (s[0]!='#') && (s[0]!=';')) { /* not comment */ split(to,s); if (strcasecmp(to,user)==0) { split(from,s); split(timestr,s); t=atol(timestr); strcpy(timestr,ctime(&t)); timestr[16]=0; strcpy(timestr,×tr[4]); tprintf(z,"### NOTE from %s (%s): %s\n",from,timestr,s); } else fprintf(g,"%s %s\n",to,s); } else fprintf(g,"%s\n",s); } } fclose(f); fclose(g); unlink(notefile); sprintf(s,"mv %s~new %s",notefile,notefile); system(s); } /* add note to notefile */ void add_note(to,from,msg,z) char *to,*from,*msg; int z; { FILE *f; int i; if (notefile[0]==0) { tprintf(z,"Notes are not supported by this bot.\n"); return; } if ((!match_attr_handle(to,USER_OP))&&(!match_attr_handle(to,USER_MASTER))&& (strcasecmp(to,"hq")!=0)) { tprintf(z,"Nobody called %s has access to the party line!\n",to); return; } for (i=0; itm_hour*60)+tt->tm_min; max=min-ii; min-=nn; f=fopen(logfile,"r"); if (f==NULL) { tprintf(z,"Can't open logfile at all.\n"); return; } tprintf(z,"--- Logfile excerpt from %d min%s ago:\n",nn,nn==1?"":"s"); /* sift thru log file for entries >nn */ while (!feof(f)) { fgets(s,255,f); if (s[strlen(s)-1]=='\n') s[strlen(s)-1]=0; if (!feof(f)) { rmspace(s); if (s[0]=='[') { /* time stamp */ i=(atoi(&s[1])*60)+(atoi(&s[4])); if ((i>=min) && (i<=max)) tprintf(z,"%s\n",s); } } } tprintf(z,"--- End of logfile excerpt.\n"); fclose(f); } /* nick in use: 433 */ void helpbot_433(from,msg) char *from,*msg; { int i,j; char *oknicks="0^1-2_\\3[45]67`89"; /* just change the last character randomly */ i=strlen(helpbot); if (i==9) i--; helpbot[i+1]=0; j=(rand()/16)%(strlen(oknicks)+26); if (j