Skip to main content

pinhook

a pluggable irc bot framework in python

Tutorial

Installation

$ pip install git+git://github.com/archangelic/pinhook.git

Creating the Bot

To create the bot, just create a python file with the following:

import pinhook.bot

bot = pinhook.bot.Bot(
    channels=['#foo', '#bar'],
    nickname='ph-bot',
    server='irc.freenode.net'
)
bot.start()

This will start a basic bot and look for plugins in the ‘plugins’ directory to add functionality.

Optional arguments are:

  • port: choose a custom port to connect to the server (default: 6667)

  • ops: list of operators who can do things like make the bot join other channels or quit (default: empty list)

  • plugin_dir: directory where the bot should look for plugins (default: “plugins”)

Creating plugins

In your chosen plugins directory (“plugins” by default) make a python file with a function. You can use the @pinhook.plugin.register decorator to tell the bot the command to activate the function.

The function will need to be structured as such:

import pinhook.plugin

@pinhook.plugin.register('!test')
def test_plugin(msg):
    message = '{}: this is a test!'.format(msg.nick)
    return pinhook.plugin.message(message)

The function will need to accept a single argument in order to accept a Message object from the bot.

The Message object has the following attributes:

  • cmd: the command that triggered the function

  • nick: the user who triggered the command

  • arg: all the trailing text after the command. This is what you will use to get optional information for the command

  • channel: the channel where the command was initiated

  • ops: the list of bot operators

  • botnick: the nickname of the bot

The plugin function must return one of the following in order to give a response to the command:

  • pinhook.plugin.message: basic message in channel where command was triggered

  • pinhook.plugin.action: CTCP action in the channel where command was triggered (basically like using /me does a thing)

Examples

There are some basic examples in the examples directory in this repository.

For a live and maintained bot running the current version of pinhook see pinhook-tilde.

Metadata

Release files for pinhook 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pinhook 1.0.2
File Size Uploaded Provenance Actions
pinhook-1.0.2.tar.gz 4.5 kB Without provenance Details for pinhook-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pinhook 1.0.2
File Interpreter ABI Platform Actions
pinhook-1.0.2-py2.py3-none-any.whl Python 3, Python 2 none any Details for pinhook-1.0.2-py2.py3-none-any.whl

Total release size: 10.3 kB

Release files / pinhook-1.0.2.tar.gz

Download URL pinhook-1.0.2.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
1a2e1b859c178ebbf08c1383d315d16d5e078b7c465f76194711d451abb81979
BLAKE2b-256 checksum
How to use checksums
e53eb2e8601a6de1ccab43e22ff0eb58f6b4c63565e9c56334ae48589c32d232
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pinhook-1.0.2-py2.py3-none-any.whl

Download URL pinhook-1.0.2-py2.py3-none-any.whl
Size 5.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
bfa1e8d15e04771ab1907f0a7ea1d48d924f641931a049ffca741752288c7e25
BLAKE2b-256 checksum
How to use checksums
f6f08514a221e7ac254b69680e9b871b621e1ed1e56a3f96766a50b8e3048247
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for pinhook 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files No provenance

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