Async IRC library for Python 3.14+
Project description
ircio
An asynchronous IRC client library for Python 3.14+, built on top of asyncio.
Features
- Fully async — all I/O is non-blocking via
asyncio.StreamReader/StreamWriter - IRCv3 message tags — parsed and serialised transparently
- TLS — plain
ssl=Truefor system CA verification, or pass a customssl.SSLContextfor client certificates and private networks - SASL authentication
PLAIN— username and password (RFC 4616)EXTERNAL— identity delegated to the TLS certificateECDSA-NIST256P-CHALLENGE— challenge–response using an ECDSA key on the NIST P-256 curve (used by Libera.Chat and other networks)
- Event dispatcher — register async handlers per command, with wildcard (
"*") support - Structured concurrency — handlers are dispatched via
asyncio.TaskGroup
Requirements
- Python ≥ 3.14
- uv (recommended) or any PEP 517-compatible build tool
Optional, for ECDSA-NIST256P-CHALLENGE:
pip install "ircio[ecdsa]"
Quick start
import asyncio
from ircio import Client
client = Client(
"irc.libera.chat",
6697,
nick="mybot",
user="mybot",
realname="My Bot",
ssl=True,
)
@client.on("PRIVMSG")
async def on_privmsg(msg):
target = msg.params[0]
text = msg.params[1]
print(f"[{target}] {msg.prefix}: {text}")
async def main():
await client.connect()
await client.join("#python")
await client.run()
asyncio.run(main())
SASL authentication
PLAIN
from ircio import Client, SASLPlain
client = Client(
"irc.libera.chat", 6697,
nick="mybot", user="mybot", realname="My Bot",
ssl=True,
sasl=SASLPlain("mybot", "s3cr3t"),
)
ECDSA-NIST256P-CHALLENGE
Register your public key with NickServ, then authenticate using the corresponding private key:
from ircio import Client, SASLEcdsaNist256pChallenge
sasl = SASLEcdsaNist256pChallenge.from_pem_file("mybot", "~/.irc/key.pem")
client = Client(
"irc.libera.chat", 6697,
nick="mybot", user="mybot", realname="My Bot",
ssl=True,
sasl=sasl,
)
Generate a key with OpenSSL:
openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -out ~/.irc/key.pem
openssl pkey -in ~/.irc/key.pem -pubout
Provide the public key to NickServ: /msg NickServ SET PUBKEY <base64-pubkey>.
EXTERNAL (client certificate)
import ssl
from ircio import Client, SASLExternal
ctx = ssl.create_default_context()
ctx.load_cert_chain("cert.pem", "key.pem")
client = Client(
"irc.libera.chat", 6697,
nick="mybot", user="mybot", realname="My Bot",
ssl=ctx,
sasl=SASLExternal(),
)
Low-level API
Connection and Dispatcher are exposed for use cases that require finer control:
from ircio import Connection, Dispatcher, Message
async def main():
async with Connection("irc.libera.chat", 6697, ssl=True) as conn:
await conn.send(Message("NICK", ["mybot"]))
await conn.send(Message("USER", ["mybot", "0", "*", "My Bot"]))
while True:
msg = await conn.readline()
print(msg)
Development
uv sync
uv run pytest
uv run ruff check src/ tests/
uv run ruff format src/ tests/
Pre-commit hooks (ruff linter + formatter) are installed automatically on first commit after:
uv run pre-commit install
Licence
MIT — see LICENSE.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ircio-1.2.1.tar.gz.
File metadata
- Download URL: ircio-1.2.1.tar.gz
- Upload date:
- Size: 33.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ac85527bdcea3ce4225a6664fd875924a7d57eee2246caccd6bafd67a65f6d2
|
|
| MD5 |
5cc0b19fc33951db24572d1ed7b17319
|
|
| BLAKE2b-256 |
f14e5db9d148d068863e8e86f847849c73100fb7ca9c74ac41d873ba29fb708a
|
Provenance
The following attestation bundles were made for ircio-1.2.1.tar.gz:
Publisher:
release.yml on pbiernacki/ircio
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ircio-1.2.1.tar.gz -
Subject digest:
2ac85527bdcea3ce4225a6664fd875924a7d57eee2246caccd6bafd67a65f6d2 - Sigstore transparency entry: 1005442594
- Sigstore integration time:
-
Permalink:
pbiernacki/ircio@9a77d3243473abbc89e0a242dc53acee4bfcee39 -
Branch / Tag:
refs/tags/v1.2.1 - Owner: https://github.com/pbiernacki
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9a77d3243473abbc89e0a242dc53acee4bfcee39 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ircio-1.2.1-py3-none-any.whl.
File metadata
- Download URL: ircio-1.2.1-py3-none-any.whl
- Upload date:
- Size: 15.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3251ab16d31b8bcec8cc97632e7a1c6db41396840d286fc2274503ca05701f56
|
|
| MD5 |
199fe60a23cf751d4a0160cf19aa69cb
|
|
| BLAKE2b-256 |
0ffc0b10a895b6a94e4799d6dae97ce26eefe9bec4c89afb7705ff409b36d82a
|
Provenance
The following attestation bundles were made for ircio-1.2.1-py3-none-any.whl:
Publisher:
release.yml on pbiernacki/ircio
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ircio-1.2.1-py3-none-any.whl -
Subject digest:
3251ab16d31b8bcec8cc97632e7a1c6db41396840d286fc2274503ca05701f56 - Sigstore transparency entry: 1005442599
- Sigstore integration time:
-
Permalink:
pbiernacki/ircio@9a77d3243473abbc89e0a242dc53acee4bfcee39 -
Branch / Tag:
refs/tags/v1.2.1 - Owner: https://github.com/pbiernacki
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9a77d3243473abbc89e0a242dc53acee4bfcee39 -
Trigger Event:
push
-
Statement type: