Giter Club home page Giter Club logo

pyrcb's Introduction

pyrcb

pyrcb is a very simple library for Python IRC bots. It isn't a full implementation of IRC; it provides just enough to write IRC bots. pyrcb is compatible with both Python 2 and 3.

To use it, import pyrcb and create a class that inherits IrcBot. Override one or more of the events. (You will most likely want to call send() from within the events.) Create an instance of your class and call connect(), register(), optionally join(), and listen(). See example.py for an example.

IrcBot's constructor takes one optional argument, debug_print. Setting this value to True will cause all communication with the IRC server to be printed to standard output.

Events

on_join(self, nickname, channel)
Called when a user joins a channel.

on_part(self, nickname, channel)
Called when a user leaves a channel.

on_quit(self, nickname)
Called when a user quits.

on_message(self, nickname, target, is_query)
Called when a message is received. target is who/what the bot should reply to. If the message is in a channel, target is the channel. If the message is in a private query, target is the other user.

Methods

connect(hostname, port)
Connects to the specified hostname and port.

register(nickname)
Sends the IRC server nickname and user information.

join(channel)
Joins the specified channel.

part(channel)
Leaves the specified channel.

quit()
Closes connection to the IRC server.

send(target, message)
Sends target the specified message. target can be a channel or user.

listen()
Listens for incoming messages, calling events when appropriate. This method is blocking and returns when connection to the IRC server is lost.

listenOnce()
Similar to listen(), except it only listens once allows the user to run other actions in between. It returns right after checking for a message once.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.