diff --git a/botthread.c b/botthread.c index 731a6a7..2c06fea 100644 --- a/botthread.c +++ b/botthread.c @@ -1,4 +1,6 @@ #include +#include +#include #include "tuved.h" @@ -85,14 +87,21 @@ return(0x0); } -int tuveBotSetSong(char *chan,char *playTime,char *file,char *title) { +int +tuveBotSetSong(char *chan,char *playTime,char *file,char *title) { tuveChanList_t *tmpChan; char output[1024]; + long min, sec; + sprintf(output,"CURPOS:0:%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); + + min = strtol(playTime, (char **)NULL, 10) / 60; + sec = strtol(playTime, (char **)NULL, 10) % 60; + + sprintf(output,"CHANMSG:@TUveBOT:%s:Playing %s (%d:%d)\n",chan,title,min,sec); tuveSendAllInChan(chan,0x0,output); tmpChan = findChan(chan); @@ -108,5 +117,5 @@ tmpChan->count = 0x0; return(0x0); - } + } // tuveBotSetSong() diff --git a/channel.c b/channel.c index f2c5950..6775572 100644 --- a/channel.c +++ b/channel.c @@ -6,6 +6,8 @@ #include #include #include +#include +#include #include "tuved.h" @@ -35,25 +37,29 @@ int tuveChanJoin(char *channel,myConnections_t *userConnection) { char output[256]; tuveChanList_t *tmpChan = 0x0; + int min, sec; - if (tuveAddChan(channel,userConnection) != 0x0) - return(0x1); + if (tuveAddChan(channel,userConnection) != 0x0) return(0x1); - /* Send JOIN to all users in the channel */ - sprintf(output,"JOIN:%s:%s\n",channel,userConnection->userInfo.username); - tuveSendAllInChan(channel,userConnection,output); + /* Send JOIN to all users in the channel */ + sprintf(output,"JOIN:%s:%s\n",channel,userConnection->userInfo.username); + tuveSendAllInChan(channel,userConnection,output); - tmpChan = findChan(channel); + tmpChan = findChan(channel); - 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); + sprintf(output,"CURPOS:%i:%s:%s\n",tmpChan->songTime - (tmpChan->songEnd - (time(NULL) + 2)),tmpChan->curSong,tmpChan->songTitle); + sSendData(userConnection,output); + + min = tmpChan->songTime / 60; + sec = tmpChan->songTime % 60; + + sprintf(output,"CHANMSG:@TUveBOT:%s:Playing %s (%i:%i)\n",channel,tmpChan->songTitle,min,sec); + sSendData(userConnection,output); - /* Notify people in the channel that someone has joined */ - sprintf(output,"CHANMSG:TUveD:%s:%s (%s) has joined the channel.\n",channel,userConnection->userInfo.username,userConnection->host); - tuveSendAllInChan(channel,userConnection,output); + /* Notify people in the channel that someone has joined */ + sprintf(output,"CHANMSG:TUveD:%s:%s (%s) has joined the channel.\n",channel,userConnection->userInfo.username,userConnection->host); + tuveSendAllInChan(channel,userConnection,output); return(0x0); } diff --git a/tuve.c b/tuve.c index bf416c0..f15cee2 100644 --- a/tuve.c +++ b/tuve.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "tuved.h" @@ -53,14 +54,16 @@ cmd = userConnection->data; - printf("DATA: [%s]\n",cmd); - + assert(userConnection->recLen > 2); + if (cmd[userConnection->recLen - 1] == '\n') cmd[userConnection->recLen - 1] = '\0'; if (cmd[userConnection->recLen - 2] == 13) cmd[userConnection->recLen - 2] = '\0'; + printf("DATA: [%s]\n",cmd); + if (strstr(userConnection->data," ")) { cmd = strtok_r(userConnection->data," ",&tok_last); data = strtok_r(NULL,"\n",&tok_last);