diff --git a/channel.c b/channel.c index 16f2ccf..dbbcfaf 100644 --- a/channel.c +++ b/channel.c @@ -14,6 +14,14 @@ tuveChanList_t *findChan(char *channel); tuveChanList_t *addChan(char *channel); +int tuveChanPart(char *channel,myConnections_t *userConnection) { + if (tuveRemoveFromChanList(channel,userConnection) == 0x1) + writeLog(0,"ERROR: Can not remove %s from %s\n",userConnection->userInfo.username,channel); + } /* End tuveChanPart(); */ + +/* + * Joins A User To A Channel + */ int tuveChanJoin(char *channel,myConnections_t *userConnection) { char output[256]; tuveChanList_t *tmpChan = 0x0; @@ -87,6 +95,24 @@ return(0x0); } + +int tuveDelChan(char *channel,myConnections_t *userConnection) { + tuveUserChans_t *tmpChan = 0x0; + + for (tmpChan = userConnection->userInfo.chans;tmpChan != 0x0;tmpChan = tmpChan->next) { + if (!strcasecmp(tmpChan->channel,channel) { + writeLog(2,"Found %s On %s And Removed\n",tmpChan->channel,userConnection->userInfo.username); + if (tmpChan->prev != 0x0) + tmpChan->prev->next = tmpChan->next; + else + userConnection->userInfo.chans = tmpChan->next; + + if (tmpChan->next != 0x0) + tmpChan->next->prev = tmpChan->prev; + } + } + return(0x1); + } int tuveRemoveFromChanList(char *channel,myConnections_t *userConnection) { tuveChanList_t *tmpChannel = 0x0; @@ -206,6 +232,9 @@ return(0x0); } +/* + * Add A Channel To The Global Channel List + */ tuveChanList_t *addChan(char *channel) { tuveChanList_t *tmpChannel = 0x0; diff --git a/tuve.c b/tuve.c index 88327b4..fc2def4 100644 --- a/tuve.c +++ b/tuve.c @@ -127,6 +127,10 @@ else if (strcasecmp(cmd,"NOSONG") == 0x0) { tuveBotNoSong(data); } + else if (strcasecmp(cmd,"PART") == 0x0) { + if (tuveChanPart(data,userConnection) == 0x1) + writeLog(0,"ERROR: Unable to remove user from channel: %s list\n",data); + } else { sSendData(userConnection,"invalid command\n"); writeLog(1,"Invalid CMD: [%s]\n",cmd); diff --git a/tuved.h b/tuved.h index 81fdf38..f45c307 100644 --- a/tuved.h +++ b/tuved.h @@ -94,6 +94,7 @@ 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);