diff --git a/botthread.c b/botthread.c index e781c91..d9db4eb 100644 --- a/botthread.c +++ b/botthread.c @@ -136,10 +136,31 @@ break; case 'e': case 'E': - tmpChan->modes[CHAN_EXCLUSIVE] = 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",tmpChan->channel,dM); + writeLog(0,"BLAH\n"); + if (dM == 0) { + tmpChan->modes[CHAN_EXCLUSIVE] = 0; + sprintf(output,"MSG:TUveD:%s:%s Sets Mode %cExclusive",chan,userConnection->userInfo.username,dMS[dM]); + tuveSendAllInChan(chan,0x0,output); + } + else { + sprintf(output,"SELECT oid FROM channels WHERE channel LIKE '%s'",tmpChan->channel); + res = dbQuery(output,1); + if (res == 0x0) { + sprintf(output,"MSG:TUveD:%s:Sorry I'm having SQL troubles today.",tmpChan->channel); + tuveSendAllInChan(tmpChan->channel,0x0,output); + } + else if (mysql_num_rows(res) == 0x0) { + sprintf(output,"MSG:TUveD:%s:Sorry this channel is not registered.",tmpChan->channel); + tuveSendAllInChan(tmpChan->channel,0x0,output); + } + else { + row = mysql_fetch_row(res); + tmpChan->modes[CHAN_EXCLUSIVE] = atoi(row[0]); + sprintf(output,"MSG:TUveD:%s:%s Sets Mode %cExclusive",chan,userConnection->userInfo.username,dMS[1]); + tuveSendAllInChan(chan,0x0,output); + } + } + sprintf(output,"MODE:%s:E:%i",tmpChan->channel,tmpChan->modes[CHAN_EXCLUSIVE]); tuveSendAllInChan(chan,0x0,output); break; case 'r': @@ -382,7 +403,10 @@ /* 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",tmpChans->modes[CHAN_RATING],tmpChans->modes[CHAN_CLASS],playCnt); + if (tmpChans->modes[CHAN_EXCLUSIVE]) + 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]); + else + 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.",tmpChans->channel); diff --git a/channel.c b/channel.c index 3cd492b..c2eb725 100644 --- a/channel.c +++ b/channel.c @@ -375,6 +375,9 @@ sprintf(output,"MODE:%s:C:%i",tmpChannel->channel,tmpChannel->modes[CHAN_CLASS]); sSendData(userConnection,output); + + sprintf(output,"MODE:%s:E:%i",tmpChannel->channel,tmpChannel->modes[CHAN_EXCLUSIVE]); + sSendData(userConnection,output); writeLog(2,"Added user: %s to Channel: %s\n",userConnection->userInfo.username,channel); diff --git a/tuved.h b/tuved.h index 39ef16b..64ea32a 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 "ubuse.ubixos.com" +#define MYSQL_HOST_NAME "72.36.193.179" #define MYSQL_USERNAME "tuve" #define MYSQL_PASSWORD "5558585" #define MYSQL_DB_NAME "tuve"