diff --git a/bot.c b/bot.c index 9021721..f0cdec4 100644 --- a/bot.c +++ b/bot.c @@ -56,6 +56,7 @@ } pthread_mutex_unlock(&chanMutex); + return(tmpChan); } @@ -66,7 +67,7 @@ int tmpVal = 0; botChanList_t *tmpChan = 0x0; - res = dbQuery("SELECT channel,rating,classification,random,queue,exclusive,time,topic FROM channels",1); + res = dbQuery("SELECT channel,rating,classification,random,queue,exclusive,time,noads,topic FROM channels",1); if (mysql_num_rows(res) > 0) { for (i = 0;i < mysql_num_rows(res);i++) { @@ -74,12 +75,12 @@ tmpChan = botAddChan(row[0]); if (tmpChan == 0x0) return(-1); - - pthread_mutex_lock(&chanMutex); sWriteSocket("JOIN %s",row[0]); sleep(2); + pthread_mutex_lock(&chanMutex); + /* Op Myself */ sWriteSocket("MSG %s:.tv MODE +O TUveBOT",row[0]); @@ -130,9 +131,17 @@ else sWriteSocket("MSG %s:.tv mode -T",row[0]); tmpChan->modes[CHAN_TIME] = tmpVal; + + /* Set NoAds */ + tmpVal = atoi(row[7]); + if (tmpVal == 1) + sWriteSocket("MSG %s:.tv mode +X",row[0]); + else + sWriteSocket("MSG %s:.tv mode -X",row[0]); + tmpChan->modes[CHAN_NOADS] = tmpVal; - if (row[7] != 0x0) { - sWriteSocket("TOPIC %s:%s",row[0],row[7]); + if (row[8] != 0x0) { + sWriteSocket("TOPIC %s:%s",row[0],row[8]); strcpy(tmpChan->topic,row[7]); } diff --git a/main.c b/main.c index 7802bea..0afd713 100644 --- a/main.c +++ b/main.c @@ -150,11 +150,11 @@ } int botProcessData(char *dataFresh) { - char *cmd = 0x0; - char *cmdData = 0x0; - char *str_tok = 0x0; - char *data = 0x0; - char *data2 = 0x0; + char *cmd = 0x0; + char *cmdData = 0x0; + char *str_tok = 0x0; + char *data = 0x0; + char *data2 = 0x0; char *data_tok = 0x0; data = strtok_r(dataFresh,"\n",&data_tok); @@ -188,15 +188,12 @@ sWriteSocket("MSG TUveD:.tv login tuvebot 5558585\n"); joinChan = 1; } - else if (!strcmp(cmd,"MSG")) { + else if (!strcmp(cmd,"MSG")) botProcessMsg(cmdData); - } - else if (!strcmp(cmd,"TOPIC")) { + else if (!strcmp(cmd,"TOPIC")) botStoreTopic(cmdData); - } - else if (!strcmp(cmd,"CURPOS")) { + else if (!strcmp(cmd,"CURPOS")) botSetCurSong(cmdData); - } else if (!strcmp(cmd,"MODE")) botSetMode(cmdData); else if (!strcmp(cmd,"JOIN"))