bot
This commit is contained in:
32
includes/bot.hpp
Normal file
32
includes/bot.hpp
Normal file
@@ -0,0 +1,32 @@
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* Bot.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/30 01:54:36 by vvaas #+# #+# */
|
||||
/* Updated: 2024/01/30 02:39:52 by vvaas ### ########.fr */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
#define IP "127.0.0.1"
|
||||
#define PORT 6667
|
||||
#define PASSWORD "gg"
|
||||
|
||||
#include <irc.hpp>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
class bot
|
||||
{
|
||||
public:
|
||||
bot();
|
||||
void init(void);
|
||||
void connect_to_server(void);
|
||||
~bot();
|
||||
private :
|
||||
struct sockaddr_in _serv_addr;
|
||||
int _fd;
|
||||
std::vector<std::string> _connect_commands;
|
||||
};
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/21 10:33:17 by maldavid #+# #+# */
|
||||
/* Updated: 2024/01/30 00:07:07 by vvaas ### ########.fr */
|
||||
/* Updated: 2024/01/30 01:45:23 by vvaas ### ########.fr */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <irc.hpp>
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include <errorscode.hpp>
|
||||
|
||||
namespace irc
|
||||
{
|
||||
@@ -38,9 +39,13 @@ namespace irc
|
||||
inline void setNewRealName(const std::string& name) { _realname = name; }
|
||||
|
||||
inline void login() { _logged = true; }
|
||||
inline void register_user() { _registered = true; }
|
||||
inline void welcome() { if (isLogged() && !isWelcomed()) return ; _welcomed = true; sendCode(RPL_WELCOME, "Welcome to yipirc :), " + _nickname); }
|
||||
inline void requireDisconnect() { _disconnect_required = true; }
|
||||
|
||||
inline bool isLogged() const { return _logged; }
|
||||
inline bool isRegistered() const { return _registered; }
|
||||
inline bool isWelcomed() const { return _welcomed; }
|
||||
inline bool disconnectRequired() const { return _disconnect_required; }
|
||||
|
||||
inline const std::string& getNickName() const { return _nickname; }
|
||||
@@ -72,7 +77,9 @@ namespace irc
|
||||
sockaddr_in _s_data;
|
||||
int _fd;
|
||||
int _id;
|
||||
bool _welcomed;
|
||||
bool _logged;
|
||||
bool _registered;
|
||||
bool _disconnect_required;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/* ************************************************************************** */
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* config.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* By: vvaas <vvaas@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/22 09:45:10 by maldavid #+# #+# */
|
||||
/* Updated: 2024/01/23 10:22:15 by maldavid ### ########.fr */
|
||||
/* Updated: 2024/01/30 01:37:03 by vvaas ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
/******************************************************************************/
|
||||
|
||||
#ifndef __CONFIG__
|
||||
#define __CONFIG__
|
||||
@@ -17,5 +17,5 @@
|
||||
#define LOGS_BUFFER_SIZE 4096
|
||||
#define MAX_USERS 20
|
||||
#define NULL_SOCKET -1
|
||||
|
||||
#define LEGAL_CHARACTER "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789{}[]\\|^`-_"
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user