From 04e1a88e14844fa692c6bb6b484a2a2d9207f194 Mon Sep 17 00:00:00 2001 From: epochqwert Date: Sat, 7 Feb 2015 03:43:14 -0600 Subject: took out startup_stuff because server messages can be handled now. !alias !004 !raw join #defualt or whatever you want the bot to do. --- segfault.c | 111 ++++++++++++++++++++++++------------------------------------- 1 file changed, 43 insertions(+), 68 deletions(-) (limited to 'segfault.c') diff --git a/segfault.c b/segfault.c index 1f063bc..8404577 100644 --- a/segfault.c +++ b/segfault.c @@ -15,6 +15,14 @@ #include "libirc/irc.h" //epoch's libirc. should be included with segfault. #include "libhashtable/hashtable.h" //epoch's also. +/*// just in case your system doesn't have strndup +char *strndup(char *s,int l) { + char *r=strdup(s); + r[l]=0; + return r; +} +*/ + //might want to change some of these. #define TSIZE 65535 #define SERVER "127.0.0.1" @@ -42,20 +50,6 @@ #define PRIVMSG_LINE_LIMIT 0 -//this function isn't with the rest of them because... meh. -char *tailmode_to_txt(int mode) { - char *modes="recmbsnf"; - int i,j=0; - char *m=malloc(strlen(modes)); - for(i=0;inick: ((fmt[i]=='u')?user->user: - ((fmt[i]=='~')?getcwd(seghome,SEGHOMELEN): + ((fmt[i]=='~')?seghome: ((fmt[i]=='h')?user->host: ((fmt[i]=='f')?from: ((fmt[i]=='p')?pid: @@ -234,8 +237,9 @@ char *format_magic(int fd,char *from,struct user *user,char *orig_fmt,char *arg) /* hate */ ((fmt[i]=='6')?argN[6]: /* this, */ ((fmt[i]=='7')?argN[7]: /* dontcha? :)*/ ((fmt[i]=='8')?argN[8]: - ((fmt[i]=='9')?argN[9]:"%" - )))))))))))))))))); + ((fmt[i]=='9')?argN[9]: + ((fmt[i]=='r')?randC[rand()%10]:"%" + ))))))))))))))))))); fmt[i-1]=0; if(!(fmt+j)) exit(68); if(!(notargs[c]=strdup(fmt+j))) exit(66); @@ -529,10 +533,6 @@ void prestartup_stuff(int fd) { } } -void startup_stuff(int fd) { - c_leettail(fd,"#cmd","150./scripts/startup",myuser); -} - void debug_time(int fd,char *from,char *msg) { char tmp[100]; if(debug) { @@ -598,7 +598,6 @@ void c_amnesia(int fd,char *from,...) {//forget aliases ht_freevalues(&alias); ht_destroy(&alias); inittable(&alias,TSIZE); - //put this as a builtin I guess. } void c_lobotomy(int fd,char *from,...) {//forget builtins @@ -689,7 +688,6 @@ void c_id(int fd,char *from,...) { privmsg(fd,from,tmp); } -//fix this fucking shit. void c_leetuntail(int fd,char *from,char *line,...) { if(!line) { privmsg(fd,from,"usage: !leetuntail [target|*] filename"); @@ -724,7 +722,6 @@ void c_leetuntail(int fd,char *from,char *line,...) { } } -//check for possibility of dedupping code. void c_istaillocked(int fd,char *from,char *file,...) { char *msg=0; int i; @@ -786,16 +783,7 @@ char append_file(int fd,char *from,char *file,char *line,unsigned short nl) { } fcntl(fileno(fp),F_SETFL,O_NONBLOCK); eofp(fp); -/* mywrite(fileno(fp),line); - mywrite(fileno(fp),"\n");*/ fprintf(fp,"%s\n",line); -/* - fcntl(fdd,F_SETFL,O_NONBLOCK); - eofd(fdd); - mywrite(fdd,line); - mywrite(fdd,"\n"); -*/ -// close(fdd); fclose(fp); return 1; } @@ -893,7 +881,6 @@ void c_rawrecord(int fd,char *from,char *line,...) { privmsg(fd,from,recording_raw?"1":"0"); } - void c_leetsetout(int fd,char *from,char *msg,...) { if(!msg) { privmsg(fd,from,"usage: don't"); @@ -988,6 +975,7 @@ void message_handler(int fd,char *from,struct user *user,char *msg,int redones) char tmp[512]; int len; int sz; + //privmsg(fd,"#debug",msg); //debug_time(fd,from); if(user->nick) { if(strcmp(user->nick,myuser->nick)) { @@ -1093,8 +1081,6 @@ void line_handler(int fd,char *line) {//this should be built into the libary? if(recording_raw) { append_file(fd,"epoch",RAWLOG,line,'\n'); } - - // rewrite this shit. if(line[0]==':') { if((user->nick=strchr(line,':'))) { *(user->nick)=0; @@ -1125,7 +1111,6 @@ void line_handler(int fd,char *line) {//this should be built into the libary? user->host=user->nick; } } - //all this shit. printf("<%s!%s@%s> '%s' '%s' '%s'\n", user->nick, @@ -1133,28 +1118,19 @@ void line_handler(int fd,char *line) {//this should be built into the libary? user->host, s,t,u); if(!user->user && s) { //server message - if(!strcmp(s,"433")) {//nick already used. - srand(time(NULL)*getpid()); - myuser->nick[strlen(myuser->nick)-3]=(rand()%10)+'0'; - myuser->nick[strlen(myuser->nick)-2]=(rand()%10)+'0'; - myuser->nick[strlen(myuser->nick)-1]=(rand()%10)+'0'; - irc_nick(fd,myuser->nick); - } - else if(!strcmp(s,"004")) {//we're connected. - startup_stuff(fd); - } //:armitage.hacking.allowed.org 353 asdf = #default :@SegFault @FreeArtMan @foobaz @wall @Lamb3_13 @gizmore @blackh0le strcpy(tmp,"!"); strcat(tmp,s); - if(ht_getnode(&alias,tmp) != NULL) { //don't bother to do a WHOLE message handler if the alias doesn't exist. + if(ht_getnode(&alias,tmp) != NULL) { snprintf(tmp,sizeof(tmp),"!%s %s",s,u); - message_handler(fd,"#cmd",user,tmp,0); + user->nick=strdup("epoch"); + user->user=strdup("epoch"); + user->host=strdup("localhost"); + message_handler(fd,"#cmd",user,tmp,1); + free(user->nick); + free(user->user); + free(user->host); } -/* -:armitage.hacking.allowed.org 376 asdf :End of MOTD commandWHO #default -:armitage.hacking.allowed.org 352 asdf #default user hostname server nick H@ :0 name -:armitage.hacking.allowed.org 315 asdf #default :End of WHO list -*/ } if(s && t && u) { if(!strcmp(s,"PRIVMSG") && strcmp(user->nick,myuser->nick)) { @@ -1178,12 +1154,11 @@ void line_handler(int fd,char *line) {//this should be built into the libary? } } } -//:Ishikawa-!~epoch@localhost NICK :checking - if(!strcmp(s,"NICK")) { + if(!strcmp(s,"NICK") && t) { if(!strcmp(user->nick,myuser->nick)) { free(myuser->nick); - if(!t+1) exit(79); - myuser->nick=strdup(t+1); + if(!t) exit(79); + if(!(myuser->nick=strdup(t+1))) exit(179); } } } -- cgit v1.2.3