Skip to main content

No project description provided

Project description

Irckaaja

A scriptable IRC bot with a Python interface.

Table of Contents

Installation

irckaaja requires Python 3.9 or newer. The package is available on PyPI and can be installed with pip

pip install irckaaja

Usage

python -m irckaaja.irckaaja -c config.ini

Scripts

To build your own scripts, subclass irckaaja.botscript.BotScript. Currently subscribable events are

    def on_channel_message(
        self, user: User, channel_name: str, message: str
    ) -> None:
        """
        Called when a channel message is received.
        """

    def on_private_message(self, user: User, message: str) -> None:
        """
        Called when a private message is received.
        """

    def on_join(self, user: User, channel_name: str) -> None:
        """
        Called when a user joins a channel.
        """

    def on_part(self, user: User, channel_name: str) -> None:
        """
        Called when a user parts a channel.
        """

    def on_quit(self, user: User) -> None:
        """
        Called when a user quits the network.
        """

    def on_connect(self) -> None:
        """
        Called when bot has connected to the network.
        """

    def on_topic(self, user: User, channel_name: str, topic: str) -> None:
        """
        Called when topic has changed on a channel.
        """

A simple greeter bot would look like this.

from irckaaja.botscript import BotScript, User


class HelloWorld(BotScript):
    """
    A simple script class. Only responds to messages starting "hello"
    in every joined channel.
    """

    def on_channel_message(
        self, user: User, channel_name: str, message: str
    ) -> None:
        if message.startswith("hello"):
            self.say(channel_name, "hello, " + user.nick)
            return

The modules should be present in the irckaaja.scripts package and named as the lowercase of the class name found in the module. E.g. script called Greeter should be placed to irckaaja.scripts.greeter.Greeter.

Loading of modules is controlled by the [modules] section of the configuration file:

[modules]
    [[Greeter]]
        arbitrary_configuration = "passed to script as a dict[str, Any]"

Configuration

Example configuration:

[servers]
    [[QuakeNet]] # also alias for the network
        hostname = se.quakenet.org
        port = 6667 # if port is no defined, default is 6667
        channels = "#example1", "#example2"
    #[[IRCNet]]
    #    hostname = irc.cs.hut.fi

[bot]
    nick = irckaaja
    altnick = irckaaja_ # if not provided, nick + "_"
    realname = Irkkaa Nörttien Kanssa
    username = irckaaja
    owner = "nick!user@example.com"

[modules]
    [[HelloWorld]]

Screenshots

Connection output

Contributing

Drop a pull request if you have something you'd want to incorporate.

License

See Licence.txt.

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

irckaaja-0.3.0.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

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

irckaaja-0.3.0-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file irckaaja-0.3.0.tar.gz.

File metadata

  • Download URL: irckaaja-0.3.0.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for irckaaja-0.3.0.tar.gz
Algorithm Hash digest
SHA256 8cfa2c6200487a4ff620352465f176c56e696462c6709de75b977e070943decf
MD5 14b4fdfb4a3e8a0a0f72e377218d7706
BLAKE2b-256 f90efacde976dd7874678b36ad3cd348148eb59a60fff25168fab3b770fc07d3

See more details on using hashes here.

File details

Details for the file irckaaja-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: irckaaja-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for irckaaja-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d0500c734ac3b716524acdc82da8737d045c6dabe37ce54e01062c94c6cbcbd1
MD5 d4754960df7fb49d4d906368cbd27158
BLAKE2b-256 550ff24ed084a2ca15ad3c76552f9a9cd49272dc2bad06c3cfbb925ea6120201

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page