Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
c548ae7
push one
Jun 10, 2024
a0f5c85
push one
Jun 12, 2024
d83c2fe
push one
Jun 15, 2024
bcbc47b
end
Jul 1, 2024
b714465
update
Jul 2, 2024
37a310b
first push from aet-tass just for setting the work space
Jul 2, 2024
16eb428
channels.hpp implimented with the bisics requrements till now
Jul 2, 2024
2ca4e97
done
Jul 2, 2024
ba01ab6
branch problem fixed
Jul 2, 2024
2033d50
Ya bissmilah, just stated by implimenting the Channel class with some…
Jul 7, 2024
f64b368
just setting up the setters and getters
Jul 7, 2024
2e41c4e
push from ayoub , nothing special added
Jul 8, 2024
dabeb5e
updating the Client class
Jul 8, 2024
38c3083
settuping the channel
Jul 8, 2024
2670c90
push
Jul 9, 2024
25b406e
just a test
Jul 15, 2024
f4ce9d8
bugs foxed
Jul 15, 2024
ef85d71
test
Jul 17, 2024
4d032df
update
Jul 17, 2024
a69ca21
.just a test baby
Jul 17, 2024
84a7e65
testing
Jul 17, 2024
bc21d58
pushed
Jul 17, 2024
1cfbcc0
last update
Jul 17, 2024
be93048
mjiid
Jul 17, 2024
dcb25b6
fix the server massage
Jul 18, 2024
9432d79
fix some error massages
Jul 18, 2024
b1010b7
done
Jul 19, 2024
0389717
ja2a lfaraj
Jul 23, 2024
4df1d37
join is ready just fix unkown command
Jul 23, 2024
2a387cd
join is ready just fix unkown command .
Jul 23, 2024
7e8f738
Spliting the joinCmd and starting the kickCmd
mbelouar Jul 23, 2024
1d23a31
KICK is DONE still just some additional settings
mbelouar Jul 24, 2024
f3ffc95
start coding the topicCmd
mbelouar Jul 24, 2024
0c8e5f5
must add privmsg, names to list the users in the channels and also to…
mbelouar Jul 24, 2024
40f41e5
topic command is DONE
mbelouar Jul 24, 2024
9f0a6d0
start implement the who command
mbelouar Jul 24, 2024
860f9c0
privmsg working just for channels
mbelouar Jul 25, 2024
f6de918
Fixing the hostname and password checks
mbelouar Jul 26, 2024
3836f2f
fixing 2 users join same channel but still fix the PART command when …
mbelouar Jul 26, 2024
d6c6473
Add PART command
mbelouar Jul 26, 2024
b958aa0
PRIVMSG is DONE
mbelouar Jul 26, 2024
4631837
KICK is DONE, still just MODE command and operators (will be handled …
mbelouar Jul 26, 2024
9088cfe
NICK is DONE
mbelouar Jul 27, 2024
f183446
QUIT is DONE
mbelouar Jul 27, 2024
627dd0a
Start implementing INVITE command
mbelouar Jul 27, 2024
0cc3d30
Add MODE command but still some errors to fix
Jul 27, 2024
76eca60
Add the operators to their vector in the channel
mbelouar Jul 27, 2024
d47de57
Merge commit '76eca60' into mbelouar
mbelouar Jul 27, 2024
d6109af
Add the operators to their vector in the channel 2
mbelouar Jul 27, 2024
d2469c8
Fixing the MODE command still just k and l, also TOPIC is updated
mbelouar Jul 28, 2024
e0690dd
MODE command is DONE
mbelouar Jul 28, 2024
7bcc883
MODE command is DONE just modify the error message for size=1
mbelouar Jul 28, 2024
d42a682
INVITE command is DONE
mbelouar Jul 28, 2024
b96ba36
try to fix nickname douplicattt
Jul 28, 2024
19ca604
IRC is DONE
mbelouar Jul 28, 2024
20e8f7e
file transfer is fixed
mbelouar Jul 28, 2024
02d43ef
fix nc command line
Jul 29, 2024
126747f
ALL IS DONE
mbelouar Jul 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 0 additions & 64 deletions .vscode/settings.json

This file was deleted.

186 changes: 186 additions & 0 deletions Channel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
#include "Channel.hpp"

Channel::Channel() {
name = "";
topic = "";
chPassword = "";
channelType = 0;
hasPassword = 0;
}
Channel::Channel(std::string channelName, int chType) {
name = channelName;
topic = "No topic"; // Default topic value
chPassword = "";
channelType = chType;
hasPassword = 0;
}


Channel::Channel(const Channel &copy) {
name = copy.name;
topic = copy.topic;
clients = copy.clients;
operators = copy.operators;
chPassword = copy.chPassword;
channelType = copy.channelType;
hasPassword = copy.hasPassword;
}

Channel &Channel::operator=(const Channel &copy) {
if (this == &copy) {
name = copy.name;
topic = copy.topic;
clients = copy.clients;
operators = copy.operators;
chPassword = copy.chPassword;
channelType = copy.channelType;
hasPassword = copy.hasPassword;
}
return *this;
}

Channel::~Channel() {
}

void Channel::setName(std::string channelName) {
name = channelName;
}

// setters and getters :

void Channel::setTopic(std::string channelTopic) {
topic = channelTopic;
}

void Channel::setClients(int id, const std::string &userName) {
clients[id].set_nickname(userName);
}

void Channel::setOperators(int op) {
operators.push_back(op);
}

void Channel::setChPassword(std::string channelPassword) {
chPassword = channelPassword;
}

void Channel::setChannelType(int chType) {
channelType = chType;
}

void Channel::setHasPassword(int hasPsd) {
hasPassword = hasPsd;
}



// void Channel::setInvitedList(int id, client &c){
// inviteList[id] = c;
// }
std::string Channel::getName() {
return name;
}

std::string Channel::getTopic() {
return topic;
}



std::vector<int> &Channel::getOperators() {
return operators;
}

std::string Channel::getChPassword() {
return chPassword;
}

int Channel::getChannelType() {
return channelType;
}

// int Channel::getHasPassword() {
// return hasPassword;
// }

int Channel::getHasPassword() const{
return hasPassword;
}


// std::map<int, client> Channel::getInvitedList() const{
// return inviteList;
// }

std::map<int, client>::const_iterator Channel::beginClientIter() const {
return clients.begin();
}

std::map<int, client>::const_iterator Channel::endClientIter() const {
return clients.end();
}

const std::map<int, client> &Channel::getClientsFromChannel() const{
return clients;

}

int Channel::getClientID(const std::string &nickname) const {
std::map<int, client>::const_iterator it;
for (it = clients.begin(); it != clients.end(); ++it) {
if (it->second.getNickname() == nickname) {
return it->first;
}
}
return -1;
}

int Channel::isClientInChannel(int fd) {
std::map<int, client>::iterator it;
it = clients.find(fd);
if (it != clients.end()) {
return 1;
}
return 0;
}

size_t Channel::getClientNb() const {
return clients.size();
}

// bool Channel::isClientInvited(int clientId) const{
// bool isInvited = (inviteList.count(clientId) > 0);
// return isInvited;
// }

void Channel::removeClient(int fd) {
clients.erase(fd);
}

void Channel::addOperator(int id) {
operators.push_back(id);
}

void Channel::removeOperator(int id) {
operators.erase(std::remove(operators.begin(), operators.end(), id), operators.end());
}

bool Channel::isOperator(int id) {
return std::find(operators.begin(), operators.end(), id) != operators.end();
}

int Channel::getChannelLimit() const {
return channeLimit;
}

void Channel::setChannelLimit(int limit) {
channeLimit = limit;
}

void Channel::addInvite(int fd) {
inviteList.push_back(fd);
}

bool Channel::isClientInvited(int fd) const {
return std::find(inviteList.begin(), inviteList.end(), fd) != inviteList.end();
}
72 changes: 72 additions & 0 deletions Channel.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#ifndef CHANNEL_HPP
#define CHANNEL_HPP

#include <iostream>
#include <string>
#include <map>
#include <vector>
#include "client.hpp"

class Channel {
private:
std::string name;
std::string topic;
std::string chPassword;
std::vector<int> operators;
std::map<int, client> clients;
// std::map<int, client> inviteList;
std::vector<int> inviteList;
int channelType;
int hasPassword;
int channeLimit;

public:
Channel();
Channel(std::string channelName, int channelType);
Channel(const Channel &copy);
Channel &operator=(const Channel &copy);
~Channel();

// setters :
void setName(std::string channelName);
void setTopic(std::string channelTopic);
// void setClients(std::map<int, client> channelClients);
void setClients(int id, const std::string &userName);
void setOperators(int op);
void setChPassword(std::string channelPassword);
void setChannelType(int channelType);
void setHasPassword(int hasPassword);
// void setInvitedList(int id, client &c);
void setChannelLimit(int limit);

// getters :
std::string getName();
std::string getTopic();
std::vector<int> &getOperators();
std::string getChPassword();
std::map<int, client>::const_iterator beginClientIter() const;
std::map<int, client>::const_iterator endClientIter() const;
int getChannelLimit() const;
int getChannelType();
int getClientID(const std::string &nickname) const;
int isClientInChannel(int fd);
int getHasPassword() const;
size_t getClientNb() const;
// std::map<int, client> getInvitedList() const;
bool isClientInvited(int clientId) const;
const std::map<int, client> &getClientsFromChannel() const;

void removeClient(int fd);
void addOperator(int id);
void removeOperator(int id);
bool isOperator(int id);
void addInvite(int fd);
bool isInvited(int fd);


};




#endif
Binary file removed FT_IRC
Binary file not shown.
39 changes: 26 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
NAME=FT_IRC
# Colors
WHITE = \033[1;37m
RED = \033[1;31m
GREEN = \033[1;32m
YELLOW = \033[1;33m
RESET = \033[0m

CC = c++
FLAGS = -Wall -Wextra -Werror -std=c++98
SRC = irc_server.cpp server.cpp client.cpp
OBJ = $(SRC:.cpp=.o)
NAME = ircserv # Change this to your desired executable name
CC = c++ # Change this if your compiler is not g++
CFLAGS = -Wall -Wextra -Werror -std=c++98
SRC = irc_server.cpp server.cpp client.cpp cmd.cpp Channel.cpp joinCmd.cpp utils.cpp kickCmd.cpp topicCmd.cpp whoCmd.cpp privmsgCmd.cpp \
partCmd.cpp modeCmd.cpp nickCmd.cpp quitCmd.cpp inviteCmd.cpp #listCmd.cpp
OBJ = ${SRC:.cpp=.o}

all: $(NAME)
all: ${NAME}

$(NAME): $(OBJ)
$(CC) $(FLAGS) $(OBJ) -o $(NAME)
${OBJ}: %.o: %.cpp
@${CC} ${CFLAGS} -c $< -o $@

%.o: %.cpp
$(CC) $(FLAGS) -c $< -o $@
${NAME}: ${OBJ}
@echo "$(YELLOW)Compiling $(NAME)...⏳$(RESET)"
@${CC} ${CFLAGS} -o ${NAME} ${OBJ}
@echo "$(GREEN)Compilation completed ✅$(RESET)"

clean:
rm -f $(OBJ)
@${RM} ${OBJ}
@echo "$(RED)Obj_files removed.$(RESET)"

fclean: clean
rm -f $(NAME)
@${RM} ${NAME}
@echo "$(RED)Executable removed.$(RESET)"

re: fclean all
re: fclean all

.PHONY: all clean fclean re
1 change: 0 additions & 1 deletion README.md

This file was deleted.

Loading