Skip to content

Marcel-git666/ft_irc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

79 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌐 ft_irc

This project has been created as part of the 42 curriculum by iarefeva, mmravec.

πŸ“– Description

Project Overview

This project is a custom IRC (Internet Relay Chat) server developed as part of the 42 curriculum.
Project was developed based on Weechat client, but other clients working with IRC protocol can be used. Server accepts allowing multiple users to join channels and exchange messages in real-time.

🧩 Features

  • Multi-client handling
  • User authentication (PASS, NICK, USER)
  • Channel management:
    • JOIN / PART
    • TOPIC
    • INVITE
    • KICK
  • Channel operator
  • Private messaging (PRIVMSG)
  • Channel modes (oklit)
  • Graceful client disconnection

⭐ Bonus Features

  • DCC File Transfer (Direct Client-to-Client)
    Supports sending files between users using DCC
    Implemented via direct TCP connection between clients
    ⚠️ Currently works only within the same local network (LAN)
  • IRC Bot

βš™οΈ Instructions

πŸ—οΈ Project Structure

ft_irc/
β”œβ”€β”€ bot/        # Bonus files for bot
β”œβ”€β”€ inc/        # Mandatory header files
β”œβ”€β”€ src/        # Mandatory source files
β”œβ”€β”€ unit_tests/ # Unit_tests
β”œβ”€β”€ Makefile
└── README.md

πŸ”§ Compilation

Clone the repository and compile using make:

git clone <link to the repo> ft_irc
cd ft_irc
make

This will generate the executable:

./ircserv

▢️ Usage

Run the server with:

./ircserv <port> <password>

Example:

./ircserv 6667 mypassword

πŸ’» Connecting to the server

There will be described connection through WeeChat, but you can use any IRC client such as:

  • nc (netcat)
  • HexChat
  • WeeChat
  • irssii

In WeeChat window, first add server:

/server add <name> <server IP>/6667 (or other port)

Second add password to the server:

/set irc.server.<name>.password <password>

Third connect to the server:

/connect <name>

All commands for connection WeeChat will send automaticaly.

🧩 Features

  • Multi-client handling
  • User authentication (PASS, NICK, USER)
  • Channel management:
    • JOIN / PART
    • TOPIC
    • INVITE
    • KICK
  • Operator commands
  • Private messaging (PRIVMSG)
  • Channel modes (depending on implementation)
  • Graceful client disconnection

πŸ§ͺ Example Usage

Client 1: JOIN #42
Client 2: JOIN #42
Client 1: PRIVMSG #42 :Hello from 42!

Expected behavior: Both clients receive the message in real time.

πŸ€– Bot Usage

This project also includes a simple IRC bot called MrBot. It connects to our IRC server and responds to basic commands.

πŸ”§ Compilation

make bonus

This will generate the executable:

./ircbot

▢️ Running the Bot

Run the bot with:

./ircbot <IP> <port> <password>

Example:

./ircbot 127.0.0.1 6667 mypassword

– IP address of your IRC server – Port used by the server – Server password (PASS command)

πŸ”Œ Behavior

After launching, the bot will:

  • Connect to the IRC server
  • Authenticate using:
    - PASS
    - NICK (MrBot)
    - USER
  • Listen for incoming messages
  • Respond to commands automatically

πŸ’¬ Available Commands

You can interact with the bot via private messages:

!joke - Returns a random joke

!help - Displays help information

πŸ§ͺ Example Interaction

User: PRIVMSG MrBot :!joke
MrBot: Why do programmers prefer dark mode? Because light attracts bugs.

User: PRIVMSG MrBot :!help
MrBot: Hi, I am MrBot! Available commands: !joke, !help

πŸ›‘ Stopping the Bot

Press Ctrl + C to gracefully terminate the bot.

⚠️ Notes

The bot currently handles:

  • PRIVMSG (commands)
  • PING (keeps connection alive)

The bot does not automatically join channels (can be extended)
Make sure the server is running

πŸ“ DCC File Transfer (WeeChat)

This project supports DCC (Direct Client-to-Client) file transfer, allowing users to send files directly to each other.

βš™οΈ Requirements

Both users must be connected to the IRC server
Both users must use a client that supports DCC (e.g., WeeChat)
⚠️ Works reliably only within the same local network (LAN)
πŸ“€ Sending a File (WeeChat)

In WeeChat, use:

/dcc send <nickname> <file_path>

Example:

/dcc send user2 ./example.txt

πŸ“₯ Receiving a File

When another user sends you a file, WeeChat will display a notification.

To accept the file:

/dcc accept <nickname>

πŸ“‚ Default Download Location

Received files are usually saved in:

~/weechat/dcc/

You can change this path in WeeChat settings.

⚠️ Notes & Limitations

DCC uses a direct TCP connection between clients, not the server
Firewalls or NAT may block transfers
This implementation currently:

  • May not work over the internet without port forwarding
  • Make sure the receiving client allows incoming DCC connections

πŸ§ͺ Example

User1: /dcc send user2 ./file.txt
User2: (receives notification)
User2: /dcc accept user1

Result: file.txt is transferred directly from User1 to User2.

πŸ“š Resources

πŸ“– Documentation

RFC 1459 – Internet Relay Chat Protocol
RFC 2812 – IRC Client Protocol
Beej’s Guide to Network Programming
Linux poll / select man pages

πŸ€– AI Usage

AI tools (such as ChatGPT, Clode) were used in this project for:

Clarifying IRC protocol behavior and edge cases
Understanding socket programming concepts
Debugging specific issues
Improving code structure and readability
Assisting in writing documentation (including this README)

All implementation decisions, architecture, and final code were designed and validated by the authors.

πŸš€ Possible Improvements

Full support of all IRC modes
Better scalability (epoll/kqueue)
Logging system
TLS/SSL support

About

IRC server for 42 Prague project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors