diff --git a/botthread.c b/botthread.c index c7e4130..6622e4d 100644 --- a/botthread.c +++ b/botthread.c @@ -46,7 +46,7 @@ sprintf(output,"INSERT INTO active (gid,uid,userid) VALUES(%s,%s,%lld)",row[1],row[2],userConnection->userInfo.uid); dbQuery(output,0); if (atoi(row[1]) == 1) { - sprintf(output,"EMOTE:%s:STATUS:Is now an Evil Overlord!\n",userConnection->userInfo.username); + sprintf(output,"EMOTE:%s:STATUS:Is now an Evil Overlord!",userConnection->userInfo.username); tuveSendAllInUsersChans(userConnection,output); userConnection->userInfo.modes[USER_OVERLORD] = 1; } @@ -108,7 +108,7 @@ tmp = strtok_r(NULL," ",&tok_last); if (tmp != 0x0) { if (tuveChanOp(chan,tmp,dM) == 0x0) { - sprintf(output,"MSG:TUveD:%s:%s Sets Mode %cO %s\n",chan,userConnection->userInfo.username,dMS[dM],tmp); + sprintf(output,"MSG:TUveD:%s:%s Sets Mode %cO %s",chan,userConnection->userInfo.username,dMS[dM],tmp); tuveSendAllInChan(chan,0x0,output); } } @@ -121,7 +121,7 @@ tmp = strtok_r(NULL," ",&tok_last); if (tmp != 0x0) { tmpChan->modes[CHAN_RATING] = atoi(tmp); - sprintf(output,"MODE:%s:A:%i\n",tmpChan->channel,tmpChan->modes[CHAN_RATING]); + sprintf(output,"MODE:%s:A:%i",tmpChan->channel,tmpChan->modes[CHAN_RATING]); tuveSendAllInChan(chan,0x0,output); } break; @@ -130,32 +130,32 @@ tmp = strtok_r(NULL," ",&tok_last); if (tmp != 0x0) { tmpChan->modes[CHAN_CLASS] = atoi(tmp); - sprintf(output,"MODE:%s:C:%i\n",tmpChan->channel,tmpChan->modes[CHAN_CLASS]); + sprintf(output,"MODE:%s:C:%i",tmpChan->channel,tmpChan->modes[CHAN_CLASS]); tuveSendAllInChan(chan,0x0,output); } break; case 'e': case 'E': tmpChan->modes[CHAN_EXCLUSIVE] = dM; - sprintf(output,"MSG:TUveD:%s:%s Sets Mode %cExclusive\n",chan,userConnection->userInfo.username,dMS[dM]); + sprintf(output,"MSG:TUveD:%s:%s Sets Mode %cExclusive",chan,userConnection->userInfo.username,dMS[dM]); tuveSendAllInChan(chan,0x0,output); - sprintf(output,"MODE:%s:E:%i\n",tmpChan->channel,dM); + sprintf(output,"MODE:%s:E:%i",tmpChan->channel,dM); tuveSendAllInChan(chan,0x0,output); break; case 'r': case 'R': tmpChan->modes[CHAN_RANDOM] = dM; - sprintf(output,"MSG:TUveD:%s:%s Sets Mode %cRandom\n",chan,userConnection->userInfo.username,dMS[dM]); + sprintf(output,"MSG:TUveD:%s:%s Sets Mode %cRandom",chan,userConnection->userInfo.username,dMS[dM]); tuveSendAllInChan(chan,0x0,output); - sprintf(output,"MODE:%s:R:%i\n",tmpChan->channel,dM); + sprintf(output,"MODE:%s:R:%i",tmpChan->channel,dM); tuveSendAllInChan(chan,0x0,output); break; case 'q': case 'Q': tmpChan->modes[CHAN_QUEUE] = dM; - sprintf(output,"MSG:TUveD:%s:%s Sets Mode %cQueue\n",chan,userConnection->userInfo.username,dMS[dM]); + sprintf(output,"MSG:TUveD:%s:%s Sets Mode %cQueue",chan,userConnection->userInfo.username,dMS[dM]); tuveSendAllInChan(chan,0x0,output); - sprintf(output,"MODE:%s:Q:%i\n",tmpChan->channel,dM); + sprintf(output,"MODE:%s:Q:%i",tmpChan->channel,dM); tuveSendAllInChan(chan,0x0,output); break; case 't': @@ -165,17 +165,17 @@ if (tmp != 0x0) { tmpChan->modes[CHAN_TIME] = dM; tmpChan->maxTime = atoi(tmp); - sprintf(output,"MSG:TUveD:%s:%s Sets Mode +Time Limit %s\n",chan,userConnection->userInfo.username,tmp); + sprintf(output,"MSG:TUveD:%s:%s Sets Mode +Time Limit %s",chan,userConnection->userInfo.username,tmp); tuveSendAllInChan(chan,0x0,output); - sprintf(output,"MODE:%s:T:%i:%s\n",tmpChan->channel,dM,tmp); + sprintf(output,"MODE:%s:T:%i:%s",tmpChan->channel,dM,tmp); tuveSendAllInChan(chan,0x0,output); } } else { tmpChan->modes[CHAN_TIME] = dM; - sprintf(output,"MSG:TUveD:%s:%s Sets Mode %cTime Limit\n",chan,userConnection->userInfo.username,dMS[dM]); + sprintf(output,"MSG:TUveD:%s:%s Sets Mode %cTime Limit",chan,userConnection->userInfo.username,dMS[dM]); tuveSendAllInChan(chan,0x0,output); - sprintf(output,"MODE:%s:T:%i\n",tmpChan->channel,dM); + sprintf(output,"MODE:%s:T:%i",tmpChan->channel,dM); tuveSendAllInChan(chan,0x0,output); } break; @@ -197,7 +197,7 @@ sprintf(output,"SELECT artist,title,file,length,vid,classification,rating,count FROM videos WHERE rating <= %i AND classification = %i AND count <= %i",tmpChan->modes[CHAN_RATING],tmpChan->modes[CHAN_CLASS],playCnt); res = dbQuery(output,1); if (res == 0x0) { - sprintf(output,"MSG:TUveD:%s:Sorry I'm Have SQL Troubles Today.\n",chan); + sprintf(output,"MSG:TUveD:%s:Sorry I'm Have SQL Troubles Today.",chan); tuveSendAllInChan(chan,0x0,output); } else if (mysql_num_rows(res) == 0x0) { @@ -264,7 +264,7 @@ //dbQuery(output,0); if ((res == 0x0) || (mysql_num_rows(res) == 0x0)) { - sprintf(output,"MSG:TUveD:%s:Sorry I'm Have SQL Troubles Today.\n",chan); + sprintf(output,"MSG:TUveD:%s:Sorry I'm Have SQL Troubles Today.",chan); tuveSendAllInChan(chan,0x0,output); } else { @@ -310,11 +310,11 @@ sprintf(tmpChan->videoChanTitle,"%s's Pick -> [%s - %s]",nick,vid,artist,title); sprintf(tmpChan->videoTitle,"%s - %s",artist,title); - sprintf(output,"CURPOS:%s:0:%s:%s:%i:%i\n",tmpChan->channel,file,tmpChan->videoTitle,length,vid); + sprintf(output,"CURPOS:%s:0:%s:%s:%i:%i",tmpChan->channel,file,tmpChan->videoTitle,length,vid); writeLog(0,"[%s][%s]\n",output,channel); tuveSendAllInChan(channel,0x0,output); - sprintf(output,"MSG:TUveD:%s:Playing %s (%d:%.2d)\n",channel,tmpChan->videoChanTitle,min,sec); + sprintf(output,"MSG:TUveD:%s:Playing %s (%d:%.2d",channel,tmpChan->videoChanTitle,min,sec); tuveSendAllInChan(channel,0x0,output); if (tmpChan->count != -1) { @@ -329,7 +329,8 @@ } // tuveBotSetSong() int nextSong() { - char output[1024]; + short lC = 0x0; + char output[1024]; tuveChanList_t *tmpChans; tuveUserList_t *tmpUser; MYSQL_RES *res = 0x0; @@ -345,6 +346,7 @@ /* Set point to starting user */ tmpUser = tmpChans->nextUser; findUser: + lC++; if (tmpChans->modes[CHAN_QUEUE] == 0x0) /* If Channel Has Queues Disabled Jump Right To Random */ goto getRandom; if (tmpChans->nextUser != 0x0) { @@ -366,7 +368,8 @@ } else { tmpChans->count = MAX_COUNT; - if(tmpUser != tmpChans->nextUser) { + if ((tmpUser != tmpChans->nextUser) && (lC < 3)) { + writeLog(0,"MAXCNT"); goto findUser; } @@ -376,7 +379,7 @@ sprintf(output,"SELECT artist,title,file,length,vid,classification,rating,count FROM videos WHERE rating <= %i AND classification = %i AND count <= %i",tmpChans->modes[CHAN_RATING],tmpChans->modes[CHAN_CLASS],playCnt); res = dbQuery(output,1); if (res == 0x0) { - sprintf(output,"MSG:TUveD:%s:Sorry I'm Have SQL Troubles Today.\n",tmpChans->channel); + sprintf(output,"MSG:TUveD:%s:Sorry I'm Have SQL Troubles Today.",tmpChans->channel); tuveSendAllInChan(tmpChans->channel,0x0,output); } else if (mysql_num_rows(res) == 0x0) { diff --git a/channel.c b/channel.c index 8179155..3cd492b 100644 --- a/channel.c +++ b/channel.c @@ -54,9 +54,9 @@ } if (inChan == 0x0) { - sprintf(output,"MSG:TUveD:%s:%s Part (Left Channel)\n",channel,userConnection->userInfo.username); + sprintf(output,"MSG:TUveD:%s:%s Part (Left Channel)",channel,userConnection->userInfo.username); tuveSendAllInChan(channel,0x0,output); - sprintf(output,"PART:%s:%s\n",channel,userConnection->userInfo.username); + sprintf(output,"PART:%s:%s",channel,userConnection->userInfo.username); tuveSendAllInChan(channel,0x0,output); return(0x0); } @@ -80,7 +80,7 @@ tmpChan->modes[CHAN_LIVE] = 0x1; - sprintf(output,"CURPOS:%s:-1:%s:Live Stream:0:0\n",tmpChan->channel,stream); + sprintf(output,"CURPOS:%s:-1:%s:Live Stream:0:0",tmpChan->channel,stream); tuveSendAllInChan(channel,0x0,output); return(0x0); } /* End int tuveChanLive(channel,stream) */ @@ -95,7 +95,7 @@ tmpChan->modes[CHAN_LIVE] = 0x0; - sprintf(output,"CURPOS:%s:%i:%s:%s:%i:%i\n",tmpChan->channel,tmpChan->videoTime - (tmpChan->videoEnd - (time(NULL) + VIDE_PAD_TIME)),tmpChan->videoFile,tmpChan->videoTitle,tmpChan->videoTime,tmpChan->vid); + sprintf(output,"CURPOS:%s:%i:%s:%s:%i:%i",tmpChan->channel,tmpChan->videoTime - (tmpChan->videoEnd - (time(NULL) + VIDE_PAD_TIME)),tmpChan->videoFile,tmpChan->videoTitle,tmpChan->videoTime,tmpChan->vid); tuveSendAllInChan(channel,0x0,output); return(0x0); } @@ -125,7 +125,7 @@ if (tuveAddChanToUser(channel,userConnection) != 0x0) return(0x1); /* Send JOIN to all users in the channel */ - sprintf(output,"JOIN:%s:%s:%lld\n",channel,userConnection->userInfo.username,userConnection->userInfo.uid); + sprintf(output,"JOIN:%s:%s:%lld",channel,userConnection->userInfo.username,userConnection->userInfo.uid); tuveSendAllInChan(channel,userConnection,output); tmpChan = findChan(channel); @@ -144,14 +144,13 @@ } /* Notify people in the channel that someone has joined */ - sprintf(output,"MSG:TUveD:%s:%s (%s) has joined the channel.\n",channel,userConnection->userInfo.username,userConnection->host); + sprintf(output,"MSG:TUveD:%s:%s (%s) has joined the channel.",channel,userConnection->userInfo.username,userConnection->host); tuveSendAllInChan(channel,userConnection,output); return(0x0); } int tuveDelUserChans(myConnections_t *userConnection,char *msg) { - char output[256]; tuveUserChans_t *tmpChan = 0x0; tuveUserChans_t *tmpChan2 = 0x0; @@ -159,10 +158,8 @@ tmpChan2 = tmpChan; for (;tmpChan != 0x0;tmpChan = tmpChan->next) { - sprintf(output,"MSG:TUveD:%s:%s Quit (%s)\n",tmpChan->channel,userConnection->userInfo.username,msg); - tuveSendAllInChan(tmpChan->channel,userConnection,output); - sprintf(output,"PART:%s:%s\n",tmpChan->channel,userConnection->userInfo.username); - tuveSendAllInChan(tmpChan->channel,userConnection,output); + tuveSendAllInChan(tmpChan->channel,userConnection,"MSG:TUveD:%s:%s Quit (%s)",tmpChan->channel,userConnection->userInfo.username,msg); + tuveSendAllInChan(tmpChan->channel,userConnection,"PART:%s:%s",tmpChan->channel,userConnection->userInfo.username); tuveRemoveFromChanList(tmpChan->channel,userConnection); free(tmpChan2); tmpChan2 = tmpChan->next; @@ -346,18 +343,15 @@ sprintf(output,"TOPIC:%s:%s",tmpChannel->channel,tmpChannel->topic); sSendData(userConnection,output); - sprintf(output,"MSG:TUveD:%s:Topic for %s: %s",tmpChannel->channel,tmpChannel->channel,tmpChannel->topic); - sSendData(userConnection,output); + sSendData(userConnection,"MSG:TUveD:%s:Topic for %s: %s",tmpChannel->channel,tmpChannel->channel,tmpChannel->topic); len = sprintf(output,"MSG:TUveD:%s:Topic was set by %s on %s",tmpChannel->channel,tmpChannel->topicSetBy, ctime(&tmpChannel->topicSet)); output[len-1] = '\0'; sSendData(userConnection,output); if (tmpChannel->modes[CHAN_TIME] == 1) { - sprintf(output,"MSG:TUveD:%s:This channel has a time limit of %i seconds for songs.",tmpChannel->channel,tmpChannel->maxTime); - sSendData(userConnection,output); - sprintf(output,"MODE:%s:T:1:%i",tmpChannel->channel,tmpChannel->maxTime); - sSendData(userConnection,output); + sSendData(userConnection,"MSG:TUveD:%s:This channel has a time limit of %i seconds for songs.",tmpChannel->channel,tmpChannel->maxTime); + sSendData(userConnection,"MODE:%s:T:1:%i",tmpChannel->channel,tmpChannel->maxTime); } else { sprintf(output,"MODE:%s:T:0",tmpChannel->channel); @@ -492,16 +486,16 @@ va_start(ap,fmt); len = vsnprintf(data,2046,fmt,ap); va_end(ap); - data[len++] = '\r'; +// data[len++] = '\r'; data[len++] = '\n'; //THIS IS A TEMP SOLUTION I HATE IT! for (;tmpUsers != 0x0;tmpUsers = tmpUsers->next) { if (userConnection == 0x0) - send(tmpUsers->user->fd,data,strlen(data),MSG_NOSIGNAL);//sSendData(tmpUsers->user,data); + send(tmpUsers->user->fd,data,len,MSG_NOSIGNAL);//sSendData(tmpUsers->user,data); else if (strcasecmp(tmpUsers->user->userInfo.username,userConnection->userInfo.username)) - send(tmpUsers->user->fd,data,strlen(data),MSG_NOSIGNAL);//sSendData(tmpUsers->user,data); + send(tmpUsers->user->fd,data,len,MSG_NOSIGNAL);//sSendData(tmpUsers->user,data); } return(0x0); @@ -519,9 +513,9 @@ } strncpy(tmpChannel->topic,topic,128); - sprintf(output,"TOPIC:%s:%s\n",chan,tmpChannel->topic); + sprintf(output,"TOPIC:%s:%s",chan,tmpChannel->topic); tuveSendAllInChan(chan,0x0,output); - sprintf(output,"MSG:TUveD:%s:%s has set the topic to: %s\n",chan,userConnection->userInfo.username,tmpChannel->topic); + sprintf(output,"MSG:TUveD:%s:%s has set the topic to: %s",chan,userConnection->userInfo.username,tmpChannel->topic); tuveSendAllInChan(chan,0x0,output); tmpChannel->topicSet = time(NULL); @@ -560,10 +554,10 @@ writeLog(0,"ERROR: Can not remove %s from %s's List\n",chan,userConnection->userInfo.username); - sprintf(output,"MSG:TUveD:%s:%s has been kicked by %s, Reason: %s\n",chan,nick,byConnection->userInfo.username,msg); + sprintf(output,"MSG:TUveD:%s:%s has been kicked by %s, Reason: %s",chan,nick,byConnection->userInfo.username,msg); tuveSendAllInChan(chan,0x0,output); - sprintf(output,"PART:%s:%s\n",chan,nick); + sprintf(output,"PART:%s:%s",chan,nick); tuveSendAllInChan(chan,0x0,output); writeLog(0,"Kicked %s\n",output); @@ -608,7 +602,7 @@ } } - sprintf(output,"MSG:TUveD:%s:%s has been banned for %i seconds\n",channel,userConnection->userInfo.username,length); + sprintf(output,"MSG:TUveD:%s:%s has been banned for %i seconds",channel,userConnection->userInfo.username,length); tuveSendAllInChan(channel,0x0,output); return(0x0); @@ -641,7 +635,7 @@ } } - sprintf(output,"MSG:TUveD:%s:%s has been unbanned\n",channel,userConnection->userInfo.username); + sprintf(output,"MSG:TUveD:%s:%s has been unbanned",channel,userConnection->userInfo.username); tuveSendAllInChan(channel,0x0,output); return(0x0); @@ -721,7 +715,7 @@ for (tmpUser = tmpChannel->users;tmpUser != 0x0;tmpUser = tmpUser->next) { if (!strcasecmp(tmpUser->user->userInfo.username,nick)) { tmpUser->chanLevel = level; - sprintf(output,"MODE:%s:O:%i:%s\n",tmpChannel->channel,level,tmpUser->user->userInfo.username); + sprintf(output,"MODE:%s:O:%i:%s",tmpChannel->channel,level,tmpUser->user->userInfo.username); tuveSendAllInChan(channel,0x0,output); return(0x0); } diff --git a/socket.c b/socket.c index daf2d02..045dd93 100644 --- a/socket.c +++ b/socket.c @@ -280,7 +280,7 @@ len = vsnprintf(data,2046,fmt,ap); va_end(ap); - data[len++] = '\r'; + //data[len++] = '\r'; data[len++] = '\n'; diff --git a/tuve.c b/tuve.c index dc9a972..253f570 100644 --- a/tuve.c +++ b/tuve.c @@ -164,7 +164,7 @@ else { strncpy(buffer,msg,1024); //sprintf(output,"MSG:%s:%s:%s\n",userConnection->userInfo.username,chan,buffer); - tuveSendAllInChan(chan,userConnection,"MSG:%s:%s:%s\n",userConnection->userInfo.username,chan,buffer); + tuveSendAllInChan(chan,userConnection,"MSG:%s:%s:%s",userConnection->userInfo.username,chan,buffer); } } }