diff options
-rw-r--r-- | ircify.c | 20 |
1 files changed, 12 insertions, 8 deletions
@@ -10,7 +10,7 @@ int pout[2]; char channel[256]; -void line_handler(struct shit *me,char *line) { +void irc_handler(struct shit *me,char *line) { char tmp[1024]; if(!strncmp(line,"PING ",5)) { printf("PONG :%s\r\n",line+5); @@ -33,17 +33,21 @@ void line_handler(struct shit *me,char *line) { fprintf(stderr,"%s\n",line); } -void line_handler2(struct shit *me,char *line) { +void subproc_handler(struct shit *me,char *line) { printf("PRIVMSG %s :%s\r\n",channel,line); } int main(int argc,char *argv[]) { setlinebuf(stdout); - printf("NICK revbot\r\n"); - printf("USER asdf asdf asdf :asdf\r\n"); + if(argc < 3) { + fprintf(stderr,"usage: ircify nick channel program\n"); + return 1; + } + printf("NICK %s\r\n",argv[1]); + printf("USER %s %s %s :%s\r\n",argv[1],argv[1],argv[1],argv[1]); fflush(stdout); - strcpy(channel,argv[1]); - argv+=2; + strcpy(channel,argv[2]); + argv+=3; int i=0; for(i=0;i<100;i++) { libline.fds[i].fd=-1; @@ -58,7 +62,7 @@ int main(int argc,char *argv[]) { dup2(pout[1],1); execv(argv[0],argv); } - add_fd(0,line_handler); - add_fd(pout[0],line_handler2); + add_fd(0,irc_handler); + add_fd(pout[0],subproc_handler); select_on_everything(); } |