diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..3597c2c --- /dev/null +++ b/.clang-format @@ -0,0 +1,9 @@ +Language: Cpp +BasedOnStyle: Microsoft +AccessModifierOffset: -4 +BreakBeforeBraces: Allman +AllowShortFunctionsOnASingleLine: false +AllowShortBlocksOnASingleLine: false +AllowShortIfStatementsOnASingleLine: false +IndentWidth: 4 +TabWidth: 4 diff --git a/include/typedefs.hpp b/include/typedefs.hpp index 525225d..bc005e5 100644 --- a/include/typedefs.hpp +++ b/include/typedefs.hpp @@ -3,8 +3,6 @@ #ifndef TYPEDEFS_HPP #define TYPEDEFS_HPP -// #include "class.User.hpp" // needed for User class -// #include "class.Channel.hpp" // needed for Channel class #include // needed for std::map <-- c11 would be unordered map #include // needed for poll_fd #include // needed for std::string @@ -18,15 +16,15 @@ class Channel; /* used to describe channel users rights */ enum UserPrivilege { - USER, - OPERATOR, + USER, + OPERATOR, }; /* used to store bot information/data */ struct ServerBot { - int socket; - User *self; + int socket; + User *self; }; // ------------------ std::string --------------------------- // @@ -44,13 +42,13 @@ typedef t_vec_str const t_vec_str_c; typedef t_vec_str::iterator t_vec_str_it; typedef t_vec_str::const_iterator t_vec_str_cit; -/* used to store all accepted socket fd */ +/* used to store all accepted socket fds */ typedef std::vector t_vec_pollfd; typedef t_vec_pollfd::iterator t_vec_pollfd_it; // ------------------ std::maps --------------------------- // -/* used to store sockets and their User class */ +/* used to store user sockets and their User class */ typedef std::map t_um_users; typedef t_um_users::iterator t_um_users_it; typedef t_um_users::const_iterator t_um_users_cit; @@ -60,11 +58,11 @@ typedef std::map t_um_channels; typedef t_um_channels::iterator t_um_channels_it; typedef t_um_channels::const_iterator t_um_channels_cit; -/* used to store users and their privileges in a channel */ +/* used to store user sockets and their privileges in a channel */ typedef std::map t_channel_users; typedef t_channel_users::iterator t_channel_users_it; typedef t_channel_users::const_iterator t_channel_users_cit; #endif // TYPEDEFS_HPP -// -------------------------------------------------------------------------- // \ No newline at end of file +// -------------------------------------------------------------------------- // diff --git a/src/class.Server.Messages.cpp b/src/class.Server.Messages.cpp index 66e0004..3302d71 100644 --- a/src/class.Server.Messages.cpp +++ b/src/class.Server.Messages.cpp @@ -384,6 +384,14 @@ void Server::CMD_KICK(int socketSender) } else { + if (nicknameKicked == "Marvin") + { + broadcast(nicknameKicked, channelName, "", + "Hey " + um.getNickname(socketSender) + ", you tried to kick me ... Bloody Bastard!", + "PRIVMSG"); + continue; + } + int socketTarget = um.getSocket(nicknameKicked); if (channel->isMember(socketTarget) == false) { @@ -570,4 +578,4 @@ void Server::CMD_MODE(int socket) } } -// -------------------------------------------------------------------------- // \ No newline at end of file +// -------------------------------------------------------------------------- // diff --git a/src/class.Server.cpp b/src/class.Server.cpp index 7a08733..1641400 100644 --- a/src/class.Server.cpp +++ b/src/class.Server.cpp @@ -113,12 +113,13 @@ void Server::start(int argc, char **argv) bool Server::getPortAndPasswd(char **argv) { std::string str = argv[1]; - for (size_t i = 0; i < str.size(); i++) - if (isnumber(str[i]) == false) + for (size_t i = 0; i < str.size(); i++){ + if (std::isdigit(str[i]) == false) { LOG_ERR("Bad input as Port"); return false; } + } this->m_port = atoi(argv[1]); if (this->m_port != PORT) { @@ -686,4 +687,4 @@ void Server::broadcast(t_str_c &sender, t_str_c &channelName, t_str_c &nicknameK } } -// -------------------------------------------------------------------------- // \ No newline at end of file +// -------------------------------------------------------------------------- //