Skip to content

Instantly share code, notes, and snippets.

@bloodywing
Created March 1, 2014 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bloodywing/9292094 to your computer and use it in GitHub Desktop.
Save bloodywing/9292094 to your computer and use it in GitHub Desktop.
from circuits import Component, Debugger
from circuits.core.events import started
from circuits.net.sockets import TCPClient
from circuits.net.events import connect
from circuits.protocols.irc import IRC, PRIVMSG, USER, NICK, JOIN
from circuits.protocols.irc import ERR_NICKNAMEINUSE, RPL_ENDOFMOTD, ERR_NOMOTD
class Bot(Component):
channel = "ircbot"
def init(self, host, port=6667, channel=channel):
self.port = port
self.host = host
TCPClient(channel=channel).register(self)
IRC(channel=channel).register(self)
def ready(self, component):
self.fire(connect(self.host, self.port))
def connected(self, host, port):
self.fire(USER("circuitsbot", host, host, "Bloodys Circuits Bot"))
self.fire(NICK("circuitsbot"))
def numeric(self, source, target, numeric, args, message):
if numeric == ERR_NICKNAMEINUSE:
self.fire(NICK("%s_" % args))
if numeric in (RPL_ENDOFMOTD, ERR_NOMOTD):
self.fire(JOIN("#bloodysbot"))
def message(self, source, target, message):
self.fire(PRIVMSG(source[0], message.swapcase()))
bot = Bot("tiger.irc.bakashimoe.me")
(bot + Debugger()).run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment