Skip to content

Commit

Permalink
finish
Browse files Browse the repository at this point in the history
  • Loading branch information
berat-samli committed Dec 4, 2023
1 parent 26fb4bb commit 80e382a
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 42 deletions.
Binary file added .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion ft_irc/Commands/join.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void Commands::Join(User &user, vector<Channel> &channels, int clientSocket)
SendToClient(clientSocket, user.getClientName() + " JOIN you joined the " + *itArgs + " channel!\n");
return;
}
else if (itChannels->userOnTheChannel(user.getNickName()))
else if (itChannels->getName() == *itArgs && itChannels->userOnTheChannel(user.getNickName()))
{
SendToClient(clientSocket, user.getClientName() + " JOIN You're already on this channel!\n");
return;
Expand Down
9 changes: 3 additions & 6 deletions ft_irc/Commands/kick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,14 @@ void Commands::Kick(User &user, vector<Channel> &channels, int clientSocket)
string reason = args[3];
Channel *channel = findChannel(channels);
if(!channel)
{
errorHandle(user, channel->getName(), clientSocket, ERR_NOSUCHCHANNEL);
return ;
}
if (channel->userIsTheAdmin(user.getNickName()))
errorHandle(user, "", clientSocket, ERR_NOSUCHCHANNEL);
else if (channel->userIsTheAdmin(user.getNickName()))
{
User *kickUser = channel->getUser(kickNickName);
SendToClient(kickUser->socket, kickUser->getClientName() + " KICK You're kicked for Reason: " + reason + "\n");
channel->removeUser(kickNickName);
}
}
else errorHandle(user, "", clientSocket, ERR_NEEDMOREPARAMS);
else errorHandle(user, "", clientSocket, ERR_NEEDMOREPARAMS);
}
}
2 changes: 1 addition & 1 deletion ft_irc/Commands/mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void Commands::Mode(User& user, vector<Channel> &channels, int clientSocket)
}
}
}
else errorHandle(user, channel->getName(), clientSocket, ERR_NOSUCHCHANNEL);
else errorHandle(user, "", clientSocket, ERR_NOSUCHCHANNEL);
}
else errorHandle(user, "", clientSocket, ERR_NEEDMOREPARAMS);
}
Expand Down
6 changes: 1 addition & 5 deletions ft_irc/Commands/nick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,5 @@ void Commands::Nick(map<int, User> &users, int clientSocket) {
}
users[clientSocket]._isNicked = true;
}
else
{
cout << "\nCONTROL\n" << endl;
errorHandle(users[clientSocket], "", clientSocket, ERR_NONICKNAMEGIVEN);
}
else errorHandle(users[clientSocket], "", clientSocket, ERR_NONICKNAMEGIVEN);
}
5 changes: 1 addition & 4 deletions ft_irc/Commands/pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ void Commands::Pass(User& user, int clientSocket, string svPasswd) {
if(args.size() == 2)
{
if(user._isAuth)
{
errorHandle(user, "", clientSocket, 462);
return;
}
if (user._isRegister) {
else if (user._isRegister) {
(void)user;
string message;
vector<string>::iterator it = args.begin() + 1;
Expand Down
2 changes: 1 addition & 1 deletion ft_irc/Commands/topic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void Commands::Topic(User &user, vector<Channel> &channels, int clientSocket)
SendToClient((*it)->socket, (*it)->getClientName() + " TOPIC Topic has chanced: " + *topic + "!\n");
}
}
else errorHandle(user, channel->getName(), clientSocket, ERR_NOSUCHCHANNEL);
else errorHandle(user, "", clientSocket, ERR_NOSUCHCHANNEL);
}
else errorHandle(user, "", clientSocket, ERR_NEEDMOREPARAMS);
}
Expand Down
4 changes: 2 additions & 2 deletions ft_irc/Commands/user.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ void Commands::Usèr(User& user, int clientSocket) {
user._isUser = true;
if (user._isNicked) {
user._isRegister = true;
SendToClient(clientSocket, user.getClientName() + user.getUserName() + " USER You are registered now!\n");
string newClientName = user.getNickName() + "!" + user.getUserName() + "@" + user.hostname;
user.setClientName(newClientName);
SendToClient(clientSocket, user.getClientName() + user.getUserName() + " USER You are registered now!\n");
}
else if(user._isUser){
else if (user._isUser){
string newClientName = "!" + user.getUserName() + "@" + user.hostname;
user.setClientName(newClientName);
}
Expand Down
5 changes: 3 additions & 2 deletions ft_irc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ OBJECTS = $(FILE:.cpp=.o)
FILE = server.cpp \
main.cpp \
user.cpp \
commands.cpp channel.cpp \
commands.cpp \
channel.cpp \
./commands/nick.cpp \
./commands/pass.cpp \
./commands/user.cpp \
./commands/Quit.cpp \
./commands/quit.cpp \
./commands/ping.cpp \
./commands/join.cpp \
./commands/kick.cpp \
Expand Down
20 changes: 0 additions & 20 deletions ft_irc/ircserv.dSYM/Contents/Info.plist

This file was deleted.

Binary file removed ft_irc/ircserv.dSYM/Contents/Resources/DWARF/ircserv
Binary file not shown.

0 comments on commit 80e382a

Please sign in to comment.