mirror of
https://github.com/Ladebeze66/ft_irc.git
synced 2026-11-09 13:17:13 +01:00
botok
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/21 18:09:05 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/06/01 18:48:32 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/06/06 18:41:04 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "InviteHandler.hpp"
|
||||
#include "TopicHandler.hpp"
|
||||
#include "KickHandler.hpp"
|
||||
#include "BotFilter.hpp"
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
@@ -31,6 +32,7 @@
|
||||
class Server;
|
||||
class Client;
|
||||
class Channel;
|
||||
class BotFilter;
|
||||
class AdditionalCommands
|
||||
{
|
||||
private:
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/06/06 11:44:44 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/06/06 13:41:41 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/06/06 18:50:12 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -25,21 +25,24 @@
|
||||
#include "Client.hpp"
|
||||
#include "Channel.hpp"
|
||||
|
||||
class Server;
|
||||
class Client;
|
||||
class Channel;
|
||||
class BotFilter
|
||||
{
|
||||
public:
|
||||
BotFilter(Server *server);
|
||||
void loadBadWords(const std::string &fileName);
|
||||
bool checkMessage(Client *client, Channel *channel, const std::string &message);
|
||||
BotFilter(Server* server);
|
||||
void loadBadWords(const std::string& fileName);
|
||||
bool checkMessage(Client* client, Channel* channel, const std::string& message);
|
||||
void warnClient(Client* client, Channel* channel);
|
||||
void kickClient(Client* client, Channel* channel);
|
||||
|
||||
private:
|
||||
Server *_server;
|
||||
bool containsBadWords(const std::string& message);
|
||||
|
||||
Server* _server;
|
||||
std::vector<std::string> _badWords;
|
||||
std::map<int, int> _warnings;
|
||||
|
||||
bool containsBadWords(const std::string &message);
|
||||
void warnClient(Client *client, Channel *channel);
|
||||
void kickClient(Client *client, Channel *channel);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/15 12:41:35 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/06/04 16:12:23 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/06/06 21:03:34 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -28,54 +28,55 @@ class Client;
|
||||
|
||||
class Channel
|
||||
{
|
||||
public:
|
||||
Channel(const std::string &name);
|
||||
~Channel();
|
||||
public:
|
||||
Channel(const std::string &name);
|
||||
~Channel();
|
||||
|
||||
const std::string &getName() const;
|
||||
void addClient(Client *client);
|
||||
void removeClient(Client *client);
|
||||
bool isEmpty() const;
|
||||
const std::vector<Client *> &getClients() const;
|
||||
void addOperator(Client *client);
|
||||
bool isOperator(Client *client) const;
|
||||
void removeOperator(Client *client); // Ajouté
|
||||
bool hasClient(Client *client) const;
|
||||
void broadcast(const std::string &message, Client *_client, Server *_server);
|
||||
bool isBanned(Client *client) const;
|
||||
bool isFull() const;
|
||||
bool isInviteOnly() const;
|
||||
bool isInvited(Client *client) const;
|
||||
bool checkKey(const std::string &key) const;
|
||||
const std::string &getTopic() const;
|
||||
const std::string &getTopicSetter() const;
|
||||
time_t getTopicTime() const;
|
||||
void setTopic(const std::string &topic, const std::string &setter);
|
||||
std::string getKey();
|
||||
const std::string &getName() const;
|
||||
void addClient(Client *client);
|
||||
void removeClient(Client *client);
|
||||
bool isEmpty() const;
|
||||
const std::vector<Client *> &getClients() const;
|
||||
void addOperator(Client *client);
|
||||
bool isOperator(Client *client) const;
|
||||
void removeOperator(Client *client);
|
||||
bool hasClient(Client *client) const;
|
||||
void broadcast(const std::string &message, Client *_client, Server *_server);
|
||||
bool isBanned(Client *client) const;
|
||||
void banClient(Client *client, Channel *channel);
|
||||
bool isFull() const;
|
||||
bool isInviteOnly() const;
|
||||
bool isInvited(Client *client) const;
|
||||
bool checkKey(const std::string &key) const;
|
||||
const std::string &getTopic() const;
|
||||
const std::string &getTopicSetter() const;
|
||||
time_t getTopicTime() const;
|
||||
void setTopic(const std::string &topic, const std::string &setter);
|
||||
std::string getKey();
|
||||
|
||||
void setClientLimit(size_t limit);
|
||||
size_t getClientLimit() const;
|
||||
void setInviteOnly(bool inviteOnly);
|
||||
void setKey(const std::string &key);
|
||||
void setTopicProtection(bool protection);
|
||||
std::string getModes() const;
|
||||
bool getTopicProtection() const;
|
||||
void addInvitedClient(Client* client);
|
||||
|
||||
private:
|
||||
std::string _name;
|
||||
std::vector<Client *> _clients;
|
||||
std::vector<Client *> _operators;
|
||||
std::set<Client *> _bannedClients;
|
||||
std::set<Client *> _invitedClients;
|
||||
std::string _key;
|
||||
std::string _topic;
|
||||
std::string _topicSetter;
|
||||
time_t _topicTime;
|
||||
size_t _clientLimit;
|
||||
bool _inviteOnly;
|
||||
bool _topicProtection;
|
||||
void setClientLimit(size_t limit);
|
||||
size_t getClientLimit() const;
|
||||
void setInviteOnly(bool inviteOnly);
|
||||
void setKey(const std::string &key);
|
||||
void setTopicProtection(bool protection);
|
||||
std::string getModes() const;
|
||||
bool getTopicProtection() const;
|
||||
void addInvitedClient(Client* client);
|
||||
|
||||
private:
|
||||
Server *_server;
|
||||
std::string _name;
|
||||
std::vector<Client *> _clients;
|
||||
std::vector<Client *> _operators;
|
||||
std::set<int> _bannedClients;
|
||||
std::set<Client *> _invitedClients;
|
||||
std::string _key;
|
||||
std::string _topic;
|
||||
std::string _topicSetter;
|
||||
time_t _topicTime;
|
||||
size_t _clientLimit;
|
||||
bool _inviteOnly;
|
||||
bool _topicProtection;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/15 12:15:42 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/06/06 13:23:23 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/06/06 19:59:39 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/19 15:12:47 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/06/06 12:28:50 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/06/06 19:36:05 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -541,11 +541,10 @@ inline std::string MODEACCEPTMESSAGE(Client *client, std::string channel, const
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
|
||||
inline std::string BOTMESSAGE(Client *client, std::string channel, const std::string& message)
|
||||
inline std::string BOTMESSAGE(Client *client, const std::string &channel, const std::string& message)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << ":" << client->getNickname() << " WARNING " << channel << " " << message << " :" << "\r\n";
|
||||
oss << ":" << client->getNickname() << " NOTICE " << channel << " :" << message << "\r\n";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/15 12:15:13 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/06/06 12:04:58 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/06/06 18:51:31 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -64,6 +64,7 @@ class Server
|
||||
void disconnectClient(int clientFd);
|
||||
bool MatchFd(const pollfd& pfd, int clientFd);
|
||||
void removePollFd(int clientFd);
|
||||
BotFilter* getBotFilter() const;
|
||||
|
||||
protected:
|
||||
int _server_fd;
|
||||
|
||||
Reference in New Issue
Block a user