A chat server written in Python.
Tested on Python 3.11 and 3.12 on a Unix system only.
This project consist of a server (command line) and a client (graphic).
You can:
The default rooms are:
After installing Python and cloning the git:
python -m venv "path_to_your_venv"
source "path_to_your_venv"/bin/activate
pip install -r client/requirements.txt
source "path_to_your_venv"/bin/activate
python client/main.py
After installing Python and cloning the git:
python -m venv "path_to_your_venv"
source "path_to_your_venv"/bin/activate
pip install -r server/requirements.txt
The database is using MySQL and should be imported:
└── server
└── db
└── chat.sql -> database to import
mysql -u root -p chat < server/db/chat.sql
source "path_to_your_venv"/bin/activate
python server/main.py -a <ip_to_use> -p <port_to_use>
Commands of the server:
help - display this help message
messages <time> - display a list of all messages since a time
users - display a list of all users
rooms - display a list of all rooms
add room <room1,room2,...> - add a room
pending rooms <username> - display a list of pending rooms for a user
accept pending <username> <room1,room2,...> - accept pending rooms for a user
kick <username> <timeout> <reason> - kick a user
unkick <username> - unkick a user
ban <username> <reason> - ban a user
ban ip <ip> <reason> - ban an IP address
unban <username> - unban a user
unban ip <ip> - unban an IP address
kill <username> <reason> - kill a user
shutdown - shutdown the server
Here is the structure of the project:
client
├── backend
│ ├── client.py -> client class
│ ├── handler.py -> redirects messages
│ └── types.py -> handles messages content
├── interface
│ ├── chat.py -> chat window class
│ ├── error.gif
│ ├── login.css
| └── login.py -> login window class
├── main.py -> starts the programm
└── requirements.txt
server
├── db
| └── chat.sql -> database to import
├── server
│ ├── admin.py -> handles commands in the terminal
│ ├── client.py -> client class
│ ├── database.py -> database class (database logic)
│ ├── message_handler.py -> redirects messages
│ ├── server.py -> server class
| └── types.py -> handles messages content
├── main.py -> start the programm
└── requirements.txt
Here is the structure of the database:
You can also find a docstring sphinx for the client and the server.
This chat server shouldn't be used outside of a local trusted network as the data traffic isn't encrypted:
Messages can't be sent to users not connected to the server.
Even if all messages are stored on the server those aren't served when a client connect, meaning the history of a room isn't readable by clients.
Bugs can be encountered when unexpected operations are made on the server or clients