42 lines
1.5 KiB
C++
42 lines
1.5 KiB
C++
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ping.cpp :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2025/05/24 17:29:48 by rparodi #+# #+# */
|
|
/* Updated: 2025/06/03 14:49:27 by rparodi ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "ping.hpp"
|
|
#include "commands.hpp"
|
|
#include "logs.hpp"
|
|
#include "pong.hpp"
|
|
#include <ctime>
|
|
|
|
using namespace cmd;
|
|
|
|
bool Ping::checkArgs() {
|
|
if (_args.size() < 3) {
|
|
WARNING_MSG("Not enough arguments for PING command");
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* @brief Execute the Ping
|
|
* @note To send a private message to a user / a channel
|
|
*/
|
|
void Ping::execute() {
|
|
clock_t start = clock() / CLOCKS_PER_SEC;
|
|
if (checkArgs() == false) {
|
|
ERROR_MSG("Invalid arguments for PRIVMSG command (see warning message)");
|
|
return;
|
|
}
|
|
clock_t diff = Pong().answer(start);
|
|
INFO_MSG(diff);
|
|
// check how the com
|
|
}
|