diff --git a/channel.c b/channel.c index a506554..3dd3aa4 100644 --- a/channel.c +++ b/channel.c @@ -230,3 +230,21 @@ return(0x0); } + +int tuveSetTopic(myConnections_t *userConnection,char *chan,char *topic) { + char output[1024]; + tuveChanList_t *tmpChannel = 0x0; + + tmpChannel = findChan(chan); + + if (tmpChannel == 0x0) { + writeLog("findChan Failed: SetTopic\n"); + return(0x1); + } + + sprintf(tmpChannel->topic,topic); + sprintf(output,"TOPIC:%s:%s\n",chan,tmpChannel->topic); + tuveSendAllInChan(chan,userConnection,output); + + return(0x0); + } diff --git a/tuve.c b/tuve.c index 48b6a6d..5b06933 100644 --- a/tuve.c +++ b/tuve.c @@ -168,6 +168,10 @@ sprintf(output,"chanmsg:%s:%s:%s\n",userConnection->userInfo.username,msg,strtok_r(NULL,"\n",&tok_last)); tuveSendAllInChan(msg,userConnection,output); } + else if (strcasecmp(cmd,"topic") == 0x0) { + msg = strtok_r(data,":",&tok_last); + tuveSetTopic(userConnection,msg,strtok_r(NULL,"\n",&tok_last)); + } else { send(userConnection->fd,"invalid command",sizeof("invalid command"),MSG_NOSIGNAL); writeLog("Invalid CMD: [%s]\n",cmd); diff --git a/tuved.h b/tuved.h index 939f67c..9a0bc01 100644 --- a/tuved.h +++ b/tuved.h @@ -82,3 +82,4 @@ int tuveSendAllInChan(char *channel,myConnections_t *userConnection,char *output); int tuveDelUserChans(myConnections_t *userConnection,char *msg); int tuveRemoveFromChanList(char *channel,myConnections_t *userConnection); +int tuveSetTopic(myConnections_t *userConnection,char *chan,char *topic);