diff --git a/botthread.c b/botthread.c index f11fa40..9e3043f 100644 --- a/botthread.c +++ b/botthread.c @@ -4,7 +4,7 @@ #include "tuved.h" -//int playCnt = 0; +int playCnt = 0; int nextSong(); int chanMaint(); @@ -271,10 +271,17 @@ void *tuveCMD_Thread(void *threadid) { int tid; + MYSQL_RES *res = 0x0; + MYSQL_ROW row; tid = (int)threadid; writeLog(0,"Starting Bot Thread: [%d]\n", tid); + res = dbQuery("SELECT count FROM videos ORDER BY count ASC LIMIT 1",1); + row = mysql_fetch_row(res); + playCnt = atoi(row[0]); + mysql_free_result(res); + while (1) { sleep(5); nextSong(); @@ -474,7 +481,9 @@ getCommercial: tmpChans->comDelay = COM_DELAY; - sprintf(output,"SELECT artist,title,file,length,vid,classification,rating FROM videos WHERE rating <= %i AND classification = 7",tmpChans->modes[CHAN_RATING]); + + getComAgain: + sprintf(output,"SELECT artist,title,file,length,vid,classification,rating FROM videos WHERE rating <= %i AND classification = 7 AND count <= %i",tmpChans->modes[CHAN_RATING],playCnt); res = dbQuery(output,1); if (res == 0x0) { @@ -482,6 +491,9 @@ tuveSendAllInChan(tmpChans->channel,0x0,output); } else if (mysql_num_rows(res) == 0x0) { + playCnt++; + mysql_free_result(res); + goto getComAgain; sprintf(output,"MSG:TUveD:%s:Sorry Videos Matching The Channels Settings.",tmpChans->channel); tuveSendAllInChan(tmpChans->channel,0x0,output); } diff --git a/channel.c b/channel.c index 9f68008..13d218a 100644 --- a/channel.c +++ b/channel.c @@ -468,6 +468,7 @@ tmpChannel->modes[CHAN_QUEUE] = 0x1; tmpChannel->modes[CHAN_RATING] = 0x2; tmpChannel->modes[CHAN_CLASS] = 0x1; + tmpChannel->comDelay = COM_DELAY; channels->prev = tmpChannel; channels = tmpChannel; writeLog(2,"ADDED CHAN2\n"); diff --git a/tuved.h b/tuved.h index dfcacca..cbf368f 100644 --- a/tuved.h +++ b/tuved.h @@ -24,7 +24,7 @@ #define MAX_CHAN_LEN 32 #define MAX_USER_LEN 32 #define MAX_USER_AWAYMSG 128 -#define VERSION "v1.80" +#define VERSION "v1.87" #define MYSQL_HOST_NAME "localhost" #define MYSQL_USERNAME "tuve" #define MYSQL_PASSWORD "5558585"