diff --git a/botthread.c b/botthread.c index 22406c0..294ec9f 100644 --- a/botthread.c +++ b/botthread.c @@ -4,6 +4,8 @@ #include "tuved.h" +//int playCnt = 0; + int nextSong(); int chanMaint(); @@ -211,14 +213,16 @@ } else if (strcasecmp(cmd,"random") == 0x0) { tmpChan = findChan(chan); + if (tmpChan == 0x0) + return(0x0); if (tmpChan->modes[CHAN_LIVE] == 0x1) return(0x0); - sprintf(output,"SELECT artist,title,file,length,vid,classification,rating FROM videos WHERE rating <= %i",tmpChans->modes[CHAN_RATING]); - if (tmpChans->modes[CHAN_EXCLUSIVE]) - sprintf(output,"%s AND oid = %i",tmpChans->modes[CHAN_EXCLUSIVE]); - if (tmpChans->modes[CHAN_CLASS]) - sprintf(output,"%s AND classification = %i",tmpChans->mode[CHAN_CLASS]); + sprintf(output,"SELECT artist,title,file,length,vid,classification,rating FROM videos WHERE rating <= %i",tmpChan->modes[CHAN_RATING]); + if (tmpChan->modes[CHAN_EXCLUSIVE]) + sprintf(output,"%s AND oid = %i",output,tmpChan->modes[CHAN_EXCLUSIVE]); + if (tmpChan->modes[CHAN_CLASS]) + sprintf(output,"%s AND classification = %i",output,tmpChan->modes[CHAN_CLASS]); res = dbQuery(output,1); if (res == 0x0) { @@ -281,6 +285,9 @@ res = dbQuery(output,1); + //sprintf(output,"UPDATE videos SET count = %i WHERE vid = %i",atoi(row[6])+1,vid); + //dbQuery(output,0); + if ((res == 0x0) || (mysql_num_rows(res) == 0x0)) { sprintf(output,"MSG:TUveD:%s:Sorry I'm Have SQL Troubles Today.",chan); tuveSendAllInChan(chan,0x0,output); @@ -337,6 +344,15 @@ sprintf(output,"MSG:TUveD:%s:Playing %s (%d:%.2d)",channel,tmpChan->videoChanTitle,min,sec); tuveSendAllInChan(channel,0x0,output); +/* + + if (tmpChan->count != -1) { + if (tmpChan->nextUser != 0x0) + tmpChan->nextUser = tmpChan->nextUser->next; + if (tmpChan->nextUser == 0x0) + tmpChan->nextUser = tmpChan->users; + } +*/ tmpChan->count = MAX_COUNT; @@ -394,12 +410,18 @@ /* Find A Random Song */ getRandom: if (tmpChans->modes[CHAN_RANDOM] == 0x1) { + //sprintf(output,"SELECT artist,title,file,length,vid,classification,rating,count FROM videos WHERE rating <= %i AND classification = %i AND count <= %i AND oid = %i",tmpChans->modes[CHAN_RATING],tmpChans->modes[CHAN_CLASS],playCnt,tmpChans->modes[CHAN_EXCLUSIVE]); sprintf(output,"SELECT artist,title,file,length,vid,classification,rating FROM videos WHERE rating <= %i",tmpChans->modes[CHAN_RATING]); if (tmpChans->modes[CHAN_EXCLUSIVE]) - sprintf(output,"%s AND oid = %i",tmpChans->modes[CHAN_EXCLUSIVE]); + sprintf(output,"%s AND oid = %i",output,tmpChans->modes[CHAN_EXCLUSIVE]); if (tmpChans->modes[CHAN_CLASS]) - sprintf(output,"%s AND classification = %i",tmpChans->mode[CHAN_CLASS]); + sprintf(output,"%s AND classification = %i",output,tmpChans->modes[CHAN_CLASS]); + + //sprintf(output,"SELECT artist,title,file,length,vid,classification,rating,count FROM videos WHERE rating <= %i AND classification = %i AND oid = %i",tmpChans->modes[CHAN_RATING],tmpChans->modes[CHAN_CLASS],tmpChans->modes[CHAN_EXCLUSIVE]); + //else + //sprintf(output,"SELECT artist,title,file,length,vid,classification,rating,count FROM videos WHERE rating <= %i AND classification = %i",tmpChans->modes[CHAN_RATING],tmpChans->modes[CHAN_CLASS]); + //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 Having SQL Troubles Today.",tmpChans->channel); @@ -408,6 +430,8 @@ else if (mysql_num_rows(res) == 0x0) { sprintf(output,"MSG:TUveD:%s:Sorry Videos Matching The Channels Settings.",tmpChans->channel); tuveSendAllInChan(tmpChans->channel,0x0,output); + //playCnt++; + //goto getRandom; } else { mysql_data_seek(res,(random() % mysql_num_rows(res))); diff --git a/tuved.h b/tuved.h index 64ea32a..e69f3c2 100644 --- a/tuved.h +++ b/tuved.h @@ -25,7 +25,7 @@ #define MAX_USER_LEN 32 #define MAX_USER_AWAYMSG 128 #define VERSION "v1.20" -#define MYSQL_HOST_NAME "72.36.193.179" +#define MYSQL_HOST_NAME "localhost" #define MYSQL_USERNAME "tuve" #define MYSQL_PASSWORD "5558585" #define MYSQL_DB_NAME "tuve"