Skip to main content

asyncio-based rfc2812-compliant IRC Client

Project description

bottom 0.9.0

Build:

build coverage

Downloads:

http://pypi.python.org/pypi/bottom

Source:

https://github.com/numberoverzero/bottom

asyncio-based rfc2812-compliant IRC Client

Installation

pip install bottom

Getting Started

bottom isn’t a kitchen-sink library. Instead, it provides an API with a small surface area, tuned for performance and ease of extension. Similar to the routing style of bottle.py, hooking into events is one line.

from bottom import Client

NICK = 'bottom-bot'
CHANNEL = '#python'

bot = Client('localhost', 6697)


@bot.on('CLIENT_CONNECT')
def connect():
    bot.send('NICK', NICK)
    bot.send('USER', NICK, 0, '*', message='Bot using bottom.py')
    bot.send('JOIN', CHANNEL)


@bot.on('PING')
def keepalive(message):
    bot.send('PONG', message=message)


@bot.on('PRIVMSG')
def message(nick, target, message):
    ''' Echo all messages '''

    # Don't echo ourselves
    if nick == NICK:
        return
    # Direct message to bot
    if target == NICK:
        bot.send("PRIVMSG", nick, message=message)
    # Message in channel
    else:
        bot.send("PRIVMSG", target, message=message)

bot.run()

API

While there are other internal classes and structures, everything should be considered private except the Client class.

Client.run

Client.on

Client.connect

Client.disconnect

Client.send

Other Classes and Modules

The routing module is used to unpack an irc line into the appropriate named objects based on the command’s grammar.

The rfc module holds a set of command aliases and the full list of rfc2812’s available command and response strings. It primarily parses a single line of text into a (prefix, command, params, message) tuple which is (usually) consumed by the router. It also handles dumping a command into the appropriate wire format.

The Connection class handles the main read/write loop and socket connections, and is entirely asynchronous.

The Handler class is used to distribute events and register functions decorated by Client.on. It does some optimization using the partial_bind function to speed up the connection read -> function call time.

Supported Commands

All commands and responses listed in http://tools.ietf.org/html/rfc2812 will be available. Currently, only the following have working parsers:

  • PING

  • CLIENT_CONNECT

  • CLIENT_DISCONNECT

  • NOTICE

  • PRIVMSG

  • JOIN

  • PART

  • QUIT

  • RPL_MOTDSTART

  • RPL_MOTD

  • RPL_ENDOFMOTD

  • RPL_WELCOME

  • RPL_YOURHOST

  • RPL_CREATED,

  • RPL_LUSERCLIENT

  • RPL_LUSERME

  • RPL_STATSDLINE

  • RPL_LUSEROP

  • RPL_LUSERUNKNOWN

  • RPL_LUSERCHANNELS

  • RPL_MYINFO

  • RPL_BOUNCE

Command Parameters

This section will eventually list the available parameters for each command or reply, and what type they are.

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

bottom-0.9.0.tar.gz (8.9 kB view details)

Uploaded Source

File details

Details for the file bottom-0.9.0.tar.gz.

File metadata

  • Download URL: bottom-0.9.0.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for bottom-0.9.0.tar.gz
Algorithm Hash digest
SHA256 99bf0b77674ef8fdd66c2e0f72c4e025f90175c00d6700cb20bc2a864f57e601
MD5 3580679d8f70ec10ad38adc299fbfc8d
BLAKE2b-256 9325cbd255f8083ff039bd8402e73e6420e1baa6343dfe32cf8010c02f5185fe

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