Python implementation of a lightweight IRC stack for local experimentation. The repo contains two server variants, a simple CLI client, and two bots for scripted interactions.
server.py– Threaded IPv6 server that handles core IRC flow (NICK,USER,JOIN,PART,PRIVMSG,PING/PONG) with heartbeat checks and dynamic channel management.server_asyncio.py– Asyncio server with broader RFC 1459 coverage (QUIT,LIST,NAMES,WHO,WHOIS,MODE,CAP, etc.), idle tracking, and safer concurrency via async locks.client.py– Minimal CLI client. Runs in interactive user mode or a lightweight bot mode (--role robot) that replies to a few commands.bot.py– Featureful bot that replies to!hello,!slap,!list,!whois, and can send random facts or private replies.facts.txt– Fact snippets used bybot.py.
- Python 3.10+.
psutilis required only forserver_asyncio.py:pip install psutil
- (Optional) Create a virtual environment:
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt # if you add one, otherwise install psutil manually- Start a server (default host
::, port6667):
python server_asyncio.py
# or: python server.py- Start a test client against the server:
python client.py --host ::1 --port 6667 --name alice --channel #hello- Type messages and press Enter to broadcast to the joined channel.
- Use
/quitto exit cleanly. - To try the built-in lightweight bot mode instead:
python client.py --role robot --host ::1 --port 6667 --name miniBot --channel #hello.
- Run the richer bot that uses
facts.txt:
python bot.py --host ::1 --port 6667 --name SuperBot --channel helloNote: pass the channel without #; the script adds it when needed.
NICK/USER– registrationJOIN/PART– channel membershipPRIVMSG– channel or direct messagingPING/PONG– heartbeat handling- Extras in
server_asyncio.py:QUIT,LIST,NAMES,WHO,WHOIS,MODE,CAP
- The code listens on IPv6 by default (
AF_INET6). Use::1for local testing. If your IRC client prefers IPv4, update the socket family in the server/client or use an IPv6-capable client. - Align client port flags with the server port (both servers default to
6667;client.pydefaults to6666, so override with--port 6667). - No TLS is implemented; traffic is plain TCP.
- Not a full RFC-compliant implementation; edge cases and additional numerics are still missing.
- No SSL/TLS support.
- IPv6-only sockets by default; adjust if your environment needs IPv4.