Skip to content
Create a gist now

Instantly share code, notes, and snippets.

@anfedorov / secret

from twisted.words.protocols.irc import IRCClient
from twisted.internet import protocol, reactor
class Connect(object):
class IMBot(IRCClient):
def signedOn(self):
self.connected = True
def nickname(self):
return self.factory.nickname
def privmsg(self, user, channel, msg):
# needs to return from `next' below
class IMBotFactory(protocol.ClientFactory):
protocol = IMBot
def __init__(self, nickname):
self.nickname = nickname
def clientConnectionLost(self, connector, reason):
print "Lost connection (%s), reconnecting." % (reason,)
def clientConnectionFailed(self, connector, reason):
print "Could not connect: %s" % (reason,)
def __init__(self, host='', port=6667, nick='robot'): = host
self.port = port
self.connector = reactor.connectTCP(host, port, IMBotFactory(nick))
def join(self, *chans):
return Channels(self, *chans)
class Channels(object):
def __init__(self, connection, *chans):
self.connection = connection
self.chans = chans
def __next__(self):
# ...
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.