diff --git a/includes/Bot.hpp b/includes/Bot.hpp index 8116947..9e17bfe 100644 --- a/includes/Bot.hpp +++ b/includes/Bot.hpp @@ -6,7 +6,7 @@ /* By: vvaas +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/30 01:54:36 by vvaas #+# #+# */ -/* Updated: 2024/02/07 16:57:53 by maldavid ### ########.fr */ +/* Updated: 2024/02/10 17:24:56 by vvaas ### ########.fr */ /* */ /******************************************************************************/ @@ -26,7 +26,8 @@ class Bot ~Bot(); - private : + private: + clock_t begin; std::vector _connect_commands; struct sockaddr_in _serv_addr; int _fd; diff --git a/includes/config.hpp b/includes/config.hpp index cdcc151..8e23024 100644 --- a/includes/config.hpp +++ b/includes/config.hpp @@ -6,7 +6,7 @@ /* By: vvaas +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/22 09:45:10 by maldavid #+# #+# */ -/* Updated: 2024/02/06 12:35:38 by vvaas ### ########.fr */ +/* Updated: 2024/02/10 17:23:13 by vvaas ### ########.fr */ /* */ /******************************************************************************/ @@ -18,6 +18,5 @@ #define MAX_USERS 20 #define FD_MAX 1023 #define NULL_SOCKET -1 -#define LEGAL_CHARACTER "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789{}[]\\|^`-_" #endif diff --git a/srcs/channel.cpp b/srcs/channel.cpp index 03a47c8..8becfc8 100644 --- a/srcs/channel.cpp +++ b/srcs/channel.cpp @@ -6,7 +6,7 @@ /* By: vvaas +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/21 10:36:21 by maldavid #+# #+# */ -/* Updated: 2024/02/06 12:36:19 by vvaas ### ########.fr */ +/* Updated: 2024/02/10 18:01:38 by vvaas ### ########.fr */ /* */ /******************************************************************************/ diff --git a/srcs/server_functions.cpp b/srcs/server_functions.cpp index cbc6651..88f28f6 100644 --- a/srcs/server_functions.cpp +++ b/srcs/server_functions.cpp @@ -6,7 +6,7 @@ /* By: vvaas +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/22 17:31:06 by maldavid #+# #+# */ -/* Updated: 2024/02/07 16:45:33 by maldavid ### ########.fr */ +/* Updated: 2024/02/10 17:59:06 by vvaas ### ########.fr */ /* */ /******************************************************************************/ @@ -293,7 +293,7 @@ namespace irc } complete_msg.erase(complete_msg.begin()); } - (*itc)->sendMsg(client->getNickName(), "NOTICE " + (*itc)->getNickName(), complete_msg); + (*itc)->sendMsg(":YipIRC", "NOTICE " + (*itc)->getNickName(), complete_msg); break; } } diff --git a/srcs_bonus/bot.cpp b/srcs_bonus/bot.cpp index 7b962cd..4d4185c 100644 --- a/srcs_bonus/bot.cpp +++ b/srcs_bonus/bot.cpp @@ -6,7 +6,7 @@ /* By: vvaas +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/30 01:54:56 by vvaas #+# #+# */ -/* Updated: 2024/02/07 16:41:47 by maldavid ### ########.fr */ +/* Updated: 2024/02/10 18:03:17 by vvaas ### ########.fr */ /* */ /******************************************************************************/ @@ -20,10 +20,11 @@ #include #include #include +#include bool active = true; -Bot::Bot() : _fd(-1), _channel_created(false), _logged(false) +Bot::Bot() : begin(clock()), _fd(-1), _channel_created(false), _logged(false) {} Bot::~Bot() @@ -108,9 +109,10 @@ void Bot::handle_response(std::string buffer) } else if(!_channel_created) return; - if(buffer.find("KICK #greg greg :") != std::string::npos || buffer.find("explose") != std::string::npos) + if(buffer.find("KICK #greg greg :") != std::string::npos || buffer.find("explose") != std::string::npos || buffer.find(":YipIRC KILL greg :") != std::string::npos) { - send_message("QUIT: Explose\r\n"); + irc::logs::report(irc::log_message, "Exiting server"); + send_message("QUIT :Salut mon pote\r\n"); active = false; } if(buffer.find("quoi") != std::string::npos) @@ -132,6 +134,11 @@ void Bot::connect_to_server() } while(active) { + if (((clock() - begin) * 1000 / CLOCKS_PER_SEC) > 1000 && !_logged) + { + active = false; + irc::logs::report(irc::log_error, "Couldn't log into server"); + } if(recv(_fd, buffer, 1024, 0) > 0) handle_response(buffer); std::memset(buffer, 0, sizeof(buffer));