From bfccf0ca4c240a1664fc9957482301865d0d03e8 Mon Sep 17 00:00:00 2001 From: epoch Date: Sun, 26 May 2019 01:07:46 +0000 Subject: ircify now sends the first arg as nick. also renamed a couple functions. --- ircify.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/ircify.c b/ircify.c index 3b24e47..f2dd643 100644 --- a/ircify.c +++ b/ircify.c @@ -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(); } -- cgit v1.2.3