Skip to content

Commit

Permalink
Allow extending IRC bit to add custom commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Douglas Hubler committed Aug 5, 2009
1 parent 5be6259 commit e17a4dd
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions buildbot/status/words.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def started(self, c):
d = s.waitUntilFinished()
d.addCallback(self.parent.watchedBuildFinished)


class Contact:
"""I hold the state for a single user's interaction with the buildbot.
Expand Down Expand Up @@ -661,6 +660,7 @@ class IrcStatusBot(irc.IRCClient):
"""I represent the buildbot to an IRC server.
"""
implements(IChannel)
contactClass = IRCContact

def __init__(self, nickname, password, channels, status, categories, notify_events):
"""
Expand Down Expand Up @@ -690,7 +690,7 @@ def addContact(self, name, contact):
def getContact(self, name):
if name in self.contacts:
return self.contacts[name]
new_contact = IRCContact(self, name)
new_contact = self.contactClass(self, name)
self.contacts[name] = new_contact
return new_contact

Expand Down Expand Up @@ -742,6 +742,9 @@ def signedOn(self):

def joined(self, channel):
self.log("I have joined %s" % (channel,))
# trigger contact contructor, which in turn subscribes to notify events
self.getContact(channel)

def left(self, channel):
self.log("I have left %s" % (channel,))
def kickedFrom(self, channel, kicker, message):
Expand Down Expand Up @@ -829,7 +832,7 @@ class IRC(base.StatusReceiverMultiService):
"categories"]

def __init__(self, host, nick, channels, port=6667, allowForce=True,
categories=None, password=None, notify_events={}):
categories=None, password=None, notify_events={}, statusFactory=None):
base.StatusReceiverMultiService.__init__(self)

assert allowForce in (True, False) # TODO: implement others
Expand All @@ -843,12 +846,13 @@ def __init__(self, host, nick, channels, port=6667, allowForce=True,
self.allowForce = allowForce
self.categories = categories
self.notify_events = notify_events

# need to stash the factory so we can give it the status object
self.f = IrcStatusFactory(self.nick, self.password,
log.msg('Notify events %s' % notify_events)
if (statusFactory is None):
self.f = IrcStatusFactory(self.nick, self.password,
self.channels, self.categories, self.notify_events)

c = internet.TCPClient(host, port, self.f)
else:
self.f = statusFactory
c = internet.TCPClient(self.host, self.port, self.f)
c.setServiceParent(self)

def setServiceParent(self, parent):
Expand Down

0 comments on commit e17a4dd

Please sign in to comment.