j'espere vrmt que sa marche sinon j'explose

This commit is contained in:
2024-02-10 18:03:49 +01:00
parent 44d9ec54d6
commit f931263ead
5 changed files with 18 additions and 11 deletions

View File

@@ -6,7 +6,7 @@
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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<std::string> _connect_commands;
struct sockaddr_in _serv_addr;
int _fd;

View File

@@ -6,7 +6,7 @@
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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

View File

@@ -6,7 +6,7 @@
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 */
/* */
/******************************************************************************/

View File

@@ -6,7 +6,7 @@
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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;
}
}

View File

@@ -6,7 +6,7 @@
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 <cstdlib>
#include <signal.h>
#include <cerrno>
#include <ctime>
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));