diff --git a/Makefile b/Makefile index 1c90a44..1e049ba 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ REMOVE = rm -f #Objects -OBJS = nick.o botthread.o main.o socket.o tuve.o channel.o +OBJS = server.o nick.o botthread.o main.o socket.o tuve.o channel.o LIBRARIES = -lthr CFLAGS = -Wall -W -O2 -ggdb diff --git a/botthread.c b/botthread.c index 022a4c2..3564b1a 100644 --- a/botthread.c +++ b/botthread.c @@ -8,7 +8,7 @@ int botNextSong(); -int tuveBotCMD(char *chan,char *data) { +int tuveBotCMD(myConnections_t *userConnection,char *chan,char *data) { char output[512]; char *cmd = 0x0; char *cmdData = 0x0; @@ -21,7 +21,7 @@ cmdData = strtok(NULL,"\n"); if (strcasecmp(cmd,"echo") == 0x0) { - sprintf(output,"CHANMSG:TUveBOT:%s:%s\n",chan,cmdData); + sprintf(output,"CHANMSG:@TUveBOT:%s:%s\n",chan,cmdData); tuveSendAllInChan(chan,0x0,output); } else if (strcasecmp(cmd,"skip") == 0x0) { @@ -29,6 +29,17 @@ if (tmpChan != 0x0) tmpChan->songEnd = 0x0; } + else if (strcasecmp(cmd,"login") == 0x0) { + if (!strcmp(cmdData,"b00b5")) { + sprintf(output,"CHANMSG:@TUveBOT:%s:You have successfully logged in.\n",chan); + sSendData(userConnection,output); + } + else { + sprintf(output,"CHANMSG:@TUveBOT:%s:You have failed login. Your connection will now be terminated!\n",chan); + sSendData(userConnection,output); + close(userConnection->fd); + } + } return(0x0); } diff --git a/channel.c b/channel.c index 5d166af..aaf070b 100644 --- a/channel.c +++ b/channel.c @@ -14,10 +14,9 @@ tuveChanList_t *channels = 0x0; -tuveChanList_t *findChan(char *channel); -tuveChanList_t *addChan(char *channel); +tuveChanList_t *addChan(const char *channel); -int tuveChanPart(char *channel,myConnections_t *userConnection) { +int tuveChanPart(const char *channel,myConnections_t *userConnection) { char output[512]; short inChan = 0x0; @@ -44,7 +43,7 @@ * Joins A User To A Channel */ int -tuveChanJoin(char *channel,myConnections_t *userConnection) { +tuveChanJoin(const char *channel,myConnections_t *userConnection) { char output[256]; tuveChanList_t *tmpChan = 0x0; int min, sec; @@ -102,7 +101,7 @@ return(0x0); } -int tuveAddChan(char *channel,myConnections_t *userConnection) { +int tuveAddChan(const char *channel,myConnections_t *userConnection) { tuveUserChans_t *tmpChan = 0x0; if (userConnection->userInfo.chans == 0x0) { @@ -125,7 +124,7 @@ return(0x0); } -int tuveDelChan(char *channel,myConnections_t *userConnection) { +int tuveDelChan(const char *channel,myConnections_t *userConnection) { tuveUserChans_t *tmpChan = 0x0; if (channel == 0x0) @@ -151,7 +150,7 @@ return(0x1); } -int tuveRemoveFromChanList(char *channel,myConnections_t *userConnection) { +int tuveRemoveFromChanList(const char *channel,myConnections_t *userConnection) { tuveChanList_t *tmpChannel = 0x0; tuveUserList_t *tmpUsers = 0x0; @@ -196,7 +195,7 @@ } int -tuveAddToChanList(char *channel,myConnections_t *userConnection) { +tuveAddToChanList(const char *channel,myConnections_t *userConnection) { tuveChanList_t *tmpChannel = 0x0; tuveUserList_t *tmpUsers = 0x0; @@ -262,7 +261,7 @@ return(0x0); } -tuveChanList_t *findChan(char *channel) { +tuveChanList_t *findChan(const char *channel) { tuveChanList_t *tmpChannel = 0x0; assert(channel); @@ -284,7 +283,7 @@ /* * Add A Channel To The Global Channel List */ -tuveChanList_t *addChan(char *channel) { +tuveChanList_t *addChan(const char *channel) { tuveChanList_t *tmpChannel = 0x0; pthread_mutex_lock(&chanMutex); @@ -303,7 +302,7 @@ else { tmpChannel = (tuveChanList_t *)malloc(sizeof(tuveChanList_t)); sprintf(tmpChannel->channel,channel); - sprintf(tmpChannel->topic,"No Topic Set\n"); + sprintf(tmpChannel->topic,"No Topic Set"); sprintf(tmpChannel->curSong,"NoVideo"); tmpChannel->next = channels; tmpChannel->prev = 0x0; @@ -327,7 +326,7 @@ return(0x0); } -int tuveSendAllInChan(char *channel,myConnections_t *userConnection,char *output) { +int tuveSendAllInChan(const char *channel,myConnections_t *userConnection,char *output) { tuveChanList_t *tmpChannel = 0x0; tuveUserList_t *tmpUsers = 0x0; @@ -364,8 +363,8 @@ sprintf(tmpChannel->topic,topic); sprintf(output,"TOPIC:%s:%s\n",chan,tmpChannel->topic); tuveSendAllInChan(chan,0x0,output); - sprintf(output,"CHANMSG:TUveD:%s:%s Has Set The Topic\n",chan,userConnection->userInfo.username); - tuveSendAllInChan(chan,userConnection,output); + sprintf(output,"CHANMSG:TUveD:%s:%s Has Set The Topic To: %s\n",chan,userConnection->userInfo.username,tmpChannel->topic); + tuveSendAllInChan(chan,0x0,output); return(0x0); } diff --git a/tuve.c b/tuve.c index 15652b1..867659a 100644 --- a/tuve.c +++ b/tuve.c @@ -113,7 +113,7 @@ chan = strtok_r(data,":",&tok_last); msg = strtok_r(NULL,"\n",&tok_last); if (msg[0] == '.' && msg[1] == 't' && msg[2] == 'v') - tuveBotCMD(chan,msg+3); + tuveBotCMD(userConnection,chan,msg+3); else sprintf(output,"CHANMSG:%s:%s:%s\n",userConnection->userInfo.username,chan,msg); tuveSendAllInChan(chan,userConnection,output); diff --git a/tuved.h b/tuved.h index d132cf9..2a9d134 100644 --- a/tuved.h +++ b/tuved.h @@ -98,22 +98,22 @@ int writeLog(int level,char const * __restrict, ...); /* Channel Functions */ -int tuveChanPart(char *channel,myConnections_t *userConnection); -int tuveChanJoin(char *channel,myConnections_t *userConnection); -int tuveAddChan(char *channel,myConnections_t *userConnection); -int tuveAddToChanList(char *channel,myConnections_t *userConnection); -int tuveSendAllInChan(char *channel,myConnections_t *userConnection,char *output); +int tuveChanPart(const char *channel,myConnections_t *userConnection); +int tuveChanJoin(const char *channel,myConnections_t *userConnection); +int tuveAddChan(const char *channel,myConnections_t *userConnection); +int tuveAddToChanList(const char *channel,myConnections_t *userConnection); +int tuveSendAllInChan(const char *channel,myConnections_t *userConnection,char *output); int tuveDelUserChans(myConnections_t *userConnection,char *msg); -int tuveRemoveFromChanList(char *channel,myConnections_t *userConnection); +int tuveRemoveFromChanList(const char *channel,myConnections_t *userConnection); int tuveSetTopic(myConnections_t *userConnection,char *chan,char *topic); int tuveSendAllInUsersChans(myConnections_t *userConnection,char *output); -int tuveDelChan(char *channel,myConnections_t *userConnection); +int tuveDelChan(const char *channel,myConnections_t *userConnection); int tuveKick(char *by,char *chan,char *nick,char *msg); -tuveChanList_t *findChan(char *); +tuveChanList_t *findChan(const char *); /* Bot Functions */ void *tuveBotThread(void *threadid); -int tuveBotCMD(char *chan,char *data); +int tuveBotCMD(myConnections_t *userConnection,char *chan,char *data); int tuveBotSetSong(char *chan,char *playTime,char *file,char *title); int tuveBotNoSong(char *chan);