summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorepoch <epoch@hack.thebackupbox.net>2019-05-26 01:07:46 +0000
committerepoch <epoch@hack.thebackupbox.net>2019-05-26 01:07:46 +0000
commitbfccf0ca4c240a1664fc9957482301865d0d03e8 (patch)
treeaae0b4c7e2bf68d273db156b59cc3cafae1c01dc
parent0eda34e6ce5e8bef3b4ecc8cb9209b1f8b5b8555 (diff)
downloadlibidc-bfccf0ca4c240a1664fc9957482301865d0d03e8.tar.gz
libidc-bfccf0ca4c240a1664fc9957482301865d0d03e8.zip
ircify now sends the first arg as nick. also renamed a couple functions.
-rw-r--r--ircify.c20
1 files 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();
}