diff --git a/botthread.c b/botthread.c index 93a306e..2fc8869 100644 --- a/botthread.c +++ b/botthread.c @@ -63,6 +63,22 @@ return(0x0); } +int tuveBotNoSong(char *chan) { + tuveChanList_t *tmpChan; + + tmpChan = findChan(chan); + + tmpChan->nextUser = tmpChan->nextUser->next; + + if (tmpChan->nextUser == 0x0) + tmpChan->nextUser = tmpChan->users; + + if (tmpChan->nextUser != 0x0) + sSendData(tmpChan->nextUser->user,"GETSONG\n"); + + return(0x0); + } + int tuveBotSetSong(char *chan,char *playTime,char *file,char *title) { tuveChanList_t *tmpChan; @@ -70,11 +86,14 @@ sprintf(output,"CURPOS:1:%s:%s\n",file,title); writeLog(0,"[%s][%s]\n",output,chan); tuveSendAllInChan(chan,0x0,output); + sprintf(output,"CHANMSG:@TUveBOT:%s:Now Playing %s @ %sSeconds Long\n",chan,title,playTime); + tuveSendAllInChan(chan,0x0,output); tmpChan = findChan(chan); tmpChan->songTime = atoi(playTime); tmpChan->songEnd = atoi(playTime) + time(NULL) + 2; sprintf(tmpChan->curSong,file); + sprintf(tmpChan->songTitle,title); tmpChan->nextUser = tmpChan->nextUser->next; if (tmpChan->nextUser == 0x0) diff --git a/channel.c b/channel.c index 7a92090..16f2ccf 100644 --- a/channel.c +++ b/channel.c @@ -27,7 +27,9 @@ tmpChan = findChan(channel); - sprintf(output,"CURPOS:%i:%s\n",tmpChan->songTime - (tmpChan->songEnd - (time(NULL) + 2)),tmpChan->curSong); + sprintf(output,"CURPOS:%i:%s:%s\n",tmpChan->songTime - (tmpChan->songEnd - (time(NULL) + 2)),tmpChan->curSong,tmpChan->songTitle); + sSendData(userConnection,output); + sprintf(output,"CHANMSG:@TUveBOT:%s:Now Playing %s @ %iSeconds Long\n",channel,tmpChan->songTitle,tmpChan->songTime); sSendData(userConnection,output); @@ -168,7 +170,7 @@ tmpChannel->count = 0x0; memset(output,0x0,256); - sprintf(output,"JOIN:%s:TUveBOT",tmpChannel->channel); + sprintf(output,"JOIN:%s:@TUveBOT",tmpChannel->channel); /* Send the new user the channel list */ for (tmpUsers = tmpChannel->users->next;tmpUsers != 0x0;tmpUsers = tmpUsers->next) { diff --git a/tuve.c b/tuve.c index 3487997..88327b4 100644 --- a/tuve.c +++ b/tuve.c @@ -20,13 +20,6 @@ userConnection->userInfo.pong = time(NULL); - writeLog(3,"Got: [%i][%s]\n",userConnection->recLen,userConnection->data); - - if (userConnection->recLen == 1) { - writeLog(2,"[%i][%c]\n",userConnection->data[0],userConnection->data[0]); - while(1); - } - podzProcessData(userConnection); return(0x0); @@ -68,12 +61,8 @@ if (strstr(userConnection->data," ")) { cmd = strtok_r(userConnection->data," ",&tok_last); data = strtok_r(NULL,"\n",&tok_last); - writeLog(2,"DATA[%s:%s]\n",cmd,data); tok_last = 0x0; } - else { - writeLog(2,"DATA[%s]\n",cmd); - } if (!strcasecmp(cmd,"ident")) { writeLog(2,"(ident)\n"); @@ -127,17 +116,6 @@ if (data != 0x0) tuveSendAllInChan(data,userConnection,output); } - else if (strcasecmp(cmd,"CURPOS") == 0x0) { - tok_last = 0x0; - chan = strtok_r(data,":",&tok_last); - msg = strtok_r(NULL,":",&tok_last); - nick = strtok_r(NULL,"\n",&tok_last); - if ((nick != 0x0) && (msg != 0x0)) { - sprintf(output,"CURPOS:%s:%s\n",msg,nick); - tuveSendAllInChan(chan,userConnection,output); - writeLog(1,"%s Has Sent CURPOS\n",userConnection->userInfo.username); - } - } else if (strcasecmp(cmd,"NEXTSONG") == 0x0) { tok_last = 0x0; chan = strtok_r(data,":",&tok_last); @@ -146,6 +124,9 @@ title = strtok_r(NULL,"\n",&tok_last); tuveBotSetSong(chan,msg,nick,title); } + else if (strcasecmp(cmd,"NOSONG") == 0x0) { + tuveBotNoSong(data); + } else { sSendData(userConnection,"invalid command\n"); writeLog(1,"Invalid CMD: [%s]\n",cmd); diff --git a/tuved.h b/tuved.h index b33955e..81fdf38 100644 --- a/tuved.h +++ b/tuved.h @@ -33,6 +33,7 @@ char topic[128]; char channel[32]; char curSong[256]; + char songTitle[256]; int songEnd; int songTime; short count; @@ -107,3 +108,4 @@ void *tuveBotThread(void *threadid); int tuveBotCMD(char *chan,char *data); int tuveBotSetSong(char *chan,char *playTime,char *file,char *title); +int tuveBotNoSong(char *chan);