Skip to main content

pydle

Python IRC library.

pydle is a compact, flexible and standards-abiding IRC library for Python 3.10+.

Features

  • Well-organized: Thanks to the modularized feature system, it's not hard to find what you're looking for in the well-organised source code.
  • Standards-abiding: Based on RFC1459 with some small extension tweaks, with full support of optional extension standards:
  • Asynchronous: IRC is an asynchronous protocol and so should be a library that implements it. Coroutines are used to process events from the server asynchronously.
  • Modularised and extensible: Features on top of RFC1459 are implemented as separate modules for a user to pick and choose, and write their own. Broad features are written to be as extensible as possible.
  • Liberally licensed: The 3-clause BSD license ensures you can use it everywhere.

Basic Usage

pip install pydle

From there, you can import pydle and subclass pydle.Client for your own functionality.

To enable SSL support, install the sasl extra. pip install pydle[sasl]

Setting a nickname and starting a connection over TLS:

import pydle


# Simple echo bot.
class MyOwnBot(pydle.Client):
    async def on_connect(self):
        await self.join("#bottest")

    async def on_message(self, target, source, message):
        # don't respond to our own messages, as this leads to a positive feedback loop
        if source != self.nickname:
            await self.message(target, message)


client = MyOwnBot("MyBot", realname="My Bot")
client.run("irc.rizon.net", tls=True, tls_verify=False)

But wait, I want to handle multiple clients!

No worries! Use pydle.ClientPool like such:

pool = pydle.ClientPool()
for i in range(10):
    client = MyOwnBot("MyBot" + str(i))
    pool.connect(client, "irc.rizon.net", 6697, tls=True, tls_verify=False)

# This will make sure all clients are treated in a fair way priority-wise.
pool.handle_forever()

Furthermore, since pydle is simply asyncio-based, you can run the client in your own event loop, like this:

import asyncio

client = MyOwnBot("MyBot")
asyncio.run(client.connect("irc.rizon.net", tls=True, tls_verify=False))

Customization

If you want to customize bot features, you can subclass pydle.BasicClient and one or more features from pydle.features or your own feature classes, like such:

# Only support RFC1459 (+small features), CTCP and our own ACME extension to IRC.
class MyFeaturedBot(
    pydle.features.ctcp.CTCPSupport, acme.ACMESupport, rfc1459.RFC1459Support
):
    pass

To create your own features, just subclass from pydle.BasicClient and start adding callbacks for IRC messages:

# Support custom ACME extension.
class ACMESupport(pydle.BasicClient):
    async def on_raw_999(self, source, params):
        """ACME's custom 999 numeric tells us to change our nickname."""
        nickname = params[0]
        await self.set_nickname(nickname)

FAQ

Q: When constructing my own client class from several base classes, I get the following error: TypeError: Cannot create a consistent method resolution order (MRO) for bases X, Y, Z. What causes this and how can I solve it?

Pydle's use of class inheritance as a feature model may cause method resolution order conflicts if a feature inherits from a different feature, while a class inherits from both the original feature and the inheriting feature. To solve such problem, pydle offers a featurize function that will automatically put all classes in the right order and create an appropriate base class:

# Purposely mis-ordered base classes, as SASLSupport inherits from CapabilityNegotiationSupport, but everything works fine.
MyBase = pydle.featurize(
    pydle.features.CapabilityNegotiationSupport, pydle.features.SASLSupport
)


class Client(MyBase):
    pass

Q: How do I...?

Stop! Read the documentation first. If you're still in need of support, please raise a new issue in this repository! Also, we are on IRC! We hang at #pydle on irc.libera.chat. If someone is around, they'll most likely gladly help you.

License

Pydle is licensed under the 3-clause BSD license. See LICENSE.md for details.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydle-1.2.0.tar.gz (38.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydle-1.2.0-py3-none-any.whl (47.6 kB view details)

Uploaded Python 3

File details

Details for the file pydle-1.2.0.tar.gz.

File metadata

  • Download URL: pydle-1.2.0.tar.gz
  • Upload date:
  • Size: 38.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.7

File hashes

Hashes for pydle-1.2.0.tar.gz
Algorithm Hash digest
SHA256 e830debe5f10b1ba2d2bf8ea4c5c26427989c8a842edcc42d194b6cff6aeac11
MD5 a53ecc127346a14d7954dfd44b003504
BLAKE2b-256 f3fcb418bb4ce8fa579ff775c443d83216cdc4ef0c721d0c5f45fb3086245f4c

See more details on using hashes here.

File details

Details for the file pydle-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: pydle-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 47.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.7

File hashes

Hashes for pydle-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 46f857fe41cf5b10dad84034abfa0f76dfec679bf01fefcba297eb8febd889da
MD5 56c1481276b02f56a069321595762b87
BLAKE2b-256 302d970a49495d2eae0261ab4aad9a575acd6a1b0c7fbaa67f9d66e54ad25193

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 files

1.1.0

2 files

1.0.1

2 files

1.0.0

2 files

0.9.4

1 file

0.9.3

1 file

0.9.2

2 files

0.9.1

2 files

0.9.0

2 files

0.8.5

2 files

0.8.4

2 files

0.8.3

2 files

0.8.2

2 files

0.8.0

1 file

0.7.1

1 file

0.7.0

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page